UA Bundle SDK .NET  2.4.2.373
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Modules Pages
Integrating the Model into an Empty Server

We are using the basic OPC UA server from Lesson 1 as a starting point. The prepared sample code can be found in the Lesson 2 project of the UA Server Getting Started solution.

At first, we have to add the file containing the model (buildingautomation.xml) to the Visual Studio project (Add → Existing Item). Choose “Properties” from the context menu and set “Build Action” to “Embedded Resource” as shown in the following screenshot.

serverlesson02a_st5_add_model.png
Figure 2.12: Add buildingautomation.xml as Embedded Resource

Then, we have to load the model in Lesson2NodeManager.cs

using System.Reflection;

public override void Startup()
{

...
Console.WriteLine("Loading the Controller Model.");
ImportUaNodeset(Assembly.GetEntryAssembly(), "buildingautomation.xml");

Now we are ready to compile and start-up the server.

When connecting to the server with an OPC UA client, e.g. UaExpert, we will notice that the type nodes are already visible in the server’s address space (see Figure 2.13).

Type nodes in the server’s address space

serverlesson02a_st5_expert.png
Figure 2.13: Type nodes in the server’s address space

Next step: Preparing Instance Creation