eclipse-basyx / basyx-python-sdk

MIT License
61 stars 28 forks source link

How can I specify the order of submodels? #287

Closed SpicyYeol closed 3 months ago

SpicyYeol commented 3 months ago

I want to specify the order of submodels under Adminshell.

However, if you add a submodel using Modelreference, this order gets messed up and the result changes every time.

What function should I use to specify the order?

I am using the following code

    aas.submodel.add(model.ModelReference.from_referable(
        create_submodel(submodel_name, submodel_data, extract_columns_containing_word(data, submodel_name))))
SpicyYeol commented 3 months ago

I modified AssetAdministrationShell.Submodel set to List and solbed my issue

mhrimaz commented 3 months ago

@SpicyYeol FYI, neither submodel nor submodel elements within a submodel don't have any order. It is wrong to rely on any specific order.

s-heppner commented 3 months ago

Hi @SpicyYeol, thanks for asking your question here.

@mhrimaz is correct, an AssetAdministrationShell only has a "soft" reference to its Submodels, as by the specification. That means, an AssetAdministrationShell does not contain Submodels, which is a common misconception. These references to the Submodel don't have any order, however each Submodel must have a globally unique Identifier (Submodel.id). The suggested way to identify the correct Submodel you want to deal with is using that Identifier.

Changing the AssetAdministrationShell.submodel to a List may have lots of unforseen consequences, but most importantly, you will break the resolving of Submodels. (Also your AAS won't be interoperable with anyone else anymore)