Häufig gestellte Frage

How to implement a method node
Zuletzt aktualisiert vor 7 Jahren

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.

Bitte warten!

Bitte warten... es dauert eine Sekunde!