Skip to content

Commit

Permalink
Remove DataSpecificationPhysicalUnit (#137)
Browse files Browse the repository at this point in the history
As the DataSpecificationPhysicalUnit is not part of V3.0 it was removed from the SDK.
Fixes #136
  • Loading branch information
zrgt authored Oct 12, 2023
1 parent cb596a9 commit 35bc834
Show file tree
Hide file tree
Showing 16 changed files with 2 additions and 745 deletions.
72 changes: 0 additions & 72 deletions basyx/aas/adapter/json/aasJSONSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,77 +337,6 @@
}
]
},
"DataSpecificationPhysicalUnit": {
"allOf": [
{
"$ref": "#/definitions/DataSpecificationContent"
},
{
"properties": {
"unitName": {
"type": "string",
"minLength": 1
},
"unitSymbol": {
"type": "string",
"minLength": 1
},
"definition": {
"type": "array",
"items": {
"$ref": "#/definitions/LangStringDefinitionTypeIec61360"
},
"minItems": 1
},
"siNotation": {
"type": "string",
"minLength": 1
},
"siName": {
"type": "string",
"minLength": 1
},
"dinNotation": {
"type": "string",
"minLength": 1
},
"eceName": {
"type": "string",
"minLength": 1
},
"eceCode": {
"type": "string",
"minLength": 1
},
"nistName": {
"type": "string",
"minLength": 1
},
"sourceOfDefinition": {
"type": "string",
"minLength": 1
},
"conversionFactor": {
"type": "string",
"minLength": 1
},
"registrationAuthorityId": {
"type": "string",
"minLength": 1
},
"supplier": {
"type": "string",
"minLength": 1
}
},
"required": [
"unitName",
"unitSymbol",
"definition"
]
}
]
},
"DataTypeDefXsd": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -869,7 +798,6 @@
"Capability",
"ConceptDescription",
"DataSpecificationIEC61360",
"DataSpecificationPhysicalUnit",
"Entity",
"File",
"MultiLanguageProperty",
Expand Down
32 changes: 0 additions & 32 deletions basyx/aas/adapter/json/json_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ def object_hook(cls, dct: Dict[str, object]) -> object:
'Range': cls._construct_range,
'ReferenceElement': cls._construct_reference_element,
'DataSpecificationIEC61360': cls._construct_data_specification_iec61360,
'DataSpecificationPhysicalUnit': cls._construct_data_specification_physical_unit,
}

