Jump to content

Trying to close a child and return to the parent gui process?


Recommended Posts

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Misc.au3>
#include <File.au3>
#include <Date.au3>
#include <StaticConstants.au3>
AutoItSetOption('MouseCoordMode' , 0)
Opt("WinTitleMatchMode", 2)
Opt("PixelCoordMode", 0)
HotKeySet("{SPACE}", "Pause")
HotKeySet("{ESC}", "EscapeApplication")


#Region ### START Koda GUI section ### Form=c:\users\sdunn\desktop\autoit stuff\firmwareupdaterform.kxf
Global $firmwareUpdater = GUICreate("BP3 Firmware Updater", 631, 502, 266, 124)
   GUISetBkColor(0x696969)
Global $Group1 = GUICtrlCreateGroup("Choose the devices you would like to update", 32, 96, 329, 297)
  GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
  GUICtrlSetColor(-1, 0x000000)
Global $centralController = GUICtrlCreateCheckbox("Central Controller", 64, 128, 193, 17)
  GUICtrlSetColor(-1, 0xFFFFFF)
Global $remote1 = GUICtrlCreateCheckbox("Remote Node #1", 64, 149, 137, 17)
Global $remote2 = GUICtrlCreateCheckbox("Remote Node #2", 64, 170, 137, 17)
Global $remote3 = GUICtrlCreateCheckbox("Remote Node #3", 64, 190, 137, 17)
Global $remote4 = GUICtrlCreateCheckbox("Remote Node #4", 64, 211, 137, 17)
Global $remote5 = GUICtrlCreateCheckbox("Remote Node #5", 64, 232, 137, 17)
Global $inputNode = GUICtrlCreateCheckbox("Input Node", 64, 253, 137, 17)
Global $RA200 = GUICtrlCreateCheckbox("200R Siren A", 64, 274, 137, 17)
Global $RB200 = GUICtrlCreateCheckbox("200R Siren B", 64, 294, 137, 17)
Global $Amp480 = GUICtrlCreateCheckbox("480 Amplifier", 64, 315, 137, 17)
Global $controlPanel = GUICtrlCreateCheckbox("Control Panel", 64, 336, 137, 17)
Global $CPport = GUICtrlCreateRadio("CP port", 88, 357, 73, 17)
  GUICtrlSetState(-1, $GUI_CHECKED)
Global $SirenPort = GUICtrlCreateRadio("SIREN port", 171, 357, 97, 17)
Global $Both = GUICtrlCreateRadio("Both", 285, 357, 57, 17)
  GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $updateSelected = GUICtrlCreateButton("Update Selected", 400, 166, 185, 33)
  GUICtrlSetFont(-1, 11, 800, 0, "Verdana")
  GUICtrlSetColor(-1, 0xFFFFFF)
  GUICtrlSetBkColor(-1, 0x000000)
Global $updateAll = GUICtrlCreateButton("Update ALL Devices", 400, 238, 185, 33)
  GUICtrlSetFont(-1, 11, 800, 0, "Verdana")
  GUICtrlSetColor(-1, 0xFFFFFF)
  GUICtrlSetBkColor(-1, 0x000000)
Global $openBP3 = GUICtrlCreateButton("Open bluePrint3", 208, 42, 185, 33)
  GUICtrlSetFont(-1, 11, 800, 0, "Verdana")
  GUICtrlSetBkColor(-1, 0x0066CC)
Global $Exit = GUICtrlCreateButton("Exit", 208, 418, 185, 33)
  GUICtrlSetFont(-1, 11, 800, 0, "Verdana")
  GUICtrlSetBkColor(-1, 0x800000)
Global $latestFw = GUICtrlCreateCheckbox("Use Latest FW", 472, 120, 145, 17)
  GUICtrlSetState(-1, $GUI_CHECKED)
  GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
  GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;##################################################### Global variables ##########################################################################################
Global $PageTitle = 'bluePRINT 3 - Version 3.'
Global $diagnosticsWin = 'bluePRINT Diagnostics'

