bisher hab ich Autohotkey dazu verwendet um nach einem Tastendruck etwas im geöffneten Programm unmittelbar auszugeben. ( F12:: Send {Down}{Left}{Left}{Right}{Left} )
Jetzt versuche ich mich seit einigen Tagen an einem Script welches mir die maximalen Schleifenwiderstände im TN-Netz, bei unterschiedlichen Spannungen (230 / 400V) bei verschiedenen Absicherungen der Stromkreise berechnen soll.
Es hakt momentan bei der Berechnung der "Rschl" und "RschlSI" bei 230V und der "Rschl" bei 400V.
Und bei den Ausgaben von "vAbschalt", "Rschl" und "RschlSI".
Zu Testzwecken habe ich je eine MsgBox, für den Abschaltstrom, "Rschl" und "RschlSI" eingebaut, welche mir nur bei "RschlSI" bei 400V und beim "Abschalt"strom ein vernünftiges / korrektes Ergebnis anzeigt.
Was ich nicht verstehe da die anderen Berechnungen den gleichen Aufbau haben.
Vielleicht kann ja mal einer von Euch über den Code schauen und einem Anfänger erklären welche Fehler er gemacht hat?
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, force
; --------- Tool zum maximalen Schleifenwiderstand berechnen -------------------------
; ---------------------------Variabeln & Co ------------------------------------------
Transform, Prozent, Chr, 37
global Spannung := 0
global Volt := 0
global Charakteristik := 0
global Charakter := 0
global Ampere := 0
global Rschl := 0.00
global RschlSI := 0.00
global Abschalt := 0.00
; --------------------------- GUI ----------------------------------------------------
Gui, Show, w400 h400, Rschl max.
; -------- DropDown Spannung ------------------
Gui, Add, Text, x10 y10, % "Spannung:"
Gui, Add, Text, x195 y10, % "Volt"
Gui, Add, DropDownList, x130 y5 w55 vSpannung gSpannung, 230|400
Gui, Add, Text, x10 y205, % "Spannung:"
Gui, Add, Edit, x130 y200 w55 vVolt
; ---------- DropDown Ampere der Sicherung ----------
Gui, Add, Text, x10 y40, % "Absicherung:"
Gui, Add, Text, x195 y40, % "Ampere"
Gui, Add, DropDownList, x130 y35 w55 vAmpere gStrom, 1|2|4|6|10|13|16|20|25|32
Gui, Add, Text, x10 y235, % "Ampere:"
Gui, Add, Edit, x130 y230 w55 vStrom
; ----------- DropDown Sicherungs Charakteristik ---------------------------
Gui, Add, Text, x10 y70, % "Charakteristik:"
Gui, Add, DropDownList, x130 y65 w55 vCharakteristik gCharakter, B|C|D|E|K|Z
Gui, Add, Text, x10 y265, % "Faktor:"
Gui, Add, Edit, x130 y260 w55 vCharakter
; --------------- Anzeige Abschaltstrom ---------------------------
Gui, Add, Text, x10 y295, % "Abschaltstrom:" ;neu v1.2
Gui, Add, Edit, x130 y290 w55 vAbschalt ; neu v1.2
; --------------------- Anzeige max. Schleife ----------------------- ; neu v1.3
Gui, Add, Text, x22 y325 w55 h30 , max. Rschl: ; neu v1.3
Gui, Add, Edit, x95 y320 w100 h25 vRschl ; neu v1.3
Gui, Add, Text, x22 y355 w145 h30 , max. Rschl + 30%Prozent% Sicherheitsreserve: ; neu v1.3
Gui, Add, Edit, x130 y350 w100 h25 vRschlSI ; neu v1.3
return
; ----------------- Auswertung DropDown Spannung ------------------------
Spannung:
Gui, Submit, NoHide
IfEqual, Spannung, 230
GuiControl,, Volt, 230
else IfEqual, Spannung, 400
GuiControl,, Volt, 400
return
; ----------------- Auswertung DropDown Ampere ------------------------
Strom:
Strom =
Gui, Submit, NoHide
IfEqual, Ampere, 1
GuiControl,, Strom, 1
else IfEqual, Ampere, 2
GuiControl,, Strom, 2
IfEqual, Ampere, 4
GuiControl,, Strom, 4
else IfEqual, Ampere, 6
GuiControl,, Strom, 6
IfEqual, Ampere, 10
GuiControl,, Strom, 10
else IfEqual, Ampere, 13
GuiControl,, Strom, 13
IfEqual, Ampere, 16
GuiControl,, Strom, 16
else IfEqual, Ampere, 20
GuiControl,, Strom, 20
IfEqual, Ampere, 25
GuiControl,, Strom, 25
else IfEqual, Ampere, 32
GuiControl,, Strom, 32
Strom := Strom
; if (Strom >1) gosub, Charakter
Return
; ---------------------- Auswertung DropDown Charakteristik ---------------
Charakter:
Charakter =
Gui, Submit, NoHide
IfEqual, Charakteristik, B
GuiControl,, Charakter, 5
else IfEqual, Charakteristik, C
GuiControl,, Charakter, 10
IfEqual, Charakteristik, D
GuiControl,, Charakter, 20
else IfEqual, Charakteristik, E
GuiControl,, Charakter, 6.25
IfEqual, Charakteristik, K
GuiControl,, Charakter, 14
else IfEqual, Charakteristik, Z
GuiControl,, Charakter, 3
Charakter := Charakter
;--------------------------- Abschaltstrom berechnen ----------------------
Abschalt:
Gui, Submit, NoHide
Abschalt =
Abschalt := Charakter * Strom
Abschalt := Abschalt
IFEqual Charakteristik, E ; neu v1.2
Abschalt := Round(Abschalt, 2) ;neu v1.2
sleep, 600
MsgBox, %Abschalt% ; neu v1.2 Testweise eingefügt
; ----------------------- max Schleife berechnen ---------------
Rschl = ; neu v1.3
RschlSI = ; neu v1.3
IfEqual, Spannung, 230 ; neu v1.3
{
Rschl = Spannung / Abschalt ; neu v1.3
RschlSI = 0.7 * (Spannung / Abschalt) ; neu v1.3
Rschl := Rschl ; neu v1.3
RschlSI := RschlSI ; neu v1.3
Gosub, Schleifeausgabe ; neu v1.3
}
IfEqual, Spannung, 400 ; neu v1.3
{
Rschl = 0.6666666666 * (Spannung / Abschalt) ; neu v1.3 0.666666666666 = (2/3)
RschlSI := 0.4666666666 * (Spannung / Abschalt) ; neu v1.3 0.466666666666 = 0.7 * (2/3)
Rschl := Rschl ; neu v1.3
RschlSI := RschlSI ; neu v1.3
gosub, Schleifeausgabe ; neu v1.3
}
Return ; neu v1.3
; -------- testweise eingefügt ---------------
Schleifeausgabe:
Rschl := Round(Rschl, 2) ; neu v1.3
RschlSI := Round(RschlSI, 2) ; neu v1.3
MsgBox, %Rschl% ; neu v1.3
MsgBox, %RschlSI% ; neu v1.3
return