# Get modelType and constructor function
Expand Down Expand Up @@ -460,37 +459,6 @@ def _construct_concept_description(cls, dct: Dict[str, object], object_class=mod
ret.is_case_of.add(cls._construct_reference(case_data))
return ret

@classmethod
def _construct_data_specification_physical_unit(cls, dct: Dict[str, object],
object_class=model.base.DataSpecificationPhysicalUnit)\
-> model.base.DataSpecificationPhysicalUnit:
ret = object_class(
unit_name=_get_ts(dct, 'unitName', str),
unit_symbol=_get_ts(dct, 'unitSymbol', str),
definition=cls._construct_lang_string_set(_get_ts(dct, 'definition', list), model.DefinitionTypeIEC61360)
)
if 'siNotation' in dct:
ret.si_notation = _get_ts(dct, 'siNotation', str)
if 'siName' in dct:
ret.si_name = _get_ts(dct, 'siName', str)
if 'dinNotation' in dct:
ret.din_notation = _get_ts(dct, 'dinNotation', str)
if 'eceName' in dct:
ret.ece_name = _get_ts(dct, 'eceName', str)
if 'eceCode' in dct:
ret.ece_code = _get_ts(dct, 'eceCode', str)
if 'nistName' in dct:
ret.nist_name = _get_ts(dct, 'nistName', str)
if 'sourceOfDefinition' in dct:
ret.source_of_definition = _get_ts(dct, 'sourceOfDefinition', str)
if 'conversionFactor' in dct:
ret.conversion_factor = _get_ts(dct, 'conversionFactor', str)
if 'registrationAuthorityId' in dct:
ret.registration_authority_id = _get_ts(dct, 'registrationAuthorityId', str)
if 'supplier' in dct:
ret.supplier = _get_ts(dct, 'supplier', str)
return ret

@classmethod
def _construct_data_specification_iec61360(cls, dct: Dict[str, object],
object_class=model.base.DataSpecificationIEC61360)\
Expand Down
38 changes: 0 additions & 38 deletions basyx/aas/adapter/json/json_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def default(self, obj: object) -> object:
model.Capability: self._capability_to_json,
model.ConceptDescription: self._concept_description_to_json,
model.DataSpecificationIEC61360: self._data_specification_iec61360_to_json,
model.DataSpecificationPhysicalUnit: self._data_specification_physical_unit_to_json,
model.Entity: self._entity_to_json,
model.Extension: self._extension_to_json,
model.File: self._file_to_json,
Expand Down Expand Up @@ -367,43 +366,6 @@ def _data_specification_iec61360_to_json(
data_spec['levelType'] = {v: k in obj.level_types for k, v in _generic.IEC61360_LEVEL_TYPES.items()}
return data_spec

@classmethod
def _data_specification_physical_unit_to_json(
cls, obj: model.base.DataSpecificationPhysicalUnit) -> Dict[str, object]:
"""
serialization of an object from class DataSpecificationPhysicalUnit to json
:param obj: object of class DataSpecificationPhysicalUnit
:return: dict with the serialized attributes of this object
"""
data_spec: Dict[str, object] = {
'modelType': 'DataSpecificationPhysicalUnit',
'unitName': obj.unit_name,
'unitSymbol': obj.unit_symbol,
'definition': obj.definition
}
if obj.si_notation is not None:
data_spec['siNotation'] = obj.si_notation
if obj.si_name is not None:
data_spec['siName'] = obj.si_name
if obj.din_notation is not None:
data_spec['dinNotation'] = obj.din_notation
if obj.ece_name is not None:
data_spec['eceName'] = obj.ece_name
if obj.ece_code is not None:
data_spec['eceCode'] = obj.ece_code
if obj.nist_name is not None:
data_spec['nistName'] = obj.nist_name
if obj.source_of_definition is not None:
data_spec['sourceOfDefinition'] = obj.source_of_definition
if obj.conversion_factor is not None:
data_spec['conversionFactor'] = obj.conversion_factor
if obj.registration_authority_id is not None:
data_spec['registrationAuthorityId'] = obj.registration_authority_id
if obj.supplier is not None:
data_spec['supplier'] = obj.supplier
return data_spec

@classmethod
def _asset_administration_shell_to_json(cls, obj: model.AssetAdministrationShell) -> Dict[str, object]:
"""
Expand Down
102 changes: 0 additions & 102 deletions basyx/aas/adapter/xml/AAS.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@
<xs:group name="dataSpecificationContent_choice">
<xs:choice>
<xs:element name="dataSpecificationIec61360" type="dataSpecificationIec61360_t"/>
<xs:element name="dataSpecificationPhysicalUnit" type="dataSpecificationPhysicalUnit_t"/>
</xs:choice>
</xs:group>
<xs:group name="dataSpecificationIec61360">
Expand Down Expand Up @@ -254,102 +253,6 @@
<xs:element name="levelType" type="levelType_t" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:group>
<xs:group name="dataSpecificationPhysicalUnit">
<xs:sequence>
<xs:group ref="dataSpecificationContent"/>
<xs:element name="unitName">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="unitSymbol">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="definition">
<xs:complexType>
<xs:sequence>
<xs:element name="langStringDefinitionTypeIec61360" type="langStringDefinitionTypeIec61360_t" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="siNotation" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="siName" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="dinNotation" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="eceName" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="eceCode" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nistName" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="sourceOfDefinition" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="conversionFactor" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="registrationAuthorityId" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="supplier" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:group>
<xs:group name="embeddedDataSpecification">
<xs:sequence>
<xs:element name="dataSpecification" type="reference_t"/>
Expand Down Expand Up @@ -1226,11 +1129,6 @@
<xs:group ref="dataSpecificationIec61360"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="dataSpecificationPhysicalUnit_t">
<xs:sequence>
<xs:group ref="dataSpecificationPhysicalUnit"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="embeddedDataSpecification_t">
<xs:sequence>
<xs:group ref="embeddedDataSpecification"/>
Expand Down
45 changes: 0 additions & 45 deletions basyx/aas/adapter/xml/xml_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,53 +1093,11 @@ def construct_data_specification_content(cls, element: etree.Element, **kwargs:
data_specification_contents: Dict[str, Callable[..., model.DataSpecificationContent]] = \
{NS_AAS + k: v for k, v in {
"dataSpecificationIec61360": cls.construct_data_specification_iec61360,
"dataSpecificationPhysicalUnit": cls.construct_data_specification_physical_unit,
}.items()}
if element.tag not in data_specification_contents:
raise KeyError(f"{_element_pretty_identifier(element)} is not a valid DataSpecificationContent!")
return data_specification_contents[element.tag](element, **kwargs)

@classmethod
def construct_data_specification_physical_unit(cls, element: etree.Element,
object_class=model.DataSpecificationPhysicalUnit, **_kwargs: Any) \
-> model.DataSpecificationPhysicalUnit:
dspu = object_class(_child_text_mandatory(element, NS_AAS + "unitName"),
_child_text_mandatory(element, NS_AAS + "unitSymbol"),
_child_construct_mandatory(element, NS_AAS + "definition",
cls.construct_definition_type_iec61360))
si_notation = _get_text_or_none(element.find(NS_AAS + "siNotation"))
if si_notation is not None:
dspu.si_notation = si_notation
si_name = _get_text_or_none(element.find(NS_AAS + "siName"))
if si_name is not None:
dspu.si_name = si_name
din_notation = _get_text_or_none(element.find(NS_AAS + "dinNotation"))
if din_notation is not None:
dspu.din_notation = din_notation
ece_name = _get_text_or_none(element.find(NS_AAS + "eceName"))
if ece_name is not None:
dspu.ece_name = ece_name
ece_code = _get_text_or_none(element.find(NS_AAS + "eceCode"))
if ece_code is not None:
dspu.ece_code = ece_code
nist_name = _get_text_or_none(element.find(NS_AAS + "nistName"))
if nist_name is not None:
dspu.nist_name = nist_name
source_of_definition = _get_text_or_none(element.find(NS_AAS + "sourceOfDefinition"))
if source_of_definition is not None:
dspu.source_of_definition = source_of_definition
conversion_factor = _get_text_or_none(element.find(NS_AAS + "conversionFactor"))
if conversion_factor is not None:
dspu.conversion_factor = conversion_factor
registration_authority_id = _get_text_or_none(element.find(NS_AAS + "registrationAuthorityId"))
if registration_authority_id is not None:
dspu.registration_authority_id = registration_authority_id
supplier = _get_text_or_none(element.find(NS_AAS + "supplier"))
if supplier is not None:
dspu.supplier = supplier
cls._amend_abstract_attributes(dspu, element)
return dspu

@classmethod
def construct_data_specification_iec61360(cls, element: etree.Element, object_class=model.DataSpecificationIEC61360,
**_kwargs: Any) -> model.DataSpecificationIEC61360:
Expand Down Expand Up @@ -1319,7 +1277,6 @@ class XMLConstructables(enum.Enum):
EMBEDDED_DATA_SPECIFICATION = enum.auto()
DATA_SPECIFICATION_CONTENT = enum.auto()
DATA_SPECIFICATION_IEC61360 = enum.auto()
DATA_SPECIFICATION_PHYSICAL_UNIT = enum.auto()


def read_aas_xml_element(file: IO, construct: XMLConstructables, failsafe: bool = True, stripped: bool = False,
Expand Down Expand Up @@ -1415,8 +1372,6 @@ def read_aas_xml_element(file: IO, construct: XMLConstructables, failsafe: bool
constructor = decoder_.construct_embedded_data_specification
elif construct == XMLConstructables.DATA_SPECIFICATION_IEC61360:
constructor = decoder_.construct_data_specification_iec61360
elif construct == XMLConstructables.DATA_SPECIFICATION_PHYSICAL_UNIT:
constructor = decoder_.construct_data_specification_physical_unit
# the following constructors decide which constructor to call based on the elements tag
elif construct == XMLConstructables.DATA_ELEMENT:
constructor = decoder_.construct_data_element
Expand Down
Loading

0 comments on commit 35bc834

Please sign in to comment.