From fe8ef44191a70e5e4d526c4947b3c0b6d5d1533f Mon Sep 17 00:00:00 2001 From: Benjamin Linnik Date: Fri, 23 Aug 2013 16:13:42 +0200 Subject: [PATCH] Added automatic temperature adjustment --- bot/GUI/MABS.au3 | 24 +++++++++++++++++------- bot/Mimosa_Autorun.au3 | 26 ++++++++++++++++++++------ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/bot/GUI/MABS.au3 b/bot/GUI/MABS.au3 index 35f95e1..ad0c477 100755 --- a/bot/GUI/MABS.au3 +++ b/bot/GUI/MABS.au3 @@ -13,6 +13,7 @@ $Form1_1 = GUICreate("MABS (Mimosa Automation Bot System)", 477, 412, 395, 335) $ProgressPercent1 = GUICtrlCreateLabel("0", -40, -40, 21, 17) $ProgressPercent2 = GUICtrlCreateLabel("0", -40, -40, 21, 17) $LogEdit = GUICtrlCreateEdit("", 155, 74, 316, 311, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) +$lblTemperatur = GUICtrlCreateLabel("-", 20, 178, 46, 17, $SS_RIGHT) $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenuItem("&Save"&@TAB&"Ctrl+S", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("&Load"&@TAB&"Ctrl+L", $MenuItem1) @@ -25,8 +26,8 @@ $ChipCombo = GUICtrlCreateCombo("", 11, 74, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUT GUICtrlSetData(-1, "Mi32|Mi32Ter|Mi34", "Mi34") $ChipNumInput = GUICtrlCreateInput("1", 107, 74, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Label2 = GUICtrlCreateLabel("Number", 107, 55, 41, 17) -$TempInput = GUICtrlCreateInput("20", 11, 175, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_RIGHT)) -$Label3 = GUICtrlCreateLabel("Temperature", 11, 156, 64, 17) +;$TempInput = GUICtrlCreateInput("20", 11, 175, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_RIGHT)) +$Label3 = GUICtrlCreateLabel("Current Temperature", 11, 156, 104, 17) $Label4 = GUICtrlCreateLabel("° C", 72, 178, 18, 17) $Label5 = GUICtrlCreateLabel("Rad source", 95, 110, 59, 17) $RadInput = GUICtrlCreateInput("none", 97, 129, 51, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_RIGHT)) @@ -60,7 +61,9 @@ Global $Checkboxes[3] = [ $CheckboxStefan, $CheckboxDennis, $CheckboxBenny] Loadini("../config.ini") AutoItSetOption("TrayIconHide", 1) GUISetState(@SW_SHOW) +Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\..\Functions\TemperatureControl.au3"') +$i = 0 While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[1] @@ -104,24 +107,31 @@ While 1 GUICtrlSetColor($NotifyCustom, 0x000000) EndIf EndIf - GUICtrlSetData($Progress1, GUICtrlRead($ProgressPercent1)) - GUICtrlSetData($Progress2, GUICtrlRead($ProgressPercent2)) Case $InfoForm Switch $nMsg[0] Case $Form1_1 Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $InfoForm) Case $LabelMail - ShellExecute("mailto:test@test.com?subject=MABS V. " & $programversion & "") + ShellExecute("mailto:b.linnik@gsi.de?subject=MABS V. " & $programversion & "") EndSwitch EndSwitch + If $i >= 10000 Then + $i = 0 + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\..\Functions\TemperatureControl.au3"') + EndIf + If Mod($i, 1000) == 0 Then + GUICtrlSetData($Progress1, GUICtrlRead($ProgressPercent1)) + GUICtrlSetData($Progress2, GUICtrlRead($ProgressPercent2)) + EndIf + ;GUICtrlSetData($lblTemperatur, $i) + $i = $i + 1 WEnd Func SaveIni($file) Local $config = "ChipVersion = " & GUICtrlRead ($ChipCombo) & @LF & _ "ChipInstalled = " & GUICtrlRead ($ChipNumInput) & @LF & _ "ExcelPath = " & GUICtrlRead ($ExcelPath) & @LF & _ - "SystemTemperature = " & GUICtrlRead($TempInput) & @LF & _ "RadSource = " & GUICtrlRead($RadInput) & @LF & _ "Radiated = " & GUICtrlRead($RadiatedInput) & @LF If ( NOT IniWriteSection ( $file, "experimental setup", $config )) Then @@ -157,7 +167,7 @@ Func Loadini($file) ControlSetText($Form1_1, "", $ExcelPath, IniRead ( $file, "experimental setup", "ExcelPath", "H:\dennis doering\Arbeitsprogramme\Mimosa34\LaborbuchMi34.xls")); current chip generation in the system$PathExcel ControlSetText($Form1_1, "", $ChipCombo, IniRead ( $file, "experimental setup", "ChipVersion", "Mi34")); current chip generation in the system ControlSetText($Form1_1, "", $ChipNumInput, IniRead($file, "experimental setup", "ChipInstalled", "5")); chip number currently mounted into the system - ControlSetText($Form1_1, "", $TempInput, IniRead($file, "experimental setup", "SystemTemperature", "20")) ; current temperatur of the system +; ControlSetText($Form1_1, "", $TempInput, IniRead($file, "experimental setup", "SystemTemperature", "20")) ; current temperatur of the system ControlSetText($Form1_1, "", $RadInput, IniRead($file, "experimental setup", "RadSource", "none")) ; current radioactive source of the system ControlSetText($Form1_1, "", $RadiatedInput, IniRead($file, "experimental setup", "Radiated", "")) ; current radioactive source of the system ControlSetText($Form1_1, "", $notifycustom, IniRead ( $file, "various", "NotifyCustom", "(Optional)")); current chip generation in the system$PathExcel diff --git a/bot/Mimosa_Autorun.au3 b/bot/Mimosa_Autorun.au3 index d14a866..f0c283e 100644 --- a/bot/Mimosa_Autorun.au3 +++ b/bot/Mimosa_Autorun.au3 @@ -21,17 +21,17 @@ #include "Chips/Mimosa34.au3" #include "Functions/BinaryIntegerConvert.au3" #include "Functions/EpochConvert.au3" -$programversion = "0.94" +#include "Functions/TemperatureControl.au3" +$programversion = "0.95" $FileName = IniRead(@ScriptDir&"\config.ini", "experimental setup", "ExcelPath", "H:\dennis doering\Arbeitsprogramme\Mimosa34\LaborbuchMi34.xls") ; read path to Excel file -$systemtemp = IniRead(@ScriptDir&"\config.ini", "experimental setup", "SystemTemperature", "20") ; current temperatur of the system $chipversion = IniRead(@ScriptDir&"\config.ini", "experimental setup", "ChipVersion", "Mi34") ; current chip generation in the system $chipinstalled = IniRead(@ScriptDir&"\config.ini", "experimental setup", "ChipInstalled", "5") ; chip number currently mounted into the system $radSource = IniRead(@ScriptDir&"\config.ini", "experimental setup", "RadSource", "none") ; current radioactive source of the system $radiated = IniRead(@ScriptDir&"\config.ini", "experimental setup", "Radiated", "") ; radiated chip $excelLineBegin = "46" ; Change this to the range of cells you want to be processed -$excelLineEnd = "700" +$excelLineEnd = "1000" Global $vref = 650 ; Initial vref, will be adjusted during runtime $completelog = "" @@ -56,7 +56,6 @@ $CellRange = "A" & $excelLineBegin & ":N" & $excelLineEnd ; 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 & _ - "Temperatur: " & $systemtemp & " C" & @CRLF & _ "Radioactive source: " & $radSource & @CRLF & _ "Chip: " & $chipversion & " (#" & $chipinstalled & ")" & @CRLF & _ "Radiated: " & $radiated & @CRLF & _ @@ -84,7 +83,7 @@ If (Not @error) And IsObj($oExcelDoc) Then ; Check again if everything went well $totallexcelines = UBound($aArray, 2) $totalruns = 0 For $run = 0 To UBound($aArray, 2) - 1 - If ($aArray[4][$run] == $systemtemp And $aArray[6][$run] == $chipinstalled And "Mi" & $aArray[2][$run] == $chipversion And $aArray[10][$run] == $radSource And $aArray[12][$run] == $radiated And $aArray[0][$run] == "") Then + If ($aArray[6][$run] == $chipinstalled And "Mi" & $aArray[2][$run] == $chipversion And $aArray[10][$run] == $radSource And $aArray[12][$run] == $radiated And $aArray[0][$run] == "") Then $totalruns = $totalruns + 1 EndIf Next @@ -146,7 +145,22 @@ If (Not @error) And IsObj($oExcelDoc) Then ; Check again if everything went well $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[4][0] == $systemtemp And $currentline[6][0] == $chipinstalled And "Mi" & $currentline[2][0] == $chipversion And $currentline[10][0] == $radSource And $currentline[12][0] == $radiated And $currentline[0][0] == "") Then + + ;TODO + $tempcorrent = False + While Not $tempcorrent + $currenttemp = GetTemperature() + If ($currentline[4][0] < $currenttemp + 0.5 And $currentline[4][0] > $currenttemp - 0.5) Then + $tempcorrent = True + Else + If Not SetTemperature($currentline[4][0]) Then + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "Could not set temperature to "' & $currentline[4][0] & '". Will try again in 10 minutes."', @ScriptDir) + EndIf + Sleep(1000 * 60 * 10) + EndIf + WEnd + + If ($tempcorrent And $currentline[6][0] == $chipinstalled And "Mi" & $currentline[2][0] == $chipversion And $currentline[10][0] == $radSource And $currentline[12][0] == $radiated And $currentline[0][0] == "") Then $clock = $currentline[11][0] ; save needed clock If $clock == "" Then $clock = "100" -- 2.43.0