Hello everybody!
I have conceptual question about samples.
Let's take "UA Quick Start Applications" -> "DataTypes" for example.
Our last task is understand how to work with data types. We have structure in out C# project and want to make data variable of similar structure in OPC-UA, for example...
We expected to see next in the samples:
1. Some set of structures.
2. Code which show how to create all neccessary nodes to support these structures in address space.
3. Some sample of using such structures (creation of data variable of structure type, for example).
Instead of that, we found some .xml, .uanodes, .bsd, .csv, and so on files, which describes structures. And seems like these files than handled by other tool (seems this is ModelCompiler) and than result of it work used in project for address space building.
As a result, we have big difficulties with understanding how to implement what we need. We absolutely don't understand why samples were implemented in such way. The questions are next:
1) Where these .xml, .uanodes, .bsd, .csv files were created (maybe in some tool) ?
2) Why simple C# codes was not used without any model compilers and other tools?
3) Sometimes we see in samples something like this:
private const string InitializationString = "AQAAADcAAABodHRwOi8vb3BjZm91bmRhdGlvbi5vcmcvVUEvUXVpY2tzdGFydHMvRGF0YVR5cGVzL1R5" +
"cGVz/////wRggAABAAAAAQASAAAARHJpdmVyVHlwZUluc3RhbmNlAQFVAQEBVQH/////AgAAABVgqQoC" +
"AAAAAQAOAAAAUHJpbWFyeVZlaGljbGUBAVYBAC4ARFYBAAAWAQE+AQKcAAAAPENhclR5cGUgeG1sbnM9" +
"Imh0dHA6Ly9vcGNmb3VuZGF0aW9uLm9yZy9VQS9RdWlja3N0YXJ0cy9EYXRhVHlwZXMvVHlwZXMiPjxN" +
"YWtlPlRveW90YTwvTWFrZT48TW9kZWw+UHJpdXM8L01vZGVsPjxOb09mUGFzc2VuZ2Vycz40PC9Ob09m" +
"UGFzc2VuZ2Vycz48L0NhclR5cGU+AQE6Af////8DA/////8AAAAAFWCpCgIAAAABAA0AAABPd25lZFZl" +
"aGljbGVzAQFYAQAuAERYAQAAlgIAAAABAT8BAp0AAAA8VHJ1Y2tUeXBlIHhtbG5zPSJodHRwOi8vb3Bj" +
"Zm91bmRhdGlvbi5vcmcvVUEvUXVpY2tzdGFydHMvRGF0YVR5cGVzL1R5cGVzIj48TWFrZT5Eb2RnZTwv" +
"TWFrZT48TW9kZWw+UmFtPC9Nb2RlbD48Q2FyZ29DYXBhY2l0eT41MDA8L0NhcmdvQ2FwYWNpdHk+PC9U" +
"cnVja1R5cGU+AQE+AQLwAAAAPFZlaGljbGVUeXBlIHhzaTp0eXBlPSJDYXJUeXBlIiB4bWxuczp4c2k9" +
"Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4bWxucz0iaHR0cDovL29w" +
"Y2ZvdW5kYXRpb24ub3JnL1VBL1F1aWNrc3RhcnRzL0RhdGFUeXBlcy9UeXBlcyI+PE1ha2U+UG9yY2hl" +
"PC9NYWtlPjxNb2RlbD5Sb2Fkc3RlcjwvTW9kZWw+PE5vT2ZQYXNzZW5nZXJzPjI8L05vT2ZQYXNzZW5n" +
"ZXJzPjwvVmVoaWNsZVR5cGU+AQE6AQEAAAADA/////8AAAAA";
protected override void Initialize(ISystemContext context)
{
Initialize(context, InitializationString);
}
Can anybody explain how people, who looking at such codes, can understand what does this code do?
4) Sometimes we see such codes:
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public static partial class DataTypes
{
///
/// The identifier for the VehicleType DataType.
///
public const uint VehicleType = 314;
And we don't understand why 314 was used, why not 520, for example, and how to know what number is acceptable and what is not acceptable? What numbers should we use in our codes?
Please, help us to understand all this.
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/admindefault.png)
05/30/2017
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
The process is:
1) Define your DataTypes in a ModelDesign file (the CSV is produced automatically);
2) Use the ModelCompiler to produce code;
3) Add your application specific logic to a server that includes the generated code;
While the inner workings of the generated code may be interesting from an academic perspective people who want to get something up and running quickly usually find the ModelCompiler or similar tool a more productive development environment.
The IDs are assigned automatically by the ModelCompiler. Any number is acceptable provided it is unique within a model identified with a NamespaceUri.
The model of using a tool to generate code is a common paradigm (e.g. using xsd to create XML serialization code).
You told that "using a tool to generate code is a common paradigm", but this is only one case of using, it is not universal approach.
What do you say if developer need to create address space using some external information (config file or database, ets?)
About your answers:
>> 1) Define your DataTypes in a ModelDesign.xml file (the CSV is produced automatically);
I've opened ModelDesign.xml in Visual Studio XML editor and saw that schema is not applyed. This means that this file was created by someone who very familar with model design schema or in some external tool, which can generate such file. But we can not find any special editor on OPC foundation site. What editor is intended to be used?
>> 2) Use the ModelCompiler to produce code;
This is official description of the sources: https://github.com/OPCFoundati.....ETStandard
Model compiler is an external tool. Yes, it's created by OPC Foundation, but this is only an auxiliary tool. This means that all coding can be made without ModelCompiler in poor C#. We think that samples, which demonstrates basic possibilities, should not use any external tools in principle. Do you agree or not?
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/admindefault.png)
05/30/2017
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Yes, in the ideal world, a simple DataType example that does not require the ModelCompiler would be a useful learning tool.
Unfortunately, we do not have such a sample at this time.
You can add a feature request on GitHub so it will get added to the task list.
I don't know when that might occur.
Thank you very much!
The problem is that currently we trying to create library which cretes address space using our custom descriprors. Currently this descriptors created using custom attrubutes. So, our task is real...
And you did not aswer on the question about ModelDesign.xml editor. Do you have some special tool for it (like Unified automation made UaModeller for their library) or you make models in some universal XML editor?
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/moderatordefault.png)
Moderators-Specifications
Moderators-Companion
Moderators-Implementation
Moderators-Certification
Moderators-COM
02/24/2014
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
I just use my standard XML editor,You can use your favorite XML editor tool and yes editing the file requires some practice (and looking at some of the samples).
A number of other vendors have adapted the model builder for their custom requirments
Paul
Paul Hunkar - DSInteroperability
Thank you, Paul.
I thinked about XML editor, but, as i wrote before, it is very strange for me that xml schema location is not specified in the file.
Yet one problem is a description. Let's take DataTypes sample again. There are three projects: Types library, Server and Client.
But it is not clear for me what exactly should i do to see benefits of datatype using. I've started server, started client, connected from client to server, saw some nodes and what? In some nodes i saw BadUnexpectedError (bug report already created). What should i do in client to understand what's going? I can not find any description.
Also i do not se any description of steps i need to perform to use DataTypes. I understood that i need:
1) Create my custom class and implement IEncodeable interface
2) Create DataTypeState node based on Structure data type
3) Add HasSubtype to Structure node
4) Create encodings and add them to address space (not clear how to do this)
5) Assign ancodings with data type (not clear how)
6) Create data type descriptors (not clear how to do this)
7) Create VariableTypes in case when i want to use my data type in variables
And i can't undrstand where to got answers on these questions. I've tried to make debugging of what's going in sample application, but it's too complex for me 🙁 So, currently i'm stumped. Meybe someone can help...
In parallel i'm working with TwinCAT PLC and they also generates data types based on structures. Then they allow to use these data types as variables or method parameters. UaExpert also can handle these structures. It shows custom editor for each data type. Data type nesting is also supported. We want to implement something similar. We need to pass diffirent complex structures in method parameters. But have problems with implementation because do not have enough documentation 🙁
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/admindefault.png)
05/30/2017
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Creating DataTypes from first principles for v1.04 is relatively easly.
1) Create a class.
2) Create a serializer (any will do as long as it works with byte[]);
3) Assign a unique DataType NodeId and DataType Encoding NodeId;
4) Create the Nodes;
When the value is read you use your serializer to populate an ExtensionObject along with the DataType Encoding NodeId.
When the value is written you check that the value has an ExtensionObject and the correct DataType Encoding NodeId and then use your serializer to decode.
1 Guest(s)