Пример #1
0
    def from_xml(tag: ET.Element):
        field_types_by_caption = {
            ft.caption: ft
            for ft in FieldType.load_from_xml()
        }

        name = tag.get("name", "blank")
        id = tag.get("id", None)
        assigned_by_ruleset = bool(int(tag.get("assigned_by_ruleset", 0)))
        assigned_by_logic_analyzer = bool(
            int(tag.get("assigned_by_logic_analyzer", 0)))
        labels = []
        for lbl_tag in tag.findall("label"):
            labels.append(
                ProtocolLabel.from_xml(
                    lbl_tag, field_types_by_caption=field_types_by_caption))
        for lbl_tag in tag.findall("checksum_label"):
            labels.append(
                ChecksumLabel.from_xml(
                    lbl_tag, field_types_by_caption=field_types_by_caption))
        result = MessageType(name=name,
                             iterable=labels,
                             id=id,
                             ruleset=Ruleset.from_xml(tag.find("ruleset")))
        result.assigned_by_ruleset = assigned_by_ruleset
        result.assigned_by_logic_analyzer = assigned_by_logic_analyzer

        return result
Пример #2
0
    def from_xml(tag: ET.Element):
        field_types_by_caption = {ft.caption: ft for ft in FieldType.load_from_xml()}

        name = tag.get("name", "blank")
        id = tag.get("id", None)
        assigned_by_ruleset = bool(int(tag.get("assigned_by_ruleset", 0)))
        assigned_by_logic_analyzer = bool(int(tag.get("assigned_by_logic_analyzer", 0)))
        labels = []
        for lbl_tag in tag.findall("label"):
            labels.append(ProtocolLabel.from_xml(lbl_tag, field_types_by_caption=field_types_by_caption))
        for lbl_tag in tag.findall("checksum_label"):
            labels.append(ChecksumLabel.from_xml(lbl_tag, field_types_by_caption=field_types_by_caption))
        result = MessageType(name=name, iterable=labels, id=id, ruleset=Ruleset.from_xml(tag.find("ruleset")))
        result.assigned_by_ruleset = assigned_by_ruleset
        result.assigned_by_logic_analyzer = assigned_by_logic_analyzer

        return result
Пример #3
0
    def from_xml(cls, tag: ET.Element, field_types_by_caption=None):
        """

        :param tag:
        :type field_types_by_caption: dict[str, FieldType]
        :return:
        """
        label_tag = tag.find("label")
        if label_tag is not None:
            label = ProtocolLabel.from_xml(label_tag, field_types_by_caption)
        else:
            label = ChecksumLabel.from_xml(tag.find("checksum_label"), field_types_by_caption)
        result = SimulatorProtocolLabel(label)
        result.value_type_index = Formatter.str2val(tag.get("value_type_index", "0"), int)
        result.external_program = tag.get("external_program", "")
        result.formula = tag.get("formula", "")
        result.random_min = Formatter.str2val(tag.get("random_min", "0"), int)
        result.random_max = Formatter.str2val(tag.get("random_max", str(label.fuzz_maximum-1)), int)
        return result
Пример #4
0
    def from_xml(cls, tag: ET.Element, field_types_by_caption=None):
        """

        :param tag:
        :type field_types_by_caption: dict[str, FieldType]
        :return:
        """
        label_tag = tag.find("label")
        if label_tag is not None:
            label = ProtocolLabel.from_xml(label_tag, field_types_by_caption)
        else:
            label = ChecksumLabel.from_xml(tag.find("checksum_label"),
                                           field_types_by_caption)
        result = SimulatorProtocolLabel(label)
        result.value_type_index = Formatter.str2val(
            tag.get("value_type_index", "0"), int)
        result.external_program = tag.get("external_program", "")
        result.formula = tag.get("formula", "")
        result.random_min = Formatter.str2val(tag.get("random_min", "0"), int)
        result.random_max = Formatter.str2val(
            tag.get("random_max", str(label.fuzz_maximum - 1)), int)
        return result