--- /dev/null
+#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
--- /dev/null
+
+; 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
--- /dev/null
+; $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
--- /dev/null
+#include <String.au3>
+#include <GUIConstants.au3>
+#include <WindowsConstants.au3>
+#include <StaticConstants.au3>
+#include <GuiEdit.au3>
+#include <Date.au3>
+#include <GuiTab.au3>
+#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
--- /dev/null
+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
--- /dev/null
+$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.'')"')
--- /dev/null
+
+$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
--- /dev/null
+#include <Date.au3>
+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
--- /dev/null
+$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
--- /dev/null
+#include <String.au3>
+$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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+$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
--- /dev/null
+#include <Date.au3>
+#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
--- /dev/null
+;
+; 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
--- /dev/null
+;
+; 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
--- /dev/null
+[experimental setup]
+ChipVersion = Mi34
+ChipInstalled = 5
+ExcelPath = H:\dennis doering\Arbeitsprogramme\Mimosa34\LaborbuchMi34 - Neu2.xls
+RadSource = Fe55
+Radiated = 0
+[various]
+Notify = 3
+NotifyCustom = (Optional)
--- /dev/null
+[experimental setup]
+ChipVersion = Mi34
+ChipInstalled = 4
+ExcelPath = H:\dennis doering\Arbeitsprogramme\Mimosa34\LaborbuchMi34 - Neu.xls
+RadSource = none
+Radiated = 0
+[various]
+Notify = 3
+NotifyCustom = (Optional)