Global $sameFWpopup = 'Same Firmware'
Global $sameFWtext = "The current firmware version on the device is the same as the firmware file version."

Global $youSurePopup = "One Click Update"
Global $youSureText = "This operation will erase the device and update firmware."

Global $fwUpdateCompPopup = "Firmware Update"
Global $fwUpdateCompText = "Firmware update is complete"

Global $notRecognizedCPpopup = "Control Panel Firmware"
Global $notRecognizedCPtext = "Control Panel type is not recognized on selected central port."

Global $fwUpdateCompPopup2 = "Update Firmware Result"
Global $fwUpdateCompText2 = "Update successful."

Global $centralNotConnectedPop = "Firmware Update"
Global $centralNotConnectedText = "No USB connection to controller detected."

Global $cpUpdateCompPopup = "Control Panel Update"
Global $cpUpdateCompText = "Control panel update successful!"

Global $useLatestCheckBoxText = "Use Latest"

Global $selectFWfile = "Please select the firmware update file for the device being updated:"

Global $centralStatus = "Not Attempted"
Global $r1Status = "Not Attamepted"
Global $r2Status = "Not Attempted"
Global $r3Status = "Not Attempted"
Global $r4Status = "Not Attempted"
Global $r5Status = "Not Attempted"
Global $inputNodeStatus = "Not Attempted"
Global $RA200Status = "Not Attempted"
Global $RB200Status = "Not Attempted"
Global $amp480Status = "Not Attempted"
Global $CPpanelStatus = "Not Attempted"
Global $SIRENpanelStatus = "Not Attempted"
Global $x = 0
Global $status = ""
Global $checkedYN = ""

;##################################################### Program order of events #############################################################################


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Exit
            Exit
        Case $openBP3
            _bluePRINT3()

        Case $updateSelected
            _goToDiagnosticsFWtab()

            ;if central is selected update it
            If GUICtrlRead($centralController) = 1 Then
                _updateCentral()
            EndIf

            ;if remotnode 1 is selected update it
            If GUICtrlRead($remote1) = 1 Then
                _updateRemote1()
            EndIf

            ;if remotenode 2 is selected update it
            If GUICtrlRead($remote2) = 1 Then
                _updateRemote2()
            EndIf

            ;if remotenode 3 is selected update it
            If GUICtrlRead($remote3) = 1 Then
                _updateRemote3()
            EndIf

            ;if remotenode 4 is selected update it
            If GUICtrlRead($remote4) = 1 Then
                _updateRemote4()
            EndIf

            ;if remotenode 5 is selected update it
            If GUICtrlRead($remote5) = 1 Then
                _updateRemote5()
            EndIf

            ;if input node is selected update it
            If GUICtrlRead($inputNode) = 1 Then
                _updateInputNode()
            EndIf

            ;if 200R siren A is selected update it
            If GUICtrlRead($RA200) = 1 Then
                _update200Ra()
            EndIf

            ;if 200R siren B is selected update it
            If GUICtrlRead($RB200) = 1 Then
                _update200Rb()
            EndIf

            ;if 480 Amplifier is selected update it
            If GUICtrlRead($Amp480) = 1 Then
                _update480Amp()
            EndIf

            ;if control panel is selected update it
            If GUICtrlRead($controlPanel) = 1 Then
                _updateControlPanel()
            EndIf
            _updateStatusReportAll()

        Case $updateAll
            _goToDiagnosticsFWtab()
            _updateCentral()
            ;_updateRemote1()
            ;_updateRemote2()
            ;_updateRemote3()
            ;_updateRemote4()
            ;_updateRemote5()
            ;_updateInputNode()
            ;_update200Ra()
            ;_update200Rb()
            ;_update480Amp()
            ;GUICtrlSetState($Both, $GUI_CHECKED)
            ;_updateControlPanel()

    EndSwitch
WEnd



;##################################################### HotKey Functions ###########################################################################################

