From: Benjamin Linnik Date: Tue, 20 Sep 2016 14:21:28 +0000 (+0200) Subject: bot: Add Telegram, start to work on Piper2 X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=9329da3833717b23f24c2dbcb6007ce360cd18b3;p=radhard.git bot: Add Telegram, start to work on Piper2 --- diff --git a/bot/Chips/Mimosa19.au3 b/bot/Chips/Mimosa19.au3 index 6ef6be0..fd3c126 100755 --- a/bot/Chips/Mimosa19.au3 +++ b/bot/Chips/Mimosa19.au3 @@ -11,8 +11,10 @@ EndFunc ;==>Mi34_SelectBoard Func Mi19_SetMiParameter($matrix, $vref) Sleep(1000) - $savedir = "F:\currentrun" ; overwrite store path set in other Mimosa files read in by include - $storedir = "O:\Mi19" +;~ $savedir = "F:\currentrun" ; overwrite store path set in other Mimosa files read in by include + $savedir = "O:\Mi19" ; overwrite store path set in other Mimosa files read in by include +;~ For Mi19 use StoreDir == Savedir, no moving involved, too short runs + $storedir = "" EndFunc ;==>Mi34_SetMiParameter Func Mi19_TestSystem() diff --git a/bot/Chips/Mimosa29.au3 b/bot/Chips/Mimosa29.au3 index 069790a..91a2f1a 100755 --- a/bot/Chips/Mimosa29.au3 +++ b/bot/Chips/Mimosa29.au3 @@ -3,7 +3,7 @@ Global $hWnd Global $hCounter $savedir = "F:\Mi29" Global $vref = -1 ; Initial vref, will be adjusted during runtime -$temperaturebefore = 600 +$temperaturebefore = -10000 Func Mi29_GotoMiTab() diff --git a/bot/Chips/Piper2.au3 b/bot/Chips/Piper2.au3 new file mode 100755 index 0000000..cc9d54d --- /dev/null +++ b/bot/Chips/Piper2.au3 @@ -0,0 +1,40 @@ +#include +Global $Mi34_buttons[3] = ["Edit2", "TCSpinEdit5", "TEdit11"] + +Func Mi34_GotoMiTab() + GotoTab(7) ; Go to "Mi34" tab +EndFunc ;==>Mi34_GotoMiTab + +Func Mi34_SelectBoard() + GotoTab(0) ; Go to first tab + ControlCommand($chipsoftware[0], "", "[TEXT:Mimosa34]", "Check") +EndFunc ;==>Mi34_SelectBoard + +Func Mi34_GetVref() + return ControlGetText($chipsoftware[0], "", $Mi34_buttons[2]) +EndFunc ;==>Mi34_GetVref + +Func Mi34_SetVref($vref) + ControlSetText($chipsoftware[0], "", $Mi34_buttons[2], $vref) +EndFunc ;==>Mi34_SetVref + +Func Mi34_SetMiParameter($matrix, $vref) + ControlFocus($chipsoftware[0], "", $Mi34_buttons[0]) + ControlSetText($chipsoftware[0], "", $Mi34_buttons[0], "") + Sleep(100) + ControlSend($chipsoftware[0], "", $Mi34_buttons[0], $matrix) + Sleep(100) + ;Send($matrix) + ;ControlCommand($chipsoftware[0], "", "[TEXT:Clamp Enabled]", "Uncheck") + ;ControlCommand($chipsoftware[0], "", "[TEXT:High (Default)]", "Check") + ControlFocus($chipsoftware[0], "", $Mi34_buttons[1]) + ControlSetText($chipsoftware[0], "", $Mi34_buttons[1], "") + Sleep(100) + ControlSetText($chipsoftware[0], "", $Mi34_buttons[1], "1") + Sleep(100) + ControlFocus($chipsoftware[0], "", $Mi34_buttons[2]) + ControlSetText($chipsoftware[0], "", $Mi34_buttons[2], "") + Sleep(100) + ControlSetText($chipsoftware[0], "", $Mi34_buttons[2], $vref) + Sleep(100) +EndFunc ;==>Mi34_SetMiParameter diff --git a/bot/Functions/CommonFunctions.au3 b/bot/Functions/CommonFunctions.au3 index 5ceaf99..a6cc899 100755 --- a/bot/Functions/CommonFunctions.au3 +++ b/bot/Functions/CommonFunctions.au3 @@ -1,3 +1,9 @@ +;~ $currenttempchip = GetTemperatureForSure("ChipUSB") +;~ MsgBox(0, "Debug", "Wieso nicht full precision " & $currenttempchip & " ?") +;~ $currenttemp = GetTemperatureForSure("USB") +;~ MsgBox(0, "Debug", "Wieso nicht full precision " & $currenttemp & " ?") +;~ Exit + ; $whichone can be set to ChipPXI, ChipUSB (chiptemperature) or PXI, USB for cooling temperature Func GetTemperatureForSure($whichone) $tempgeti = 0 @@ -11,18 +17,18 @@ Func GetTemperatureForSure($whichone) $currenttemp = RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\TemperatureControl.au3" "' & $whichone & '"', @ScriptDir) EndIf $tempgeti = $tempgeti + 1 - Until $currenttemp < 100000 - Return $currenttemp / 100.0 + Until $currenttemp < 100000.0 + Return $currenttemp / 100 EndFunc Func GetTemperature($whichone) - $currenttemp = 100000; + $currenttemp = 100000.0; 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 - Return $currenttemp / 100.0 + Return $currenttemp / 100 EndFunc Func RefreshGUISendNtfct( $msg ) diff --git a/bot/Functions/MoveFolder.au3 b/bot/Functions/MoveFolder.au3 index 4891911..ec6a503 100755 --- a/bot/Functions/MoveFolder.au3 +++ b/bot/Functions/MoveFolder.au3 @@ -1,3 +1,5 @@ +Local $skippedruns +#include "mysql_functions.au3" $returnval = 10000 If ($CmdLine[0] = 2) Then @@ -18,11 +20,23 @@ EndFunc ;==>MoveFolder Func MoveFolders($src, $dst, $runnumber) - For $i = -2 To 0 - DirCopy ( $src & "\" & $runnumber+$i, $dst & "\" & $runnumber+$i ) - ;FileDelete($src & "\" & $runnumber+$i & "\*") - DirRemove( $src & "\" & $runnumber+$i, 1) - Next - ShellExecuteWait("C:\Programme\PuTTY\plink.exe", "-ssh -2 -l maps -i 'C:\Users\DAQ\Documents\Putty\save.ppk' jspc48.x-matter.uni-frankfurt.de /u/blinnik/radhard/MABS_run_analyzer/analyzerun.sh " & $runnumber, "", "", @SW_HIDE) + If StringLen($dst) > 1 Then + For $i = -2 To 0 + DirCopy ( $src & "\" & $runnumber+$i, $dst & "\" & $runnumber+$i ) + ;FileDelete($src & "\" & $runnumber+$i & "\*") + DirRemove( $src & "\" & $runnumber+$i, 1) + Next + EndIf + ShellExecuteWait("C:\Programme\PuTTY\plink.exe", "-ssh -2 -l maps -pw mimosa88 jspc48.x-matter.uni-frankfurt.de /u/blinnik/radhard/MABS_run_analyzer/analyzerun.sh " & $runnumber, "", "", @SW_SHOW) + $runcandidates = ReturnRunInfo($runnumber) + $msg = "Analysis of run " & $runnumber & " finished:" & @CRLF + $msg = $msg & GetValueFromRunInfo($runcandidates,"Comment") & @CRLF + $msg = $msg & "Average leakage current: " & GetValueFromRunInfo($runcandidates,"LeakageCurfA") & " fA" & @CRLF + $msg = $msg & "Average noise: " & GetValueFromRunInfo($runcandidates,"Avg.Noise") & " e" & @CRLF + $msg = $msg & "Average F0: " & GetValueFromRunInfo($runcandidates,"AvgF0") & " " & @CRLF + $msg = $msg & "Sigma of F0: " & GetValueFromRunInfo($runcandidates,"SigmaF0") & " " & @CRLF + $msg = $msg & "Temperature at start: " & GetValueFromRunInfo($runcandidates,"TempChipStart") & " °C" & @CRLF + $msg = $msg & "Temperature at end: " & GetValueFromRunInfo($runcandidates,"TempChipEnd") & " °C" + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Telegram.au3" "' & $msg & '"', @ScriptDir) Return 0 -EndFunc ;==>MoveFolder \ No newline at end of file +EndFunc ;==>MoveFolder ' \ No newline at end of file diff --git a/bot/Functions/ReadAndSaveSQLParameters.au3 b/bot/Functions/ReadAndSaveSQLParameters.au3 index 76f5d0a..960ad8d 100755 --- a/bot/Functions/ReadAndSaveSQLParameters.au3 +++ b/bot/Functions/ReadAndSaveSQLParameters.au3 @@ -4,6 +4,14 @@ $TempWaitFor = $suitrun[2] If $TempWaitFor == "" Then $TempWaitFor = 0 $clock = $suitrun[3] If $clock == "" Then $clock = 100 +If IsDeclared("runnumber") Then + If $runnumber+1 <> $suitrun[4] Then + RefreshGUISendNtfct("No suitable and consecutive run found." & @CRLF & "Please change source.") + _ArrayAdd($skippedruns, $runnumber) + $suitrun = ReturnSuitRun($chipversion, $chipinstalled, $radSource, "Nothing") + ContinueLoop + EndIf +EndIf Global $runnumber = $suitrun[4] $matrix = $suitrun[5] $events = $suitrun[6] \ No newline at end of file diff --git a/bot/Functions/SaveToSQL.au3 b/bot/Functions/SaveToSQL.au3 index 381fe40..f4a3f07 100755 --- a/bot/Functions/SaveToSQL.au3 +++ b/bot/Functions/SaveToSQL.au3 @@ -5,8 +5,13 @@ If $temperaturechipstart = 100000 Then $temperaturechipstart = "NULL" If $temperaturechipend = 100000 Then $temperaturechipstart = "NULL" $datetime = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC if (IsDeclared("storedir")) Then - $path = StringReplace ( $storedir, "\", "\\") & "\\" & $runnumber -Else + If StringLen($storedir) > 1 Then + $path = StringReplace ( $storedir, "\", "\\") & "\\" & $runnumber + EndIf +EndIf +if (Not IsDeclared("storedir")) Then + $path = StringReplace ( $savedir, "\", "\\") & "\\" & $runnumber +ElseIf StringLen($storedir) <= 1 Then $path = StringReplace ( $savedir, "\", "\\") & "\\" & $runnumber EndIf $path = StringReplace ( $path, "/", "//") diff --git a/bot/Functions/SendNtfctn.au3 b/bot/Functions/SendNtfctn.au3 index 2ed142b..e116a54 100755 --- a/bot/Functions/SendNtfctn.au3 +++ b/bot/Functions/SendNtfctn.au3 @@ -2,19 +2,14 @@ $notify = IniRead("config.ini", "various", "Notify", "1") ; notifycode $notifycustom = IniRead("config.ini", "various", "NotifyCustom", "") ; chip number currently mounted into the system +;~ $text = "Estimated runtime: sdfjaskdf askdfjkasdfj asdf aksjdfka sjdfkaj skdfa sdfas4df5as4df45 454:545" +;~ $text = urlencode($text) +;~ HttpPost("https://api.telegram.org/bot" & $telegramBotToken & "/sendmessage", "chat_id=" & $sendto & "&text=" & $text) +;~ ConsoleWrite("https://api.telegram.org/bot" & $telegramBotToken & "/sendmessage?chat_id=" & $sendto & "&text=" & $text & @CRLF) + $error = 1 If $CmdLine[0] > 1 Then SendNtfctn($CmdLine[2], $CmdLine[1]) -;~ If $CmdLine[1] == "USB" Then -;~ SendNtfctn($CmdLine[2], "USB") -;~ $error = 0 -;~ ElseIf $CmdLine[1] == "PXI" Then -;~ SendNtfctn($CmdLine[2], "PXI") -;~ $error = 0 -;~ ElseIf $CmdLine[1] == "Pegasus" Then -;~ SendNtfctn($CmdLine[2], "Pegasus") -;~ $error = 0 -;~ EndIf EndIf ConsoleWrite($error) @@ -41,11 +36,16 @@ Func SendNtfctn($text, $system) 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:%20System-" & $system & ":%20" & $text & "&password=TannenbaumSaftSchorle") + $oHTTP.Open("GET", "http://autoremotejoaomgcd.appspot.com/sendmessage?key=APA91bEejQPoLUIipcNpfeDvNoa5Bd48AASVBHRphY4ySu8U2FSfuDym2iHdkC_YJ2zyhhbVXVB0oRacd_QmDFsrNRATF0rT4b7pqIHj8EeUrOdq0s_gQq7BE0ERaUfHHikhet06D8ff8BUXe8uVZ5RqoI2ygWc48Q&message=RadHardSMS015735341144:%20System-" & $system & ":%20" & $text & "&password=TannenbaumSaftSchorle") $oHTTP.Send() EndIf EndIf + If Not StringInStr($text, "Percent%20done") Then + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Telegram.au3" "' & $text & '"', @ScriptDir) +;~ HttpPost("https://api.telegram.org/bot" & $telegramBotToken & "/sendmessage", "chat_id=" & $sendto & "&text=" & $text) + EndIf + $oHTTP = 0 EndFunc ;==>SendNtfctn diff --git a/bot/Functions/Telegram.au3 b/bot/Functions/Telegram.au3 new file mode 100755 index 0000000..d0c301b --- /dev/null +++ b/bot/Functions/Telegram.au3 @@ -0,0 +1,71 @@ +#include "WinHttp.au3" +$telegramBotToken = "229250039:AAE1ZLSaPlEYyLk8Az-uxaHUv2QUGy6CAqE" +;~ $sendto = "@MABS_Updates" ; Old public channel +;~ $sendto = "-1001070398675" ; Old channel +$sendto = "-155736448" ; mew group chat + +$error = 1 +If $CmdLine[0] > 0 Then + SendTelegramNtfctn($CmdLine[1]) +EndIf +ConsoleWrite($error) + +Func SendTelegramNtfctn($text) + ;$text = urlencode($text) + HttpPost("https://api.telegram.org/bot" & $telegramBotToken & "/sendmessage", "chat_id=" & $sendto & "&text=" & $text) + $error = 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 + + +;~ Func _Test1() +;~ Global Const $fTestMode = false ; testmode will delete images after 15 minutes +;~ Global Const $sAPIURL = "/bot1718sdfer7:AAGVRavnvnvnv/sendphoto?chat_id=183783345" +;~ Global Const $sURL = "api.telegram.org" +;~ Global $hOpen = _WinHttpOpen("") +;~ Global $hConnect = _WinHttpConnect($hOpen, $sURL) +;~ Global $hRequest = _WinHttpOpenRequest($hConnect, "POST", $sAPIURL) +;~ Global $sData = "" +;~ If $fTestMode Then +;~ $sData &= '----------darker' & @CRLF +;~ $sData &= 'Content-Disposition: multipart/form-data; name="testMode"' & @CRLF & @CRLF +;~ $sData &= '1' & @CRLF +;~ EndIf +;~ $sData &= '----------darker' & @CRLF +;~ $sData &= 'Content-Disposition: form-data; name="xmlOutput"' & @CRLF & @CRLF +;~ $sData &= '1' & @CRLF +;~ $sData &= '----------darker' & @CRLF +;~ $sData &= 'Content-Disposition: multipart/form-data; name="imageMD5"' & @CRLF & @CRLF +;~ $sData &= StringLower(Hex(_Crypt_HashFile("C:\Users\Pictures\342_640x960_net.jpg", $CALG_MD5))) & @CRLF +;~ $sData &= '----------darker' & @CRLF +;~ $sData &= 'Content-Disposition: multipart/form-data; name="photo"; filename="testimage.jpg"' & @CRLF +;~ $sData &= 'Content-Type: image/jpg' & @CRLF & @CRLF +;~ $sData &= FileRead("C:\Users\Pictures\342_640x960_net.jpg") & @CRLF +;~ $sData &= '----------darker--' +;~ _WinHttpSendRequest($hRequest, "Content-Type: multipart/form-data; boundary=--------darker", Binary($sData)) +;~ _WinHttpReceiveResponse($hRequest) +;~ $sResult = _WinHttpReadData($hRequest) +;~ MsgBox(0, "", $sResult) +;~ ConsoleWrite($sResult & @CRLF) +;~ _WinHttpCloseHandle($hRequest) +;~ _WinHttpCloseHandle($hConnect) +;~ _WinHttpCloseHandle($hOpen) +;~ EndFunc \ No newline at end of file diff --git a/bot/Functions/TemperatureControl.au3 b/bot/Functions/TemperatureControl.au3 index 3a4a59f..a84c93d 100755 --- a/bot/Functions/TemperatureControl.au3 +++ b/bot/Functions/TemperatureControl.au3 @@ -7,14 +7,15 @@ If ($CmdLine[0] > 1) Then Else If StringInStr($CmdLine[1], "Chip") Then $parameter = StringRegExpReplace ($CmdLine[1], "Chip", "") - $returnval = GetTemperatureChip($parameter) * 100 + $returnval = GetTemperatureChip($parameter) Else - $returnval = GetTemperatureCooling($CmdLine[1]) * 100 + $returnval = GetTemperatureCooling($CmdLine[1]) EndIf EndIf ConsoleWrite($returnval) ;### Debug Console Exit $returnval + Func GetTemperatureCooling($system) ;ConsoleWrite('@@ (6) :(' & @MIN & ':' & @SEC & ') GetTemperature()' & @CR) ;### Function Trace $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") @@ -38,12 +39,12 @@ Func GetTemperatureCooling($system) $curtemperatur = StringReplace($curtemperaturmatch[0], "Internal Sensor: ", "") ;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $curtemperatur = ' & $curtemperatur & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ControlSetText("MABS (Mimosa Automation Bot System)", "", "Static3", $curtemperatur) - Return $curtemperatur + Return $curtemperatur * 100.0 EndIf EndIf EndIf $oHTTP = 0 - Return 1000 + Return 100000 EndFunc ;==>GetTemperature @@ -69,12 +70,12 @@ Func GetTemperatureChip($system) $curtemperatur = StringRegExpReplace ($curtemperaturmatch[0], "Sensor .+?-System => ", "") ;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $curtemperatur = ' & $curtemperatur & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ControlSetText("MABS (Mimosa Automation Bot System)", "", "Static4", $curtemperatur) - Return $curtemperatur + Return $curtemperatur * 100.0 EndIf EndIf EndIf $oHTTP = 0 - Return 1000 + Return 100000 EndFunc ;==>GetTemperature Func SetTemperature($system, $temperature) @@ -93,7 +94,7 @@ Func SetTemperature($system, $temperature) Switch $system Case "USB" ;.Open("GET", "http://cerberus.x-matter.uni-frankfurt.de:8700/tools/cooling/cooling.pl?/dev/USBCooling&" & $command) - .Open("GET", "http://cerberus.x-matter.uni-frankfurt.de:8700/tools/cooling/cooling.pl?/dev/USBCooling&" & $command) + .Open("GET", "http://cerberus.x-matter.uni-frankfurt.de:8700/tools/cooling/cooling.pl?/dev/PXICooling&" & $command) Case "PXI" .Open("GET", "http://cerberus.x-matter.uni-frankfurt.de:8700/tools/cooling/cooling.pl?/dev/PXICooling&" & $command) Case "Pegasus" diff --git a/bot/Functions/WaitForTemperature.au3 b/bot/Functions/WaitForTemperature.au3 index 1abc60f..fccba81 100755 --- a/bot/Functions/WaitForTemperature.au3 +++ b/bot/Functions/WaitForTemperature.au3 @@ -1,3 +1,4 @@ + If $TempCooling == $temperaturebefore Then $tempcorrent = True Else @@ -19,17 +20,19 @@ While Not $tempcorrent ;If $tempwaiti > 5 Then ; after 30 minutes give up waiting If $tempwaiti > 0 Then ; Dennis changed to 5 Minutes to accelerate noise-T-scan $currenttempchip = GetTemperatureForSure("Chip" & $system) - RefreshGUISendNtfct("Cooling could not reach needed temperature of " & $TempCooling & " °C within 5 minutes. Current cooling temperature is " & $currenttemp & ", chip temperature is " & $currenttempchip & ". Will proceed anyway.") + RefreshGUISendNtfct("Cooling could not reach needed temperature of " & String($TempCooling) & " °C within 5 minutes. Current cooling temperature is " & String($currenttemp) & ", chip temperature is " & String($currenttempchip) & ". Will proceed anyway.") $tempcorrent = True ExitLoop 1 EndIf - $completelog &= _NowCalc() & " Current temperature is " & $currenttemp & "." & @CRLF & "Will set it to " & $TempCooling & " and wait for 5 minutes." & @CRLF + $texttosend = "Current temperature is " & $currenttemp & "." & @CRLF & "Will set it to " & $TempCooling & " and wait for 5 minutes." + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\Telegram.au3" "' & $texttosend & '"', @ScriptDir) + $completelog &= _NowCalc() & " " & $texttosend & @CRLF Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $completelog & '"') $tempseti = 0 Do If $tempseti > 10 Then ; after 10 failed attempts $currenttempchip = GetTemperatureForSure("Chip" & $system) - RefreshGUISendNtfct("Could not set temperature to " & $TempCooling & ". Current cooling temperature is " & $currenttemp & " °C, chip temperature is " & $currenttempchip & ". Will proceed anyway.") + RefreshGUISendNtfct("Could not set temperature to " & String($TempCooling) & ". Current cooling temperature is " & String($currenttemp) & " °C, chip temperature is " & String($currenttempchip) & ". Will proceed anyway.") $tempcorrent = True ExitLoop 2 EndIf @@ -41,7 +44,9 @@ While Not $tempcorrent EndIf WEnd If $TempWaitFor > 0 Then - $completelog &= _NowCalc() & " Found user defined waiting time, will wait for " & $TempWaitFor & " minutes before proceeding." & @CRLF + $texttosend = "Found user defined waiting time, will wait for " & $TempWaitFor & " minutes before proceeding." + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\Telegram.au3" "' & $texttosend & '"', @ScriptDir) + $completelog &= _NowCalc() & " " & $texttosend & @CRLF Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\RefreshGUI.au3" "' & $completelog & '"') Sleep($TempWaitFor * 60 * 1000) ; wait for user specified minutes EndIf diff --git a/bot/Functions/Watchrun.au3 b/bot/Functions/Watchrun.au3 index 6968002..2d486ef 100755 --- a/bot/Functions/Watchrun.au3 +++ b/bot/Functions/Watchrun.au3 @@ -1,24 +1,24 @@ $i = 0 Do $oldcounter = GetCounter() - $percentCurrent = Round($oldcounter / $events * 100, 2) - $percentoverall = Round(($oldcounter / $events / $totalruns + $totalrealruns / $totalruns) * 100, 2) - If Not $estimate And $percentoverall > 1 Then + $percentCurrent = Round($oldcounter / $events * 100, 3) + $percentoverall = Round(($oldcounter / $events / $totalruns + $totalrealruns / $totalruns) * 100, 3) + If Not $estimate And $percentCurrent > 5 Then $calcsecestimate = _DateDiff('s', $starttime, _NowCalc()) ; n for minites, s for seconds - $calcsecestimate = $calcsecestimate * 100 / $percentoverall + $calcsecestimate = $calcsecestimate * 100 / $percentCurrent $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) + $completelog &= _NowCalc() & " Estimated runtime of current run: " & $calcmin & " minutes." & @CRLF & "Estimated endtime: " & $timeend & @CRLF + Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "Estimated runtime of current run: ' & $calcmin & ' minutes. 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 + If Not Mod($i, 10) Then $currenttempchip = GetTemperature("Chip" & $system) Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\WriteTemperatureLog.au3" "' & $savedir & '\' & $runnumber & '\temperature.log" "' & $system & '"', @ScriptDir) Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Functions\SendNtfctn.au3" "' & $system & '" "Percent done: ' & $percentoverall & ' (' & $totalrealruns & '/' & $totalruns & ') TempChip: ' & $currenttempchip & '"', @ScriptDir) diff --git a/bot/Functions/WinHttp.au3 b/bot/Functions/WinHttp.au3 new file mode 100755 index 0000000..adbf50e --- /dev/null +++ b/bot/Functions/WinHttp.au3 @@ -0,0 +1,48 @@ +#include-once + +Global Const $HTTP_STATUS_OK = 200 +Global Const $WinHttpRequestOption_SslErrorIgnoreFlags = 4 + +Func HttpPost($sURL, $sData = "") + Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") + + $oHTTP.Open("POST", $sURL, False) + If (@error) Then Return SetError(1, 0, 0) + + $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") + +;~ //ignore all SSL errors + $oHTTP.Option($WinHttpRequestOption_SslErrorIgnoreFlags) = 0x3300 +;~ //Unknown certification authority (CA) or untrusted root 0x0100 +;~ //Wrong usage 0x0200 +;~ //Invalid common name (CN) 0x1000 +;~ //Invalid date or certificate expired 0x2000 + + $oHTTP.Send($sData) + If (@error) Then Return SetError(2, 0, 0) + + If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) + + Return SetError(0, 0, $oHTTP.ResponseText) +EndFunc + +Func HttpGet($sURL, $sData = "") + Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") + + $oHTTP.Open("GET", $sURL & "?" & $sData, False) + If (@error) Then Return SetError(1, 0, 0) + +;~ //ignore all SSL errors + $oHTTP.Option($WinHttpRequestOption_SslErrorIgnoreFlags) = 0x3300 +;~ //Unknown certification authority (CA) or untrusted root 0x0100 +;~ //Wrong usage 0x0200 +;~ //Invalid common name (CN) 0x1000 +;~ //Invalid date or certificate expired 0x2000 + + $oHTTP.Send() + If (@error) Then Return SetError(2, 0, 0) + + If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) + + Return SetError(0, 0, $oHTTP.ResponseText) +EndFunc diff --git a/bot/Functions/mysql_functions.au3 b/bot/Functions/mysql_functions.au3 index dcf5330..4e721bf 100755 --- a/bot/Functions/mysql_functions.au3 +++ b/bot/Functions/mysql_functions.au3 @@ -24,7 +24,34 @@ ;~ ; $suitrun = ReturnSuitRun("Mi34", "3", "3", "Fe55", "USB") +;~ Local $skippedruns + +Func GetValueFromRunInfo($runcandidates, $name) + If IsArray($runcandidates) Then + $i = -1 + Do + $i=$i+1 + If $runcandidates[0][$i][0] == $name Then + Return $runcandidates[0][$i][1] + EndIf + Until $i == UBound($runcandidates, 2) - 1 Or $runcandidates[0][$i][0] == $name + Return "-" + EndIf +EndFunc +Func ReturnRunInfo($runnumber) + $sql = GetSQLConnection() + $sqlstring = "SELECT * FROM labbook WHERE runnumber='" & $runnumber & "' ORDER BY id DESC" + ConsoleWrite($sqlstring & @CRLF) + $runcandidates = mysql_fetch_array($sqlstring, $sql) + $number = _CountDifferentRecords($sql, "labbook", "runnumber", $runnumber) + _MySQLEnd($sql) + If $number > 0 Then + Return $runcandidates + Else + Return 0 + EndIf +EndFunc Func UpdateDBwithRun($id, $datetime, $temperaturechipstart, $temperaturechipend, $vref, $calcsec, $programversion, $path) $sql = GetSQLConnection() @@ -102,9 +129,10 @@ Func ReturnSuitRun($ChipGen, $ChipNum, $RadiationSource, $System, $Clock=0) $sqlstring = $sqlstring & " AND runnumber != " & $skippedrun EndIf Next + $sqlstring = $sqlstring & " ORDER BY runnumber ASC" $sqlstring = $sqlstring & " LIMIT 1" ConsoleWrite($sqlstring & @CRLF) -;~ MsgBox (0,"SQL", $sqlstring) +;~ MsgBox (0,"SQL", $sqlstring) $runcandidates = _Query($sql, $sqlstring) diff --git a/bot/GUI/MABS.au3 b/bot/GUI/MABS.au3 index 43302b3..eaf2523 100755 --- a/bot/GUI/MABS.au3 +++ b/bot/GUI/MABS.au3 @@ -28,7 +28,7 @@ $MenuItem5 = GUICtrlCreateMenu("&Help") $MenuItem6 = GUICtrlCreateMenuItem("About", $MenuItem5) $Label1 = GUICtrlCreateLabel("Mimosa Chip", 11, 7, 64, 17) $ChipCombo = GUICtrlCreateCombo("", 11, 26, 89, 25) -GUICtrlSetData(-1, "FSBB|Mi32|Mi32Ter|Mi34|Pegasus") +GUICtrlSetData(-1, "FSBB|Mi32|Mi32Ter|Mi34|Pegasus|Pipper2") $ChipNumInput = GUICtrlCreateInput("1", 107, 26, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Label2 = GUICtrlCreateLabel("Number", 107, 7, 41, 17) $Label3 = GUICtrlCreateLabel("Temperature", 11, 116, 64, 17) @@ -51,7 +51,7 @@ $CheckboxBenny = GUICtrlCreateCheckbox("Benny", 11, 205, 52, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Label8 = GUICtrlCreateLabel("Notify:", 11, 188, 34, 17) $CheckboxDennis = GUICtrlCreateCheckbox("Dennis", 81, 205, 52, 17) -$CheckboxStefan = GUICtrlCreateCheckbox("Your name here", 11, 225, 124, 17) +$CheckboxStefan = GUICtrlCreateCheckbox("Ali", 11, 225, 124, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $hNotifyCustom = ControlGetHandle ($Form1_1, "", $NotifyCustom) diff --git a/bot/MABS.lnk b/bot/MABS.lnk index 96f43e7..3404017 100755 Binary files a/bot/MABS.lnk and b/bot/MABS.lnk differ diff --git a/bot/Mimosa_Autorun_USB.au3 b/bot/Mimosa_Autorun_USB.au3 index c7d774c..6d7c9fd 100755 --- a/bot/Mimosa_Autorun_USB.au3 +++ b/bot/Mimosa_Autorun_USB.au3 @@ -103,7 +103,6 @@ If (Not @error) Then ; Check again if everything went well $suitrun = ReturnSuitRun($chipversion, $chipinstalled, $radSource, "USB") While Not $suitrun[0] = "" ; Do runs, until no new run found #include "Functions\ReadAndSaveSQLParameters.au3" - RefreshGUISendNtfct("Begin with runnumber " & $runnumber & ".") #include "Functions\WaitForTemperature.au3" _CheckWindowExist() SelectBoard() @@ -137,6 +136,7 @@ If (Not @error) Then ; Check again if everything went well Sleep(100) ControlFocus($hWnd, "", "TEdit23") Sleep(1000) + RefreshGUISendNtfct("Begin with runnumber " & $runnumber & ".") $starttime = _NowCalc() StartRun() Sleep(1000) @@ -154,7 +154,7 @@ If (Not @error) Then ; Check again if everything went well Sleep(200) $j = 0 - If ($avg > 2300 Or $avg < 1700) Then + If ($avg > 2150 Or $avg < 1500) Then ; change 1400 back to 1700 Do ControlClick($hWnd, "", "[TEXT:Stop Run;CLASS:TButton]") $vref = GetVref() diff --git a/bot/config_USB.ini b/bot/config_USB.ini index 41e8823..6a4897b 100755 --- a/bot/config_USB.ini +++ b/bot/config_USB.ini @@ -1,7 +1,7 @@ [experimental setup] ChipVersion = Mi19 ChipInstalled = 10 -RadSource = Fe55 +RadSource = none [various] -Notify = 1 -NotifyCustom = aliyazgili@yahoo.de +Notify = 0 +NotifyCustom = (Optional) diff --git a/bot/mysql-connector-odbc-5.2.6-win32.msi b/bot/mysql-connector-odbc-5.2.6-win32.msi new file mode 100755 index 0000000..8c42489 Binary files /dev/null and b/bot/mysql-connector-odbc-5.2.6-win32.msi differ