Ejemplo n.º 1
0
    def load_item_from_xml(self, xml_tag: ET.Element,
                           message_types) -> SimulatorItem:
        if xml_tag.tag == "simulator_message":
            item = SimulatorMessage.new_from_xml(
                xml_tag, self.participants, self.project_manager.decodings,
                message_types)
        elif xml_tag.tag == "simulator_label":
            item = SimulatorProtocolLabel.from_xml(
                xml_tag, self.project_manager.field_types_by_caption)
        elif xml_tag.tag == "simulator_trigger_command_action":
            item = SimulatorTriggerCommandAction.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_sleep_action":
            item = SimulatorSleepAction.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_counter_action":
            item = SimulatorCounterAction.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_rule":
            item = SimulatorRule.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_rule_condition":
            item = SimulatorRuleCondition.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_goto_action":
            item = SimulatorGotoAction.from_xml(xml_tag)
        elif xml_tag.tag in ("message", "label", "checksum_label"):
            return None
        else:
            raise ValueError("Unknown simulator item tag: {}".format(
                xml_tag.tag))

        for child_tag in xml_tag:
            child = self.load_item_from_xml(child_tag, message_types)
            if child is not None:
                item.add_child(child)

        return item
Ejemplo n.º 2
0
    def load_item_from_xml(self, xml_tag: ET.Element, message_types) -> SimulatorItem:
        if xml_tag.tag == "simulator_message":
            item = SimulatorMessage.new_from_xml(xml_tag, self.participants, self.project_manager.decodings,
                                                 message_types)
        elif xml_tag.tag == "simulator_label":
            item = SimulatorProtocolLabel.from_xml(xml_tag, self.project_manager.field_types_by_caption)
        elif xml_tag.tag == "simulator_trigger_command_action":
            item = SimulatorTriggerCommandAction.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_sleep_action":
            item = SimulatorSleepAction.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_counter_action":
            item = SimulatorCounterAction.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_rule":
            item = SimulatorRule.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_rule_condition":
            item = SimulatorRuleCondition.from_xml(xml_tag)
        elif xml_tag.tag == "simulator_goto_action":
            item = SimulatorGotoAction.from_xml(xml_tag)
        elif xml_tag.tag in ("message", "label", "checksum_label"):
            return None
        else:
            raise ValueError("Unknown simulator item tag: {}".format(xml_tag.tag))

        for child_tag in xml_tag:
            child = self.load_item_from_xml(child_tag, message_types)
            if child is not None:
                item.add_child(child)

        return item
Ejemplo n.º 3
0
    def update_goto_combobox(self):
        goto_combobox = self.ui.goto_combobox

        goto_combobox.blockSignals(True)
        goto_combobox.clear()
        goto_combobox.addItem("Select item ...")
        goto_combobox.addItems(SimulatorGotoAction.goto_identifier())
        goto_combobox.setCurrentIndex(-1)
        goto_combobox.blockSignals(False)

        index = goto_combobox.findText(self.active_item.goto_target)

        if index == -1:
            index = 0

        goto_combobox.setCurrentIndex(index)
Ejemplo n.º 4
0
    def update_goto_combobox(self, active_item: SimulatorGotoAction):
        assert isinstance(active_item, SimulatorGotoAction)
        goto_combobox = self.ui.goto_combobox

        goto_combobox.blockSignals(True)
        goto_combobox.clear()
        goto_combobox.addItem("Select item ...")
        goto_combobox.addItems(active_item.get_valid_goto_targets())
        goto_combobox.setCurrentIndex(-1)
        goto_combobox.blockSignals(False)

        index = goto_combobox.findText(self.active_item.goto_target)

        if index == -1:
            index = 0

        goto_combobox.setCurrentIndex(index)
Ejemplo n.º 5
0
    def update_goto_combobox(self, active_item: SimulatorGotoAction):
        assert isinstance(active_item, SimulatorGotoAction)
        goto_combobox = self.ui.goto_combobox

        goto_combobox.blockSignals(True)
        goto_combobox.clear()
        goto_combobox.addItem("Select item ...")
        goto_combobox.addItems(active_item.get_valid_goto_targets())
        goto_combobox.setCurrentIndex(-1)
        goto_combobox.blockSignals(False)

        index = goto_combobox.findText(self.active_item.goto_target)

        if index == -1:
            index = 0

        goto_combobox.setCurrentIndex(index)
Ejemplo n.º 6
0
 def add_goto_action(self, ref_item, position):
     goto_action = SimulatorGotoAction()
     pos, parent = self.insert_at(ref_item, position, False)
     self.simulator_config.add_items([goto_action], pos, parent)
     return goto_action