def __get_msg(self): msg = InterfaceState() msg.is_diff = True msg.interface_id = self.interface_id msg.items.append(InterfaceStateItem()) return msg
def __publish_state(self): msg = InterfaceState() msg.is_diff = False msg.interface_id = self.interface_id sys_state = InterfaceStateItem() sys_state.type = self.state.current_syst_state if self.state.current_syst_state in [InterfaceStateItem.STATE_LEARNING, InterfaceStateItem.STATE_PROGRAM_STOPPED, InterfaceStateItem.STATE_PROGRAM_RUNNING]: sys_state.idata.append(self.state.program_id) sys_state.idata.append(self.state.instruction_id) elif self.state.current_syst_state == InterfaceStateItem.STATE_PROGRAM_FINISHED: sys_state.idata.append(self.state.program_id) msg.items.append(sys_state) for obj_id in self.state.selected_object_ids: tmp = InterfaceStateItem() tmp.type = InterfaceStateItem.SELECTED_OBJECT_ID tmp.data.append(obj_id) msg.items.append(tmp) for obj_type in self.state.selected_object_types: tmp = InterfaceStateItem() tmp.type = InterfaceStateItem.SELECTED_OBJECT_TYPE tmp.data.append(obj_type) msg.items.append(tmp) for place in self.state.selected_places: tmp = InterfaceStateItem() tmp.type = InterfaceStateItem.SELECTED_PLACE tmp.place = place msg.items.append(tmp) for polygon in self.state.polygons: tmp = InterfaceStateItem() tmp.type = InterfaceStateItem.POLYGON tmp.polygon = polygon msg.items.append(tmp) self.interface_state_pub.publish(msg)