Skip to content

Commit

Permalink
model: Adapt constructor of class Key
Browse files Browse the repository at this point in the history
We adapt the changes in the specification for class `Key`:

- Rename `model.KeyElements` to `model.KeyTypes` as defined for 
  V3.0RC02 and V3.0. Adapted to new constructor of `model.Key`
- `test.model`: Change Indices of `model.ModelReference` in 
  `test_base.test_resolve()`
-  Change all occurrences of value in `model.Key()` from 
  `abc` to `model.Identifier(abc)`
- V3.0 changed type of `model.Key.value` from `str` to `Identifier`
- Change type of `Key.value` from str to `Identifier`
- Delete unnecessary length check in constructor of `base.Key` 
  because `model.Identifier` checks length constrains
- Change __str__() in `base.Key` to fit the new type of `Key.value`

---------

Co-authored-by: David Niebert <d.niebert@plt.rwth-aachen.de>
Co-authored-by: s-heppner <s.heppner@plt.rwth-aachen.de>
  • Loading branch information
3 people committed Jun 20, 2023
1 parent 1445bdd commit 0136081
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 44 deletions.
50 changes: 29 additions & 21 deletions basyx/aas/examples/data/example_aas.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

_embedded_data_specification_iec61360 = model.EmbeddedDataSpecification(
data_specification=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='https://admin-shell.io/DataSpecificationTemplates/'
'DataSpecificationIEC61360/3/0'),)),
value=model.Identifier('https://admin-shell.io/'
'DataSpecificationTemplates/'
'DataSpecificationIEC61360/3/0')),)),
data_specification_content=model.DataSpecificationIEC61360(preferred_name=model.LangStringSet({
'de': 'Test Specification',
'en-US': 'TestSpecification'
Expand All @@ -32,26 +33,29 @@
'en-US': 'This is a DataSpecification for testing purposes'}),
short_name=model.LangStringSet({'de': 'Test Spec', 'en-US': 'TestSpec'}), unit='SpaceUnit',
unit_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/Units/SpaceUnit'),)),
value=model.Identifier('http://acplt.org/Units/SpaceUnit')),)),
source_of_definition='http://acplt.org/DataSpec/ExampleDef', symbol='SU', value_format=model.datatypes.String,
value_list={
model.ValueReferencePair(
value_type=model.datatypes.String,
value='exampleValue',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)), ),
value=model.Identifier('http://acplt.org/ValueId/'
'ExampleValueId')),)), ),
model.ValueReferencePair(
value_type=model.datatypes.String,
value='exampleValue2',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId2'),)), )},
value=model.Identifier('http://acplt.org/ValueId/'
'ExampleValueId2')),)), )},
value="TEST", level_types={model.IEC61360LevelType.MIN, model.IEC61360LevelType.MAX})
)

_embedded_data_specification_physical_unit = model.EmbeddedDataSpecification(
data_specification=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='https://admin-shell.io/DataSpecificationTemplates/'
'DataSpecificationPhysicalUnit/3/0'),)),
value=model.Identifier('https://admin-shell.io/'
'DataSpecificationTemplates/'
'DataSpecificationPhysicalUnit/3/0')),)),
data_specification_content=model.DataSpecificationPhysicalUnit(
unit_name='TestPhysicalUnit',
unit_symbol='TPU',
Expand Down Expand Up @@ -102,31 +106,32 @@ def create_example_asset_identification_submodel() -> model.Submodel:
value_type=model.datatypes.Int,
value=100,
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
kind=model.QualifierKind.CONCEPT_QUALIFIER)

qualifier2 = model.Qualifier(
type_='http://acplt.org/Qualifier/ExampleQualifier2',
value_type=model.datatypes.Int,
value=50,
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
kind=model.QualifierKind.TEMPLATE_QUALIFIER)

qualifier3 = model.Qualifier(
type_='http://acplt.org/Qualifier/ExampleQualifier3',
value_type=model.datatypes.DateTime,
value=model.datatypes.DateTime(2023, 4, 7, 16, 59, 54, 870123),
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
kind=model.QualifierKind.VALUE_QUALIFIER)

