]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Initial commit
authorBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Thu, 25 Jul 2013 14:25:42 +0000 (16:25 +0200)
committerBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Thu, 25 Jul 2013 14:25:42 +0000 (16:25 +0200)
bot/I2C_control_Mim32.au3 [new file with mode: 0755]
bot/Mimosa32.au3 [new file with mode: 0755]
bot/Mimosa32Ter.au3 [new file with mode: 0755]
bot/Mimosa34.au3 [new file with mode: 0755]
bot/Mimosa_Autorun.au3 [new file with mode: 0755]
bot/config.ini [new file with mode: 0755]

diff --git a/bot/I2C_control_Mim32.au3 b/bot/I2C_control_Mim32.au3
new file mode 100755 (executable)
index 0000000..055634a
--- /dev/null
@@ -0,0 +1,49 @@
+#include-once\r
+Global $chipsoftware[3] = ["I2C control Software for Mimosa32", "TTabSheet1", "TPageControl1"]\r
+\r
+Func CheckWindowExist() ; Check if Mimosa window exists\r
+       If WinExists($chipsoftware[0]) = False Then\r
+               Run("C:\CCMOS_SCTRL\MIMOSA34\I2C_ms_gui_labo_Debug.bat", "C:\CCMOS_SCTRL\MIMOSA34\")\r
+               WinWait($chipsoftware[0])\r
+       EndIf\r
+       WinWait("I2C control Software for Mimosa32")\r
+EndFunc\r
+\r
+Func CheckIfBoardOK()\r
+       ControlClick($chipsoftware[0], "", "[TEXT:Inactive;CLASS:TButton]") ; Activate Polling\r
+       Local $i = 0\r
+       While (ControlGetText($chipsoftware[0], "", "TEdit6") <> "Target Board OK")\r
+               If ($i > 20) Then\r
+                       MsgBox(16, "Message", "Mimosa board could not be polled, please check if board is connected properly.")\r
+                       Exit\r
+               EndIf\r
+               $i = $i + 1\r
+               Sleep(500)\r
+       WEnd\r
+       ControlClick($chipsoftware[0], "", "[TEXT:Active;CLASS:TButton]")\r
+EndFunc\r
+\r
+Func GotoDebugTab()\r
+       Local $i = 0\r
+       While (ControlGetText($chipsoftware[0], "", $chipsoftware[1]) <> "Debug")\r
+               If ($i > 20) Then\r
+                       MsgBox(16, "Message", "Debug tab not found in I2C Control software!")\r
+                       Exit\r
+               EndIf\r
+               ControlCommand($chipsoftware[0], "", $chipsoftware[2], "TabRight")\r
+               $i = $i + 1\r
+               Sleep(100)\r
+       WEnd\r
+EndFunc\r
+\r
+Func GotoFirstTab()\r
+       For $i = 0 To 20\r
+               ControlCommand($chipsoftware[0], "", $chipsoftware[2], "TabLeft")\r
+       Next\r
+EndFunc\r
+\r
+Func ProgramMi()\r
+       ControlClick($chipsoftware[0], "", "[TEXT:Prog All Analog;CLASS:TButton]") ; Program!\r
+       Sleep(1000)\r
+EndFunc\r
+\r
diff --git a/bot/Mimosa32.au3 b/bot/Mimosa32.au3
new file mode 100755 (executable)
index 0000000..35994ec
--- /dev/null
@@ -0,0 +1,50 @@
+#include <I2C_control_Mim32.au3>\r
+Global $Mi32_buttons[3] = ["Edit2", "TCSpinEdit4", "TEdit15"]\r
+\r
+Func Mi32_GotoMiTab()\r
+       GotoFirstTab()\r
+       $i = 0\r
+       While (ControlGetText($chipsoftware[0], "", $chipsoftware[1]) <> "Mi32 A")\r
+               If ($i > 20) Then\r
+                       MsgBox(0, "Message", "Mi32 A tab not found in I2C Control software!")\r
+                       Exit\r
+               EndIf\r
+               ControlCommand($chipsoftware[0], "", $chipsoftware[2], "TabRight")\r
+               $i = $i + 1\r
+               Sleep(100)\r
+       WEnd\r
+EndFunc\r
+\r
+Func Mi32_SelectBoard()\r
+       GotoFirstTab()\r
+       ControlCommand($chipsoftware[0], "", "[TEXT:Mimosa32]", "Check")\r
+EndFunc\r
+\r
+Func Mi32_GetVref()\r
+       return ControlGetText($chipsoftware[0], "", $Mi32_buttons[2])\r
+EndFunc\r
+\r
+Func Mi32_SetVref($vref)\r
+       ControlSetText($chipsoftware[0], "", $Mi32_buttons[2], $vref)\r
+EndFunc\r
+\r
+Func Mi32_SetMiParameter($matrix, $vref)\r
+       ControlFocus($chipsoftware[0], "", $Mi32_buttons[0])\r
+       ControlSetText($chipsoftware[0], "",  $Mi32_buttons[0], "")\r
+       Sleep(100)\r
+       ControlSend($chipsoftware[0], "", $Mi32_buttons[0], $matrix)\r
+       Sleep(100)\r
+       ;Send($matrix)\r
+       ControlCommand($chipsoftware[0], "", "[TEXT:Clamp Enabled]", "Uncheck")\r
+       ControlCommand($chipsoftware[0], "", "[TEXT:High (Default)]", "Check")\r
+       ControlFocus($chipsoftware[0], "", $Mi32_buttons[1])\r
+       ControlSetText($chipsoftware[0], "",  $Mi32_buttons[1], "")\r
+       Sleep(100)\r
+       ControlSetText($chipsoftware[0], "", $Mi32_buttons[1], "1")\r
+       Sleep(100)\r
+       ControlFocus($chipsoftware[0], "", $Mi32_buttons[2])\r
+       ControlSetText($chipsoftware[0], "",  $Mi32_buttons[2], "")\r
+       Sleep(100)\r
+       ControlSetText($chipsoftware[0], "",  $Mi32_buttons[2], $vref)\r
+       Sleep(100)\r
+EndFunc\r
diff --git a/bot/Mimosa32Ter.au3 b/bot/Mimosa32Ter.au3
new file mode 100755 (executable)
index 0000000..c54861e
--- /dev/null
@@ -0,0 +1,50 @@
+#include <I2C_control_Mim32.au3>\r
+Global $Mi32Ter_buttons[3] = ["Edit2", "TCSpinEdit4", "TEdit27"]\r
+\r
+Func Mi32Ter_GotoMiTab()\r
+       GotoFirstTab()\r
+       $i = 0\r
+       While (ControlGetText($chipsoftware[0], "", $chipsoftware[1]) <> "Mi32 Ter A")\r
+               If ($i > 20) Then\r
+                       MsgBox(0, "Message", "Mi32 A tab not found in I2C Control software!")\r
+                       Exit\r
+               EndIf\r
+               ControlCommand($chipsoftware[0], "", $chipsoftware[2], "TabRight")\r
+               $i = $i + 1\r
+               Sleep(100)\r
+       WEnd\r
+EndFunc\r
+\r
+Func Mi32Ter_SelectBoard()\r
+       GotoFirstTab()\r
+       ControlCommand($chipsoftware[0], "", "[TEXT:Mimosa32Ter]", "Check")\r
+EndFunc\r
+\r
+Func Mi32Ter_GetVref()\r
+       return ControlGetText($chipsoftware[0], "", $Mi32Ter_buttons[2])\r
+EndFunc\r
+\r
+Func Mi32Ter_SetVref($vref)\r
+       ControlSetText($chipsoftware[0], "", $Mi32Ter_buttons[2], $vref)\r
+EndFunc\r
+\r
+Func Mi32Ter_SetMiParameter($matrix, $vref)\r
+       ControlFocus($chipsoftware[0], "", $Mi32Ter_buttons[0])\r
+       ControlSetText($chipsoftware[0], "",  $Mi32Ter_buttons[0], "")\r
+       Sleep(100)\r
+       ControlSend($chipsoftware[0], "", $Mi32Ter_buttons[0], $matrix)\r
+       Sleep(100)\r
+       ;Send($matrix)\r
+       ControlCommand($chipsoftware[0], "", "[TEXT:Clamp Enabled]", "Uncheck")\r
+       ControlCommand($chipsoftware[0], "", "[TEXT:High (Default)]", "Check")\r
+       ControlFocus($chipsoftware[0], "", $Mi32Ter_buttons[1])\r
+       ControlSetText($chipsoftware[0], "",  $Mi32Ter_buttons[1], "")\r
+       Sleep(100)\r
+       ControlSetText($chipsoftware[0], "", $Mi32Ter_buttons[1], "1")\r
+       Sleep(100)\r
+       ControlFocus($chipsoftware[0], "", $Mi32Ter_buttons[2])\r
+       ControlSetText($chipsoftware[0], "",  $Mi32Ter_buttons[2], "")\r
+       Sleep(100)\r
+       ControlSetText($chipsoftware[0], "",  $Mi32Ter_buttons[2], $vref)\r
+       Sleep(100)\r
+EndFunc\r
diff --git a/bot/Mimosa34.au3 b/bot/Mimosa34.au3
new file mode 100755 (executable)
index 0000000..8adb2ec
--- /dev/null
@@ -0,0 +1,50 @@
+#include <I2C_control_Mim32.au3>\r
+Global $Mi34_buttons[3] = ["Edit2", "TCSpinEdit5", "TEdit11"]\r
+\r
+Func Mi34_GotoMiTab()\r
+       GotoFirstTab()\r
+       $i = 0\r
+       While (ControlGetText($chipsoftware[0], "", $chipsoftware[1]) <> "Mi34")\r
+               If ($i > 20) Then\r
+                       MsgBox(0, "Message", "Mi34 tab not found in I2C Control software!")\r
+                       Exit\r
+               EndIf\r
+               ControlCommand($chipsoftware[0], "", $chipsoftware[2], "TabRight")\r
+               $i = $i + 1\r
+               Sleep(100)\r
+       WEnd\r
+EndFunc\r
+\r
+Func Mi34_SelectBoard()\r
+       GotoFirstTab()\r
+       ControlCommand($chipsoftware[0], "", "[TEXT:Mimosa34]", "Check")\r
+EndFunc\r
+\r
+Func Mi34_GetVref()\r
+       return ControlGetText($chipsoftware[0], "", $Mi34_buttons[2])\r
+EndFunc\r
+\r
+Func Mi34_SetVref($vref)\r
+       ControlSetText($chipsoftware[0], "", $Mi34_buttons[2], $vref)\r
+EndFunc\r
+\r
+Func Mi34_SetMiParameter($matrix, $vref)\r
+       ControlFocus($chipsoftware[0], "", $Mi34_buttons[0])\r
+       ControlSetText($chipsoftware[0], "",  $Mi34_buttons[0], "")\r
+       Sleep(100)\r
+       ControlSend($chipsoftware[0], "", $Mi34_buttons[0], $matrix)\r
+       Sleep(100)\r
+       ;Send($matrix)\r
+       ;ControlCommand($chipsoftware[0], "", "[TEXT:Clamp Enabled]", "Uncheck")\r
+       ;ControlCommand($chipsoftware[0], "", "[TEXT:High (Default)]", "Check")\r
+       ControlFocus($chipsoftware[0], "", $Mi34_buttons[1])\r
+       ControlSetText($chipsoftware[0], "",  $Mi34_buttons[1], "")\r
+       Sleep(100)\r
+       ControlSetText($chipsoftware[0], "", $Mi34_buttons[1], "1")\r
+       Sleep(100)\r
+       ControlFocus($chipsoftware[0], "", $Mi34_buttons[2])\r
+       ControlSetText($chipsoftware[0], "",  $Mi34_buttons[2], "")\r
+       Sleep(100)\r
+       ControlSetText($chipsoftware[0], "",  $Mi34_buttons[2], $vref)\r
+       Sleep(100)\r
+EndFunc\r
diff --git a/bot/Mimosa_Autorun.au3 b/bot/Mimosa_Autorun.au3
new file mode 100755 (executable)
index 0000000..64d3c75
--- /dev/null
@@ -0,0 +1,395 @@
+;\r
+; AutoIt Version: 3.0\r
+; Language:    English\r
+; Platform:       Win9x/NT\r
+; Author:         Benny Linnik (b.linnik@gsi.de)\r
+;\r
+; Script Function:\r
+;   Reads MAPS running data from an Excel file and\r
+\r
+\r
+; set external parameters\r
+#include <String.au3>\r
+#include <GUIConstants.au3>\r
+#include <WindowsConstants.au3>\r
+#include <StaticConstants.au3>\r
+#Include <GuiEdit.au3>\r
+#include <Date.au3>\r
+#include "Mimosa32.au3"\r
+#include "Mimosa32Ter.au3"\r
+#include "Mimosa34.au3"\r
+\r
+$programversion = "0.7"\r
+$FileName = IniRead ( "config.ini", "experimental setup", "ExcelPath", "H:\dennis doering\Arbeitsprogramme\Mimosa34\LaborbuchMi34.xls" ) ; read path to Excel file\r
+$systemtemp = IniRead ( "config.ini", "experimental setup", "SystemTemperature", "20" )  ; current temperatur of the system\r
+$chipversion = IniRead ( "config.ini", "experimental setup", "ChipVersion", "Mi34" )  ; current chip generation in the system\r
+$chipinstalled = IniRead ( "config.ini", "experimental setup", "ChipInstalled", "5" ) ; chip number currently mounted into the system\r
+$radSource = IniRead ( "config.ini", "experimental setup", "RadSource", "none" )  ; current radioactive source of the system\r
+\r
+$excelLineBegin = "46" ; Change this to the range of cells you want to be processed\r
+$excelLineEnd = "500"\r
+Global $vref = 650 ; Initial vref, will be adjusted during runtime\r
+\r
+;create virtual functions\r
+Func GotoMiTab()\r
+    Call ( $chipversion & "_GotoMiTab" )\r
+EndFunc\r
+\r
+Func GetVref()\r
+    Return Call ( $chipversion & "_GetVref" )\r
+EndFunc\r
+\r
+Func SetVref($vref)\r
+    Call ( $chipversion & "_SetVref", $vref )\r
+EndFunc\r
+\r
+Func SetMiParameter($matrix, $vref)\r
+    Call ( $chipversion & "_SetMiParameter", $matrix, $vref )\r
+EndFunc\r
+\r
+Func SelectBoard()\r
+    Call ( $chipversion & "_SelectBoard" )\r
+EndFunc\r
+\r
+$CellRange = "A" & $excelLineBegin &":N"& $excelLineEnd\r
+\r
+; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)\r
+Local $answer = MsgBox(4, "Run script?", "Preparing to do all runs in range " & $CellRange & @CRLF & _\r
+               "of file " & $FileName & " with " & @CRLF & _\r
+               "Temperatur: " & $systemtemp & " °C" & @CRLF & _\r
+               "Radioactive source: " & $radSource & @CRLF & _\r
+               "Chip: " & $chipversion & " (" & $chipinstalled & ")"& @CRLF & _\r
+               "If you run this script, daq.exe will be closed and the current run aborted, proceed?")\r
+\r
+\r
+; Check the user's answer to the prompt (see the help file for MsgBox return values)\r
+; If "No" was clicked (7) then exit the script\r
+If $answer = 7 Then\r
+       Exit\r
+EndIf\r
+\r
+If Not FileExists($FileName) Then ; Just a check to be sure..\r
+       MsgBox(16, "Excel Data Test", "Error: Can't find file " & $FileName)\r
+       Exit\r
+EndIf\r
+\r
+$oExcelDoc = ObjGet($FileName) ; Get an Excel Object from an existing filename\r
+\r
+If (Not @error) And IsObj($oExcelDoc) Then ; Check again if everything went well\r
+       ; NOTE: $oExcelDoc is a "Workbook Object", not Excel itself!\r
+       $oDocument = $oExcelDoc.Worksheets(1) ; We use the 'Default' worksheet\r
+       $aArray = $oDocument.range($CellRange).value ; Retrieve the cell values from given range\r
+       ;$oExcelDoc.Close ; Close the Excel document\r
+       ; The data should now be in the 2-dimensional array: $aArray\r
+\r
+       If IsArray($aArray) And UBound($aArray, 0) > 0 Then ; Check if we retrieved any data\r
+               ;Msgbox (0,"Excel Data Test","Debugging information for retrieved cells:" & @CRLF & _\r
+               ;       "Number of dimensions: " & UBound($aArray,0) & @CRLF & _\r
+               ;       "Size of first dimension: " & Ubound($aArray,1) & @CRLF & _\r
+               ;       "Size of second dimension: " & Ubound($aArray,2))\r
+               ;       "Size of second dimension: " & Ubound($aArray,2))\r
+\r
+               ; The next lines are just for debugging purposes, it puts all cell values into\r
+               ; a string to display in a MsgBox.\r
+               ; Note: you can't use a FOR..IN loop for a multi-dimensional array!\r
+;~       ; debugging read data\r
+;~       $string=""\r
+;~       for $x=0 to ubound($aArray,1)-1\r
+;~              for $y=0 to ubound ($aArray,2)-1\r
+;~                      $string=$string & "(" & $x & "," & $y & ")=" & $aArray[$x][$y] & @CRLF\r
+;~              Next\r
+;~       Next\r
+;~       Msgbox(0,"Excel Data Test","Debug information: Read Cell contents: " & @CRLF & $string)\r
+\r
+               $totallexcelines=UBound($aArray, 2)\r
+               $totalruns = 0\r
+               For $run = 0 To UBound($aArray, 2) - 1\r
+                       If ($aArray[4][$run] == $systemtemp And $aArray[6][$run] == $chipinstalled And "Mi"&$aArray[2][$run] == $chipversion And $aArray[10][$run] == $radSource And $aArray[0][$run] == "") Then\r
+                               $totalruns = $totalruns + 1\r
+                       EndIf\r
+               Next\r
+               Local $answer = MsgBox(4, "Total runs", "Number of suitable runs found at the moment: " & $totalruns )\r
+               If $answer = 7 Then\r
+                       Exit\r
+               EndIf\r
+\r
+               If ProcessExists("daq.exe") = True Then\r
+                       ProcessClose("daq.exe")\r
+                       ProcessWaitClose("daq.exe")\r
+               EndIf\r
+\r
+               If ProcessExists("i2c_ms_gui.exe") = True Then\r
+                       ProcessClose("i2c_ms_gui.exe")\r
+                       ProcessWaitClose("i2c_ms_gui.exe")\r
+               EndIf\r
+\r
+               Run("C:\ccmos_daq\v3.5.10\daq_v3.5.10.bat", "C:\ccmos_daq\v3.5.10\")\r
+               WinWait("Debug")\r
+               ControlClick("Debug", "", "[TEXT:Messages Clear]")\r
+               Sleep(100)\r
+               ControlClick("Debug", "", "[TEXT:Board Testing]")\r
+               Sleep(2000)\r
+               $i = 0\r
+               Do\r
+                       $text = WinGetText("[CLASS:TDebugFrm]", "")\r
+                       $texthex = _StringToHex($text)\r
+                       If ($texthex == "4D657373616765730A5072696E7420426F6172647320526567730A0D0A3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D0D0A426F6172642049643D302074657374207374617274696E67202E2E2E0D0A3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D0D0A0D0A53746F70206163717569736974696F6E202E2E2E0D0A41445220434F554E54455220412074657374696E67202E2E2E0D0A41445220434F554E54455220412030204572726F72730D0A52414D20412074657374696E67202E2E2E0D0A52414D20412030204572726F72730D0A52414D20422074657374696E67202E2E2E0D0A52414D20422030204572726F72730D0A52414D20432074657374696E67202E2E2E0D0A52414D20432030204572726F72730D0A52414D20442074657374696E67202E2E2E0D0A52414D20442030204572726F72730D0A0D0A3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D0D0A426F6172642049643D312074657374207374617274696E67202E2E2E0D0A3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D3D0D0A0D0A53746F70206163717569736974696F6E202E2E2E0D0A41445220434F554E54455220412074657374696E67202E2E2E0D0A41445220434F554E54455220412030204572726F72730D0A52414D20412074657374696E67202E2E2E0D0A52414D20412030204572726F72730D0A52414D20422074657374696E67202E2E2E0D0A52414D20422030204572726F72730D0A52414D20432074657374696E67202E2E2E0D0A52414D20432030204572726F72730D0A52414D20442074657374696E67202E2E2E0D0A52414D20442030204572726F72730D0A0A555342322042616E647769647468204D65617375726D656E740A426F6172642054657374696E670A536F66747761726520496E697469616C697A6174696F6E0A4D6573736167657320436C6561720A") Then\r
+                               EndIf\r
+                       Sleep(500)\r
+                       $i = $i + 1\r
+                       If ($i > 20) Then\r
+                               MsgBox(16, "Message", "USB Boards could be not OK! Please check the Debug output.")\r
+                               Exit\r
+                       EndIf\r
+               Until 1\r
+               If StringRegExp ( $text, "[1-9]+ Errors" ) Then ; for some reasons the previous check sometimes doesn't work.\r
+                       MsgBox(16, "Message", "USB Boards could be not OK! Please check the Debug output.")\r
+                       Exit\r
+               EndIf\r
+\r
+\r
+               WinClose("Debug")\r
+               WinWaitClose("Debug", 1000)\r
+               $aArray = 0\r
+               $totalrealruns=0\r
+\r
+               For $run = 0 To $totallexcelines-1\r
+\r
+                       $currentrange="A"& $excelLineBegin+$run & ":N" & $excelLineBegin+$run\r
+                       $oExcelDoc = ObjGet($FileName) ; if doc was closed and object destroyed -> reopen it. A possibility to check if object exists would come handy here....\r
+                       $oDocument = $oExcelDoc.Worksheets(1) ; We use the 'Default' worksheet\r
+                       $currentline=$oDocument.range($currentrange).value\r
+                       If ($currentline[4][0] == $systemtemp And $currentline[6][0] == $chipinstalled And "Mi"&$currentline[2][0] == $chipversion And $currentline[10][0] == $radSource And $currentline[0][0] == "") Then\r
+                               $clock = $currentline[11][0] ; save needed clock\r
+                               If $clock == "" Then\r
+                                       $clock = "100"\r
+                                       $currentline[11][0] = "100"\r
+                               EndIf\r
+                               $runnum = $currentline[3][0] ; save runnumber\r
+                               $matrix = $currentline[9][0] ; save matrix\r
+                               $eventnum = $currentline[5][0] ; save number of events to save\r
+                               If $eventnum == "" Then\r
+                                       $eventnum = 100000\r
+                                       $currentline[5][0]  = "100000"\r
+                               EndIf\r
+\r
+                               CheckWindowExist()\r
+                               SelectBoard()\r
+                               CheckIfBoardOK()\r
+                               GotoDebugTab()\r
+\r
+                               If ($clock == "100") Then\r
+                                       ControlCommand($chipsoftware[0], "", "[TEXT:Intern]", "Check")\r
+                                       ;If (Not ControlCommand("I2C control Software for Mimosa32", "", "[TEXT:Intern]", "IsChecked")) Then\r
+                                       ;Msgbox (16,"Message","Could not set clock to intern")\r
+                                       ;EndIf\r
+                               Else\r
+                                       ShellExecuteWait ("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'SOURce1:FREQuency:Fixed " & $clock & "Mhz'", "", "", @SW_HIDE)\r
+                                       ShellExecuteWait ("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'SOURce1:VOLTage:HIGH 3.3'", "", "", @SW_HIDE)\r
+                                       ShellExecuteWait ("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'SOURce1:VOLTage:LOW 0'", "", "", @SW_HIDE)\r
+                                       ShellExecuteWait ("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'OUTPut1:STATe ON'", "", "", @SW_HIDE)\r
+                                       Sleep(500)\r
+                                       ControlCommand("I2C control Software for Mimosa32", "", "[TEXT:Extern]", "Check")\r
+                                       ;If (Not ControlCommand("I2C control Software for Mimosa32", "", "[TEXT:Extern]", "IsChecked")) Then\r
+                                       ;Msgbox (16,"Message","Could not set clock to extern")\r
+                                       ;EndIf\r
+                               EndIf\r
+\r
+                               GotoMiTab()\r
+                               SetMiParameter($matrix, $vref)\r
+                               ProgramMi()\r
+\r
+                               If WinExists("CMOS USB DAQ V3.5.10") = True Then\r
+                                       ;WinActivate("CMOS USB DAQ V3.5.10")\r
+                               Else\r
+                                       Run("C:\ccmos_daq\v3.5.10\daq_v3.5.10.bat", "C:\ccmos_daq\v3.5.10\")\r
+                               EndIf\r
+                               WinWait("CMOS USB DAQ V3.5.10")\r
+\r
+                               For $i = 0 To 20\r
+                                       ControlCommand("CMOS USB DAQ V3.5.10", "", "TPageControl1", "TabLeft")\r
+                               Next\r
+                               $i = 0\r
+                               While (ControlGetText("CMOS USB DAQ V3.5.10", "", "TTabSheet1") <> "Run Parameters")\r
+                                       If ($i > 20) Then\r
+                                               MsgBox(0, "Message", "CMOS USB DAQ V3.5.10 RUN tab not found in DAQ software!")\r
+                                               Exit\r
+                                       EndIf\r
+                                       ControlCommand("CMOS USB DAQ V3.5.10", "", "TPageControl1", "TabRight")\r
+                                       $i = $i + 1\r
+                                       Sleep(100)\r
+                               WEnd\r
+\r
+                               ControlSetText("CMOS USB DAQ V3.5.10", "", "TEdit23", "")\r
+                               Sleep(100)\r
+                               ControlFocus("CMOS USB DAQ V3.5.10", "", "TEdit23")\r
+                               ;Send($runnum)\r
+                               ControlSend("CMOS USB DAQ V3.5.10", "", "TEdit23", $runnum)\r
+\r
+                               ControlSetText("CMOS USB DAQ V3.5.10", "", "TEdit22", "")\r
+                               Sleep(100)\r
+                               ControlFocus("CMOS USB DAQ V3.5.10", "", "TEdit22")\r
+;~                             Send($eventnum)\r
+                               ControlSend("CMOS USB DAQ V3.5.10", "", "TEdit22", $eventnum)\r
+                               ControlFocus("CMOS USB DAQ V3.5.10", "", "TEdit23")\r
+\r
+                               Sleep(1000)\r
+                               $starttime = _NowCalc()\r
+\r
+                               ControlClick("CMOS USB DAQ V3.5.10", "", "[TEXT:Start Run;CLASS:TButton]")\r
+                               ;WinWaitActive("Avertissement") ;Force overwrite\r
+                               ;ControlClick("Avertissement", "", "TButton2")\r
+\r
+                               Sleep(500)\r
+                               If (WinExists("Avertissement")) Then\r
+                                       MsgBox(16, "Message", "Stopping. Could overwrite data!")\r
+                                       Exit\r
+                               EndIf\r
+\r
+\r
+                               $i = 0\r
+                               While (ControlGetText("CMOS USB DAQ V3.5.10", "", "TTabSheet1") <> "Local Monitoring")\r
+                                       If ($i > 20) Then\r
+                                               MsgBox(0, "Message", "CMOS USB DAQ V3.5.10 Local Monitoring tab not found in DAQ software!")\r
+                                               Exit\r
+                                       EndIf\r
+                                       ControlCommand("CMOS USB DAQ V3.5.10", "", "TPageControl1", "TabRight")\r
+                                       $i = $i + 1\r
+                                       Sleep(100)\r
+                               WEnd\r
+\r
+                               Sleep(1000)\r
+\r
+                               $avg = ControlGetText("CMOS USB DAQ V3.5.10", "", "[TEXT:DispAvg;CLASS:TEdit]")\r
+                               For $i = 0 To 20\r
+                                       ControlCommand("CMOS USB DAQ V3.5.10", "", "TPageControl1", "TabLeft")\r
+                               Next\r
+                               $i = 0\r
+                               While (ControlGetText("CMOS USB DAQ V3.5.10", "", "TTabSheet1") <> "Run Parameters")\r
+                                       If ($i > 20) Then\r
+                                               MsgBox(0, "Message", "CMOS USB DAQ V3.5.10 RUN tab not found in DAQ software!")\r
+                                               Exit\r
+                                       EndIf\r
+                                       ControlCommand("CMOS USB DAQ V3.5.10", "", "TPageControl1", "TabRight")\r
+                                       $i = $i + 1\r
+                                       Sleep(100)\r
+                               WEnd\r
+                               $j = 0\r
+                               If ($avg > 2300 Or $avg < 1700) Then\r
+                                       Do\r
+                                               ControlClick("CMOS USB DAQ V3.5.10", "", "[TEXT:Stop Run;CLASS:TButton]")\r
+                                               ;WinActivate("I2C control Software for Mimosa32")\r
+                                               $vref = GetVref()\r
+                                               ;$vref = ControlGetText("I2C control Software for Mimosa32", "", "TEdit11")\r
+                                               $diff = $avg - 2000\r
+                                               Select\r
+                                                       Case Abs($diff) > 600\r
+                                                               $vref = $vref + SGN($diff) * 100\r
+                                                       Case Else\r
+                                                               $vref = $vref +SGN($diff) * 50\r
+                                               EndSelect\r
+                                               If ($vref > 1000 Or $vref < 300) Then\r
+                                                       MsgBox(0, "Message", "Stopped, vref value needs to be too low (<300) or too high (>1000), please check manually!")\r
+                                                       Exit\r
+                                               EndIf\r
+\r
+                                               ;ControlSetText("I2C control Software for Mimosa32", "", "TEdit11", $vref)\r
+                                               ;ControlClick("I2C control Software for Mimosa32", "", "[TEXT:Prog All Analog;CLASS:TButton]")\r
+                                               SetVref($vref)\r
+                                               ProgramMi()\r
+                                               ;WinActivate("CMOS USB DAQ V3.5.10")\r
+                                               WinWait("CMOS USB DAQ V3.5.10")\r
+                                               Sleep(1000)\r
+                                               ControlClick("CMOS USB DAQ V3.5.10", "", "[TEXT:Start Run;CLASS:TButton]")\r
+                                               WinWait("Avertissement")\r
+                                               ControlClick("Avertissement", "", "TButton2")\r
+\r
+\r
+                                               $i = 0\r
+                                               While (ControlGetText("CMOS USB DAQ V3.5.10", "", "TTabSheet1") <> "Local Monitoring")\r
+                                                       If ($i > 20) Then\r
+                                                               MsgBox(0, "Message", "CMOS USB DAQ V3.5.10 Local Monitoring tab not found in DAQ software!")\r
+                                                               Exit\r
+                                                       EndIf\r
+                                                       ControlCommand("CMOS USB DAQ V3.5.10", "", "TPageControl1", "TabRight")\r
+                                                       $i = $i + 1\r
+                                                       Sleep(100)\r
+                                               WEnd\r
+\r
+                                               Sleep(1000)\r
+\r
+                                               $avg = ControlGetText("CMOS USB DAQ V3.5.10", "", "[TEXT:DispAvg;CLASS:TEdit]")\r
+                                               For $i = 0 To 20\r
+                                                       ControlCommand("CMOS USB DAQ V3.5.10", "", "TPageControl1", "TabLeft")\r
+                                               Next\r
+                                               $i = 0\r
+                                               While (ControlGetText("CMOS USB DAQ V3.5.10", "", "TTabSheet1") <> "Run Parameters")\r
+                                                       If ($i > 20) Then\r
+                                                               MsgBox(0, "Message", "CMOS USB DAQ V3.5.10 RUN tab not found in DAQ software!")\r
+                                                               Exit\r
+                                                       EndIf\r
+                                                       ControlCommand("CMOS USB DAQ V3.5.10", "", "TPageControl1", "TabRight")\r
+                                                       $i = $i + 1\r
+                                                       Sleep(100)\r
+                                               WEnd\r
+\r
+                                               $j = $j + 1\r
+                                               If ($j > 7) Then\r
+                                                       ControlClick("CMOS USB DAQ V3.5.10", "", "[TEXT:Stop Run;CLASS:TButton]")\r
+                                                       MsgBox(0, "Message", "VRef could not be set properly")\r
+                                                       Exit\r
+                                               EndIf\r
+\r
+                                       Until ($avg < 2300 And $avg > 1700)\r
+                               EndIf\r
+\r
+                               While (ControlGetText("CMOS USB DAQ V3.5.10", "", "TEdit18") < $eventnum)\r
+                                       Sleep(10000)\r
+                                       ;If EnvGet('SESSIONNAME') <> "Console" Then\r
+                                               ;ShowWarning()\r
+                                       ;EndIf\r
+                                       ;WinWait("CMOS USB DAQ V3.5.10")\r
+                               WEnd\r
+                               WinWait("CMOS USB DAQ V3.5.10")\r
+                               ControlClick("CMOS USB DAQ V3.5.10", "", "[TEXT:Stop Run;CLASS:TButton]")\r
+                               ;If ($clock <> "100") Then\r
+                               ;   ShellExecuteWait("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'OUTPut1:STATe Off'", "", "", @SW_HIDE)\r
+                               ;EndIf\r
+\r
+                               $currentline[0][0] = @MDAY & "." & @MON & "." & @YEAR\r
+                               $currentline[8][0] = $vref\r
+                               $calcmin = _DateDiff('s', $starttime, _NowCalc()) ; n for minites, s for seconds\r
+                               $currentline[13][0] = "Automated run, performed by V." & $programversion & " runtime in minutes: " &  $calcmin\r
+\r
+                               $oExcelDoc = ObjGet($FileName) ; if doc was closed and object destroyed -> reopen it. A possibility to check if object exists would come handy here....\r
+                               $oDocument = $oExcelDoc.Worksheets(1) ; We use the 'Default' worksheet\r
+                               $oDocument.range($currentrange).value = $currentline\r
+                               $oExcelDoc.Windows(1).Visible = True ; Otherwise the worksheet window will be saved 'hidden'\r
+                               $oExcelDoc.Save ; Save the workbook\r
+\r
+                               $oExcelDoc.saved = 1\r
+                               $totalrealruns = $totalrealruns + 1\r
+                       EndIf\r
+               Next\r
+               ShellExecuteWait("C:\Programme\PuTTY\plink.exe", "-ssh cerberus /home/maps/bin/vxi11_cmd 192.168.10.152 'OUTPut1:STATe Off'", "", "", @SW_HIDE)\r
+               MsgBox(0, "Sucess!", "All runs (" & $totalrealruns & ") ended without errors." & @CRLF & _\r
+                               "Please check the Excel sheet and the results for errors.")\r
+\r
+       Else\r
+               MsgBox(0, "Excel Data Test", "Error: Could not retrieve data from cell range: " & $CellRange)\r
+       EndIf\r
+\r
+Else\r
+       MsgBox(0, "Excel Data Test", "Error: Could not open " & $FileName & " as an Excel Object.")\r
+EndIf\r
+\r
+$oExcelDoc = 0\r
+\r
+\r
+Func SGN($i)\r
+    Return ($i>0)-($i<0)\r
+ EndFunc   ;==>SGN\r
+\r
+ Func CheckValues($vref, $matrix, $runnum, $eventnum, $clock)\r
+    Return 0\r
+EndFunc\r
diff --git a/bot/config.ini b/bot/config.ini
new file mode 100755 (executable)
index 0000000..95ed98b
--- /dev/null
@@ -0,0 +1,10 @@
+[experimental setup]\r
+ChipVersion = Mi32Ter\r
+; Mi32, Mi32Ter or Mi34\r
+ChipInstalled= 4C\r
+; chip currently mounted into the system\r
+ExcelPath = "H:\dennis doering\Arbeitsprogramme\Mimosa34\LaborbuchMi34.xls"\r
+SystemTemperature = 40\r
+; current temperatur of the system, only runs with this temepratur wiull be run\r
+RadSource = none\r
+; RadSource for which the runs should be performed\r