Example #1
0
    def __init__(self,
                 name,
                 source_dict: dict,
                 parent=None,
                 children=None,
                 break_on_noncore_attribute=False):
        """Creates an VSS Node object from parsed yaml instance represented as a dict.

            Args:
                name: Name of this VSS instance.
                source_dict: VSS instance represented as dict from yaml parsing.
                parent: Optional parent of this node instance.
                children: Optional children instances of this node.

            Returns:
                VSSNode object according to the Vehicle Signal Specification.

        """

        super().__init__(name, parent, children)
        try:
            VSSNode.validate_vss_element(source_dict, name)
        except NonCoreAttributeException as e:
            print("Warning: {}".format(e))
            if break_on_noncore_attribute:
                print("You asked for strict checking. Terminating.")
                sys.exit(-1)

        self.description = source_dict["description"]
        self.type = VSSType.from_str(source_dict["type"])
        self.uuid = source_dict["uuid"]

        if "datatype" in source_dict.keys():
            self.data_type = VSSDataType.from_str(source_dict["datatype"])

        if "unit" in source_dict.keys():
            self.unit = Unit.from_str(source_dict["unit"])

        if "min" in source_dict.keys():
            self.min = source_dict["min"]

        if "max" in source_dict.keys():
            self.max = source_dict["max"]

        if "enum" in source_dict.keys():
            self.enum = source_dict["enum"]

        if "aggregate" in source_dict.keys():
            self.aggregate = source_dict["aggregate"]

        if "default" in source_dict.keys():
            self.default_value = source_dict["default"]

        if "instances" in source_dict.keys():
            self.instances = source_dict["instances"]

        if "deprecation" in source_dict.keys():
            self.deprecation = source_dict["deprecation"]
Example #2
0
    def __init__(self, name, source_dict: dict, parent=None, children=None):
        """Creates an VSS Node object from parsed yaml instance represented as a dict.

            Args:
                name: Name of this VSS instance.
                source_dict: VSS instance represented as dict from yaml parsing.
                parent: Optional parent of this node instance.
                children: Optional children instances of this node.

            Returns:
                VSSNode object according to the Vehicle Signal Specification.

        """

        super().__init__(name, parent, children)
        VSSNode.validate_vss_element(source_dict, name)
        self.description = source_dict["description"]
        self.type = VSSType.from_str(source_dict["type"])
        self.uuid = source_dict["uuid"]

        if "datatype" in source_dict.keys():
            self.data_type = VSSDataType.from_str(source_dict["datatype"])

        if "unit" in source_dict.keys():
            self.unit = Unit.from_str(source_dict["unit"])

        if "min" in source_dict.keys():
            self.min = source_dict["min"]

        if "max" in source_dict.keys():
            self.max = source_dict["max"]

        if "enum" in source_dict.keys():
            self.enum = source_dict["enum"]

        if "aggregate" in source_dict.keys():
            self.aggregate = source_dict["aggregate"]

        if "default" in source_dict.keys():
            self.default_value = source_dict["default"]

        if "value" in source_dict.keys():
            self.value = source_dict["value"]

        if "instances" in source_dict.keys():
            self.instances = source_dict["instances"]
Example #3
0
    def test_vss_data_types(self):
        """
        Test correct parsing of VSS Data Types
        """

        self.assertEqual(VSSDataType.INT8, VSSDataType.from_str("int8"))
        self.assertEqual(VSSDataType.UINT8, VSSDataType.from_str("uint8"))
        self.assertEqual(VSSDataType.INT16, VSSDataType.from_str("int16"))
        self.assertEqual(VSSDataType.UINT16, VSSDataType.from_str("uint16"))
        self.assertEqual(VSSDataType.INT32, VSSDataType.from_str("int32"))
        self.assertEqual(VSSDataType.UINT32, VSSDataType.from_str("uint32"))
        self.assertEqual(VSSDataType.INT64, VSSDataType.from_str("int64"))
        self.assertEqual(VSSDataType.UINT64, VSSDataType.from_str("uint64"))
        self.assertEqual(VSSDataType.BOOLEAN, VSSDataType.from_str("boolean"))
        self.assertEqual(VSSDataType.FLOAT, VSSDataType.from_str("float"))
        self.assertEqual(VSSDataType.DOUBLE, VSSDataType.from_str("double"))
        self.assertEqual(VSSDataType.STRING, VSSDataType.from_str("string"))
        self.assertEqual(VSSDataType.UNIX_TIMESTAMP, VSSDataType.from_str("UNIX Timestamp"))
Example #4
0
 def test_invalid_vss_data_types(self):
     with self.assertRaises(Exception): VSSDataType.from_str("not_a_valid_case")