--- /dev/null
+#include <String.au3>
+AutoItSetOption("TrayIconHide", 1)
+$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler
+
+If ($CmdLine[0] > 0) Then
+ SetTemperature($CmdLine[1])
+Else
+ GetTemperature()
+EndIf
+
+Func GetTemperature()
+ ;ConsoleWrite('@@ (6) :(' & @MIN & ':' & @SEC & ') GetTemperature()' & @CR) ;### Function Trace
+ $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
+ WITH $oHTTP
+ .Open("GET", "http://cerberus.x-matter.uni-frankfurt.de:8700/tools/cooling/cooling.pl?/dev/ttyUSB1")
+ .Send()
+ $HTMLSource = .Responsetext
+ ENDWITH
+ If $HTMLSource <> "" Then
+ $curtemperaturmatch = StringRegExp ( $HTMLSource, "Internal Sensor\: (-)?[0-9]+\.[0-9]+", 2)
+ If IsArray($curtemperaturmatch) Then
+ If $curtemperaturmatch[0] <> "" Then
+ $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
+ EndIf
+ EndIf
+ EndIf
+ $oHTTP = 0
+EndFunc ;==>GetTemperature
+
+Func SetTemperature($temperature)
+ If IsInt($temperature) Then
+ If $temperature > 0 Then
+ $signum = "+"
+ Else
+ $signum = ""
+ EndIf
+ $temperature = $temperature * 100
+ $command = "SP@" & $signum & PadZeros($temperature,5);
+
+ $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
+ WITH $oHTTP
+ .Open("GET", "http://cerberus.x-matter.uni-frankfurt.de:8700/tools/cooling/cooling.pl?/dev/ttyUSB1&" & $command)
+ .Send()
+ $HTMLSource = .Responsetext
+ ENDWITH
+ If $HTMLSource <> "" Then
+ $sucess = StringRegExp ( $HTMLSource, "okay")
+ If $sucess Then
+ MsgBox(0, "ok", "Yes!")
+ Return 1
+ EndIf
+ EndIf
+ $oHTTP = 0
+ EndIf
+EndFunc ;==>SetTemperature
+
+
+; This is my custom error handler
+Func MyErrFunc()
+ ConsoleWrite('@@ (27) :(' & @MIN & ':' & @SEC & ') MyErrFunc()' & @CR) ;### Function Trace
+ $HexNumber=hex($oMyError.number,8)
+ ConsoleWrite("Intercepted a COM Error !" & @CRLF & _
+ "Number is: " & $HexNumber & @CRLF & _
+ "Windescription is: " & $oMyError.windescription)
+Endfunc
+
+
+Func PadZeros($theNumber, $max)
+ While StringLen($theNumber) < $max
+ $theNumber = "0" & $theNumber
+ WEnd
+ return $theNumber
+EndFunc
\ No newline at end of file