def from_xml(self, tag: ET.Element, participants, decoders=None, message_types=None): timestamp = tag.get("timestamp", None) if timestamp: self.timestamp = float(timestamp) part_id = tag.get("participant_id", None) message_type_id = tag.get("message_type_id", None) self.modulator_index = int(tag.get("modulator_index", self.modulator_index)) self.pause = int(tag.get("pause", self.pause)) decoding_index = tag.get("decoding_index", None) if decoding_index and decoders is not None: try: self.decoder = decoders[int(decoding_index)] except IndexError: pass if part_id: self.participant = Participant.find_matching(part_id, participants) if self.participant is None: logger.warning("No participant matched the id {0} from xml".format(part_id)) if message_type_id and message_types: for message_type in message_types: if message_type.id == message_type_id: self.message_type = message_type break message_type_tag = tag.find("message_type") if message_type_tag: self.message_type = MessageType.from_xml(message_type_tag)
def new_from_xml(cls, tag: ET.Element, participants, decoders=None, message_types=None): msg = Message.new_from_xml(tag.find("message"), participants=participants, decoders=decoders, message_types=message_types) destination = Participant.find_matching(tag.get("destination_id", ""), participants) return SimulatorMessage(destination, msg.plain_bits, msg.pause, msg.message_type, msg.decoder, msg.participant, timestamp=msg.timestamp)
def from_xml(self, tag: ET.Element, participants, decoders=None, message_types=None): super().from_xml(tag, participants, decoders, message_types) self.destination = Participant.find_matching( tag.get("destination_id", ""), participants) self.repeat = Formatter.str2val(tag.get("repeat", "1"), int, 1)
def from_xml(self, tag: ET.Element, participants, decoders=None, message_types=None): super().from_xml(tag, participants, decoders, message_types) self.destination = Participant.find_matching(tag.get("destination_id", ""), participants) self.repeat = Formatter.str2val(tag.get("repeat", "1"), int, 1)