-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to add SubmodelElementCollection to SubmodelElementList #233
Comments
Okay, the way I understand this, you managed to create a lot of problems for yourself, based on one relatively small thing, that hopefully is pretty easy to fix. I think the problem at the very beginning when you tried to:
Could it be that the specific collection already was part of some other Every Therefore, if you want to add a |
Thank you for providing all the information. As you mentioned, I confirmed that my collection already has a parent by checking KeyError Traceback (most recent call last) File c:\Users\uwicore\anaconda3\Lib\site-packages\basyx\aas\model\base.py:1725, in UniqueIdShortNamespace.remove_referable(self, id_short) File c:\Users\uwicore\anaconda3\Lib\site-packages\basyx\aas\model\base.py:522, in Namespace._remove_object(self, object_type, attribute_name, attribute) KeyError: 'Referable with id_short generated_submodel_list_hack_b1f50651ca5b11ee8000f057a6e54ba0 not found in this namespace' |
I think there's something weird with your code. qos_flow.parent.remove_referable In
is to be expected, considering it tells you that This nested structure gives us a clue. The Now, could it be that your Using qos_flow.parent.remove_referable(qos_flow.id_short) should definitly be the correct way of removing an object from a parent, so I am not entirely sure why this wouldn't work, based on the information you provided. |
Yes, I also don't understand why this command doesn't work, and I couldn't locate this element within the namespace, especially considering we are already searching by the parent of this element. It doesn't seem to make sense. As you mentioned, this is a nested structure. I'm encountering difficulties with every list in my AAS when attempting to add a class that inherits from SubmodelElementCollection. |
Would you be able to provide a minimal working example of code that can show your problem? |
I have prepared an example with all the information that I can provide to offer you the maximum possible context. The ExampleSubmodel is the same structure I use for my submodel and gives me the same error. |
Thanks for reaching out! To assist you efficiently, could you please provide a minimal example that reproduces the issue? This could be a concise code snippet or a simplified version of your project that isolates the problem. Please post it directly here into an issue comment, for example using three backticks for code snippets like so: ```Python
import foo
print("bar")
``` Sharing entire projects as zip files makes it challenging for us to pinpoint the exact issue. Also, for security reasons, we refrain from opening random zip files shared externally. If you need any guidance on preparing the minimal example or have questions, feel free to ask. |
Ok, here you have some classes for this example:
And now here you have an example of code I use in my jupiter notebook to read the aasx file and copy to my structure.
|
Your custom subclasses such as class Nameplate(Submodel):
def __init__(self, manufacturer_name, manufacturer_typ_name, physical_address, typ_class, serialno, chargeid,
countryoforigin, yearofconstruction, *args, **kwargs):
self.manufacturerName = manufacturer_name
self.manufacturerTypName = manufacturer_typ_name
self.physicalAddress = physical_address
self.typClass = typ_class
self.serialNo = serialno
self.chargeId = chargeid
self.countryOfOrigin = countryoforigin
self.yearOfConstruction = yearofconstruction
super().__init__(*args, **kwargs) Aside that, you didn't include the file |
I have this classes for it (e.g. QosFlowStatus) which inherit from e.g. SubmodelElementCollection class:
When I try to add this collection to QosFlowStatusList:
And I obtain this error (which I don´t understand):
Then I have tried to add this
qos_flow
to a very simple list like that:So now I check attributes of
qos_flow
and try to add to this simple list:generated_submodel_list_hack_4ecbd1f2c73f11ee8000f057a6e54ba0
Now I try to add this
qos_flow
:So, I try this:
So now I try with id_short=None:
And I have found this error:
So, the last thing that I have tried is to ask if this
qos_flow
is a submodelElementCollection:So now I don´t know what can I do with this list. If you need more information to try to find the solution to this problem, let me know.
Thank you in advance.
EDIT (by @s-heppner): I took the liberty to fix the syntax in your issue. Feel free to check the text, for example by pressing "edit" yourself, so that you can learn how to write more readable issues
Originally posted by @jorgegomezjumh in #47 (comment)
EDIT 2 (by @s-heppner): Since the question does fit to the other issue, I created a new one.
The text was updated successfully, but these errors were encountered: