Skip to content
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

Trying to instantiate optionals #1327

Open
herculesp17 opened this issue Jun 5, 2023 · 10 comments
Open

Trying to instantiate optionals #1327

herculesp17 opened this issue Jun 5, 2023 · 10 comments

Comments

@herculesp17
Copy link

This is how I instantiate my object in the server. so far so good.
`

instantiate objects in server

    self.device = await instantiate(await self.server.nodes.objects.get_child('3:Machines'),
                                    await self.server.nodes.base_object_type.get_child('4:WwMachineType'),
                                    bname = 'testServer_SA_OPCUA',
                                    dname = ua.LocalizedText('Dickenhobel'),
                                    idx = 4, instantiate_optional = False)`

but i want to add some optional children of the node type such as variables and properties. I just don't know how to get there.

@herculesp17 herculesp17 changed the title Trying to instansiate optionals Trying to instantiate optionals Jun 5, 2023
@AndreasHeine
Copy link
Member

instantiate_optional = True

@herculesp17
Copy link
Author

herculesp17 commented Jun 5, 2023

yes but that instatiates all optionals; i don't want all of them though. I just want some specific ones.

@AndreasHeine
Copy link
Member

thats currently not possible...

@schroeder-
Copy link
Contributor

Delete the unwanted ones afterwards.

@herculesp17
Copy link
Author

@schroeder- There are like 100 nodes more beeing instaniated than i actually want

@schroeder-
Copy link
Contributor

You can make a pr for a extended interface if you want. Otherwise you can copy the code from instantiate and adapt it to your needs.

@AndreasHeine
Copy link
Member

modify the instantiate method with another optional parameter (list of str) containing the browsenames of the childs to be instantiated? would be a cool new feature!

@herculesp17
Copy link
Author

@AndreasHeine I agree

@herculesp17
Copy link
Author

herculesp17 commented Jun 5, 2023

@schroeder- Can you tell me exactly how to do that? I tried the following, but it didn't work. My programming skills are not very good, yet and it's hard for me to understand the documention perfectly.

self.device = await instantiate(await self.device, ua.NodeIdType(3), ua.NodeId('ns=1;i=6028'), bname = '4:Location', dname = 'Biel', idx = 4, instantiate_optional = False)

@schroeder-
Copy link
Contributor

schroeder- commented Jun 5, 2023

Started a pr #1328, this is missing a test.
self.device = await instantiate(await self.device, ua.NodeIdType(3), ua.NodeId('ns=1;i=6028'), bname = '4:Location', dname = 'Biel', idx = 4, instantiate_optional_list=["Optional1", ua.QualifiedName("Optional2", 3)])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants