Frequently Asked Question

How to implement a method node
Last Updated 7 years ago

In order to implement a method node that points to a C#/VB.Net method, you can create an OpcMethodNode instance and specify the method to execute, like in the following NodeManager Sample:

protected override IEnumerable CreateNodes(OpcNodeReferenceCollection references)
OpcFolderNode machineOne = new OpcFolderNode(
new OpcName("Machine_1", this.DefaultNamespaceIndex));
references.Add(machineOne, OpcObjectTypes.ObjectsFolder);

new OpcDataVariableNode(machineOne, "Name", "Machine 1");
new OpcDataVariableNode(machineOne, "Status", 1);

// Method Node
new OpcMethodNode(machineOne, "MyMethod 1", new Func(MyMethod1));

return new IOpcNode[] { machineOne };

private string MyMethod1(int a, int b)
return "Result: " + (a + b);
With this code, the OPC Framework will automatically create a method node with the parameters and return type of the .NET method which you specify.

Please Wait!

Please wait... it will take a second!