What's the simplest way to get started publishing my data through an OPC UA server?|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
What's the simplest way to get started publishing my data through an OPC UA server?
Avatar
Vegard Guttormsen_1
New Member
Members
Forum Posts: 1
Member Since:
11/08/2022
sp_UserOfflineSmall Offline
1
11/10/2022 - 03:09
sp_Permalink sp_Print

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!Laugh

Avatar
Randy Armstrong
Admin
Forum Posts: 1438
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
11/10/2022 - 06:41
sp_Permalink sp_Print sp_EditHistory

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).

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 23
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1341
Posts: 4545