Func Pause()
   While _IsPressed(20)
   WEnd
EndFunc

Func EscapeApplication()
    Exit
EndFunc



;################################################### Functions ####################################################################################################

Func _bluePRINT3()              ;opens bp3 app
Local $aBluePRINT3 = _FileListToArrayRec(@LocalAppDataDir & "\Apps\2.0", "bluePRINT3.exe", 1, 1, 1, 2) ;creates an array with 1st entry being path, second being file
        If @error Then Exit MsgBox(16, "bluePRINT3", "Unable to find bluePRINT3.exe files under " & @LocalAppDataDir & "\Apps\2.0")  ;if the bp3.exe file can't be found it gives error


    Local $aBP3Version[$aBluePRINT3[0]][2]     ;creates a new array that takes each entry in the first array and gives it a version/time
    For $i = 1 To $aBluePRINT3[0]
        $aBP3Version[$i-1][0] = $aBluePRINT3[$i]
        $aBP3Version[$i-1][1] = FileGetTime($aBluePRINT3[$i], 1, 1)  ;  Organizes by the time the BP3.exe file was created,  FileGetVersion($aBluePRINT3[$i])


    Next
    _ArraySort($aBP3Version, 1, 0, 0, 1)  ; Sorts array so that the file created most recently is shown first [0][0] descending order

    Run($aBP3Version[0][0])  ;runs the most recently created bp3.exe file
    WinWait($PageTitle)
    WinActivate($PageTitle)
EndFunc


Func _findFwFile($folder, $name)   ;finds the correct firmware file for each device
                                    ;Path to all FW files  J:\PD\Development\Products\Control_Systems\EV_Control_System\03-Software\firmware_images_for_Autotest\
                                    ;Newest RemRot FW file: CP_SO_RR_v01_09.enc
                                    ;Newest Remote Push FW File: CP_SO_RE_v02_17.enc
                                    ;Newest Handheld FW file: CP_SO_HH_v02_17.enc
                                    ;Newest Console FW file: CP_SO_CN_v02_06.enc

    $FWfolderPath = 'J:\PD\Development\Products\Control_Systems\EV_Control_System\03-Software\firmware_images_for_Autotest\' & $folder
    Local $aFWFileList = _FileListToArray($FWfolderPath, $name, 1)
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Break

    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Break
    EndIf

   ; _ArrayDisplay($aFWFileList, "$aFWFileList")         ;Line used to test the array $aFWFileList

    _ArrayReverse($aFWFileList)                          ;Reverses the order of the array so it can find the very last element which is the newest version

    ;_ArrayDisplay($aFWFileList, "$aFWFileList")         ;Line used to test the array $aFWFileList

    $FWfile = $aFWFileList[0]                            ;Saves name of file into a variable

    ;MsgBox(0, "FW File", $fwFile)                       ;Line used to test the array $aFWFileList


    WinWait($selectFWfile)
    WinActivate($selectFWfile)
    ControlClick ($selectFWfile, "", "[CLASS:Edit; INSTANCE:1]", 'primary', 1, 149, 12)
    Sleep(200)
    Send($FWfolderpath)
    Send($FWfile)
    Send ("{ENTER}")
    ControlClick($selectFWfile, "&Open", "[CLASS:Button; INSTANCE:1]", "primary", 1,313, 12)
    _popUps()
EndFunc


Func _goToDiagnosticsFWtab()    ;opens the diagnostics window and goes to firmware update tab
    WinActivate($pageTitle)
        MouseClick('primary',351, 47, 1, 0)
    WinWait($diagnosticsWin)
    WinActivate($diagnosticsWin)
        MouseClick('primary', 125, 40, 1, 0)

EndFunc



Func _FWdeviceSelect()          ;Clicks the device drop down box in firmware update tab
    WinActivate($diagnosticsWin)
        ControlClick($diagnosticsWin, "", "[NAME:cB_FW_Module]", 'primary', 1, 57, 13 )
EndFunc


