python-opcua icon indicating copy to clipboard operation
python-opcua copied to clipboard

improve export of values, support list and extension objects

Open oroulet opened this issue 9 years ago • 9 comments

I am looking at that

oroulet avatar Aug 22 '16 18:08 oroulet

I don't have time to work on the exporter for a while. Too much work for my employer at the moment. If I get time I'll check for PRs before starting.

zerox1212 avatar Aug 23 '16 14:08 zerox1212

Question on ExtensionObject:

I need to access/use GetData Method and SetData Method. Just wonder how to phrase input and out arguments for particular method call. Appreciated if you could send some example code with these methods.

Another question is on Extension object. When I executed below command print(client.get_node(ua.NodeId(5069,2)).call_method(ua.NodeId(7073,2)))

It prints a Extension object ExtensionObject(TypeId:FourByteNodeId(ns=2;i=5079), Encoding:1, 160 bytes)

When I use get_value() method on above object it thrown an error. Just wonder how to access the data of 160Bytes information from above extension object.

SeetaiahB avatar Jul 12 '17 12:07 SeetaiahB

https://github.com/FreeOpcUa/python-opcua/blob/master/examples/client_read-custom_structures.py

oroulet avatar Jul 12 '17 12:07 oroulet

and please do not post the same question everywhere

oroulet avatar Jul 12 '17 12:07 oroulet

I am sorry I was accidently done …thanks

From: oroulet [mailto:[email protected]] Sent: Wednesday, July 12, 2017 6:10 PM To: FreeOpcUa/python-opcua [email protected] Cc: Bachhu, Seetaiah (GE Power) [email protected]; Comment [email protected] Subject: EXT: Re: [FreeOpcUa/python-opcua] improve export of values, support list and extension objects (#292)

and please do not post the same question everywhere

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/FreeOpcUa/python-opcua/issues/292#issuecomment-314756782, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AUV78P__3PrVc7kk8NlvPGH0AZR_489Gks5sNL6bgaJpZM4JqI_B.

SeetaiahB avatar Jul 12 '17 12:07 SeetaiahB

hi orulet,

when i used they presented way https://github.com/FreeOpcUa/python-opcua/blob/master/examples/client_read-custom_structures.py

the following error message displayed. registring new extension object: Amps FourByteNodeId(ns=2;i=5029) <class 'structures_Elvs.Amps'> registring new extension object: BasicMetering FourByteNodeId(ns=2;i=5086) <class 'structures_Elvs.BasicMetering'> registring new extension object: BreakerSettings FourByteNodeId(ns=2;i=5079) <class 'structures_Elvs.BreakerSettings'> registring new extension object: OCSettings FourByteNodeId(ns=2;i=5058) <class 'structures_Elvs.OCSettings'> registring new extension object: PkUp_Delay FourByteNodeId(ns=2;i=5050) <class 'structures_Elvs.PkUp_Delay'> registring new extension object: Rating FourByteNodeId(ns=2;i=5041) <class 'structures_Elvs.Rating'> registring new extension object: RelaySettings FourByteNodeId(ns=2;i=5025) <class 'structures_Elvs.RelaySettings'> registring new extension object: Volts FourByteNodeId(ns=2;i=5031) <class 'structures_Elvs.Volts'> Traceback (most recent call last): File "C:/Projects/2017/Entellisys6.0_CPU_Testing/Functions_Library/CPU_Functions/OPC_Functions.py", line 47, in after = struct.get_value() File "C:\Projects\2017\Entellisys6.0_CPU_Testing\CPUTesting_3.5Virtual_Envi\lib\site-packages\opcua\common\node.py", line 129, in get_value result = self.get_data_value() File "C:\Projects\2017\Entellisys6.0_CPU_Testing\CPUTesting_3.5Virtual_Envi\lib\site-packages\opcua\common\node.py", line 138, in get_data_value return self.get_attribute(ua.AttributeIds.Value) File "C:\Projects\2017\Entellisys6.0_CPU_Testing\CPUTesting_3.5Virtual_Envi\lib\site-packages\opcua\common\node.py", line 245, in get_attribute result[0].StatusCode.check() File "C:\Projects\2017\Entellisys6.0_CPU_Testing\CPUTesting_3.5Virtual_Envi\lib\site-packages\opcua\ua\uatypes.py", line 207, in check raise UaStatusCodeError(self.value) opcua.ua.uaerrors._auto.BadAttributeIdInvalid: The attribute is not supported for the specified Node.(BadAttributeIdInvalid)

Appreciated if you could share some examples to call extension object retrieve information like body etc..from it.

SeetaiahB avatar Jul 13 '17 08:07 SeetaiahB

Post your code and example of extensionobject (and encoding).

zerox1212 avatar Jul 13 '17 11:07 zerox1212

Here is the my code:

[cid:[email protected]] [cid:[email protected]] [cid:[email protected]] Node structure Output Argument Attributes for get Data SetData Input Argument

Above is the my server node structure pulled from UaExpert.

I need to access/use GetData Method and SetData Method. Just wonder how to phrase input and out arguments for particular method call. Appreciated if you could send some example code with these methods.

Another question is on Extension object.

When I executed below command print(client.get_node(ua.NodeId(5069,2)).call_method(ua.NodeId(7073,2)))

It prints a Extension object ExtensionObject(TypeId:FourByteNodeId(ns=2;i=5079), Encoding:1, 160 bytes)

When I use get_value() method on above object it thrown an error. Just wonder how to access the data of 160Bytes information from above extension object.

Appreciated your help

From: Andrew [mailto:[email protected]] Sent: Thursday, July 13, 2017 5:25 PM To: FreeOpcUa/python-opcua [email protected] Cc: Bachhu, Seetaiah (GE Power) [email protected]; Comment [email protected] Subject: EXT: Re: [FreeOpcUa/python-opcua] improve export of values, support list and extension objects (#292)

Post your code and example of extensionobject (and encoding).

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/FreeOpcUa/python-opcua/issues/292#issuecomment-315056403, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AUV78B1PDbsmMVrCYxmYk2IDciKYkQpzks5sNgWJgaJpZM4JqI_B.

SeetaiahB avatar Jul 13 '17 12:07 SeetaiahB

I get this following error: opcua.ua.uaerrors._auto.BadAttributeIdInvalid: "The attribute is not supported for the specified Node."(BadAttributeIdInvalid) Any one knows what it says and how to fix it?

I want to read the complete structure of a node and I want to export all its node IDs and store it into a CSV file, so that it would be easy to import it in Nodered!

This is the code I used:

`import sys
sys.path.insert(0, "..")
import time
import logging
from IPython import embed

from opcua import Client
from opcua import ua



if __name__ == "__main__":
    logging.basicConfig(level=logging.WARN)
    client = Client("opc.tcp://192.168.64.194:4840")
    try:
        client.connect()
        root = client.get_root_node()
        objects = client.get_objects_node()
        struct = client.get_node("ns=2;i=5001")
        struct_array = client.get_node('"ns=3;s="Control"')
        before = struct.get_value()
        before_array = struct_array.get_value()
        client.load_type_definitions()  # scan server for custom structures and import them
        after = struct.get_value()
        after_array = struct_array.get_value()
        

        embed()
    finally:
        client.disconnect()`

mkdthanga avatar Sep 08 '22 10:09 mkdthanga