From cf1cab2296a834d6b965f109b44d646dfa38bd44 Mon Sep 17 00:00:00 2001 From: Benjamin Linnik Date: Tue, 24 Sep 2013 18:25:40 +0200 Subject: [PATCH] bot: Added new Function files, more modulare code from now on, easier to maintain and read --- bot/Chips/daq_mi32a_v32(Host).vi.au3 | 71 +++++++ bot/Functions/Checkdata.au3 | 20 ++ bot/Functions/CommonFunctions.au3 | 23 +++ bot/Functions/Header.au3 | 38 ++++ bot/Functions/MoveFolder.au3 | 16 ++ bot/Functions/PrintSucessMessage.au3 | 7 + bot/Functions/ReadAndSaveExcelParameters.au3 | 19 ++ bot/Functions/RefreshGUISendNtfct.au3 | 13 ++ bot/Functions/SaveToExcel.au3 | 13 ++ bot/Functions/SendLog.au3 | 60 ++++++ bot/Functions/SetChipClock.au3 | 10 + bot/Functions/WaitForTemperature.au3 | 41 ++++ bot/Functions/Watchrun.au3 | 37 ++++ bot/Functions/WriteTemperatureLog.au3 | 21 ++ bot/GUI/PXI.ico | Bin 0 -> 15086 bytes bot/Mimosa_Autorun_PXI.au3 | 152 +++++++++++++++ bot/Mimosa_Autorun_USB.au3 | 195 +++++++++++++++++++ bot/config_PXI.ini | 9 + bot/config_USB.ini | 9 + 19 files changed, 754 insertions(+) create mode 100755 bot/Chips/daq_mi32a_v32(Host).vi.au3 create mode 100755 bot/Functions/Checkdata.au3 create mode 100755 bot/Functions/CommonFunctions.au3 create mode 100755 bot/Functions/Header.au3 create mode 100755 bot/Functions/MoveFolder.au3 create mode 100755 bot/Functions/PrintSucessMessage.au3 create mode 100755 bot/Functions/ReadAndSaveExcelParameters.au3 create mode 100755 bot/Functions/RefreshGUISendNtfct.au3 create mode 100755 bot/Functions/SaveToExcel.au3 create mode 100755 bot/Functions/SendLog.au3 create mode 100755 bot/Functions/SetChipClock.au3 create mode 100755 bot/Functions/WaitForTemperature.au3 create mode 100755 bot/Functions/Watchrun.au3 create mode 100755 bot/Functions/WriteTemperatureLog.au3 create mode 100755 bot/GUI/PXI.ico create mode 100755 bot/Mimosa_Autorun_PXI.au3 create mode 100755 bot/Mimosa_Autorun_USB.au3 create mode 100755 bot/config_PXI.ini create mode 100755 bot/config_USB.ini diff --git a/bot/Chips/daq_mi32a_v32(Host).vi.au3 b/bot/Chips/daq_mi32a_v32(Host).vi.au3 new file mode 100755 index 0000000..41093df --- /dev/null +++ b/bot/Chips/daq_mi32a_v32(Host).vi.au3 @@ -0,0 +1,71 @@ +#include-once +Global $chipsoftware[1] = ["daq_mi32a_v32(Host).vi"] +Global $vi +Global $system = "PXI" +$savedir = "C:\data\currentrun" +$storedir = "K:\Mi32" +Global $vref = 1000 ; Initial vref, will be adjusted during runtime +$temperaturebefore = -10000 + +Func CheckWindowExist() ; Check if Mimosa window exists + If WinExists($chipsoftware[0]) = False Then + Run("C:\ccmos_pxie_daq_crate\daq_mi32a_v32_own\daq_mi34_labo.bat", "C:\ccmos_pxie_daq_crate\daq_mi32a_v32_own\") + WinWait($chipsoftware[0]) + EndIf +EndFunc ;==>CheckWindowExist + +Func CheckIfBoardOK() + $i = 0 + While($vi.GetControlValue("I2C !") <> "False") + If($i > 20) Then + MsgBox(16, "Message", "Mimosa board could not be polled, please check if board is connected properly.") + Exit + EndIf + $i = $i + 1 + Sleep(500) + WEnd +EndFunc ;==>CheckIfBoardOK + +Func ProgramMi() + $vi.SetControlValue("Auto update", "1") + Sleep(1000) + $vi.SetControlValue(" Load conf file" & @LF & "Upd clk shift", "1") +EndFunc ;==>ProgramMi + +Func SetMiParameter($matrix, $vref) + $vi.SetControlValue(" Load conf file" & @LF & "Upd clk shift", "1") + $vi.SetControlValue("Auto update", "1") + $matrixnum = StringRegExp ( $matrix, "\d+" , 1 ) + $vi.SetControlValue("Matrix name", $matrixnum[0]) + $vi.SetControlValue("VRef", $vref) + $vi.SetControlValue("Extended signal ", "1") + $vi.SetControlValue("Noise events nb", "0") +EndFunc ;==>SetMiParameter + +Func GetCounter() + Return $vi.GetControlValue("Events counter") +EndFunc ;==>GetCounter + +Func StopRun() + $vi.SetControlValue("Stop Run DUT", "1") + Sleep(100) + $vi.SetControlValue("Stop Run DUT", "0") +EndFunc + +Func StartRun() + $vi.SetControlValue("Save", "1") + $vi.SetControlValue("Overwrite run", "1") + Sleep(100) + $vi.SetControlValue("Start Run DUT", "1") +EndFunc + +Func TestSystem() + $firmware = $vi.GetControlValue("Auxiliary board firmware version") + If ($firmware <> "Year:13,Day:18,Minor:1") Then + RefreshGUISendNtfct("PXI Board could be not OK! Please check the firmware version.") + ;Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUISendNtfct.au3" "' & $system & '" "' & $completelog & '" "PXI Board could be not OK! Please check the firmware version."') + MsgBox(16, "Message", "PXI Board could be not OK! Please check the firmware version.") + Return 1 + EndIf + Return 0 +EndFunc \ No newline at end of file diff --git a/bot/Functions/Checkdata.au3 b/bot/Functions/Checkdata.au3 new file mode 100755 index 0000000..d7aed2d --- /dev/null +++ b/bot/Functions/Checkdata.au3 @@ -0,0 +1,20 @@ + +; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) +Local $answer = MsgBox(4, "Run script?", "Preparing to do all runs in range " & $CellRange & @CRLF & _ + "of file " & $FileName & " with " & @CRLF & _ + "Radioactive source: " & $radSource & @CRLF & _ + "Chip: " & $chipversion & " (#" & $chipinstalled & ")" & @CRLF & _ + "Radiated: " & $radiated & @CRLF & _ + "If you run this script, daq.exe will be closed and the current run aborted, proceed?") + + +; Check the user's answer to the prompt (see the help file for MsgBox return values) +; If "No" was clicked (7) then exit the script +If $answer = 7 Then + Exit +EndIf +If Not FileExists($FileName) Then ; Just a check to be sure.. + MsgBox(16, "Excel Data Test", "Error: Can't find file " & $FileName) + Exit +EndIf +$oExcelDoc = ObjGet($FileName) ; Get an Excel Object from an existing filename \ No newline at end of file diff --git a/bot/Functions/CommonFunctions.au3 b/bot/Functions/CommonFunctions.au3 new file mode 100755 index 0000000..6cf8ab3 --- /dev/null +++ b/bot/Functions/CommonFunctions.au3 @@ -0,0 +1,23 @@ +; $whichone can be set to ChipPXI, ChipUSB (chiptemperature) or PXI, USB for cooling temperature +Func GetTemperatureForSure($whichone) + $tempgeti = 0 + Do + If $tempgeti > 20 Then + Return 100000 + EndIf + If StringInStr(@ScriptDir, "\Functions") Then + $currenttemp = RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\TemperatureControl.au3" "' & $whichone & '"', @ScriptDir) + Else + $currenttemp = RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\TemperatureControl.au3" "' & $whichone & '"', @ScriptDir) + EndIf + $tempgeti = $tempgeti + 1 + Until $currenttemp < 100000 + Return $currenttemp / 100 +EndFunc + +Func RefreshGUISendNtfct( $msg ) + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "' & $msg & '"', @ScriptDir) + $completelog &= _NowCalc() & " " & $msg & @CRLF + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $completelog & '"') + Return $completelog +EndFunc \ No newline at end of file diff --git a/bot/Functions/Header.au3 b/bot/Functions/Header.au3 new file mode 100755 index 0000000..1b51e1e --- /dev/null +++ b/bot/Functions/Header.au3 @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include +#include +#include +#include "BinaryIntegerConvert.au3" +#include "EpochConvert.au3" +$programversion = "0.99" +$excelLineBegin = "1100" ; Change this to the range of cells you want to be processed +$excelLineEnd = "4000" +Global $completelog = "" +$CellRange = "A" & $excelLineBegin & ":P" & $excelLineEnd +$cellSystem = 0 +$cellDate = 1 +$cellChipV = 3 +$cellRunNum = 4 +$cellTemp = 5 +$cellTempWait = 6 +$cellEventsN = 7 +$cellChipN = 8 +$cellVRef = 10 +$cellMatrix = 11 +$cellRadSrc = 12 +$cellClock = 13 +$cellRad = 14 +$cellTChip = 15 +$cellNote = 16 + +$temperaturebefore = -10000 + +; set external parameters +$FileName = IniRead($configfile, "experimental setup", "ExcelPath", "H:\dennis doering\Arbeitsprogramme\Mimosa34\LaborbuchMi34_PXI.xls") ; read path to Excel file +$chipversion = IniRead($configfile, "experimental setup", "ChipVersion", "Mi34") ; current chip generation in the system +$chipinstalled = IniRead($configfile, "experimental setup", "ChipInstalled", "5") ; chip number currently mounted into the system +$radSource = IniRead($configfile, "experimental setup", "RadSource", "none") ; current radioactive source of the system +$radiated = IniRead($configfile, "experimental setup", "Radiated", "") ; radiated chip diff --git a/bot/Functions/MoveFolder.au3 b/bot/Functions/MoveFolder.au3 new file mode 100755 index 0000000..1067903 --- /dev/null +++ b/bot/Functions/MoveFolder.au3 @@ -0,0 +1,16 @@ +AutoItSetOption("TrayIconHide", 1) + +$returnval = 10000 +If ($CmdLine[0] > 1) Then + $returnval = MoveFolder($CmdLine[1], $CmdLine[2]) +EndIf +ConsoleWrite($returnval) ;### Debug Console +Exit $returnval + + +Func MoveFolder($src, $dst) + DirMove ( $src, $dst ) + FileDelete($src & "\*") + DirRemove( $src ) + Return 0 +EndFunc ;==>MoveFolder \ No newline at end of file diff --git a/bot/Functions/PrintSucessMessage.au3 b/bot/Functions/PrintSucessMessage.au3 new file mode 100755 index 0000000..db651c9 --- /dev/null +++ b/bot/Functions/PrintSucessMessage.au3 @@ -0,0 +1,7 @@ +$calcmin = _DateDiff('s', $starttimetotal, _NowCalc()) ; n for minites, s for seconds +$calcmin = Round($calcmin / 60, 2) ; Minutes +$calchours= Round($calcmin / 3600, 2) ; Hoours +$calcdays= Round($calcmin / 86400, 2) ; Days +RefreshGUISendNtfct("All runs (" & $totalrealruns & ") ended in " & $calcmin & " minutes (" & $calchours &" hours).") +;Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUISendNtfct.au3" "' & $system & '" "All runs (' & $totalrealruns & ') ended in ' & $calcmin & ' minutes (' & $calchours &' hours)."') +Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Sucess!'', ''All runs (' & $totalrealruns & ') ended in ' & $calcmin & ' minutes (' & $calchours &' hours, ' & $calcdays & ' days).' & @CRLF & 'Please check the Excel sheet and the results for errors.'')"') diff --git a/bot/Functions/ReadAndSaveExcelParameters.au3 b/bot/Functions/ReadAndSaveExcelParameters.au3 new file mode 100755 index 0000000..3ee8ee6 --- /dev/null +++ b/bot/Functions/ReadAndSaveExcelParameters.au3 @@ -0,0 +1,19 @@ + +$temperaturebefore = $currentline[$cellTemp][0] +$waitfortemp = $currentline[$cellTempWait][0] +If $waitfortemp == "" Then + $waitfortemp = "0" + $currentline[$cellTempWait][0] = "0" +EndIf +$clock = $currentline[$cellClock][0] ; save needed clock +If $clock == "" Then + $clock = "100" + $currentline[$cellClock][0] = "100" +EndIf +Global $runnum = $currentline[$cellRunNum][0] ; save runnumber - Global, to pass to warning messages when run must be skipped +$matrix = $currentline[$cellMatrix][0] ; save matrix number +$eventnum = $currentline[$cellEventsN][0] ; save number of events to save +If $eventnum == "" Then + $eventnum = 100000 + $currentline[$cellEventsN][0] = "100000" +EndIf \ No newline at end of file diff --git a/bot/Functions/RefreshGUISendNtfct.au3 b/bot/Functions/RefreshGUISendNtfct.au3 new file mode 100755 index 0000000..ab89aee --- /dev/null +++ b/bot/Functions/RefreshGUISendNtfct.au3 @@ -0,0 +1,13 @@ +#include +AutoItSetOption("TrayIconHide", 1) + +If ($CmdLine[0] > 2) Then + RefreshGUISendNtfct($CmdLine[1], $CmdLine[2], $CmdLine[3]) +EndIf + +Func RefreshGUISendNtfct( $system, $completelog, $msg ) + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\SendNtfctn.au3" "' & $system & '" "' & $msg & '"', @ScriptDir) + $completelog &= _NowCalc() & " " & $msg & @CRLF + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\RefreshGUI.au3" "' & $completelog & '"') + Return $completelog +EndFunc \ No newline at end of file diff --git a/bot/Functions/SaveToExcel.au3 b/bot/Functions/SaveToExcel.au3 new file mode 100755 index 0000000..be7492d --- /dev/null +++ b/bot/Functions/SaveToExcel.au3 @@ -0,0 +1,13 @@ +$currentline[$cellDate][0] = @MDAY & "." & @MON & "." & @YEAR +$currentline[$cellTChip][0] = $currenttempchip +$currentline[$cellVRef][0] = $vref +$calcsec = _DateDiff('s', $starttime, _NowCalc()) ; n for minites, s for seconds +$calcmin = Round($calcsec / 60, 2) +$calchours = Round($calcsec / 3600, 2) +$currentline[$cellNote][0] = "Automated run, performed by V." & $programversion & " runtime in hours: " & $calchours +$oExcelDoc = ObjGet($FileName) ; if doc was closed and object destroyed -> reopen it. A possibility to check if object exists would come handy here.... +$oDocument = $oExcelDoc.Worksheets(1) ; We use the 'Default' worksheet +$oDocument.range($currentrange).value = $currentline +$oExcelDoc.Windows(1).Visible = True ; Otherwise the worksheet window will be saved 'hidden' +$oExcelDoc.Save ; Save the workbook +$oExcelDoc.saved = 1 \ No newline at end of file diff --git a/bot/Functions/SendLog.au3 b/bot/Functions/SendLog.au3 new file mode 100755 index 0000000..884b8ea --- /dev/null +++ b/bot/Functions/SendLog.au3 @@ -0,0 +1,60 @@ +#include +$notify = IniRead("config.ini", "various", "Notify", "1") ; notifycode +$notifycustom = IniRead("config.ini", "various", "NotifyCustom", "") ; chip number currently mounted into the system + +$error = 1 +If ($CmdLine[0] > 0) Then + SendLog($CmdLine[1]) + $error = 0 +EndIf +Exit $error + +Func SendLog($text) + $notify = IniRead("config.ini", "various", "Notify", "1") ; notifycode + $notifycustom = IniRead("config.ini", "various", "NotifyCustom", "") ; chip number currently mounted into the system + + $notifyBenny =BitAND($notify, 1) + $notifyDennis=BitAND($notify, 2) + $notifyStefan=BitAND($notify, 4) + + $text = urlencode($text) + $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") + + $oHTTP.Open("GET", "http://autoremotejoaomgcd.appspot.com/sendmessage?key=APA91bEejQPoLUIipcNpfeDvNoa5Bd48AASVBHRphY4ySu8U2FSfuDym2iHdkC_YJ2zyhhbVXVB0oRacd_QmDFsrNRATF0rT4b7pqIHj8EeUrOdq0s_gQq7BE0ERaUfHHikhet06D8ff8BUXe8uVZ5RqoI2ygWc48Q&message=RadHard:%20" & $text & "&password=TannenbaumSaftSchorle") + $oHTTP.Send() + EndIf + + If $notifyDennis Then + $oHTTP.Open("GET", "http://autoremotejoaomgcd.appspot.com/sendmessage?key=APA91bHCZjLkmISyt3lHjn-ym1Md9SymV5hKq05gxuPKXSMVm6e1rphU55sjiQNfQOIUpzoNqCU8kGXLwDJTRksMBRgk62dW5N_Go69dchFvfYqNIKKrvG26FGBPjKea06PU6IPxLPm0WWSM53k7QIQj0EZtMSNxpg&message=RadHard:%20" & $text & "&password=mimosa") + $oHTTP.Send() + EndIf + + If $notifyStefan Then + If Not StringInStr ( $text, "Percent%20done" ) Then + $oHTTP.Open("GET", "http://autoremotejoaomgcd.appspot.com/sendmessage?key=APA91bEejQPoLUIipcNpfeDvNoa5Bd48AASVBHRphY4ySu8U2FSfuDym2iHdkC_YJ2zyhhbVXVB0oRacd_QmDFsrNRATF0rT4b7pqIHj8EeUrOdq0s_gQq7BE0ERaUfHHikhet06D8ff8BUXe8uVZ5RqoI2ygWc48Q&message=RadHardSMS015787957348:%20" & $text & "&password=TannenbaumSaftSchorle") + $oHTTP.Send() + EndIf + EndIf + + $oHTTP = 0 + +EndFunc ;==>SendNtfctn + +Func urlencode($str, $plus = False) + Local $i, $return, $tmp, $exp + $return = "" + $exp = "[a-zA-Z0-9-._~]" + If $plus Then + $str = StringReplace($str, " ", "+") + $exp = "[a-zA-Z0-9-._~+]" + EndIf + For $i = 1 To StringLen($str) + $tmp = StringMid($str, $i, 1) + If StringRegExp($tmp, $exp, 0) = 1 Then + $return &= $tmp + Else + $return &= StringMid(StringRegExpReplace(StringToBinary($tmp, 4), "([0-9A-Fa-f]{2})", "%$1"), 3) + EndIf + Next + Return $return +EndFunc ;==>urlencode \ No newline at end of file diff --git a/bot/Functions/SetChipClock.au3 b/bot/Functions/SetChipClock.au3 new file mode 100755 index 0000000..dca8af4 --- /dev/null +++ b/bot/Functions/SetChipClock.au3 @@ -0,0 +1,10 @@ +Func SetChipClock( $clock ) + ShellExecuteWait("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'SOURce1:FREQuency:Fixed " & $clock & "Mhz'", "", "", @SW_HIDE) + Sleep(1000) + ShellExecuteWait("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'SOURce1:VOLTage:HIGH 3.3'", "", "", @SW_HIDE) + Sleep(1000) + ShellExecuteWait("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'SOURce1:VOLTage:LOW 0'", "", "", @SW_HIDE) + Sleep(1000) + ShellExecuteWait("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'OUTPut1:STATe ON'", "", "", @SW_HIDE) + Sleep(1000) +EndFunc \ No newline at end of file diff --git a/bot/Functions/WaitForTemperature.au3 b/bot/Functions/WaitForTemperature.au3 new file mode 100755 index 0000000..8c40b9b --- /dev/null +++ b/bot/Functions/WaitForTemperature.au3 @@ -0,0 +1,41 @@ +If $currentline[$cellTemp][0] == $temperaturebefore Then + $tempcorrent = True +Else + $tempcorrent = False +EndIf +$tempwaiti = 0 +While Not $tempcorrent + $currenttemp = GetTemperatureForSure($system) + If $currenttemp == 100000 Then + RefreshGUISendNtfct("Could not get temperature. Will assume it is set correctly. Please check manually later.") + $tempcorrent = True + ExitLoop 1 + EndIf + If ($currentline[$cellTemp][0] < $currenttemp + 0.5 And $currentline[$cellTemp][0] > $currenttemp - 0.5) Then + $tempcorrent = True + Else + If $tempwaiti > 5 Then + $currenttempchip = GetTemperatureForSure("Chip" & $system) + RefreshGUISendNtfct("Cooling could not reach needed temperature of " & $currentline[$cellTemp][0] & " °C within 30 minutes. Current cooling temperature is " & $currenttemp & ", chip temperature is " & $currenttempchip & ". Will proceed anyway.") + $tempcorrent = True + ExitLoop 1 + EndIf + $completelog &= _NowCalc() & " Current temperature is " & $currenttemp & "." & @CRLF & "Will set it to " & $currentline[$cellTemp][0] & " and wait for 5 minutes." & @CRLF + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $completelog & '"') + $tempseti = 0 + Do + If $tempseti > 10 Then + $currenttempchip = GetTemperatureForSure("Chip" & $system) + RefreshGUISendNtfct("Could not set temperature to " & $currentline[$cellTemp][0] & ". Current cooling temperature is " & $currenttemp & " °C, chip temperature is " & $currenttempchip & ". Will proceed anyway.") + $tempcorrent = True + ExitLoop 2 + EndIf + $settemp = RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\TemperatureControl.au3" "' & $system & '" "' & $currentline[$cellTemp][0] & '"', @ScriptDir) + $tempseti = $tempseti + 1 + Until $settemp == 0 + $tempwaiti= $tempwaiti + 1 + Sleep(1000 * 60 * 5) + EndIf +WEnd +Sleep($waitfortemp * 60 * 1000) ; wait for user specified minutes +$currenttempchip = GetTemperatureForSure("Chip" & $system) ; get chip temperature before measurement start diff --git a/bot/Functions/Watchrun.au3 b/bot/Functions/Watchrun.au3 new file mode 100755 index 0000000..7607999 --- /dev/null +++ b/bot/Functions/Watchrun.au3 @@ -0,0 +1,37 @@ +$i = 0 +Do + $oldcounter = GetCounter() + $percentCurrent = Round($oldcounter / $eventnum * 100, 2) + $percentoverall = Round(($oldcounter / $eventnum / $totalruns + $totalrealruns / $totalruns) * 100, 2) + If Not $estimate And $percentoverall > 1 Then + $calcsecestimate = _DateDiff('s', $starttime, _NowCalc()) ; n for minites, s for seconds + $calcsecestimate = $calcsecestimate * 100 / $percentoverall + $calcmin = Int($calcsecestimate / 60) + $calchour = $calcsecestimate / 3600 + $calchour = Round($calchour, 2) + $calcsecestimate = Int($calcsecestimate) + $timeend = _Epoch_encrypt(_NowCalc()) + $calcsecestimate + $timeend = _Epoch_decrypt($timeend) + $completelog &= _NowCalc() & " Estimated runtime: " & $calchour & " hours." & @CRLF & "Estimated endtime: " & $timeend & @CRLF + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "Estimated runtime: ' & $calchour & ' hours. Will end at ' & $timeend & '"', @ScriptDir) + $estimate = 1 + EndIf + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $percentoverall & '" "' & $percentCurrent & '"') + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $completelog & '"') + If Not Mod($i, 30) Then + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\WriteTemperatureLog.au3" "' & $savedir & '\' & $runnum & '\temperature.log" "' & $system & '"', @ScriptDir) + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "Percent done: ' & $percentoverall & ' (' & $totalrealruns & '/' & $totalruns & ')"', @ScriptDir) + EndIf + Sleep(10000) + If ($oldcounter == GetCounter()) Then + StopRun() + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "Skipped run ' & $runnum & ', event counter froze."', @ScriptDir) + Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(48, ''Warning'', ''Skipped run ' & $runnum & ', event counter froze.'')"') + $completelog &= _NowCalc() & " Skipped run " & $runnum & ", event counter froze." & @CRLF + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $completelog & '"') + FileDelete($savedir & "\" & $runnum & "\*") + DirRemove($savedir & "\" & $runnum) + ContinueLoop 2 + EndIf + $i = $i + 1 +Until (GetCounter() > $eventnum) \ No newline at end of file diff --git a/bot/Functions/WriteTemperatureLog.au3 b/bot/Functions/WriteTemperatureLog.au3 new file mode 100755 index 0000000..786a92a --- /dev/null +++ b/bot/Functions/WriteTemperatureLog.au3 @@ -0,0 +1,21 @@ +#include +#include "EpochConvert.au3" +#include "CommonFunctions.au3" + +$returnval = 1 +If ($CmdLine[0] > 1) Then + $returnval = WriteTemperaturLog($CmdLine[1], $CmdLine[2]) +EndIf +ConsoleWrite($returnval) ;### Debug Console +Exit $returnval + +Func WriteTemperaturLog($filepath, $system) + $timenow = _Epoch_encrypt(_NowCalc()) + $currenttempChip = GetTemperatureForSure("Chip" & $system) + If $currenttempChip == 100000 Then $currenttempChip = "-" + $currenttempCooling = GetTemperatureForSure($system) + If $currenttempCooling == 100000 Then $currenttempCooling = "-" + If Not FileExists( $filepath ) Then FileWriteLine($filepath, "UNIX timestamp" & @TAB & "Setting" & @TAB & "Cooling" & @TAB & "Sensor") + FileWriteLine ( $filepath , $timenow & @TAB & "-" & @TAB & $currenttempCooling & @TAB & $currenttempChip ) + Return 0 +EndFunc \ No newline at end of file diff --git a/bot/GUI/PXI.ico b/bot/GUI/PXI.ico new file mode 100755 index 0000000000000000000000000000000000000000..3d7a94cdaf8083e37c78bd516dd32a3bd6a085ab GIT binary patch literal 15086 zcmeHN2UJ$aw#F7sj8T)Qu|~bI1Bxvc5PQLj8hcbk#fpFp8;A%Bg2sZPf*LT22!f!3 zp!8k@sRB}LDE1ON_`Po*C68+)k-X%sx7NF}*8b-|GpFpC*?n&nl}ajAR62E1QJPyT z6_xJ%*Sz_=>pChbc^s?5UfR5>Dk|2zp)LQ*BQpt=RGRab?Yp<#e}4b71Ka_WvkQMV zUfz5;ulvK{N}R1h_>Az$AKv-<$@1{{v+?rgfB%I)9;wUeQG{g#BflU| zydwQk-YoBVpMGSlgpf;cB^VHT5E>DL#^nCeCilJ%rE{gd%)j40H1_^Ie{`+M$znp? z8Z~N+s#~}2vRbuj8C9-a`F;A4@5uQi6C4Or2^|Ub3DpT7!lUe1>HpH6k0|Z^>(cR$ z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JbjE9&LYBT&$MSyV+flAUdcA-E4Llp0zb_nk! zd|L*zIj7BM%^A8dXZ(igE(upy5dOQhRe4*0+?@Syaf%8{D?VJoMjx$V)22;UvQ}D$ z^*`m>gXO(;{MeEH`{^IpZZdzv|9SKkf1;1`efxIpJ}vK=(s9Cm&X!XrjX1B8G8^p&%VB+Q;Sn9hHXA;gKnSNy|eHiiO zPBK?+zIG{d#9z_~z5*%t}yXwAmVC zj2u2_*KZ%^ACn~u0`qBCir+eFkrs6K55UM{1JT8Eq+&Y{r2QO~OkavVoa>=ICH3ol zB{k|w)6nSj-5Foc5~(3NbJ`0-R%&CZ*9xpUzZ!G=^)c{(24*-7R`w-1F_u2xymO_` zO25>2@g~vRg{*Vlywwcj*N?){cn=(iI}BrQ6AZQQ39CKJ6hBXDtY-W;VQksw5A5IV zd#6ZhIr6Dva^S_7yQvlHa5l`uc&jn!q2G@7;wdE`=;*L5f90~p|8{=k$BoepK6g4H zD>LQIP3kYnDc)f1hSJElYZxvsEE+N oRp$y06ig})1-@krl^#R^t+|jgu%2VT0j=x;LNU1-+ulC=UtQ~XQvd(} literal 0 HcmV?d00001 diff --git a/bot/Mimosa_Autorun_PXI.au3 b/bot/Mimosa_Autorun_PXI.au3 new file mode 100755 index 0000000..7ae9680 --- /dev/null +++ b/bot/Mimosa_Autorun_PXI.au3 @@ -0,0 +1,152 @@ +; +; AutoIt Version: 3.0 +; Language: English +; Platform: Win9x/NT +; Author: Benny Linnik (b.linnik@gsi.de) +; +; Script Function: +; Automatically runs the USB or PXI system with data gathered from an Excel sheet +$configfile = @ScriptDir & "\config_PXI.ini" +#include "Functions\Header.au3" +#include "Chips\daq_mi32a_v32(Host).vi.au3" +#include "Functions\CommonFunctions.au3" +#include "Functions\Checkdata.au3" +Global $vref = 1000 ; Initial vref, will be adjusted during runtime + +If (Not @error) And IsObj($oExcelDoc) Then ; Check again if everything went well + ; NOTE: $oExcelDoc is a "Workbook Object", not Excel itself! + $oDocument = $oExcelDoc.Worksheets(1) ; We use the 'Default' worksheet + $aArray = $oDocument.range($CellRange).value ; Retrieve the cell values from given range + ;$oExcelDoc.Close ; Close the Excel document + ; The data should now be in the 2-dimensional array: $aArray + If IsArray($aArray) And UBound($aArray, 0) > 0 Then ; Check if we retrieved any data + $totallexcelines = UBound($aArray, 2) + $totalruns = 0 + For $run = 0 To UBound($aArray, 2) - 1 + If ($aArray[$cellChipN][$run] == $chipinstalled And "Mi" & $aArray[$cellChipV][$run] == $chipversion And $aArray[$cellRadSrc][$run] == $radSource And $aArray[$cellRad][$run] == $radiated And $aArray[$cellDate][$run] == "" And $aArray[$cellSystem][$run] == "PXI" And ($aArray[$cellClock][$run] == "100" Or $aArray[$cellClock][$run] == "")) Then + $totalruns = $totalruns + 1 + EndIf + Next + Local $answer = MsgBox(4, "Total runs", "Number of suitable runs found at the moment: " & $totalruns) + If $answer = 7 Then + Exit + EndIf + RefreshGUISendNtfct("Starting with " & $totalruns & " runs.") + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "0" "0"') + If ProcessExists("daq_mi32a_v32.exe") = True Then + ProcessClose("daq_mi32a_v32.exe") + ProcessWaitClose("daq_mi32a_v32.exe") + EndIf + Local $sTitle = "daq_mi32a_v32(Host).vi" + Run("C:\ccmos_pxie_daq_crate\daq_mi32a_v32_own\daq_mi34_labo.bat", "C:\ccmos_pxie_daq_crate\daq_mi32a_v32_own\") + WinWait("daq_mi32a_v32(Host).vi") + Sleep(4000) + Global $lvApp = ObjCreate("DaqMi32.Application") + $VIPath = "C:\ccmos_pxie_daq_crate\daq_mi32a_v32_own\daq_mi32a_v32.exe\prj\win\daq_pxi\daq_mimosa_ana_lab_beam\VI\Host\daq_mi32a_v32(Host).vi" + $vi = $lvApp.GetVIReference($VIPath) + Sleep(1000) + If TestSystem() Then Exit + $aArray = 0 + $estimate = 0 + $totalrealruns = 0 + $starttimetotal = _NowCalc() + For $run = 0 To $totallexcelines - 1 + $currentrange = "A" & $excelLineBegin + $run & ":P" & $excelLineBegin + $run + $oExcelDoc = ObjGet($FileName) ; if doc was closed and object destroyed -> reopen it. A possibility to check if object exists would come handy here.... + $oDocument = $oExcelDoc.Worksheets(1) ; We use the 'Default' worksheet + $currentline = $oDocument.range($currentrange).value + If ($currentline[$cellChipN][0] == $chipinstalled And "Mi" & $currentline[$cellChipV][0] == $chipversion And $currentline[$cellRadSrc][0] == $radSource And $currentline[$cellRad][0] == $radiated And $currentline[$cellDate][0] == "" And $currentline[$cellSystem][0] == "PXI" And ($currentline[$cellClock][0] == "100" Or $currentline[$cellClock][0] == "")) Then + #include "Functions\WaitForTemperature.au3" + #include "Functions\ReadAndSaveExcelParameters.au3" + SetMiParameter($matrix, $vref) + ProgramMi() + Sleep(200) + $vi.SetControlValue("Run directory", $savedir) ; get directorys to save file to + $vi.SetControlValue("Run Number", $runnum) + $vi.SetControlValue("Events number in run", $eventnum) + $vi.SetControlValue("Events number/ file", "20000") + Sleep(100) + $starttime = _NowCalc() + StartRun() + Sleep(1000) + $vi.SetControlValue("Process Stat", "1") + Sleep(2000) + $avg = 0 + $avgarr = $vi.GetControlValue("Mean (Ch0-15)") + For $iavg = 0 To UBound($avgarr) - 1 + $avg = $avg + $avgarr[$iavg] + Next + $avg = $avg / UBound($avgarr) + $j = 0 + If ($avg > 1000 Or $avg < -1000) Then + Do + StopRun() + Sleep(2000) + $vref = $vi.GetControlValue("VRef") + $diff = $avg + Select + Case Abs($diff) > 12000 + $vref = $vref + SGN($diff) * 100 + Case Abs($diff) > 6000 + $vref = $vref + SGN($diff) * 50 + Case Abs($diff) > 1000 + $vref = $vref + SGN($diff) * 10 + Case Else + $vref = $vref + SGN($diff) * 5 + EndSelect + If ($vref > 1500 Or $vref < 300) Then + StopRun() + RefreshGUISendNtfct("Skipped run " & $runnum & ", vref value could not be set properly. Frequency: " & $clock ) + Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(48, ''Warning'', ''Skipped run ' & $runnum & ', vref value needs to be too low (<300) or too high (>1500), please check manually!'')"') + FileDelete($savedir & "\" & $runnum & "\*") + $vref = 1000 + ContinueLoop 2 + EndIf + $vi.SetControlValue("VRef", $vref) + ProgramMi() + StartRun() + Sleep(2000) + $avg = 0 + $avgarr = $vi.GetControlValue("Mean (Ch0-15)") + For $iavg = 0 To UBound($avgarr) - 1 + $avg = $avg + $avgarr[$iavg] + Next + $avg = $avg / UBound($avgarr) + Sleep(100) + $j = $j + 1 + If ($j > 12) Then + StopRun() + RefreshGUISendNtfct("Skipped run " & $runnum & ", vref value could not be set properly. Frequency: " & $clock ) + Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(48, ''Warning'', ''Skipped run ' & $runnum & ', vref value needs to be too low (<300) or too high (>1500), please check manually!'')"') + FileDelete($savedir & "\" & $runnum & "\*") + $vref = 1000 + ContinueLoop 2 + EndIf + Until ($avg < 1000 And $avg > -1000) + EndIf + $vi.SetControlValue("Process Stat", "0") + #include "Functions\Watchrun.au3" + StopRun() + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\MoveFolder.au3" "' & $savedir & '\' & $runnum & '" "' & $storedir & '\' & $runnum & '"') + #include "Functions\SaveToExcel.au3" + $totalrealruns = $totalrealruns + 1 + $completelog &= _NowCalc() & " Completed run " & $runnum & ", " & $percentoverall & "% (" & $totalrealruns & "/" & $totalruns & ")" & @CRLF + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $completelog & '"') + EndIf + Next + #include "Functions\PrintSucessMessage.au3" + Else + MsgBox(16, "Excel Data Test", "Error: Could not retrieve data from cell range: " & $CellRange) + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "Could not retrieve data from cell range"', @ScriptDir) + EndIf +Else + MsgBox(16, "Excel Data Test", "Error: Could not open " & $FileName & " as an Excel Object.") + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "Could not open ' & $FileName & ' as an Excel Object."', @ScriptDir) +EndIf +$oExcelDoc = 0 +Func SGN($i) + Return ($i > 0) - ($i < 0) +EndFunc ;==>SGN +Func CheckValues($vref, $matrix, $runnum, $eventnum, $clock) + Return 0 +EndFunc ;==>CheckValues diff --git a/bot/Mimosa_Autorun_USB.au3 b/bot/Mimosa_Autorun_USB.au3 new file mode 100755 index 0000000..a0badf4 --- /dev/null +++ b/bot/Mimosa_Autorun_USB.au3 @@ -0,0 +1,195 @@ +; +; AutoIt Version: 3.0 +; Language: English +; Platform: Win9x/NT +; Author: Benny Linnik (b.linnik@gsi.de) +; +; Script Function: +; Automatically runs the USB or PXI system with data gathered from an Excel sheet +$configfile = @ScriptDir & "\config_USB.ini" +#include "Functions\Header.au3" +#include "Chips\Mimosa32.au3" +#include "Chips\Mimosa32Ter.au3" +#include "Chips\Mimosa34.au3" +#include "Functions\SetChipClock.au3" +#include "Functions\CommonFunctions.au3" +#include "Functions\Checkdata.au3" +Global $vref = 650 ; Initial vref, will be adjusted during runtime + +;create virtual functions +Func GotoMiTab() + Call($chipversion & "_GotoMiTab") +EndFunc ;==>GotoMiTab +Func GetVref() + Return Call($chipversion & "_GetVref") +EndFunc ;==>GetVref +Func SetVref($vref) + Call($chipversion & "_SetVref", $vref) +EndFunc ;==>SetVref +Func SetMiParameter($matrix, $vref) + Call($chipversion & "_SetMiParameter", $matrix, $vref) +EndFunc ;==>SetMiParameter +Func SelectBoard() + Call($chipversion & "_SelectBoard") +EndFunc ;==>SelectBoard + +If (Not @error) And IsObj($oExcelDoc) Then ; Check again if everything went well + ; NOTE: $oExcelDoc is a "Workbook Object", not Excel itself! + $oDocument = $oExcelDoc.Worksheets(1) ; We use the 'Default' worksheet + $aArray = $oDocument.range($CellRange).value ; Retrieve the cell values from given range + ;$oExcelDoc.Close ; Close the Excel document + ; The data should now be in the 2-dimensional array: $aArray + If IsArray($aArray) And UBound($aArray, 0) > 0 Then ; Check if we retrieved any data + $totallexcelines = UBound($aArray, 2) + $totalruns = 0 + For $run = 0 To UBound($aArray, 2) - 1 + If ($aArray[$cellChipN][$run] == $chipinstalled And "Mi" & $aArray[$cellChipV][$run] == $chipversion And $aArray[$cellRadSrc][$run] == $radSource And $aArray[$cellRad][$run] == $radiated And $aArray[$cellDate][$run] == "" And $aArray[$cellSystem][$run] == "USB") Then + $totalruns = $totalruns + 1 + EndIf + Next + Local $answer = MsgBox(4, "Total runs", "Number of suitable runs found at the moment: " & $totalruns) + If $answer = 7 Then + Exit + EndIf + RefreshGUISendNtfct("Starting with " & $totalruns & " runs.") + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $completelog & '"') + If ProcessExists("daq.exe") = True Then + ProcessClose("daq.exe") + ProcessWaitClose("daq.exe") + EndIf + If ProcessExists("i2c_ms_gui.exe") = True Then + ProcessClose("i2c_ms_gui.exe") + ProcessWaitClose("i2c_ms_gui.exe") + EndIf + Local $sTitle = "CMOS USB DAQ V3.5.10" + Run("C:\ccmos_daq\v3.5.10\daq_v3.5.10.bat", "C:\ccmos_daq\v3.5.10\") + If TestSystem() Then Exit + WinWait($sTitle) + $hWnd = WinGetHandle($sTitle) + $hTab = ControlGetHandle($hWnd, "", "TPageControl1") + $hCounter = ControlGetHandle($hWnd, "", "TEdit25") + $aArray = 0 + $estimate = 0 + $totalrealruns = 0 + $starttimetotal = _NowCalc() + For $run = 0 To $totallexcelines - 1 + $currentrange = "A" & $excelLineBegin + $run & ":P" & $excelLineBegin + $run + $oExcelDoc = ObjGet($FileName) ; if doc was closed and object destroyed -> reopen it. A possibility to check if object exists would come handy here.... + $oDocument = $oExcelDoc.Worksheets(1) ; We use the 'Default' worksheet + $currentline = $oDocument.range($currentrange).value + If ($currentline[$cellChipN][0] == $chipinstalled And "Mi" & $currentline[$cellChipV][0] == $chipversion And $currentline[$cellRadSrc][0] == $radSource And $currentline[$cellRad][0] == $radiated And $currentline[$cellDate][0] == "" And $currentline[$cellSystem][0] == "USB") Then + #include "Functions\WaitForTemperature.au3" + #include "Functions\ReadAndSaveExcelParameters.au3" + CheckWindowExist() + SelectBoard() + CheckIfBoardOK() + ControlCommand("I2C control Software for Mimosa32", "", "[TEXT:Intern]", "Check") + If ($clock <> "100") Then + SetChipClock( $clock ) + ControlCommand("I2C control Software for Mimosa32", "", "[TEXT:Extern]", "Check") + EndIf + GotoMiTab() + SetMiParameter($matrix, $vref) + ProgramMi() + _GUICtrlTab_SetCurFocus($hTab, 2) ; Go to "Run parameter" tab + Sleep(200) + $savedir = ControlGetText($hWnd, "", "TEdit24") ; get directorys to save file to + ControlSetText($hWnd, "", "TEdit23", "") + Sleep(100) + ControlFocus($hWnd, "", "TEdit23") + ControlSend($hWnd, "", "TEdit23", $runnum) + Sleep(100) + ControlSetText($hWnd, "", "TEdit22", "") + Sleep(100) + ControlFocus($hWnd, "", "TEdit22") + ControlSend($hWnd, "", "TEdit22", $eventnum) + Sleep(100) + ControlFocus($hWnd, "", "TEdit23") + Sleep(1000) + $starttime = _NowCalc() + StartRun() + Sleep(1000) + If (WinExists("Avertissement")) Then + RefreshGUISendNtfct("Skipped run " & $runnum & " could overwrite data." ) + Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(48, ''Warning'', ''Skipped run ' & $runnum & ', could overwrite data!'')"') + ControlClick("Avertissement", "", "TButton1") + ;FileDelete($savedir & "/" & $runnum & "/*") + ContinueLoop + EndIf + ;_GUICtrlTab_SetCurFocus($hTab, 4) ; Go to "Local monitoring" tab ; not needed + $avg = ControlGetText($hWnd, "", "[TEXT:DispAvg;CLASS:TEdit]") + ;MsgBox(0, "Message", $avg) + + ;_GUICtrlTab_SetCurFocus($hTab, 2) ; Go to "Run parameter" tab + Sleep(200) + $j = 0 + If ($avg > 2300 Or $avg < 1700) Then + Do + ControlClick($hWnd, "", "[TEXT:Stop Run;CLASS:TButton]") + ;WinActivate("I2C control Software for Mimosa32") + $vref = GetVref() + ;$vref = ControlGetText("I2C control Software for Mimosa32", "", "TEdit11") + $diff = $avg - 2000 + Select + Case Abs($diff) > 600 + $vref = $vref + SGN($diff) * 100 + Case Else + $vref = $vref + SGN($diff) * 50 + EndSelect + If ($vref > 1000 Or $vref < 300) Then + StopRun() + RefreshGUISendNtfct("Skipped run " & $runnum & ", vref value could not be set properly. Frequency: " & $clock ) + Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(48, ''Warning'', ''Skipped run ' & $runnum & ', vref value needs to be too low (<300) or too high (>1000), please check manually!'')"') + FileDelete($savedir & "/" & $runnum & "/*") + $vref = 650 + ContinueLoop 2 + EndIf + SetVref($vref) + ProgramMi() + WinWait($hWnd) + ;_GUICtrlTab_SetCurFocus($hTab, 2) ; Go to "Run parameter" tab + StartRun() + WinWait("Avertissement") + ControlClick("Avertissement", "", "TButton2") + Sleep(1000) + $avg = ControlGetText($hWnd, "", "[TEXT:DispAvg;CLASS:TEdit]") + Sleep(100) + $j = $j + 1 + If ($j > 10) Then + StopRun() + RefreshGUISendNtfct("Skipped run " & $runnum & ", vref value could not be set properly. Frequency: " & $clock ) + Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(48, ''Warning'', ''Skipped run ' & $runnum & ', vref value needs to be too low (<300) or too high (>1000), please check manually!'')"') + FileDelete($savedir & "/" & $runnum & "/*") + $vref = 650 + ContinueLoop 2 + EndIf + Until ($avg < 2300 And $avg > 1700) + EndIf + #include "Functions\Watchrun.au3" + _GUICtrlTab_SetCurFocus($hTab, 2) ; Go to "Run parameter" tab + Sleep(100) + StopRun() + #include "Functions\SaveToExcel.au3" + $totalrealruns = $totalrealruns + 1 + $completelog &= _NowCalc() & " Completed run " & $runnum & ", " & $percentoverall & "% (" & $totalrealruns & "/" & $totalruns & ")" & @CRLF + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $completelog & '"') + EndIf + Next + ControlCommand("I2C control Software for Mimosa32", "", "[TEXT:Intern]", "Check") + ShellExecuteWait("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'OUTPut1:STATe Off'", "", "", @SW_HIDE) + #include "Functions\PrintSucessMessage.au3" + Else + MsgBox(16, "Excel Data Test", "Error: Could not retrieve data from cell range: " & $CellRange) + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "Could not retrieve data from cell range"', @ScriptDir) + EndIf +Else + MsgBox(16, "Excel Data Test", "Error: Could not open " & $FileName & " as an Excel Object.") + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "Could not open ' & $FileName & ' as an Excel Object."', @ScriptDir) +EndIf +$oExcelDoc = 0 +Func SGN($i) + Return ($i > 0) - ($i < 0) +EndFunc ;==>SGN +Func CheckValues($vref, $matrix, $runnum, $eventnum, $clock) + Return 0 +EndFunc ;==>CheckValues diff --git a/bot/config_PXI.ini b/bot/config_PXI.ini new file mode 100755 index 0000000..21454c2 --- /dev/null +++ b/bot/config_PXI.ini @@ -0,0 +1,9 @@ +[experimental setup] +ChipVersion = Mi34 +ChipInstalled = 5 +ExcelPath = H:\dennis doering\Arbeitsprogramme\Mimosa34\LaborbuchMi34 - Neu2.xls +RadSource = Fe55 +Radiated = 0 +[various] +Notify = 3 +NotifyCustom = (Optional) diff --git a/bot/config_USB.ini b/bot/config_USB.ini new file mode 100755 index 0000000..1cb190c --- /dev/null +++ b/bot/config_USB.ini @@ -0,0 +1,9 @@ +[experimental setup] +ChipVersion = Mi34 +ChipInstalled = 4 +ExcelPath = H:\dennis doering\Arbeitsprogramme\Mimosa34\LaborbuchMi34 - Neu.xls +RadSource = none +Radiated = 0 +[various] +Notify = 3 +NotifyCustom = (Optional) -- 2.43.0