cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Read OPCUA structure through datalayer

marco_raffael
Occasional Visitor

Read OPCUA structure through datalayer

Hello all, I'm Marco.

I'm facing an issue reading a structure of bool in a siemens DB.

I created an opcua client in ctrlX witch connect to opcua server of siemens 1500 and I'm trying to read this structure from datalayer.

I'm using python 3.9 with package ctrlx-datalayer=2.2.0.

Below a snippet of the code I'm using, the response is at right of the print.

 

 

with ctrlxdatalayer.system.System('') as dlsystem:
    dlsystem.start(False)
    client: ctrlxdatalayer.client.Client
    client, conn_string = get_client(dlsystem, '192.168.1.1')

    res, var = client.read_sync(f'opcuaclient/siemens1/i=85/ns=3;s=PLC/ns=3;s=DataBlocksGlobal/ns=3;s="DB_test2"/ns=3;s="DB_test2"."a0"')
    r = var.get_data()
    print(res, r)  # Result.FAILED bytearray(b'\x10\x00\x00\x00\x00\x00\n\x00\x10\x00\x0c\x00\x08\x00\x04\x00\n\x00\x00\x00\x0c\x00\x00\x00\x00\x00\r\x80\x01\x02\n\rS\x00\x00\x00The operation could not complete because the client is not connected to the server.\x00')

 

 

Here the structure.

marco_raffael_0-1666774944069.png

 

I have no issue when I read simpler data types.

I encountered the same problem using node-red.

Thank you, I remain available for any clarification.

Tags (2)
3 REPLIES 3
nickH
Occasional Contributor

Re: Read OPCUA structure through datalayer

Hi Marco, 

I'm sorry, but could you explain your problem once again? I'm not sure if I understood it correctly. 

Can you see the nodes you are trying to read already in the Data Layer? If so, which Data Types do the nodes have in the Data Layer?

Maybe this document can help you: ctrlX CORE Application Manual (chapter: Data Layer -> Data types -> Introduction and overview)

Here you can see all the supported data types of the ctrlX Data Layer and how the respective data types in the different programming language.

Best regards, 

Nick

marco_raffael
Occasional Visitor

Re: Read OPCUA structure through datalayer

Hi, thank you for the reply.

Yes I'm able to see all the tree of client in datalayer page.

The type of node that I'm trying to read is a struct of 1024 bool like the image above (image taken from uaexpert tree). So would like to read the struct instead of all single bool.

I tried some method to get the value of node: get_data, get_flatbuffers.. but any of them work. Infact the nearest type of struct is complex-data-type but it doesn't works.

Sometimes get_data returns me a bytearray, but it's complex to manage when the struct form is different from this one.

 

CodeShepherd
Community Moderator

Re: Read OPCUA structure through datalayer

At the moment only flatbuffer data can be read as structure. Other elements need to be read as single nodes.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist