hello:
Can you give an example of creating method node with input and output argument grammatically in C# code? I have a need to dynamically create the method nodes.
Thanks.
create method node in code
Moderator: uasdknet
- Support Team
- Hero Member
- Posts: 3072
- Joined: 18 Mar 2011, 15:09
Re: create method node in code
Hello,
The following method adds a UA Method node with InpurtArguments and OutputArguments properties to the Method folder in .NET DemoServer:
Best regards
Support Team
The following method adds a UA Method node with InpurtArguments and OutputArguments properties to the Method folder in .NET DemoServer:
Code: Select all
private void CreateMethodInCode()
{
CreateMethodSettings settings = new CreateMethodSettings()
{
ParentNodeId = new NodeId(Demo.Model.Objects.Demo_Method, DefaultNamespaceIndex),
ReferenceTypeId = ReferenceTypeIds.HasComponent,
RequestedNodeId = new NodeId("MethodInCode", DefaultNamespaceIndex),
BrowseName = new QualifiedName("MethodInCode", DefaultNamespaceIndex),
Executable = true,
InputArguments = new List<Argument>(),
OutputArguments = new List<Argument>()
};
settings.InputArguments.Add(new Argument()
{
DataType = DataTypeIds.Double,
Name = "InputArgument1",
Description = "The first input argument",
ValueRank = ValueRanks.Scalar,
});
settings.InputArguments.Add(new Argument()
{
DataType = DataTypeIds.Double,
Name = "InputArgument2",
Description = "The second input argument",
ValueRank = ValueRanks.Scalar,
});
settings.OutputArguments.Add(new Argument()
{
DataType = DataTypeIds.Double,
Name = "Result",
Description = "The output argument",
ValueRank = ValueRanks.Scalar,
});
CreateMethod(Server.DefaultRequestContext, settings);
}
Support Team