Commit initial

This commit is contained in:
2020-05-15 12:27:34 +02:00
commit 70f72f2e54
87 changed files with 12684 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import time
from CameraModel import CameraModel
from WaitState import WaitState
from WaitActivity import WaitActivity
class WaitDisabledModeReply(WaitState):
def __init__(self, userCommand):
self.userCommand = userCommand
self.initTime = time.time()
def handle(self, context):
data = self.waitMsg(context)
if not data:
if self.userCommand:
self.userCommand.callback(False, "connection_lost")
return
if data == "disabled":
print("[WaitDisabledModeReply] : Camera ({}) at {}:{} successfully disabled".format(context.camera.id, context.connection.addr, context.connection.port))
context.camera.enabled = False
mdl = CameraModel()
mdl.update(context.camera)
context.state = WaitActivity()
if self.userCommand:
self.userCommand.callback(True)
else:
print("[WaitDisabledModeReply] : Error({}) from camera ({}) at {}:{}".format(data, context.camera.id, context.connection.addr, context.connection.port))
context.close()
if self.userCommand:
self.userCommand.callback(False, data)
def tic(self, context):
if time.time() - self.initTime > 10:
print("[WaitDisabledModeReply] : Timeout exeeded for camera ({}) at {}:{}".format(context.camera.id, context.connection.addr, context.connection.port))
context.close()
if self.userCommand:
self.userCommand.callback(False, "timeout")