]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
bot: Add Telegram, start to work on Piper2
authorBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Tue, 20 Sep 2016 14:21:28 +0000 (16:21 +0200)
committerBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Tue, 20 Sep 2016 14:21:28 +0000 (16:21 +0200)
19 files changed:
bot/Chips/Mimosa19.au3
bot/Chips/Mimosa29.au3
bot/Chips/Piper2.au3 [new file with mode: 0755]
bot/Functions/CommonFunctions.au3
bot/Functions/MoveFolder.au3
bot/Functions/ReadAndSaveSQLParameters.au3
bot/Functions/SaveToSQL.au3
bot/Functions/SendNtfctn.au3
bot/Functions/Telegram.au3 [new file with mode: 0755]
bot/Functions/TemperatureControl.au3
bot/Functions/WaitForTemperature.au3
bot/Functions/Watchrun.au3
bot/Functions/WinHttp.au3 [new file with mode: 0755]
bot/Functions/mysql_functions.au3
bot/GUI/MABS.au3
bot/MABS.lnk
bot/Mimosa_Autorun_USB.au3
bot/config_USB.ini
bot/mysql-connector-odbc-5.2.6-win32.msi [new file with mode: 0755]

index 6ef6be0d99bdd71b238f90e82127bf301df4c947..fd3c12659cf172f3a7a4abce0f1dfa555bde7929 100755 (executable)
@@ -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()
index 069790a1f5066a9e2eeacbeff618eb2ea387e3c6..91a2f1aceade10d18eb07aa7d16fa073e9dc3129 100755 (executable)
@@ -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 (executable)
index 0000000..cc9d54d
--- /dev/null
@@ -0,0 +1,40 @@
+#include <I2C_control_Mim32.au3>
+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
index 5ceaf992d91847a612e1d5d1d491758c13237c20..a6cc899349803c8f04f3abdf7f994d9f53a4dea6 100755 (executable)
@@ -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 )
index 4891911b02c6ea4c219d5b1b12ed2c3a139ed4a6..ec6a503c0906755707a0b4f6c7b7f3a8eeb0dd05 100755 (executable)
@@ -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
index 76f5d0a66881ef654c4a720fa237d3276590d825..960ad8daf5b8472b7b2b8f2fb94477efd0788c3f 100755 (executable)
@@ -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
index 381fe40c8b1d457f49125536ba39b1f528297658..f4a3f07161e3ab7dee02fe7a58348020f2e9766e 100755 (executable)
@@ -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, "/", "//")
index 2ed142b1d3adca589d7999d38acf7d7e7239f65b..e116a54105411b3eccdfc765e70f64415bf6e94f 100755 (executable)
@@ -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 (executable)
index 0000000..d0c301b
--- /dev/null
@@ -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
index 3a4a59f68003ad4bfeeb50324ab1bb72a5318c5b..a84c93d7cc38145bebeb52124e3c9d067f4239f7 100755 (executable)
@@ -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"
index 1abc60f4471a332e21da6be1f7c2fe0f47a90ee1..fccba81971189c5406d1ea3d6639d341564dd69d 100755 (executable)
@@ -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
index 696800288192ad25d098914b8a4ebdb2b4565689..2d486efcadd10de2c1f0b6cf46a303107f0860be 100755 (executable)
@@ -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 (executable)
index 0000000..adbf50e
--- /dev/null
@@ -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
index dcf53301b506ac8b723c2de5d073920a74f816b7..4e721bf15c59073f480d628600de869185386105 100755 (executable)
 
 ;~ ; $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)
 
index 43302b302bf1c05bff99e07b1dbe9de24e1e3934..eaf25230895ee91a28cc41784a4d516417eddc3a 100755 (executable)
@@ -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)
index 96f43e763df3f356b12a469a1184fe6a2f6c2412..34040175177ab6fb83ec71c65a5e952863f0399d 100755 (executable)
Binary files a/bot/MABS.lnk and b/bot/MABS.lnk differ
index c7d774c70a2bce38f21a35e9d8e3794ca7fb370d..6d7c9fd5f47747ec7b39da888c93f445e41657d1 100755 (executable)
@@ -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()
index 41e88234ab47a9a62287e9a7e3300b8605216db4..6a4897bc546c18b52ee27489f4f1ad4cf33d957d 100755 (executable)
@@ -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 (executable)
index 0000000..8c42489
Binary files /dev/null and b/bot/mysql-connector-odbc-5.2.6-win32.msi differ