def __init__(self, node, shelf, watch_list, auto): msg.MessageObserver.__init__(self) self.__node = node self.__shelf = shelf self.__auto = auto if auto: node.subMessage(msg.MembershipChangedMessage()) for message in watch_list: debug('Listening for %s messages' % message) node.subMessage(getattr(msg, message + 'Message')()) self.attachOnMessageFunc(message) node.addObserver(self)
p_NodeStatus << p_int p_NodeStatus.setParseAction(lambda x: messaging.NodeStatus(x[0])) p_NodeInputStatus << p_int p_NodeInputStatus.setParseAction(lambda x: messaging.NodeInputStatus(x[0])) p_NodeIOStatus << p_int p_NodeIOStatus.setParseAction(lambda x: messaging.NodeIOStatus(x[0])) p_OutputType << p_int p_OutputType.setParseAction(lambda x: messaging.OutputType(x[0])) p_Controller << p_int p_Controller.setParseAction(lambda x: messaging.Controller(x[0])) # Parse Messages p_MembershipChangedMessage = pp.Group(l \ + p_str \ + r).streamline() p_MembershipChangedMessage.setParseAction(lambda x: messaging.MembershipChangedMessage(*x[0])) p_DebugMessage = pp.Group(l \ + p_DebugType + c \ + p_str \ + r).streamline() p_DebugMessage.setParseAction(lambda x: messaging.DebugMessage(*x[0])) p_DebugLevelMessage = pp.Group(l \ + p_int \ + r).streamline() p_DebugLevelMessage.setParseAction(lambda x: messaging.DebugLevelMessage(*x[0])) p_MotorMessage = pp.Group(l \ + p_MotorID + c \ + p_int \ + r).streamline() p_MotorMessage.setParseAction(lambda x: messaging.MotorMessage(*x[0])) p_BearingAutopilotEnabledMessage = pp.Group(l \
p_NodeInputStatus.setParseAction(lambda x: messaging.NodeInputStatus(x[0])) p_NodeIOStatus << p_int p_NodeIOStatus.setParseAction(lambda x: messaging.NodeIOStatus(x[0])) p_OutputType << p_int p_OutputType.setParseAction(lambda x: messaging.OutputType(x[0])) p_Controller << p_int p_Controller.setParseAction(lambda x: messaging.Controller(x[0])) p_InputSchedType << p_int p_InputSchedType.setParseAction(lambda x: messaging.InputSchedType(x[0])) # Parse Messages p_MembershipChangedMessage = pp.Group(l \ + p_str \ + r).streamline() p_MembershipChangedMessage.setParseAction( lambda x: messaging.MembershipChangedMessage(*x[0])) p_DebugMessage = pp.Group(l \ + p_DebugType + c \ + p_str \ + r).streamline() p_DebugMessage.setParseAction(lambda x: messaging.DebugMessage(*x[0])) p_DebugLevelMessage = pp.Group(l \ + p_int \ + r).streamline() p_DebugLevelMessage.setParseAction( lambda x: messaging.DebugLevelMessage(*x[0])) p_MotorMessage = pp.Group(l \ + p_MotorID + c \ + p_int \ + r).streamline() p_MotorMessage.setParseAction(lambda x: messaging.MotorMessage(*x[0]))