Func _oneClickUp($w, $t)        ;clicks the OneClickUpdate button in the firmware update tab
    WinActivate($diagnosticsWin)
        _isUseLatestChecked($w, $t)
        ControlClick($diagnosticsWin,"One-Click Update","[NAME:b_OneFWUpdate]","primary", 1)

        If GUICtrlRead($latestFw) = 1 Then
        _popUps()
        EndIf
EndFunc


Func _popUps()                  ;handles popups during install and makes the app wait until the firmware is done installing to move to the next device
    $x = 1  ;this variable will only change if the fw update complete popup appears OR if there is an error message
    While $x = 1

        If WinActive("CP port panel") Then
            GUIDelete(WinGetHandle("CP port panel"))
        EndIf


        If WinActive("SIREN port panel") Then
            GUIDelete(WinGetHandle("SIREN port panel"))
        EndIf


        If WinActive($sameFWpopup, $sameFWtext) Then
            ControlClick("Same Firmware", "&Yes", 6,'primary', 1)
        EndIf


        If WinActive($youSurePopup, $youSureText) Then
            ControlClick($youSurePopup, "&Yes", 6, 'primary', 1)
        EndIf


        If WinActive($centralNotConnectedPop, $centralNotConnectedText) Then
            ControlClick($centralNotConnectedPop, "OK", 2, 'primary', 1)
            $x = 3
            $status = "FAILED - Central Not Connected"
        EndIf


        If WinActive($notRecognizedCPpopup, $notRecognizedCPtext) Then
            ControlClick($notRecognizedCPpopup, "OK", 2, 'primary', 1)
            $x = 3
            $status = "FAILED - Device Not Detected/Recognized"
        EndIf


        If WinActive($fwUpdateCompPopup, $fwUpdateCompText) Then
            ControlClick($fwUpdateCompPopup, "OK", 2, 'primary', 1)
            $x = 2
            $status = "SUCCESSFUL"
        EndIf


        If WinActive($fwUpdateCompPopup2, $fwUpdateCompText2) Then
            ControlClick($fwUpdateCompPopup2, "OK", 2, 'primary', 1)
            $x = 2
            $status = "SUCCESSFUL"
        EndIf


        If WinActive($cpUpdateCompPopup, $cpUpdateCompText) Then
            ControlClick($cpUpdateCompPopup, "OK", 2, 'primary', 1)
            $x=2
            $status = "SUCCESSFUL"
        EndIf

    WEnd

EndFunc


Func _updateStatusReportAll()   ;Produces a report that displays whether each device was attempted, succeeded, or failed the update

    MsgBox(1, "Firmware Update Results", "Central: " & $centralStatus & @LF & "Remote Node 1: " & $r1Status & @LF & "Remote Node 2: " & $r2Status & @LF & "Remote Node 3: " & $r3Status & @LF & "Remote Node 4: " & $r4Status & @LF & "Remote Node 5: " & $r5Status & @LF & "Input Node: " & $inputNodeStatus & @LF & "200R Siren A: " & $RA200Status & @LF & "200R Siren B: " & $RB200Status & @LF & "480 Amplifier: " & $amp480Status & @LF & "CP Control Panel: " & $CPpanelStatus & @LF & "SIREN Control Panel: " & $SIRENpanelStatus)

EndFunc


