Пример #1
0
def msg_master_from_sbs(data: sbs.Data) -> MsgMaster:
    """Convert SBS data to MsgMaster"""
    return MsgMaster(mid=data['mid'],
                     components=[
                         component_info_from_sbs(info)
                         for info in data['components']
                     ])
Пример #2
0
 def _process_msg_slave(self, conn, msg):
     slave_components = [
         common.component_info_from_sbs(i)
         for i in msg.data.data['components']
     ]
     slave_mid = self._connections[conn]
     self._update_global_on_local_components(slave_components, slave_mid)
Пример #3
0
 def _process_msg_master(self, msg_master):
     if (msg_master.data.module != 'HatMonitor'
             or msg_master.data.type != 'MsgMaster'):
         raise Exception('Message received from master malformed: '
                         'message MsgMaster from HatMonitor module '
                         'expected')
     self._mid = msg_master.data.data['mid']
     self._components = [
         common.component_info_from_sbs(i)
         for i in msg_master.data.data['components']
     ]
     self._change_cbs.notify()
Пример #4
0
 def _set_components(self, msg_server):
     if (msg_server.data.module != 'HatMonitor'
             or msg_server.data.type != 'MsgServer'):
         raise Exception('Message received from server malformed: message '
                         'MsgServer from HatMonitor module expected')
     self._components = [
         common.component_info_from_sbs(i)
         for i in msg_server.data.data['components']
     ]
     self._info = util.first(
         self._components, lambda i: i.cid == msg_server.data.data['cid']
         and i.mid == msg_server.data.data['mid'])
     self._change_cbs.notify()
Пример #5
0
def msg_slave_from_sbs(data: sbs.Data) -> MsgSlave:
    """Convert SBS data to MsgSlave"""
    return MsgSlave(components=[
        component_info_from_sbs(info) for info in data['components']
    ])