model: Add string serialization/deserialization of Reference objects according to DotAAS sec. 5.2.1
In Details of the Asset Administration Shell, section 5.2.1 (p. 95), a cannonical string representation of Reference
objects is presented:
In some mapping or serializations the Type “Reference” is converted into a single string. In this case we recommend to use the following serilization:
<Reference> ::= <Key>{,<Key>}* <Key> ::= (<KeyType>)(<Local>)[<KeyIdType>]<KeyValue> <KeyType> ::= value of AAS:Key/type <Local> ::= local | no-local <KeyIdType> ::= value of AAS:Key/.idType <KeyValue> ::= value of AAS:Key/value
With
<Local> == local
ifAAS:Key/local = True
andno-local
ifAAS:Key/local == False
.Examples:
(ConceptDescription)(local)[IRDI]0173-1#02-BAA120#008
(GlobalReference)(no-local)[IRDI]0173-1#01-AFZ615#016
(Submodel)(local)[IRI]http://customer.com/demo/aas/1/1/1234859590,(Property)(local)[IdShort]Temperature
(Plattform Industrie 4.0: "Details of the Asset Administration Shell – Part 1 - The exchange of information between partners in the value chain of Industrie 4.0 (Version 2.0.1)", CC BY-ND 4.0)
We could perfectly implement this representation as the __str__
method of the Reference
class and add a parser/constructor method like this:
@classmethod
def from_string(cls, value: str) -> "Reference":
# probably something with regex parsing here