Func _isUseLatestChecked($w, $t)      ;checks to see if the used latest box is checked on the fw update tab
        ;coords (203,161) detect checkmark in regular box location
        ;coords (199, 198) detect checkmark when box is moved after control panel is selected
        If $w = 203 Then
            $color = "6476A5"
        Else
            $color = "475C94"
        EndIf

    WinActivate($diagnosticsWin)

    $checked1 = PixelGetColor($w, $t)
    $checked2 = Hex($checked1, 6)
    $checkedYN = ""
    ;MsgBox(0, "color of checkmark", $checked2)                 ;used to test pixelcolor

    If $checked2 = $color Then
      $checkedYN = "Yes"
    Else
      $checkedYN = "No"
    EndIf


   ; MsgBox(0, "Is use latest checked?", "Is use Latest checked? " & $checkedYN)            ;used to test if box is checked or not


    If GUICtrlRead($latestFw) = 1 And $checkedYN = "No" Then

        ControlClick($diagnosticsWin, "Use Latest", "[NAME:chkUseLatestFirmware]", "primary", 1)
        ;MsgBox(0, "first if statement", "checked in test gui, not checked in bp3")              ;used to make sure loop is executed properly


    ElseIf GUICtrlRead($latestFW) <> 1 And $checkedYN = "Yes"  Then

        ControlClick($diagnosticsWin, "Use Latest", "[NAME:chkUseLatestFirmware]", "primary", 1)
        ;MsgBox(0, "second if statement", "not checked in test gui, checked in bp3")            ;used to make sure loop is executed properly

    EndIf

EndFunc


