OPC UA in c# using c style API

Im trying to implement the OPC UA tool in an existing csharp application writen using the c style API. But im running into some problems as there is only documentation for the C++ and python API.

Its pretty simple what I want to do; just a single node needs to be exposed to an external client;

            OpcUaServer server = new OpcUaServer(4840);
            ServerFloatNode node = new ServerFloatNode(1, "basenode", VariableType.DataVariable, server.Nodes.RootFolder);
            node.Value = 100;
            server.Nodes.Add(node);
            server.Start();

This gets me a node with the correct name, but it seems like it doesn’t have the correct type. When looking at the node in question it has string listed as its type, and no value associated to it. What did I miss?

Hi @CvK,

If you want to implement OPC UA with C# the way to go is to use the CVB.Net. We did not create the shallow DllImport wrappers for OPC UA because we did not consider the cost-benefit-ratio to be reasonable. The Stemmer.Cvb.OpcUa namespace is located in the Stemmer.Cvb.Foundation.dll (as OPC UA is part of the Foundation Package) and it is of course perfectly fine to combine use of this DLL with an application that otherwise does not interact with the CVB.Net API.

1 Like

Huh, seems like I already was using the .net interface for that. Forgot that doesn’t specifically requires a reference to the bindings in 13.2.

Got it working now :slight_smile:

If i create a float node on the server, the client still lists it as a string. How to make it a float?
image

Hi @CvK,

I can’t reproduce this here… Did you test this with a 3rd party software like UaExpert? Browsing my server there, shows me all nodes with the correct datatype.

Where does your output from the screenshot come from? From your debugger? Could you please provide me with the sourcecode you used for browsing the nodes?

Cheers,
Thomas

Found out what the culprit was; the “string” relates to the name of the node. No idea why that was featured so promintently in the OPC UA client software I used.

1 Like