Skip to content
Snippets Groups Projects

Feature/restructuring

Merged Torben Miny requested to merge feature/restructuring into master
22 unresolved threads
Files
18
@@ -736,16 +736,7 @@ class AASToJsonEncoder(json.JSONEncoder):
return super().default(obj)
def write_aas_json_file(file: IO, data: model.AbstractObjectStore, **kwargs) -> None:
"""
Write a set of AAS objects to an Asset Adminstration Shell JSON file according to 'Details of the Asset
Administration Shell', chapter 5.5
:param file: A file-like object to write the JSON-serialized data to
:param data: ObjectStore which contains different objects of the AAS meta model which should be serialized to a
JSON file
:param kwargs: Additional keyword arguments to be passed to json.dump()
"""
def _create_dict(data: model.AbstractObjectStore) -> dict:
# separate different kind of objects
assets = []
asset_administation_shells = []
@@ -760,11 +751,37 @@ def write_aas_json_file(file: IO, data: model.AbstractObjectStore, **kwargs) ->
submodels.append(obj)
if isinstance(obj, model.ConceptDescription):
concept_descriptions.append(obj)
# serialize object to json
json.dump({
dict_ = {
'assetAdministrationShells': asset_administation_shells,
'submodels': submodels,
'assets': assets,
'conceptDescriptions': concept_descriptions,
}, file, cls=AASToJsonEncoder, **kwargs)
}
return dict_
def object_store_to_json(data: model.AbstractObjectStore, **kwargs) -> str:
"""
Create a json serialization of a set of AAS objects according to 'Details of the Asset Administration Shell',
chapter 5.5
:param data: ObjectStore which contains different objects of the AAS meta model which should be serialized to a
JSON file
:param kwargs: Additional keyword arguments to be passed to json.dump()
"""
# serialize object to json
return json.dumps(_create_dict(data), cls=AASToJsonEncoder, **kwargs)
def write_aas_json_file(file: IO, data: model.AbstractObjectStore, **kwargs) -> None:
Please register or sign in to reply
"""
Write a set of AAS objects to an Asset Adminstration Shell JSON file according to 'Details of the Asset
Administration Shell', chapter 5.5
:param file: A file-like object to write the JSON-serialized data to
:param data: ObjectStore which contains different objects of the AAS meta model which should be serialized to a
JSON file
:param kwargs: Additional keyword arguments to be passed to json.dumps()
"""
# serialize object to json
json.dump(_create_dict(data), file, cls=AASToJsonEncoder, **kwargs)
Loading