status report command introduced
authorConstantin Berhard <constantin@exxxtremesys.lu>
Wed, 19 Feb 2014 22:41:34 +0000 (23:41 +0100)
committerConstantin Berhard <constantin@exxxtremesys.lu>
Wed, 19 Feb 2014 22:41:34 +0000 (23:41 +0100)
checking pin states is yet to implement

statemachine.py
tyshell
tysock.py

index e6a27570c45c2731607d95c3f0d9646ff45024db..dd9dc542bbe51524c24978bc5263bade5b1650de 100644 (file)
@@ -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 70ad6df0746316232e8f15a72dead40663215573..b535f2b9eef3d47b4938aa964c8e0041b8528ebb 100755 (executable)
--- 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',
index 2a5e193ad1ab71b967dc8b375647235eababb36b..b987567168bd9ca93a23e3ff0252b76a3f0d9c2d 100644 (file)
--- 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):