def __init__(self, node, environment): msg.MessageObserver.__init__(self) self.node = node self.env = environment self._position_lock = threading.Lock() self._position = None self._config_lock = threading.Lock() self._config = None node.addObserver(self) node.subMessage(msg.SimPositionMessage()) node.subMessage(msg.GeminiControlMessage())
p_CuttingDeviceMessage = pp.Group(l \ + p_int \ + r).streamline() p_CuttingDeviceMessage.setParseAction(lambda x: messaging.CuttingDeviceMessage(*x[0])) p_RedHerringBatteryStatusMessage = pp.Group(l \ + p_int \ + r).streamline() p_RedHerringBatteryStatusMessage.setParseAction(lambda x: messaging.RedHerringBatteryStatusMessage(*x[0])) p_SimPositionMessage = pp.Group(l \ + p_float + c \ + p_float + c \ + p_float + c \ + p_floatYPR + c \ + p_floatXYZ \ + r).streamline() p_SimPositionMessage.setParseAction(lambda x: messaging.SimPositionMessage(*x[0])) # Parse any Message def parseMessage(s): msgstart = s.find('(') msgid = int(s[:msgstart]) if msgid == 500: return p_MembershipChangedMessage.parseString(s[msgstart:])[0] elif msgid == 0: return p_DebugMessage.parseString(s[msgstart:])[0] elif msgid == 1: return p_DebugLevelMessage.parseString(s[msgstart:])[0] elif msgid == 2: return p_MotorMessage.parseString(s[msgstart:])[0] elif msgid == 60:
p_CuttingDeviceMessage.setParseAction( lambda x: messaging.CuttingDeviceMessage(*x[0])) p_RedHerringBatteryStatusMessage = pp.Group(l \ + p_int \ + r).streamline() p_RedHerringBatteryStatusMessage.setParseAction( lambda x: messaging.RedHerringBatteryStatusMessage(*x[0])) p_SimPositionMessage = pp.Group(l \ + p_float + c \ + p_float + c \ + p_float + c \ + p_floatYPR + c \ + p_floatXYZ \ + r).streamline() p_SimPositionMessage.setParseAction( lambda x: messaging.SimPositionMessage(*x[0])) # Parse any Message def parseMessage(s): msgstart = s.find('(') msgid = int(s[:msgstart]) if msgid == 500: return p_MembershipChangedMessage.parseString(s[msgstart:])[0] elif msgid == 0: return p_DebugMessage.parseString(s[msgstart:])[0] elif msgid == 1: return p_DebugLevelMessage.parseString(s[msgstart:])[0] elif msgid == 2: return p_MotorMessage.parseString(s[msgstart:])[0] elif msgid == 60: