convertersystems / opc-ua-client

Visualize and control your enterprise using OPC Unified Architecture (OPC UA) and Visual Studio.
MIT License
397 stars 115 forks source link

Read and Write Model #186

Closed franklupo closed 3 years ago

franklupo commented 3 years ago

Hi, you did a wonderful job. I can't find a way to write and read a model class. How can I do?

best regards

awcullen commented 3 years ago

Hi, If I am understanding correctly that your model is a custom type, then there a couple of steps.

First, I recommend you create a custom TypeLibrary. See https://github.com/convertersystems/opc-ua-client/blob/568ee1339a43ff4906eeb85400d2b1b5c3b7e693/CustomTypeLibrary/CustomVector.cs#L5 The types in this library must subclass Structure and provide an Encode and Decode method. They also need some attributes including the BinaryEncodingId that matches the id the server is expecting.

Second, you will be able to read the custom structure just as easy as reading the ServerStatus as shown in this example: https://github.com/convertersystems/opc-ua-client/blob/568ee1339a43ff4906eeb85400d2b1b5c3b7e693/UaClient.UnitTests/IntegrationTests/IntegrationTests.cs#L283

franklupo commented 3 years ago

Hi, similar SubscriptionBase a class and properties with attributes.

Best regards