/
13.2 Commands

13.2 Commands

Canvas also includes an easy-to-use feature that allows the user to create lists of commands to be completed without the use of scripting. These command lists can be tied to the change in a tag value, opening and closing the page, and other actions, similar to a script.

In the Command Editor, there are two command types:

  • Global Commands: This command type can be created using the Script Editor or Command Editor in the Action property for an object, and can be used by any object in the project. Editing the commands will affect all objects that use the script.

  • Local Commands: This command type can only be created using the Command Editor for an object Action property and can only be used by the object where the command is being created. Copying and pasting the object will create a new copy of the local commands. Editing local commands will only affect the object that the commands belong to.

At runtime, command lists are treated like regular scripts. You can view the generated JavaScript code by double-clicking a command list in the Script Editor.

Global Commands

Method #1

Click Tools > Script Editor… > click + icon > Create New Commands.

Method #2

Click an object > Action tab > click the Action drop-down menu > select Create New Commands. In the Command Editor, click the Local Commands drop-down > select Global Commands.

Local Commands

Click an object > Action tab > click Action drop-down menu > select Create New Commands.

The Command Editor Window

Creating or editing a command list will bring up the Command Editor window. Here, the user can add or remove commands from the list, and individual commands can be edited.

The Command List

The section on the mid-lower left shows all of the commands in the list. Selecting a specific command will let you edit its properties. When the command list is triggered at runtime, these actions will be executed in the order shown.

Command List Properties

The section in the top left lets you change the properties for the command list as a whole. You can also change the order of commands in the list using the arrow icons and check for errors using the validate icon.

Item

Description

Item

Description

Adds a new command to the list.

Deletes the selected command from the list.

Copies the selected command to the clipboard.

Pastes a single command from the clipboard into the command list.

Moves the selected command up in the list.

Moves the selected command down in the list.

Validates the command list and displays any errors in the output area.

Name

Set a name for the commands. Defaults to “New Commands”. Note that local commands do not allow you to choose a name. For global commands, this name will be shown in the Script Editor and in dropdowns when selecting an action for an object.

Global/Local

Choose whether the commands will be global or local. Defaults to global when creating through the Script Editor, and local when creating through an object. Local commands are not visible in the Script Editor, and can only be bound to one object. You may change a local command list to be global using this dropdown.

Description

Enter an optional description for the command list.

Adding a Command to the List

By default, a command list has no commands in it. To add one, click one of the Add New Command shortcuts:

Alternatively, you can make a copy of an existing command list by selecting one from the Copy Existing Commands dropdown and selecting Confirm. Editing the new copy will not affect the original.

Configuring Individual Commands

In the main section of the Command Editor window, the user can specify what the selected command will do.

First, choose one of the pre-defined actions from the “Command” drop-down, then set any additional properties.

The table below lists the functionality and properties of each command type.

Commands

Functions

Description

Commands

Functions

Description

Open Page

page.open("Page Name");

Opens the selected page. Users can select the page by name or by its unique index.

Close Page

page.close("Page Name");

Closes the selected page. Users can select the page by name or by its unique index.

Set Tag Value

tag.write("Tag Name", 7);

Sets the selected tag to a specified value. Users can select a constant value to write to the tag, or write another tag’s value to the selected tag.

Example 1: Write a specific value (7) to a tag (“Tag Name”).

Example 2: Write the value of another tag (“Other Tag“) to a tag (“Tag Name”).

Toggle Tag Value

Toggles the selected tags' value between 1 and 0.

Enter Tag Value

Open a pop-up keyboard that allows the user to enter a value to be written to the selected tag. Users can write numeric or string values to a tag.

Line 1: Launch a keypad requesting user input that will be stored to the “ANA” tag.

Lines 2-3:  Keypad will have a header and subheader title if assigned. This can be used to tell the operator what value is being requested.

Lines 4-5: Set the location for the keypad on the Xpanel screen.

Lines 6-7: Set the minimum and maximum values a user can enter.

Line 8: The value entered will appear in a chosen format. “H,HHH” is for the hexadecimal formatting, and “#,###” is for the decimal formatting.

Call Script

Runs the selected script.

If the “Run on separate thread” options is selected, the script will be run on a separate thread (system.runScript). If the option is unselected, the script will be run on the same thread (system.importScript).

Leave the “Run on separate thread” option unchecked if you want scripts to execute in the specified order.

Line 1: When the box is unchecked, the selected script will run in the current thread. This will pause the calling script until the imported scripts has completed. The order of execution is guaranteed.

Line 2: When the box is checked, the selected script will run in a new thread. This will not interrupt the operation of currently running scripts. The order of execution is not guaranteed.

Enable/Disable Schedule

Enables or disables the selected runtime schedule.

Line 1: Enabled the selected schedule.

Line 2: Disables the selected schedule.

Save Alarm CSV

Saves a log of all alarm events to a CSV. Users can select to save the file locally on the Xpanel, to a USB, or to an SD card.

You may choose where the CSV will be stored to: Local (on the device’s hard drive), USB, or SD Card.

The default CSV locations are as follows:
/run/media/mmcblk3p4/cimon/gateway/alarm_csv/ (Local)
<root directory>/alarm_csv/ (USB/SD Card)

Users can also delegate a specific alarm label to be saved in the CSV, in which case all other labels will not be included in the CSV.

Line 1: Saves a CSV for all alarm labels.

Line 2: Saves a CSV for alarms that have the specified label.

Save Data Log CSV

Saves the selected Data Log to a CSV file.

You may choose where the CSV will be stored to: Local (on the device’s hard drive), USB, or SD Card.

The default CSV locations are as follows:
/run/media/mmcblk3p4/cimon/gateway/datalogger_csv/ (Local)
<root directory>/datalogger_csv/ (USB/SD Card)

You may also choose how far back in time the CSV should cover. Options include (All, Past Hour, Past Day, Past Week, Past Month, and Past Year).

Start/Stop Data Log

Starts or stops a data log model. This function does not directly create an entry into the log; it only enables entries to be added via other triggers.

Line 1: Start the Data Logging actions

Line 2: Stop the Data Loggers action

Add Row to Data Log

Adds a new entry to the Data Log.

Open Login Window

Opens the built-in IAM login window.

Logout User

Logs out the current user from the IAM system.

Press Key

Enters the user specified keystroke. Function codes are used to enter specific key strokes, those key codes can be found at the following link:

Qt Namespace | Qt Core 5.15.10

Send Screen Notification

In the runtime, notification window will appear on the Xpanel screen.

Exit Project

Exits the project and canvas runtime.

Open Config Menu

Opens the Xpanel Settings menu.

Set Translation Language

Sets the language according to the one specified in the Action List.

 

Validating and Applying the Commands

The Command Editor window has a section at the bottom that lists any found issues. This list can be refreshed by pressing the Validate icon. As with scripts, validation is not required but is recommended.

Item

Description

Item

Description

Validation Issue List

Lists any errors or warning associated with the command list. These will disappear after fixing the errors. Any syntax errors in an “Insert Custom Script” command will be listed here.

Unbind

Applies any changes and removes the commands from the selected action. When using a local command list, this will delete the commands. When using a global command list, the commands will still be available in the Script Editor and other script dropdowns.

OK

Applies any changes and binds the commands to the selected trigger.

Cancel

Undoes any changes made while the Command Editor window was open. If you were creating a new command list, the commands will be deleted.

Related content