Closed Kuchsn closed 5 months ago
ExternalReference
and ModelReference
are modelled as separate classes in the basyx-python-sdk. model.Reference
is just the abstract base class, which cannot be instantiated on its own.
The JSON data you posted looks like the official deserialization format. Can't you just deserialize it using the JSON deserialization of the basyx-python-sdk?
The JSON data you posted looks like the official deserialization format.
Yes, it is. I just use it as a working example to generate a new AAS from a JSON file. The Input file will change later.
I solved it now like this:
creator_key = model.Key(model.KeyTypes.GLOBAL_REFERENCE,
data['submodels'][0]['administration']['creator']["keys"][0]['value'])
administration=model.AdministrativeInformation(
version=data['submodels'][0]['administration']['version'],
revision=data['submodels'][0]['administration']['revision'],
creator=model.ExternalReference((creator_key,))
),
now im stuck at the similar field of semantic_id:
semantic_key = model.Key(model.KeyTypes.CONCEPT_DESCRIPTION,
data['submodels'][0]['semanticId']["keys"][0]['value'])
submodel=model.Submodel(
id_=data['submodels'][0]['id'],
id_short=data['submodels'][0]['idShort'],
administration=model.AdministrativeInformation(
version=data['submodels'][0]['administration']['version'],
revision=data['submodels'][0]['administration']['revision'],
creator=model.ExternalReference((creator_key,))
),
semantic_id=model.ModelReference((semantic_key,), type_= ???)
)
I can't figure out what type should be. I tried "model.KeyTypes.CONCEPT_DESCRIPTION" but then it complains about missing attr name:
AttributeError: 'KeyTypes' object has no attribute 'name'
type_
is the type of the object that is referenced, in this case model.ConceptDescription
.
Yeah, i thought so.... That means i have to create a whole new ConceptDescription!? But with which id?
"submodels": [
{
"idShort": "Nameplate",
"administration": {
"version": "1",
"revision": "0",
"creator": {
"type": "ExternalReference",
"keys": [
{
"type": "GlobalReference",
"value": "AasSuite"
}
]
}
},
"id": "1397_2635_8083_5281",
"semanticId": {
"type": "ModelReference",
"keys": [
{
"type": "ConceptDescription",
"value": "https://admin-shell.io/zvei/nameplate/2/0/Nameplate"
}
]
},
"submodelElements": [
....
],
"modelType": "Submodel"
}
]
The id of the Submodel?
You don't have to create a concept description, only the type is needed here, not an instance. So just passing model.ConceptDescription
works.
thx, that worked. The fog is slowly clearing.... Now i will try to recreated the whole submodelElements.
Good Morning, currently i try to parse a json file and rebuild it as a AAS model. Now im stuck on the "Creator" part in "administration". That's the json part i want to recreate:
this is the part where i try to rebuild the submodel:
Yes i know, i can't give a string to Reference. If i understand correct, Reference should be an id of an other submodel or other element? What kind of element? Probably there is a object that creates me this key, type, value structure? Probably the same for semanticId. thx