![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
11/08/2022
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Hey all,
This is my first time attempting to make an OPC UA application. What I want to do is to fetch data from different public REST APIs, format the data and then send it securely to an automation system. It will all run on a Windows Server as a service for now, but will later be in Docker.
I've created the app that fetches the data and modelled it into C#-classes. Now, how to use the ConsoleReferenceServer project to make a minimal solution to serve my data?
The ReferenceServer has miles of classes and XML files to declare different data types, and it's a bit daunting. My objects are data classes which have some lists containing different sub-data-classes. Ultimately data types are decimal numbers (double) and strings. How can I make this into something which is compliant with OPC UA and get the server to read the data?
For the initial version, the data will be updated hourly. I would like for the client to be able to subscribe to the values.
Many thanks in advance!
![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)
If you have a bunch of classes with string and numeric data that is updated hourly then you will likely want to create an ObjectType that mirrors your classes.
i.e.
class SomeOptionalData { double X; double Y; string Z; } class SomeData{ double A; string B; SomeOptionalData C; }
would have the mapping
SomeOptionalData => SomeOptionalDataType
ObjectType SomeData => SomeDataType
where SomeOptionalData has 3 Properties X, Y and Z
and SomeData has 2 Properties A and C and a component C;
You would then create as many instances of the ObjectTypes as you need.
When it comes writing code the quickest way is to use the ModelCompiler (https://github.com/OPCFoundati.....elCompiler).
This requires that you replicate your class model in an XML file (https://github.com/OPCFoundati.....Design.xml)
Once you generate the classes you can instantiate the Objects using code you see for m_boiler2 here: https://github.com/OPCFoundati.....Manager.cs
I recommend you get the Boiler sample running, modify the ModelDesign to have a some ObjectTypes that look like your data and follow the same design patterns to instantiate and update objects,
You should have a working server in no time.
BTW: when creating instances you have 2 choices: well-known instances defined in the design file (m_boiler1) or instances created at runtime (m_boiler2).
1 Guest(s)