extension = model.Extension(
name='ExampleExtension',
value_type=model.datatypes.String,
value="ExampleExtensionValue",
refers_to=(model.ModelReference((model.Key(type_=model.KeyTypes.ASSET_ADMINISTRATION_SHELL,
value='http://acplt.org/RefersTo/ExampleRefersTo'),),
value=model.Identifier('http://acplt.org/RefersTo/'
'ExampleRefersTo')),),
model.AssetAdministrationShell),))

# Property-Element conform to 'Verwaltungssschale in der Praxis' page 41 ManufacturerName:
Expand All @@ -136,7 +141,7 @@ def create_example_asset_identification_submodel() -> model.Submodel:
value_type=model.datatypes.String,
value='ACPLT',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
category="PARAMETER",
description=model.LangStringSet({'en-US': 'Legally valid designation of the natural or judicial person which '
'is directly responsible for the design, production, packaging and '
Expand All @@ -163,7 +168,7 @@ def create_example_asset_identification_submodel() -> model.Submodel:
value_type=model.datatypes.String,
value='978-8234-234-342',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
category="PARAMETER",
description=model.LangStringSet({'en-US': 'Legally valid designation of the natural or judicial person which '
'is directly responsible for the design, production, packaging and '
Expand Down Expand Up @@ -220,7 +225,7 @@ def create_example_bill_of_material_submodel() -> model.Submodel:
value_type=model.datatypes.String,
value='exampleValue',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
category='CONSTANT',
description=model.LangStringSet({'en-US': 'Example Property object',
'de': 'Beispiel Property Element'}),
Expand All @@ -239,7 +244,7 @@ def create_example_bill_of_material_submodel() -> model.Submodel:
value_type=model.datatypes.String,
value='exampleValue2',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
category='CONSTANT',
description=model.LangStringSet({'en-US': 'Example Property object',
'de': 'Beispiel Property Element'}),
Expand Down Expand Up @@ -346,7 +351,7 @@ def create_example_submodel() -> model.Submodel:
value_type=model.datatypes.String,
value='exampleValue',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
display_name=model.LangStringSet({'en-US': 'ExampleProperty',
'de': 'BeispielProperty'}),
category='CONSTANT',
Expand All @@ -371,7 +376,7 @@ def create_example_submodel() -> model.Submodel:
value_type=model.datatypes.String,
value='exampleValue',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
display_name=model.LangStringSet({'en-US': 'ExampleProperty',
'de': 'BeispielProperty'}),
category='CONSTANT',
Expand Down Expand Up @@ -539,11 +544,13 @@ def create_example_submodel() -> model.Submodel:

submodel_element_annotated_relationship_element = model.AnnotatedRelationshipElement(
id_short='ExampleAnnotatedRelationshipElement',
first=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value='http://acplt.org/Test_Submodel'),
first=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value=model.Identifier('http://acplt.org/'
'Test_Submodel')),
model.Key(type_=model.KeyTypes.PROPERTY,
value='ExampleProperty'),),
model.Property),
second=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value='http://acplt.org/Test_Submodel'),
second=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value=model.Identifier('http://acplt.org/'
'Test_Submodel')),
model.Key(type_=model.KeyTypes.PROPERTY,
value='ExampleProperty2'),),
model.Property),
Expand Down Expand Up @@ -578,7 +585,7 @@ def create_example_submodel() -> model.Submodel:
value_type=model.datatypes.String,
value='exampleValue',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
display_name=model.LangStringSet({'en-US': 'ExampleProperty',
'de': 'BeispielProperty'}),
category='CONSTANT',
Expand Down Expand Up @@ -640,7 +647,8 @@ def create_example_submodel() -> model.Submodel:

submodel_element_basic_event_element = model.BasicEventElement(
id_short='ExampleBasicEventElement',
observed=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value='http://acplt.org/Test_Submodel'),
observed=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL,
value=model.Identifier('http://acplt.org/Test_Submodel')),
model.Key(type_=model.KeyTypes.PROPERTY,
value='ExampleProperty'),),
model.Property),
Expand Down
6 changes: 4 additions & 2 deletions basyx/aas/examples/data/example_aas_mandatory_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ def create_example_submodel() -> model.Submodel:

