Customising SystemLink Dashboards Using Event Scripts and Virtual Tags

Updated Aug 8, 2024

Environment

Software

  • SystemLink

This article demonstrates how to make use of Event Scripts and Virtual Tags in SystemLink to customise a Dashboard.
This is useful for:
  • Programmatically updating Widgets
  • Linking and binding Widget values
  • Creating custom display options
Event Scripts are sections of Python code used to retrieve and set tag or Widget properties. They can also consist of logic to evaluate tag data.
Virtual Tags are tags that only exist in the Dashboard. They are created by passing the value of a real tag into a Python function to update the Virtual Tag.

For demonstration purposes, this example Dashboard links a Text Box Input and Text Box Output, and binds a Virtual Tag to the value of an LED Output. Follow the relevant sections below to implement this functionality.


Creating a Freeform Dashboard


1. Navigate to your SystemLink Server URL in a browser.
2. From the menu, select Custom Applications >> Dashboards.

Dashboard panel.PNG
Image of the SystemLink menu.


3. Click the drop-down arrow next to NEW TILE DASHBOARD and select New freeform dashboard.

new freeform dashboard.PNG
Image of the NEW TILE DASHBOARD button.


4. Give the Dashboard a name and description, and select the Workspace to save it to. Click OK to save your changes.
  • Workspaces are used to control which systems and data different types of users can interact with. Refer to Creating a Workspace for more help.

free form dashboard name.PNG
Image of the Dashboard creation settings.


 

Using Event Scripts to Link Widgets


1. Open the Dashboard in edit mode if this isn't already the case.
  • Click the ellipsis in the top-right corner and select Edit.

Edit Dashboard.PNG
Image of the Dashboard Edit menu.


2. From the palette, drag and drop a Text Box Input on the Dashboard.

Text Box Input.PNG
Image of the Text Box Input in the palette.


3. Click the Text Box Input to define a Name in the Property Editor. The image below shows that the Text Box Input is called Textbox1.

Textbox Input name.PNG
Image of the Properties Editor window for the Text Box Input.


4. From the palette, drag and drop a Text Box Output on the Dashboard.

Text Box Output.PNG
Image of the Text Box Output in the palette.

5. In the Properties Editor window, specify:
  • A Name. The example shows a Text Box Output called Textbox2.
  • A Value.
    1. Click the small checkbox to the right of the Value property.
    2. Select the tag icon and change it to Widget.
    3. Enter the name of the Text Box Input's value property inside the field. For a Text Box Input called Textbox1, the field should state Textbox1:value.

Text Box Output Properties.PNG
Image of the Properties Editor window for the Text Box Output.

6. Create an Event Script for the Text Box Input.
  1. Select the Text Box Input.
  2. From the Properties Editor window, click the plus icon underneath the Event Scripts box.
  3. In the Script window, select User input as the Event
  4. Define a function name in the Main Function input. The example below defines a function called main.
  5. Enter the code below to obtain the value property of the Textbox1 Widget and assign this as the Textbox2 value.
    • Note: ensure that Textbox1 and Textbox2 match the names of the Text Box Widgets on your dashboard.
  6. Click OK to save your changes. The Properties Editor should now populate with an Event Script.
def main(Textbox1):
  value = get_widget_prop("Textbox1", "Value")
  set_widget_prop("Textbox2", "Value", value)

User Input Event Script.PNG
Image of the User Input Event Script.


Text Box Input Event Script.PNG
Image of the Properties Editor after creating a User Input Event Script.

7.Save the Dashboard by clicking on the save icon in the top toolbar.
8. Click the play icon to test the functionality.
  • You should observe that entering some text in the Text Box Input and pressing Enter automatically populates the Text Box Output.
dashboard toolbar.PNG
Image of the top toolbar when editing a Dashboard.


Text Box Dashboard.PNG
Image of the Dashboard running after configuring Event Scripts for the Text Boxes.

 

Binding Virtual Tags to Widgets


1. From the palette, drag and drop a Number Output on the Dashboard.
2. Set the Number Output Name to numOutput1.
3. Set the Number Output Value to a tag that you wish to monitor.
  • This example links the localhost.Health.CPU.0.UsePercentage tag to the Number Output. This tag shows the usage of CPU 0 as a percentage.
  • Note: to understand how SystemLink tags work, refer to Monitoring Data with Tags.

Number Output Name.PNG
Image of the Properties Editor for the Number Output.


4. From the palette, drag and drop an LED on the Dashboard.

LED Output.PNG
Image of the LED Output in the palette.


5. Create a Virtual Tag to evaluate whether a tag exceeds a specific value.
  • Click on some blank space in the Dashboard to de-select any Widgets.
  • In the Properties Editor window, click the plus icon underneath Virtual Tags.
  • In the Script window, specify a Name for the function. This example defines a function called checkCPU.
  • Click the plus icon underneath the Input Tags list. Enter the tag path linked to the Number Output. For this example, the Input Tag is localhost.Health.CPU.0.UsePercentage.
  • Click OK to save the Input Tag.
  • Click the plus icon underneath the Output Tags list to create a new Virtual Tag. This example names the Output Tag CPUexceed.value.
  • Click OK to save the Output Tag.
  • In the main Script window, enter the Python code below to set the Output Tag to true only if the Input Tag exceeds a value of 4.
  • Click OK to save the script.
def checkCPU(inputTag0):
  outputTag0 = (inputTag0 > 4)
  return [outputTag0]

Virtual Tag Script.PNG
Image displaying the script for the Virtual Tags.


Dashboard Properties Editor.PNG
Image displaying the Properties Editor after creating the Virtual Tag script.

6. Now that a virtual tag exists, it can be mapped to the LED:
  • Select the LED widget.
  • In the Properties window, set the Value type to tag.
  • Select the CPUexceed.value tag.

LED Properties.PNG

7. Press the play icon in the top toolbar to run the Dashboard.
  • The LED will light up when the CPU usage exceeds 4%.

LED Dashboard.PNG
Image of the Virtual Tags running in a Dashboard.
 

Download the attached .fp file to import this example Dashboard to your SystemLink Server. Refer to Importing a Dashboard for instructions.