Added stat command to find last measurement/forecast times

This commit is contained in:
2024-09-21 10:48:34 +02:00
parent ef778c3e0a
commit 0c07dcfd66
3 changed files with 45 additions and 6 deletions

View File

@@ -13,6 +13,12 @@ Implements the following commands:
CMD> TI LMW
ANS< ! 20-JAN-01 00:00:00
CMD> WN LMW,DUMMY,H10,STAT
ANS< ! 20-JAN-01 00:00
CMD> VW LMW,DUMMY,H10V,STAT
ANS< ! 20-JAN-01 00:00;20-JAN-01 01:00
CMD> WN LMW,DUMMY,H10,+HH:MM,yyyy-mm-dd,HH:MM,DATA
ANS< ! 1/10,;2/10;....
@@ -48,7 +54,7 @@ logoutcount=0
class sipProtocol(socketserver.BaseRequestHandler):
def match(self, m):
return(self.data.find(m.encode()) == 0)
return(self.data.find(m.encode()) != -1)
def send(self, a):
a = "%s\r" % a
@@ -86,12 +92,19 @@ class sipProtocol(socketserver.BaseRequestHandler):
global logoutcount
self.read()
while self.data:
if self.match("LI USER,PASS"):
if self.match("CLOSE"):
self.request.close()
elif self.match("LI USER,PASS"):
self.send("!")
elif self.match("TI LMW"):
self.send("! 20-JAN-01 00:00:00")
elif self.match("WN LMW,DUMMY,H10,"):
self.meting(10)
if self.match("STAT"):
self.send("! 20-JAN-01 00:00")
else:
self.meting(10)
elif self.match("VW LMW,DUMMY,H10V,STAT"):
self.send("! 20-JAN-01 00:00;20-JAN-01 01:00")
elif self.match("WN LMW,DUMMY,H1,"):
self.meting(1)
elif self.match("LOGOUTCOUNT"):
@@ -99,8 +112,6 @@ class sipProtocol(socketserver.BaseRequestHandler):
elif self.match("LO"):
logoutcount+=1
self.send("!")
elif self.match("CLOSE"):
self.request.close()
else:
self.send("? ERROR")
self.read()