submodel_element_basic_event_element = model.BasicEventElement(
id_short='ExampleBasicEventElement',
observed=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value='http://acplt.org/Test_Submodel'),
model.Key(type_=model.KeyTypes.PROPERTY, value='ExampleProperty'),),
observed=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL,
value=model.Identifier('http://acplt.org/Test_Submodel')),
model.Key(type_=model.KeyTypes.PROPERTY,
value=model.Identifier('ExampleProperty')),),
model.Property),
direction=model.Direction.INPUT,
state=model.StateOfEvent.OFF)
Expand Down
2 changes: 1 addition & 1 deletion basyx/aas/examples/data/example_aas_missing_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def create_example_submodel() -> model.Submodel:
value_type=model.datatypes.String,
value='exampleValue',
value_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/ValueId/ExampleValueId'),)),
value=model.Identifier('http://acplt.org/ValueId/ExampleValueId')),)),
display_name=model.LangStringSet({'en-US': 'ExampleProperty',
'de': 'BeispielProperty'}),
category='CONSTANT',
Expand Down
29 changes: 17 additions & 12 deletions basyx/aas/examples/data/example_submodel_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def create_example_submodel_template() -> model.Submodel:
'de': 'Beispiel MulitLanguageProperty Element'}),
parent=None,
semantic_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/MultiLanguageProperties/'
'ExampleMultiLanguageProperty'),)),
value=model.Identifier('http://acplt.org/MultiLanguageProperties/'
'ExampleMultiLanguageProperty')),)),
qualifier=(),
kind=model.ModelingKind.TEMPLATE)

Expand All @@ -64,7 +64,7 @@ def create_example_submodel_template() -> model.Submodel:
'de': 'Beispiel Range Element'}),
parent=None,
semantic_id=model.GlobalReference((model.Key(type_=model.KeyTypes.GLOBAL_REFERENCE,
value='http://acplt.org/Ranges/ExampleRange'),)),
value=model.Identifier('http://acplt.org/Ranges/ExampleRange')),)),
qualifier=(),
kind=model.ModelingKind.TEMPLATE)

Expand Down Expand Up @@ -123,13 +123,15 @@ def create_example_submodel_template() -> model.Submodel:

submodel_element_relationship_element = model.RelationshipElement(
id_short='ExampleRelationshipElement',
first=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value='http://acplt.org/Test_Submodel'),
first=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value=model.Identifier('http://acplt.org/'
'Test_Submodel')),
model.Key(type_=model.KeyTypes.PROPERTY,
value='ExampleProperty'),),
value=model.Identifier('ExampleProperty')),),
model.Property),
second=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value='http://acplt.org/Test_Submodel'),
second=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value=model.Identifier('http://acplt.org/'
'Test_Submodel')),
model.Key(type_=model.KeyTypes.PROPERTY,
value='ExampleProperty'),),
value=model.Identifier('ExampleProperty')),),
model.Property),
category='PARAMETER',
description=model.LangStringSet({'en-US': 'Example RelationshipElement object',
Expand All @@ -143,13 +145,15 @@ def create_example_submodel_template() -> model.Submodel:

submodel_element_annotated_relationship_element = model.AnnotatedRelationshipElement(
id_short='ExampleAnnotatedRelationshipElement',
first=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value='http://acplt.org/Test_Submodel'),
first=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value=model.Identifier('http://acplt.org/'
'Test_Submodel')),
model.Key(type_=model.KeyTypes.PROPERTY,
value='ExampleProperty'),),
value=model.Identifier('ExampleProperty')),),
model.Property),
second=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value='http://acplt.org/Test_Submodel'),
second=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value=model.Identifier('http://acplt.org/'
'Test_Submodel')),
model.Key(type_=model.KeyTypes.PROPERTY,
value='ExampleProperty'),),
value=model.Identifier('ExampleProperty')),),
model.Property),
annotation=(),
category='PARAMETER',
Expand Down Expand Up @@ -200,7 +204,8 @@ def create_example_submodel_template() -> model.Submodel:

submodel_element_basic_event_element = model.BasicEventElement(
id_short='ExampleBasicEventElement',
observed=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL, value='http://acplt.org/Test_Submodel'),
observed=model.ModelReference((model.Key(type_=model.KeyTypes.SUBMODEL,
value=model.Identifier('http://acplt.org/Test_Submodel')),
model.Key(type_=model.KeyTypes.PROPERTY,
value='ExampleProperty'),),
model.Property),
Expand Down
Loading

0 comments on commit 0136081

Please sign in to comment.