UA Bundle SDK .NET  2.2.0.255
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Groups 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.

Figure 2.11 Add buildingautomation.xml as Embedded Resource

Add buildingautomation.xml as Embedded Resource

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.Reflection; // Add this line
using UnifiedAutomation.UaBase;
using UnifiedAutomation.UaServer;
...
public override void Startup()
{
try
{
Console.WriteLine("Starting Lesson2NodeManager.");
AddNamespaceUri("http://yourorganisation.com/lesson02/");
// New Code Begin
Console.WriteLine("Loading the Controller Model.");
ImportUaNodeset(Assembly.GetEntryAssembly(), "buildingautomation.xml");
// New Code End
}

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

Figure 2.12 Type nodes in the server’s address space

Type nodes in the server’s address space

Next step: Preparing Instance Creation