From: Constantin Berhard Date: Wed, 19 Feb 2014 22:41:34 +0000 (+0100) Subject: status report command introduced X-Git-Url: https://git.ralfj.de/saartuer.git/commitdiff_plain/73cd08c855a77bc0df90d6e94f6d75d42d6f5e5e?ds=inline status report command introduced checking pin states is yet to implement --- diff --git a/statemachine.py b/statemachine.py index e6a2757..dd9dc54 100644 --- a/statemachine.py +++ b/statemachine.py @@ -86,6 +86,7 @@ class StateMachine(): CMD_LOCK = 5 CMD_FALLBACK_ON = 6 CMD_FALLBACK_OFF = 7 + CMD_STATUS = 8 class State(): def __init__(self, state_machine, nervlist = None): @@ -110,6 +111,9 @@ class StateMachine(): return StateMachine.StateFallback(self.state_machine) def handle_cmd_fallback_off_event(self,arg): arg("412 Precondition Failed: Not in fallback mode!") + def handle_cmd_status_event(self,arg): + # TODO use a proper JSON lib + arg('200 okay: {state:\"%s\"}' % self.__class__.__name__) def on_leave(self): pass def pins(self): @@ -135,6 +139,8 @@ class StateMachine(): return self.handle_cmd_fallback_on_event(arg) elif ev == StateMachine.CMD_FALLBACK_OFF: return self.handle_cmd_fallback_off_event(arg) + elif ev == StateMachine.CMD_STATUS: + return self.handle_cmd_status_event(arg) else: raise Exception("Unknown command number: %d" % ev) diff --git a/tyshell b/tyshell index 70ad6df..b535f2b 100755 --- a/tyshell +++ b/tyshell @@ -86,6 +86,7 @@ commands = alias({ 'who': CmdEntry(whocmd, 'Shows the list of people, who are allowed to control this system'), 'fallback_mode_on': CmdEntry(prompt_sure(sendcmd(tuerSock, 'fallback_mode_on'),'WARNING: This action will be reported to the admins. Use this only in case of Sphinx hardware failure when you need to ignore erroneous sensor input!'), 'Sets the system in a state where it is less dependent on sensoric input. Use it only when sensors are broken.'), 'fallback_mode_off': CmdEntry(prompt_sure(sendcmd(tuerSock, 'fallback_mode_off'),'WARNING: This action will be reported to the admins. Use this only if you have fixed the sensors of the Sphinx or activated fallback mode by accident!'), 'Resets the system to the default state. Use this when you have just repaired the sensors of the Sphinx.'), + 'status': CmdEntry(sendcmd(tuerSock, 'status'), 'Shows internal state and sensor information.'), },{ # aliases 'open': 'unlock', diff --git a/tysock.py b/tysock.py index 2a5e193..b987567 100644 --- a/tysock.py +++ b/tysock.py @@ -30,6 +30,7 @@ class TySocket(): b'lock': StateMachine.CMD_LOCK, b'fallback_mode_on': StateMachine.CMD_FALLBACK_ON, b'fallback_mode_off': StateMachine.CMD_FALLBACK_OFF, + b'status': StateMachine.CMD_STATUS, } def __init__(self, sm):