Func _updateCentral()           ;runs through updating the central
    _FWdeviceSelect()
        Send ('{UP 10}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) = 1 Then

    Else
        _findFwFile("central\", "CPDU_APP_v3_*.enc")
    EndIf
    $centralStatus = $status
    Sleep(2000)
EndFunc


Func _updateRemote1()           ;runs through updating remote node 1
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 1}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) <> 1 Then
        _findFwFile('remote\', "RPDU_APP_v01_*.enc")
    EndIf

    $r1Status = $status
EndFunc


Func _updateRemote2()           ;runs through updating remote node 2
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 2}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) <> 1 Then
        _findFwFile('remote\', "RPDU_APP_v01_*.enc")
    EndIf

    $r2Status = $status

EndFunc


Func _updateRemote3()          ;runs through updating remote node 3
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 3}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) <> 1 Then
        _findFwFile('remote\', "RPDU_APP_v01_*.enc")
    EndIf

    $r3Status = $status
EndFunc


Func _updateRemote4()           ;runs through updating remote node 4
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 4}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) <> 1 Then
        _findFwFile('remote\', "RPDU_APP_v01_*.enc")
    EndIf

    $r4Status = $status
EndFunc


Func _updateRemote5()           ;runs through updating remote node 5
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 5}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) <> 1 Then
        _findFwFile('remote\', "RPDU_APP_v01_*.enc")
    EndIf

    $r5Status = $status
EndFunc


Func _updateInputNode()         ;runs through updating the input node
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 6}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) <> 1 Then
        _findFwFile('input_node\', "INPUT_NODE_APP_v01_*.enc")
    EndIf

    $inputNodeStatus = $status
EndFunc


Func _update200Ra()             ;runs through updating the 200R siren A
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 7}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) <> 1 Then
        _findFwFile('200R\', "200R_APP_v01_*.enc")
    EndIf

    $RA200Status = $status
EndFunc


Func _update200Rb()             ;runs through updating the 200R siren B
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 8}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) <> 1 Then
        _findFwFile('200R\', "200R_APP_v01_*.enc")
    EndIf

    $RB200Status = $status
EndFunc


Func _update480Amp()            ;runs through updating the 480Amplifier
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 9}{ENTER}')
    _oneClickUp(203,161)

    If GUICtrlRead($latestFw) <> 1 Then
        _findFwFile('480R\', "480_Amp_SO_2W_v01_*.enc")
    EndIf

    $amp480Status = $status
EndFunc


Func _updateControlPanel()      ;runs through updating the control panels whether in CP port, Siren port, or both calls on updateCPpanel and updateSIRENpanel functions
    _FWdeviceSelect()
        Send ('{UP 10}{DOWN 10}{ENTER}')

        If GUICtrlRead($CPport)= 1 Then
            _updateCPpanel()

        ElseIf GUICtrlRead($SIRENport)= 1 Then
            _updateSIRENpanel()

        ElseIf GUICtrlRead($Both)= 1 Then
            _updateCPpanel()
            _updateSIRENpanel()
        EndIf

    $controlPanelStatus = $status
EndFunc


Func _updateCPpanel()            ;updates CP panel if called out by updateControlPanel function

    ControlClick($diagnosticsWin, "", "[NAME:cmbCentralPort]", "primary", 1)
    Send('{UP}{ENTER}');selects CP
    _oneClickUp(199, 198)

    If GUICtrlRead($latestFw) <> 1 Then
        WinWait($selectFWfile)

        $CPpanelMessage = GUICreate("CP port panel", 501, 154, 266, 124)
        $CPportLabel = GUICtrlCreateLabel("Which control panel type is plugged into the CP port?", 64, 16, 353, 18)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $CPpush = GUICtrlCreateButton("RemotePUSH", 41, 88, 123, 25)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $CProtary = GUICtrlCreateButton("RemoteROTARY", 193, 88, 139, 25)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $CPhandheld = GUICtrlCreateButton("HandHeld", 361, 88, 99, 25)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        GUISetState()

        $handle = WinGetHandle( "CP port panel")

            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($handle)

                    Case $CPpush
                        _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                        $CPpanelStatus = $status
                        GUIDelete($handle)

                    Case $CProtary
                        _findFwFile('control_panels\', "CP_SO_RR_v01_*.enc")
                        $CPpanelStatus = $status
                        GUIDelete($handle)

                    Case $CPhandheld
                        _findFwFile('control_panels\', "CP_SO_HH_v02_*.enc")
                        $CPpanelStatus = $status
                        GUIDelete($handle)


                EndSwitch
            WEnd




    EndIf

EndFunc


Func _updateSIRENpanel()         ;updates SIREN panel if called out by updateControlPanel function

    ControlClick($diagnosticsWin, "", "[NAME:cmbCentralPort]", "primary", 1)
    Send('{DOWN} {ENTER}');selects SIREN
    _oneClickUp(199, 198)

    If GUICtrlRead($latestFw) <> 1 Then
        WinWait($selectFWfile)

        $SIRENpanelMessage = GUICreate("SIREN port panel", 549, 258, 266, 124)
        $SIRENportLable = GUICtrlCreateLabel("Which control panel type is plugged into the SIREN port?", 80, 40, 377, 18)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENconsRotary = GUICtrlCreateButton("Console ROTARY", 120, 112, 131, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENconsPush = GUICtrlCreateButton("Console PUSH", 312, 112, 131, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENremPush = GUICtrlCreateButton("Remote PUSH", 24, 176, 123, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENremRotary = GUICtrlCreateButton("Remote ROTARY", 208, 176, 123, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENhandheld = GUICtrlCreateButton("HandHeld", 392, 176, 123, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        GUISetState()

        $handle = WinGetHandle( "SIREN port panel")
        While 1
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    GUIDelete($handle)

                Case $SIRENconsRotary
                    _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                    $SIRENpanelStatus = $status
                    GUIDelete($handle)

                Case $SIRENconsPush
                    _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                    $SIRENpanelStatus = $status
                    GUIDelete($handle)

                Case $SIRENremPush
                    _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                    $SIRENpanelStatus = $status
                    GUIDelete($handle)

                Case $SIRENremRotary
                    _findFwFile('control_panels\', "CP_SO_RR_v01_*.enc")
                    $SIRENpanelStatus = $status
                    GUIDelete($handle)

                Case $SIRENhandheld
                    _findFwFile('control_panels\', "CP_SO_HH_v02_*.enc")
                    $SIRENpanelStatus = $status
                    GUIDelete($handle)

            EndSwitch
        WEnd


    EndIf

EndFunc

Above is my code.  The two functions involved with the "child" gui (I'm not sure if that's right or not) are   _updateCPpanel   and   _updateSIRENpanel  .

What I want to happen is if I go to update a CP or SIREN panel from a file a little gui asks what type of control panel is plugged in, user clicks the relevant button, child gui goes away, it selects the correct file based on what button was pressed in child gui, and continues in the main chunk of code where it left off.

 

Right now I click a button on the child gui and it finds the file and updates the panel....then the child gui goes away BUT the main chunk of code doesn't continue where it left off.

Link to comment
Share on other sites

I haven't tried to run your code, however after a quick glance, I don't see where you exit the While loop in the function _updateSIRENpanel(). You just close the GUI and carry on looping. Maybe using ExitLoop will fix it. I'm not sure if that's where you are stuck.

One way:

While 1
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    ExitLoop

                Case $SIRENconsRotary
                    _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

                Case $SIRENconsPush
                    _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

                Case $SIRENremPush
                    _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

                Case $SIRENremRotary
                    _findFwFile('control_panels\', "CP_SO_RR_v01_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

                Case $SIRENhandheld
                    _findFwFile('control_panels\', "CP_SO_HH_v02_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

            EndSwitch
        WEnd
        GUIDelete($handle)

 

Edited by czardas
Link to comment
Share on other sites

I was using GUIDelete to close the child Gui.  I just assumed that would exit that loop and return to the original.

I will try ExitLoop.  Where should I put ExitLoop? should it be within each of the Child gui's cases? Before/After GUIDelete?

Link to comment
Share on other sites

Func _updateSIRENpanel()         ;updates SIREN panel if called out by updateControlPanel function

    ControlClick($diagnosticsWin, "", "[NAME:cmbCentralPort]", "primary", 1)
    Send('{DOWN} {ENTER}');selects SIREN
    _oneClickUp(199, 198)

    If GUICtrlRead($latestFw) <> 1 Then
        WinWait($selectFWfile)

        $SIRENpanelMessage = GUICreate("SIREN port panel", 549, 258, 266, 124)
        $SIRENportLable = GUICtrlCreateLabel("Which control panel type is plugged into the SIREN port?", 80, 40, 377, 18)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENconsRotary = GUICtrlCreateButton("Console ROTARY", 120, 112, 131, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENconsPush = GUICtrlCreateButton("Console PUSH", 312, 112, 131, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENremPush = GUICtrlCreateButton("Remote PUSH", 24, 176, 123, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENremRotary = GUICtrlCreateButton("Remote ROTARY", 208, 176, 123, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        $SIRENhandheld = GUICtrlCreateButton("HandHeld", 392, 176, 123, 33)
            GUICtrlSetFont(-1, 9, 800, 0, "Verdana")
        GUISetState()

        $handle = WinGetHandle( "SIREN port panel")
        While 1
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $GUI_EVENT_CLOSE
                    ExitLoop

                Case $SIRENconsRotary
                    _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

                Case $SIRENconsPush
                    _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

                Case $SIRENremPush
                    _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

                Case $SIRENremRotary
                    _findFwFile('control_panels\', "CP_SO_RR_v01_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

                Case $SIRENhandheld
                    _findFwFile('control_panels\', "CP_SO_HH_v02_*.enc")
                    $SIRENpanelStatus = $status
                    ExitLoop

            EndSwitch
        WEnd

        GUIDelete($handle)
    EndIf

EndFunc

Above is the code after I added the ExitLoop and it goes back to the main chunk of code again when its run, YAY! Thank you!

My only other issue now is that I would like to have the child gui go away as soon as a button is selected.  Any ideas on how to get that to work?

Link to comment
Share on other sites

My first thought would be to make each case set a variable to a certain number and exit the loop, then use an if, else if loop to look at the variable and if its this number use this file...and so on...the only issue I can see with that is that I would have to use a nested if...and autoit doesn't seem to like those.

Link to comment
Share on other sites

I'm glad that got it going again. :) I don't have time to look in detail right now. The sequence I gave was just an example. You can code this differently - closing the GUI immediately before further processing takes place. It all depends on the order in which you do things. Sometimes you can change the sequence and sometimes doing that will break things. I suggest you look for where you are experiencing lag and see if you can close the GUI earlier in the code. Check everything works.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...