Page 1 of 1

Arc-Flash Calculator...

Posted: Mon Nov 10, 2014 6:28 am
by Teddy Rogers
Here is an arc-flash calculator that I coded one afternoon using PureBasic and the Form Designer and released it on my website some months back. It is an unfinished and abandoned project partly because all I was interested in was getting the AC arc-flash calculator coded. I have cleaned the code to remove the unfinished tabs but if you are interested in seeing where I was thinking of taking the project download it and check it out (link below). There is an included readme.txt file that briefly explains how to use it...

Feel free to modify, adapt or use the code or even finish off the project! Hopefully someone will benefit from it...

Project Arc-Flash - Main.pb

Code: Select all

; Title:    Project Arc-Flash v0.02 Alpha
; Author:   Teddy Rogers
; Email:    teddyrogers@tuts4you.com
; Website:  https://tuts4you.com/download.php?view.3611

XIncludeFile "Project Arc-Flash.pbf" ; GUI built using the Form Designer tool

Global kV.d
Global mm.d

Global Error_Flag = #False

OpenMainWindow() ; Open the main window

SetGadgetText(#String_Voltage, "11")
SetGadgetText(#String_Gap, "152")
SetGadgetText(#String_Current, "13.51")
SetGadgetText(#String_Rating, "5.02")

SetGadgetState(#Combo_Equipment, 0)
SetGadgetState(#Combo_Grounding, 0)
SetGadgetState(#Combo_Equipment_Type, 1)

SetGadgetText(#String_Distance_Person, "500")
SetGadgetText(#String_Distance_Factor, "0.973")
SetGadgetText(#String_Arching_Time, "0.10")

SetGadgetState(#TrackBar_Current, 75)
SetGadgetState(#TrackBar_Integer, 15)

; log10(Ia)=K+0.662log10(Ibf)+0.0966V+0.000526G+0.5588Vlog10(Ibf)−0.00304Glog10(Ibf)

Procedure Arcing_Current(EventType)
  Protected ArcFaultCurrent.d, NormalisedEnergy.d, IncidentEnergy.d, FlashBoundary.d
  
  Equipment_Type(EventType)
  
  If Error_Flag = #True
    Error_Flag = #False
    ProcedureReturn
  EndIf
  
  kV.d = ValD(GetGadgetText(#String_Voltage))         ; V - system voltage (kV)
  mm.d = ValD(GetGadgetText(#String_Gap))             ; G - Conductor gap (mm)
  kA.d = ValD(GetGadgetText(#String_Current))         ; Ibf - three phase fault current (kA)
  
  DP.d = ValD(GetGadgetText(#String_Distance_Person)) ; Distance from arc point to the person [mm]
  DF.d = ValD(GetGadgetText(#String_Distance_Factor)) ; Distance factor - dependent on equipment type & voltage (IEEE 1584-2002, pg 12) [x]
  AT.d = ValD(GetGadgetText(#String_Arching_Time))    ; Arcing time [s]
   
  Integer = GetGadgetState(#TrackBar_Integer)
  
  ; Checkbox to see if we want results in joules or calories...
  
  If GetGadgetState(#Checkbox_Joules) = 0
    RT.d = ValD(GetGadgetText(#String_Rating))          ; PPE category rating in joules
  Else
    RT.d = ValD(GetGadgetText(#String_Rating))          ; PPE category rating in joules, convert to calories
    RT.d = RT.d*4.1858
  EndIf
  
  If kV.d
    If mm.d
      If kA.d
        If kV.d < 1 ; For systems under < 1000 volts
          
          ; 1) First equation is to work out the arc fault current...
          
          ArcFaultCurrent.d = 0.662*Log10(kA.d) + 0.0966*kV.d + 0.000526*mm.d + 0.5588*kV.d*Log10(kA.d) + -0.00304*mm.d*Log10(kA.d)
          
          If GetGadgetState(#Combo_Equipment) = 0
            ArcFaultCurrent.d = ArcFaultCurrent.d + -0.097
          ElseIf GetGadgetState(#Combo_Equipment) = 1
            ArcFaultCurrent.d = ArcFaultCurrent.d + -0.153
          EndIf
          
        Else  ; For systems greater than > 1000 volts
          
          ArcFaultCurrent.d = 0.00402 + 0.983*Log10(kA.d)
          
        EndIf
        
        ArcFaultCurrent.d = Pow(10, ArcFaultCurrent.d)
        
        SetGadgetText(#Answer, StrD(ArcFaultCurrent.d, Integer))
        
        ; 2) Second part of the equation is the normalised energy calculation...
        
        If GetGadgetState(#Combo_Equipment) = 0         ; K1 = -0.792 for open configurations and -0.555 for boxed configurations
          NormalisedEnergy.d = -0.555
        ElseIf GetGadgetState(#Combo_Equipment) = 1
          NormalisedEnergy.d = -0.792
        EndIf
        
        If GetGadgetState(#Combo_Grounding) = 0         ; K2 = 0 for ungrounded or high resistance ground systems and -0.113 for grounded systems
          NormalisedEnergy.d = NormalisedEnergy.d + -0.113
        ElseIf GetGadgetState(#Combo_Grounding) = 1
          NormalisedEnergy.d = NormalisedEnergy.d + 0
        EndIf
        
        NormalisedEnergy.d = Pow(10, (NormalisedEnergy.d + 1.0811*Log10(ArcFaultCurrent.d) + 0.0011*mm.d))
        
        ; ANSWER! 1 joule is equal to 0.238902957619 calories.
        
        If GetGadgetState(#Checkbox_Joules) = #PB_Checkbox_Unchecked
          SetGadgetText(#Answer_Normalised, StrD(NormalisedEnergy.d, Integer)) ; Display answer in joules
        Else
          SetGadgetText(#Answer_Normalised, StrD(NormalisedEnergy.d*0.238902957619, Integer)) ; Display answer in calories
        EndIf
        
        ; Check to see if the user wants to use the Lee Method for the incident energy calculation...
        
        If GetGadgetState(#Checkbox_Lee) = #PB_Checkbox_Unchecked
          
          ; 3) Third part is the calculation to work out the incident energy at working distance...
          
          If kV.d > 1 ; For systems under < 1000 volts * 1.5
            IncidentEnergy.d = 4.184 * 1.0
          Else
            IncidentEnergy.d = 4.184 * 1.5
          EndIf
          
          IncidentEnergy.d = IncidentEnergy.d*NormalisedEnergy.d*(AT.d/0.2)*(Pow(610, DF.d)/Pow(DP.d, DF.d))
          
        Else ; Use the Lee Method for the incident energy calculations (should be used for 15kV and above)...
          IncidentEnergy.d = 2.142*Pow(10, 6)*kV.d*kA.d*(AT.d/Pow(DP.d, 2))
        EndIf
        
        ; ANSWER! 1 joule is equal to 0.238902957619 calories.
        
        If GetGadgetState(#Checkbox_Joules) = #PB_Checkbox_Unchecked
          SetGadgetText(#Answer_Incident, StrD(IncidentEnergy.d, Integer))
        Else
          SetGadgetText(#Answer_Incident, StrD(IncidentEnergy.d*0.238902957619, Integer)) 
        EndIf
        
        ; 4) Forth part is to determine the flash boundary...
        
        If GetGadgetState(#Checkbox_Lee) = #PB_Checkbox_Unchecked
          If kV.d > 1 ; For systems under < 1000 volts * 1.5
            FlashBoundary.d = 4.184*1.0*NormalisedEnergy.d*(AT.d/0.2)*(Pow(610, DF.d)/RT.d)
          Else
            FlashBoundary.d = 4.184*1.5*NormalisedEnergy.d*(AT.d/0.2)*(Pow(610, DF.d)/RT.d)
          EndIf         
          
          FlashBoundary.d = Pow(FlashBoundary.d, (1/DF.d))
          
        Else ; Use the Lee Method for the incident energy calculations (should be used for 15kV and above)...
          FlashBoundary.d = Sqr(2.142*Pow(10, 6)*kV.d*kA.d*(AT.d/RT.d))
        EndIf
        
        ; ANSWER!
        
        SetGadgetText(#Answer_Flash, StrD(FlashBoundary.d, Integer))
        
        ; Calculate 75%
        
        Percentage = GetGadgetState(#TrackBar_Current)
        
        SetGadgetText(#Current_Percentage, Str(Percentage) + "% of Arc Fault Current")
        SetGadgetText(#Answer_75, StrD(((ArcFaultCurrent.d*Percentage)/100), Integer))
        SetGadgetText(#Answer_Flash_75, StrD(((FlashBoundary.d*Percentage)/100), Integer))
        
        If GetGadgetState(#Checkbox_Joules) = 0 ; Display answer in joules
          SetGadgetText(#Answer_Normalised_75, StrD(((NormalisedEnergy.d*Percentage)/100), Integer))
          SetGadgetText(#Answer_Incident_75, StrD(((IncidentEnergy.d*Percentage)/100), Integer))
        Else ; Display answer in calories
          SetGadgetText(#Answer_Normalised_75, StrD((((NormalisedEnergy.d*0.238902957619)*Percentage)/100), Integer))
          SetGadgetText(#Answer_Incident_75, StrD((((IncidentEnergy.d*0.238902957619)*Percentage)/100), Integer)) 
        EndIf
        
        ProcedureReturn
        
      EndIf
    EndIf
  EndIf
  
  SetGadgetText(#Answer, "NaN")
  
  ProcedureReturn
EndProcedure

; Check and set the distant factor [x] as per 1584-2002 Table 4, pg 12

Procedure Equipment_Type(EventType)
  
  kV.d = ValD(GetGadgetText(#String_Voltage))         ; V - system voltage (kV)
  mm.d = ValD(GetGadgetText(#String_Gap))             ; G - Conductor gap (mm)
  
  If GetGadgetState(#Checkbox_Lee) = #PB_Checkbox_Unchecked And GetGadgetState(#Checkbox_Distance) = #PB_Checkbox_Unchecked
    
    If GetGadgetState(#Combo_Equipment_Type) = -1
      MessageRequester("Equipment Type Error!", "Select equipment type or set the distance factor checkbox to manual mode.", #MB_ICONERROR | #MB_TOPMOST)
      SetGadgetState(#Combo_Equipment_Type, -1)
      Error_Flag = #True
      ProcedureReturn
    EndIf    
    
    If kV.d < 0.208 Or kV.d > 15
      MessageRequester("Voltage Error!", "Set voltage between 0.208 and 15kV or set the distance factor checkbox to manual mode.", #MB_ICONERROR | #MB_TOPMOST)
      SetGadgetState(#Combo_Equipment_Type, -1)
      Error_Flag = #True
      ProcedureReturn
    ElseIf GetGadgetState(#Combo_Equipment_Type) = 0 ; Open air
      SetGadgetText(#String_Distance_Factor, "2.000")
      DF.d = 2.000
    ElseIf GetGadgetState(#Combo_Equipment_Type) = 1 ; Switchgear
      If kV.d >= 0.208 And kV.d <= 1
        SetGadgetText(#String_Distance_Factor, "1.473")
        DF.d = 1.473
      ElseIf kV.d > 1 And kV.d <= 15
        SetGadgetText(#String_Distance_Factor, "0.973")
        DF.d = 0.973
      EndIf
    ElseIf GetGadgetState(#Combo_Equipment_Type) = 2 ; MCC and panels
      SetGadgetText(#String_Distance_Factor, "1.641")
      DF.d = 1.641
    ElseIf GetGadgetState(#Combo_Equipment_Type) = 3 ; Cables
      SetGadgetText(#String_Distance_Factor, "2.000")
      DF.d = 2.000
    EndIf
  EndIf
  
  Error_Flag = #False
  
EndProcedure

; Check and set the Lee method...

Procedure Lee_Factor(EventType)
  
  If GetGadgetState(#Checkbox_Lee) = #PB_Checkbox_Checked
    SetGadgetState(#Checkbox_Distance, #PB_Checkbox_Checked)
    SendMessage_(GadgetID(#String_Distance_Factor), #EM_SETREADONLY, #False, #False) ; Remove read only status
    Arcing_Current(EventType)
  Else
    SendMessage_(GadgetID(#String_Distance_Factor), #EM_SETREADONLY, #True, #False) ; Enable read only status
    SetGadgetState(#Checkbox_Distance, #PB_Checkbox_Unchecked)
    Arcing_Current(EventType)
  EndIf  
  
EndProcedure

; Checkbox for setting the distance factor to manual mode...

Procedure Distance_Factor(EventType)
  
  If GetGadgetState(#Checkbox_Lee) = #PB_Checkbox_Checked
    MessageRequester("Lee Checkbox Error!", "Unckeck Lee Method checkbox first!", #MB_ICONERROR | #MB_TOPMOST)
    SetGadgetState(#Checkbox_Distance, #PB_Checkbox_Checked)
  Else
    If GetGadgetState(#Checkbox_Distance) = #PB_Checkbox_Checked
      SendMessage_(GadgetID(#String_Distance_Factor), #EM_SETREADONLY, #False, #False) ; Remove read only status
    Else
      SendMessage_(GadgetID(#String_Distance_Factor), #EM_SETREADONLY, #True, #False) ; Enable read only status
      Equipment_Type(EventType)
    EndIf
  EndIf
  
EndProcedure

Procedure JoulesToCal(EventType)
  
  If GetGadgetState(#Checkbox_Joules) = #PB_Checkbox_Unchecked
    SetGadgetText(#Text_PPE_Rating, "PPE Rating (J/cm²) :")
    SetGadgetText(#Text_Energy_Normalised_100, "J/cm² :") ; Text_Energy_Normalised_100
    SetGadgetText(#Text_Energy_Normailsed_75, "J/cm² :") ; Text_Energy_Normailsed_75
    SetGadgetText(#Text_Energy_Incident_100, "J/cm² :") ; Text_Energy_Incident_100
    SetGadgetText(#Text_Energy_Incident_75, "J/cm² :") ; Text_Energy_Incident_75
    
    ; The user is changing from calories to joules so convert the number in the box
    
    RT.d = ValD(GetGadgetText(#String_Rating))          ; PPE category rating in joules
    
    If RT.d
      RT.d = RT.d*4.1858
      SetGadgetText(#String_Rating, StrD(RT.d))
    EndIf
    
  Else
    SetGadgetText(#Text_PPE_Rating, "PPE Rating (Cal/cm²) :")
    SetGadgetText(#Text_Energy_Normalised_100, "Cal/cm² :") ; Text_Energy_Normalised_100
    SetGadgetText(#Text_Energy_Normailsed_75, "Cal/cm² :") ; Text_Energy_Normailsed_75
    SetGadgetText(#Text_Energy_Incident_100, "Cal/cm² :") ; Text_Energy_Incident_100
    SetGadgetText(#Text_Energy_Incident_75, "Cal/cm² :") ; Text_Energy_Incident_75
    
    ; The user is changing from joules to calories so convert the number in the box
    
    RT.d = ValD(GetGadgetText(#String_Rating))          ; PPE category rating in calories, convert to joules
    
    If RT.d
      RT.d = RT.d*0.238902957619
      SetGadgetText(#String_Rating, StrD(RT.d))
    EndIf
    
  EndIf
  
  Arcing_Current(EventType)
  
EndProcedure

; The main event loop, calls the automatically generated event procedure.

Repeat
  Event = WaitWindowEvent()
  
  Select EventWindow()
    Case MainWindow
      MainWindow_Events(Event)
      
  EndSelect
  
Until Event = #PB_Event_CloseWindow ; Quit on any window close
Project Arc-Flash.pbf

Code: Select all

;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;

Global Frame_0, Text_Voltage, Text_Arching, Text_Fault, Text_Grounding, Frame_100_Normalised, Frame_75_Normalised, Text_Voltage_75, Frame_75_Arcing, Text_Arching_Copy1, Frame_100_Incident, Text_Equipment, Text_Gap, Text_Distance, Text_Voltage_100, Frame_100_Arcing, Frame_75_Incident, Frame_75_Flash, Text_Flash_75, Frame_Flash, Text_Flash, Text_Equipment_Type

Enumeration FormWindow
  #MainWindow
EndEnumeration

Enumeration FormGadget
  #Panel_0
  #Checkbox_Lee
  #TrackBar_Current
  #Answer
  #Button_Calculate
  #Combo_Equipment
  #String_Voltage
  #String_Arching_Time
  #String_Current
  #Current_Percentage
  #Answer_75
  #Text_Energy_Incident_100
  #Answer_Normalised_75
  #String_Distance_Factor
  #Answer_Incident
  #Current_100
  #String_Gap
  #Text_Energy_Normalised_100
  #String_Distance_Person
  #Answer_Normalised
  #Combo_Grounding
  #Answer_Incident_75
  #Text_Energy_Incident_75
  #Text_Energy_Normailsed_75
  #Text_PPE_Rating
  #String_Rating
  #Answer_Flash_75
  #Answer_Flash
  #Checkbox_Joules
  #Checkbox_Distance
  #Combo_Equipment_Type
  #TrackBar_Integer
EndEnumeration

Enumeration FormFont
  #Font_MainWindow_0
  #Font_MainWindow_1
  #Font_MainWindow_2
  #Font_MainWindow_3
EndEnumeration

LoadFont(#Font_MainWindow_0,"Arial", 10)
LoadFont(#Font_MainWindow_1,"Arial", 10, #PB_Font_Bold)
LoadFont(#Font_MainWindow_2,"Arial Rounded MT Bold", 12)
LoadFont(#Font_MainWindow_3,"Arial Rounded MT Bold", 10)

Declare Equipment_Type(EventType)
Declare Lee_Factor(EventType)
Declare JoulesToCal(EventType)
Declare Arcing_Current(EventType)
Declare Distance_Factor(EventType)

Procedure OpenMainWindow(x = 0, y = 0, width = 560, height = 530)
  OpenWindow(#MainWindow, x, y, width, height, "Project Arc-Flash v0.02 Alpha", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  PanelGadget(#Panel_0, 0, 0, 560, 530)
  SetGadgetFont(#Panel_0, FontID(#Font_MainWindow_0))
  AddGadgetItem(#Panel_0, -1, "AC Calculator", 0, 1)
  CheckBoxGadget(#Checkbox_Lee, 170, 20, 20, 20, "")
  GadgetToolTip(#Checkbox_Lee, "Apply Lee Method (Voltages >15kV)")
  SetGadgetFont(#Checkbox_Lee, FontID(#Font_MainWindow_0))
  TrackBarGadget(#TrackBar_Current, 290, 260, 240, 25, 0, 100, #PB_TrackBar_Ticks)
  StringGadget(#Answer, 100, 310, 150, 20, "", #PB_String_ReadOnly)
  SetGadgetFont(#Answer, FontID(#Font_MainWindow_1))
  ButtonGadget(#Button_Calculate, 300, 138, 230, 80, "Calculate")
  SetGadgetFont(#Button_Calculate, FontID(#Font_MainWindow_1))
  ComboBoxGadget(#Combo_Equipment, 420, 20, 110, 28)
  GadgetToolTip(#Combo_Equipment, "Distinction between open and box enclosure configurations...")
  SetGadgetFont(#Combo_Equipment, FontID(#Font_MainWindow_0))
  AddGadgetItem(#Combo_Equipment, -1, "Box Configs")
  AddGadgetItem(#Combo_Equipment, -1, "Open Configs", 0, 1)
  StringGadget(#String_Voltage, 190, 20, 100, 20, "")
  GadgetToolTip(#String_Voltage, "Set typical voltage between 0.05 and 132...")
  SetGadgetFont(#String_Voltage, FontID(#Font_MainWindow_0))
  Frame_0 = FrameGadget(#PB_Any, 10, 0, 530, 228, "System Details")
  SetGadgetFont(Frame_0, FontID(#Font_MainWindow_2))
  Text_Voltage = TextGadget(#PB_Any, 20, 20, 140, 20, "System Voltage (kV) :")
  SetGadgetFont(Text_Voltage, FontID(#Font_MainWindow_0))
  StringGadget(#String_Arching_Time, 190, 140, 100, 20, "")
  GadgetToolTip(#String_Arching_Time, "Set typical arcing time between 0.02 and 2...")
  SetGadgetFont(#String_Arching_Time, FontID(#Font_MainWindow_0))
  Text_Arching = TextGadget(#PB_Any, 20, 140, 150, 20, "Arching Time (s) :")
  SetGadgetFont(Text_Arching, FontID(#Font_MainWindow_0))
  StringGadget(#String_Current, 190, 80, 100, 20, "")
  GadgetToolTip(#String_Current, "Set typical fault current between 0.7 and 106...")
  SetGadgetFont(#String_Current, FontID(#Font_MainWindow_0))
  Text_Fault = TextGadget(#PB_Any, 20, 80, 150, 20, "Three Phase Fault (kA) :")
  SetGadgetFont(Text_Fault, FontID(#Font_MainWindow_0))
  Text_Grounding = TextGadget(#PB_Any, 300, 60, 110, 20, "Grounding :")
  SetGadgetFont(Text_Grounding, FontID(#Font_MainWindow_0))
  Frame_100_Normalised = FrameGadget(#PB_Any, 20, 340, 240, 48, "Normalised Energy (En)")
  SetGadgetFont(Frame_100_Normalised, FontID(#Font_MainWindow_3))
  FrameGadget(#Current_Percentage, 280, 238, 260, 260, "75% of Arc Fault Current")
  SetGadgetFont(#Current_Percentage, FontID(#Font_MainWindow_2))
  StringGadget(#Answer_75, 370, 310, 150, 20, "", #PB_String_ReadOnly)
  SetGadgetFont(#Answer_75, FontID(#Font_MainWindow_1))
  Frame_75_Normalised = FrameGadget(#PB_Any, 290, 340, 240, 48, "Normalised Energy (En)")
  SetGadgetFont(Frame_75_Normalised, FontID(#Font_MainWindow_3))
  TextGadget(#Text_Energy_Incident_100, 30, 410, 60, 20, "J/cm² :", #PB_Text_Right)
  SetGadgetFont(#Text_Energy_Incident_100, FontID(#Font_MainWindow_0))
  StringGadget(#Answer_Normalised_75, 370, 360, 150, 20, "", #PB_String_ReadOnly)
  SetGadgetFont(#Answer_Normalised_75, FontID(#Font_MainWindow_1))
  Text_Voltage_75 = TextGadget(#PB_Any, 300, 310, 60, 20, "kA :", #PB_Text_Right)
  SetGadgetFont(Text_Voltage_75, FontID(#Font_MainWindow_0))
  Frame_75_Arcing = FrameGadget(#PB_Any, 290, 290, 240, 48, "Arcing Current (Ia)")
  SetGadgetFont(Frame_75_Arcing, FontID(#Font_MainWindow_3))
  Text_Arching_Copy1 = TextGadget(#PB_Any, 20, 170, 140, 20, "Distance Factor (x) :")
  SetGadgetFont(Text_Arching_Copy1, FontID(#Font_MainWindow_0))
  StringGadget(#String_Distance_Factor, 190, 170, 100, 20, "", #PB_String_ReadOnly)
  GadgetToolTip(#String_Distance_Factor, "Set typical distance factor between 0.973 and 2.000...")
  SetGadgetFont(#String_Distance_Factor, FontID(#Font_MainWindow_0))
  StringGadget(#Answer_Incident, 100, 410, 150, 20, "", #PB_String_ReadOnly)
  SetGadgetFont(#Answer_Incident, FontID(#Font_MainWindow_1))
  Frame_100_Incident = FrameGadget(#PB_Any, 20, 390, 240, 48, "Incident Energy (E)")
  SetGadgetFont(Frame_100_Incident, FontID(#Font_MainWindow_3))
  FrameGadget(#Current_100, 10, 238, 260, 260, "100% of Arc Fault Current")
  SetGadgetFont(#Current_100, FontID(#Font_MainWindow_2))
  Text_Equipment = TextGadget(#PB_Any, 300, 20, 110, 20, "Configurations :")
  SetGadgetFont(Text_Equipment, FontID(#Font_MainWindow_0))
  StringGadget(#String_Gap, 190, 50, 100, 20, "")
  GadgetToolTip(#String_Gap, "Set typical gap between 1 and 2000...")
  SetGadgetFont(#String_Gap, FontID(#Font_MainWindow_0))
  Text_Gap = TextGadget(#PB_Any, 20, 50, 150, 20, "Conductor Gap (mm) :")
  SetGadgetFont(Text_Gap, FontID(#Font_MainWindow_0))
  TextGadget(#Text_Energy_Normalised_100, 30, 360, 60, 20, "J/cm² :", #PB_Text_Right)
  SetGadgetFont(#Text_Energy_Normalised_100, FontID(#Font_MainWindow_0))
  StringGadget(#String_Distance_Person, 190, 110, 100, 20, "")
  GadgetToolTip(#String_Distance_Person, "Set typical working distance between 150 and 10000...")
  SetGadgetFont(#String_Distance_Person, FontID(#Font_MainWindow_0))
  Text_Distance = TextGadget(#PB_Any, 20, 110, 150, 20, "Working Distance (mm) :")
  SetGadgetFont(Text_Distance, FontID(#Font_MainWindow_0))
  StringGadget(#Answer_Normalised, 100, 360, 150, 20, "", #PB_String_ReadOnly)
  SetGadgetFont(#Answer_Normalised, FontID(#Font_MainWindow_1))
  ComboBoxGadget(#Combo_Grounding, 420, 60, 110, 25)
  GadgetToolTip(#Combo_Grounding, "Ungrounded and high-resistance grounded systems...")
  SetGadgetFont(#Combo_Grounding, FontID(#Font_MainWindow_0))
  AddGadgetItem(#Combo_Grounding, -1, "Grounded")
  AddGadgetItem(#Combo_Grounding, -1, "Ungrounded", 0, 1)
  Text_Voltage_100 = TextGadget(#PB_Any, 30, 310, 60, 20, "kA :", #PB_Text_Right)
  SetGadgetFont(Text_Voltage_100, FontID(#Font_MainWindow_0))
  Frame_100_Arcing = FrameGadget(#PB_Any, 20, 290, 240, 48, "Arcing Current (Ia)")
  SetGadgetFont(Frame_100_Arcing, FontID(#Font_MainWindow_3))
  Frame_75_Incident = FrameGadget(#PB_Any, 290, 390, 240, 48, "Incident Energy (E)")
  SetGadgetFont(Frame_75_Incident, FontID(#Font_MainWindow_3))
  StringGadget(#Answer_Incident_75, 370, 410, 150, 20, "", #PB_String_ReadOnly)
  SetGadgetFont(#Answer_Incident_75, FontID(#Font_MainWindow_1))
  TextGadget(#Text_Energy_Incident_75, 300, 410, 60, 20, "J/cm² :", #PB_Text_Right)
  SetGadgetFont(#Text_Energy_Incident_75, FontID(#Font_MainWindow_0))
  TextGadget(#Text_Energy_Normailsed_75, 300, 360, 60, 20, "J/cm² :", #PB_Text_Right)
  SetGadgetFont(#Text_Energy_Normailsed_75, FontID(#Font_MainWindow_0))
  TextGadget(#Text_PPE_Rating, 20, 200, 140, 20, "PPE Rating (J/cm²) :")
  SetGadgetFont(#Text_PPE_Rating, FontID(#Font_MainWindow_0))
  StringGadget(#String_Rating, 190, 200, 100, 20, "")
  GadgetToolTip(#String_Rating, "Set between 5 and 800, note: 5.0 J/cm2 is bare skin...")
  SetGadgetFont(#String_Rating, FontID(#Font_MainWindow_0))
  Frame_75_Flash = FrameGadget(#PB_Any, 290, 440, 240, 48, "Distance Boundary (DB)")
  SetGadgetFont(Frame_75_Flash, FontID(#Font_MainWindow_3))
  Text_Flash_75 = TextGadget(#PB_Any, 300, 460, 60, 20, "mm :", #PB_Text_Right)
  SetGadgetFont(Text_Flash_75, FontID(#Font_MainWindow_0))
  StringGadget(#Answer_Flash_75, 370, 460, 150, 20, "", #PB_String_ReadOnly)
  SetGadgetFont(#Answer_Flash_75, FontID(#Font_MainWindow_1))
  Frame_Flash = FrameGadget(#PB_Any, 20, 440, 240, 48, "Distance Boundary (DB)")
  SetGadgetFont(Frame_Flash, FontID(#Font_MainWindow_3))
  Text_Flash = TextGadget(#PB_Any, 30, 460, 60, 20, "mm :", #PB_Text_Right)
  SetGadgetFont(Text_Flash, FontID(#Font_MainWindow_0))
  StringGadget(#Answer_Flash, 100, 460, 150, 20, "", #PB_String_ReadOnly)
  SetGadgetFont(#Answer_Flash, FontID(#Font_MainWindow_1))
  CheckBoxGadget(#Checkbox_Joules, 170, 200, 20, 20, "")
  GadgetToolTip(#Checkbox_Joules, "Alternate between joules and calories...")
  SetGadgetFont(#Checkbox_Joules, FontID(#Font_MainWindow_0))
  CheckBoxGadget(#Checkbox_Distance, 170, 170, 20, 20, "")
  GadgetToolTip(#Checkbox_Distance, "Set distance x factor to manual mode...")
  SetGadgetFont(#Checkbox_Distance, FontID(#Font_MainWindow_0))
  ComboBoxGadget(#Combo_Equipment_Type, 420, 100, 110, 25)
  GadgetToolTip(#Combo_Equipment_Type, "This needs to be set if distance factor is not set to manual mode...")
  SetGadgetFont(#Combo_Equipment_Type, FontID(#Font_MainWindow_0))
  AddGadgetItem(#Combo_Equipment_Type, -1, "Open Air")
  AddGadgetItem(#Combo_Equipment_Type, -1, "Switchgear", 0, 1)
  AddGadgetItem(#Combo_Equipment_Type, -1, "MCC / Panels", 0, 2)
  AddGadgetItem(#Combo_Equipment_Type, -1, "Cable", 0, 3)
  Text_Equipment_Type = TextGadget(#PB_Any, 300, 100, 110, 20, "Equipment Type :")
  SetGadgetFont(Text_Equipment_Type, FontID(#Font_MainWindow_0))
  TrackBarGadget(#TrackBar_Integer, 20, 260, 240, 25, 0, 15, #PB_TrackBar_Ticks)
  CloseGadgetList()
EndProcedure

Procedure MainWindow_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Checkbox_Lee
          Lee_Factor(EventType())          
        Case #TrackBar_Current
          Arcing_Current(EventType())          
        Case #Button_Calculate
          Arcing_Current(EventType())          
        Case #Combo_Equipment
          Arcing_Current(EventType())          
        Case #Combo_Grounding
          Arcing_Current(EventType())          
        Case #Checkbox_Joules
          JoulesToCal(EventType())          
        Case #Checkbox_Distance
          Distance_Factor(EventType())          
        Case #Combo_Equipment_Type
          Equipment_Type(EventType())          
        Case #TrackBar_Integer
          Arcing_Current(EventType())          
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure
Ted.

Re: Arc-Flash Calculator...

Posted: Thu Nov 27, 2014 3:00 pm
by aucrobert
Hi,
after use the 2 files I got error:

[COMPILER] Ligne 235 Procedure is already declared: Arcing_Current (/……flash.pbf line 234).

the fact is .pbf we can't Modify the file is a automatic file.

If you don't have the same result please give more info.

Compile with MacBook Pro 32g 512ssd with PureBasic MAC x64 5.31

Thanks

Re: Arc-Flash Calculator...

Posted: Thu Nov 27, 2014 4:25 pm
by aucrobert
Hi,
After working with the program:
This is the problem LINE 234

234- SendMessage (GadgetID(#String_Distance_Factor), #EM_SETREADONLY, #False, #False) ; Remove read only status
237- ; SendMessage_(GadgetID(#String_Distance_Factor), #EM_SETREADONLY, #True, #False) ; Enable read only status
253 ;
255 ;


CODE error:

[COMPILER] Ligne 234 SendMessage() is not a function, array, list, map or macro

if I comment the line ; 234, 237, 253 and 255 with ( ; ) The program compile

Thanks