Skip to main content
Version: 2.6

Commands

A CommandNode specifies an action that can be performed inside the node space.

Following attributes define a command:

AttributeDescriptionData Type
IdId of the command. Not used for dynamic instantiation of schema nodesSystem.Guid
NameName of the commandSystem.String
PropertiesProperties of the commandsSystem.String
ArgumentsA list of input and output argumentsTArgumentInfo[]
TypeCommand node typeECommandNodeType

ECommandNodeType defines following command types:

TypeDescription
CommandNodeGeneric command used by UHAL Driver Plugins
CSharpScriptCommandNodeCommand using a script file as action part.
InstantiationCommandNodeCommand used to instantiate a schema by proactive action.
CommandProxyNodeCommand proxy to an C# implementation in a plugin

Arguments

Arguments specify how to pass or return values from commands.

AttributeDescriptionData Type
NameArgument nameSystem.String
DataTypeData type of the argumentSystem.Type
DescriptionOptional descriptionSystem.String
TypeArgument type:
  • Input: Input argument
  • Output: Out argument
  • InOut: In and out argument
EArgumentType
MinMaxConstraintOptional min and max value constraintTMinMaxConstraintInfo
RegExpConstraintOptional regular expression constraintTRegExpConstraintInfo

Example of MinMaxConstraint:

{
"Id": "F80F0B87-40DA-4DA2-B5A2-0DD853CCC082",
"Name": "MyCommand",
"Type": "CommandNode",
"Arguments": [
{
"Name": "Value",
"Type": "Input",
"DataType": "System.Int32",
"MinMaxConstraint": {
"MinValue": 0,
"MaxValue": 99
}
}
]
}

Example with a regular expression:

{
"Id": "F80F0B87-40DA-4DA2-B5A2-0DD853CCC082",
"Name": "MyCommand",
"Type": "CommandNode",
"Arguments": [
{
"Name": "Value",
"Type": "Input",
"DataType": "System.Int32",
"RegExpConstraint": {
"IgnoreCase": true,
"Pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
}
}
]
}

Scripted Commands

This command type allows to add a command directly to the node space. The command action is provided by a C# script file.

  • Attribute Type is set to CSharpScriptCommandNode
  • The property list must contain the property ScriptFileName.
PropertyDescriptionData Type
ScriptFileNamename of script fileSystem.String
NOTE

The script file must be located in $(ConfigPath)\Scripts\Commands\

Example

Declaration of the command:

{
"Id": "F80F0B87-40DA-4DA2-B5A2-0DD853CCC082",
"Name": "MyCommand",
"Type": "CSharpScriptCommandNode",
"Properties": [
{
"Name": "ScriptFileName",
"Value": "TCommand_MyCommand.cs"
}
],
"Arguments": [
{
"Name": "Id",
"Type": "Input",
"DataType": "System.Guid"
},
{
"Name": "Stream",
"Type": "Output",
"DataType": "System.Byte[]"
}
]
}

The command script class must be derived from TAbstractCommandScriptObject:

  /// <summary>
/// Command script
/// </summary>
public class TCommand_MyCommand : TAbstractCommandScriptObject
{
/// <see cref="TAbstractCommandScriptObject"/>
public override TCommandResult executeCommand(ICommandNode CommandNode,
Dictionary<string, object> dicInputArguments,
Dictionary<string, object> dicOutputArguments)
{
TCommandResult Retval = new TCommandResult();
INodeSpace Space = (INodeSpace)CommandNode.Relations.First(n => n is INodeSpace);


return Retval;
}
}

Instantiation Command

The instantiation command is used to create dynamically nodes from a schema.

  • Attribute Type is set to InstantiationCommandNode.
  • Property SchemaId must be set
PropertyDescriptionData Type
SchemaIdId of the schema to instantiateSystem.Guid
ExecuteModeIf the ExecuteMode = true, all workflows in the schema are automatically started.System.Boolean

Example

{
"Id": "F80F0B87-40DA-4DA2-B5A2-0DD853CCC082",
"Name": "MyCommand",
"Type": "InstantiationCommandNode",
"Properties": [
{
"Name": "SchemaId",
"DataType": "System.Guid",
"Value": "D395F890-03C1-44F3-9CF7-1FF34FEEDA5F"
}
]
}

Command Proxy Node

The command proxy node allows to call C# compiled code of a HumanOS plugin.

  • Attribute Type is set to InstantiationCommandNode.
  • Property CommandType must be set
PropertyDescriptionData Type
CommandTypeC# class type and assembly name of the command implementationSystem.Type

Example

{
"Name": "HumanOS.Service.IdentityService.SessionCleanupCommand",
"Id": "CB00EE4E-AAE6-4C01-A9D8-C8E949D5AC6F",
"Type": "CommandProxyNode",
"Properties": [
{
"Name": "CommandType",
"Value": "HumanOS.Service.IdentityService.EntityModel.Commands.TSessionCleanupCommand, HumanOS.Service.IdentityService.EntityModel"
}
]
}

CommandNode Extension for UHAL Plugins

For device information model, only the command type CommandNode is supported.

AttributeDescriptionData Type
AddressDevice addressSystem.String
ScriptFile[OPT] If address is empty, a script file can be specified. This allows to implement some kind of a UHAL logic.System.String

Example of a device command:

{
"Id": "8FEDA09C-C947-4A56-9703-59A6662B0E9F",
"Name": "WriteMDI",
"Type": "CommandNode",
"Address": "Nc1.writeMDI",
"Arguments": [
{
"Name": "Content",
"Type": "Input",
"DataType": "System.String",
"Description": "Content"
}
]
}

Example of a UHAL logic command:

{
"Id": "1247ECB2-A5C2-4793-B5C8-3A8B816458BD",
"Name": "WriteToolToTag",
"Type": "CommandNode",
"ScriptFile": "Balluff_Logic_WriteToolToTag.cs",
"Arguments": [
{
"Name": "Id",
"Type": "Input",
"DataType": "System.Guid"
},
{
"Name": "TagId",
"Type": "Input",
"DataType": "System.String"
}
]
}

Troubleshooting

Wrong command type

If you receive a message like Command of type 'CommandNode' does not contain executable code (depending on your command type), check if you selected the correct command type. For example this can happen, if you have a script command node but declared the command as CommandNode, whereas the correct type would be CSharpScriptCommandNode.