getCommandList Function

The getCommandList method returns the list of commands associated with a property. If the property is not specified, the result will contain the commands associated to the object (meaning that the command alias is defined).

Syntax

It is possible to retrieve the list of the commands defined for a specific property. See the following syntax:

 

(one instruction)

var result = getCommandList(<objectReference>, <propertyName>, <filterCommands>, <commandName>)

 

(two instructions with variable)

var obj= new BrowserObject(<objectReference>);

var result = getCommandList(obj, <propertyName>, <filterCommands>, <commandName>)

Parameters Usage

Parameter

Type

Default

Use

Annotation

objectReference

String

BrowserObject

Point

-

Mandatory

CNS full path (reference to the system object location).

propertyName

String

-

Mandatory

Name of the property whose commands are concerned.

filterCommands

Boolean

True

Optional

Whether to filter the list of commands based on commands availability.

If this flag is True, the command list is filtered by availability, so that only the commands available at that moment will be retrieved.

If this flag is False, all the commands defined on the specified property are returned, regardless of their availability.

commandName

String

-

Optional

String to match to filter the list of commands based on the command name.

Result

  • If the operation of getting the list of commands is successful, the getCommandList method returns the CommandListResult object that contains the list of commands included in the Command collection. In case no commands are available for the specified property, CommandListResult is null.
  • If any errors occurred during the get list of commands operation, the getCommandList method returns the CommandListResult object with the error property that indicates the reason why the operation failed.

Error Handling

Errors can occur in case:

  • The object is invalid
    • result.error: "Node not found"
  • <objectReference> is empty
    • result.error: "The object reference is empty"
  • <propertyName> is empty or invalid
    • result.error: "The DPID could not be resolved."
  • <filterCommands> type is invalid
    • result.error: "Invalid input"
  • <commandName> type is Invalid
    For example, if a numeric value is used for the command name, the default command name is used (empty string); and all the commands will be returned.
    • result.error: " "

Examples of Use

 

How to access and print to Console the result of a getCommandList call

function printCommandList(commandList) {

    if (commandList.error) {

        console("Error retrieving command list: {0}", commandList.error);

        return;

    }

        for (var i = 0; i < commandList.commands.length; i++) {

        var cmd = commandList.commands[i];

        if (cmd != null)

            console("Label = '{0}'; Name = '{1}'; Alias = '{2}'", cmd.label, cmd.name, cmd.alias);

    }

}

 

Another way to print the result of the call is, for example:

console(result);

 

How to get the list of all the commands defined for the property Out_Of_Service of a BACnet Analog Input point

var result = getCommandList("System1.ManagementView:ManagementView.FieldNetworks.MyBACnetNet.Hardware.5000/5000SimDev1_5000.5000/0Local_IO.5000/1AI_1", "Out_Of_Service", false);

printCommandList(result);

 

The output in the Console expander is:

Label = 'Out Of Svc'; Name = 'Out Of Svc'; Alias = ''

Label = 'In Service'; Name = 'In Service'; Alias = ''

Label = ''; Name = 'Write'; Alias = ''

 

How to get the list of the commands currently available for the property Event_State of a BACnet Multistate Input point (default values for <filterCommands> and <commandName> omitted)

var result = getCommandList("System1.ManagementView:ManagementView.FieldNetworks.MyBACnetNet.Hardware.5000/5000SimDev1_5000.5000/0Local_IO.5000/1MI_1", "Event_State");

console(result);

 

The output in the Console expander:

Label = 'Ack All'; Name = 'Ack All'; Alias = 'BlockAck (7)'

Label = 'Ack OffNormal'; Name = 'Ack OffNormal'; Alias = 'Ack (5)'

Label = 'Ack Fault'; Name = 'Ack Fault'; Alias = 'AckFault (27)'

Label = 'Ack Normal'; Name = 'Ack Normal'; Alias = 'Reset (6)'

 

How to get the list of the commands currently available for the AutomaticStart.State property of a BACnet driver point

var object = new BrowserObject("System1.ManagementView:ManagementView.ManagementSystem.Servers.Server.Drivers.GmsBacnetDriver_1");

var result = getCommandList(object, "AutomaticStart.State", true);

console("{0}", result.toString());

 

If the BACnet driver is not running, the output in the Console expander is the following:

Label = 'Start'; Name = ''; Alias = 'Start (32)'

Label = 'Start Config Mode'; Name = ''; Alias = ''

 

If the BACnet driver is running in configuration mode, the output in the Console expander is the following:

Label = 'Stop'; Name = ''; Alias = 'Stop (33)'

 

How to get the list of the commands that have name "Write" for the property Value of the "Day and Night" Organization Modes

var object = new BrowserObject("System1.ManagementView:ManagementView.SystemSettings.OrganizationModes.DayNight");

var result = getCommandList(object, "Value", false, "Write");

printCommandList(result);

 

The output in the Console expander is:

Label = 'Set'; Name = 'Write'; Alias = ''

 

In a valid configuration the Name is uniquely defined on a property, consequently filtering by name should always return only one command.

If the Name is defined more than once for the same property, the configuration error is detected and traced as warning in the Trace Viewer. Nonetheless, the getCommandList method returns all the commands matching the specified name.