You are currently viewing 应用笔记 | TSMaster快速入门篇(1)-系统变量

Application Notes | TSMaster Quick Start (1) - System Variables

This article introduces you to an important concept of TSMaster - system variables. System variables can be used to monitor signals, convey information, and can be used in automation as well as testing and many other areas. Almost all of TSMaster's functions are related to system variables.

1. Overview

Variables that can be directly accessed by the user when using Panel, Scripting, Calibration, Diagnostics or other extended functions are defined as System Variables. According to the principle of system variable generation, there are two main types: Internal Variable and User Variable. Their main differences are:

➢ Endogenous system variables are automatically generated and released by the system, and users cannot directly add or delete them;

➢ User-defined variables are created and managed by the users themselves

The system variable system architecture is shown below:
To view the currently available system variables, users need to open the system variable management interface according to the path Simulation->System Variable, as shown in the following figure:

2. Internal Variables

Endogenous system variables are automatically generated and released following the system. Common endogenous system variables are shown below:

  1. System Information
  2. Equipment Statistics
  3. Small program variables.
Take the device statistics as an example, if CAN1 device is added, only the statistics related to StaticsCAN1 will be generated dynamically; if CAN1 device is deleted, these statistics will disappear. With the upgrading of the TSMaster software system, more such dynamically generated and loaded data types will be added later.

3. User Variables (system of user-defined variables)

This type of variable is user-defined and the user can perform operations such as adding and deleting.

➢ The first step: in the system variable management interface, right click, click: create user variables
➢ Step 2: Setting the properties of user variables

Name: The name of the variable.
Category: The group to which the variable belongs to, so that the user can manage the variable, the same name may be used in different applications.
Comment: Add some comments and descriptions to the variables.
Data Type: Variable types, including Plastic and Float. Expand for details.
ReadOnly: whether the variable is read-only or not, if it is read-only, the user cannot modify it.
Minimun Value: The minimum value allowed for this variable.
Maximum Value: The maximum value allowed for this variable.
Current Value: The current value of the variable.

➢ Once added to the system it is shown below:

4. System variable data types

TSMaster system variables mainly contain the following data types: Int32, UInt32, Int64, UInt64, UInt8 Array, Int32 Array, Int64 Array, double ,double Array, string, as shown below:

The significance of their respective representations is as follows:
Int32: Signed 32-bit type, can cover Int8, Int16, etc.
UInt32: Unsigned 32-bit type that covers UInt8, UInt16 and other data types.
Int64: Signed 64-bit data type.
UInt64: Unsigned 64-bit data type.
UInt8 Array: Unsigned 8-bit array, also known as the most commonly used Byte array. For data types, when assigning values, theArray elements are separated by ';'., as shown below, is equivalent to an array defined as:
UInt8 Var6[5] = {12,34,56,78,90};

➢ Int32 Array: integer 32-bit array type with array elements separated by ';'.
➢ Int64 Array: integer 64-bit array type with array elements separated by ';'.
➢ Double: Double precision data type.
➢ double Array: double precision array type, array elements are separated by ';'.
➢ string: string data type.

5. Access to system variables

Both endogenous and user-defined variables are accessed in exactly the same way. Two main application scenarios are described:

  1.  Panel Associated System Variables
  2. Reads and writes system variables through scripts.
1. Panel Linked System Variables

The Panel Associated System Variables process is shown in the figure above:

  1. The control association variable type is selected as SystemVar.
  2. Double-click to expand the Variable Selection panel.
  3. Just select Built-in System Variables and User Defined System Variables on the panel.
2. Scripts read and write system variables

As shown in the above figure, in simple terms, the access to system variables mainly uses two types of functions, which are located under the APP directory of the applet Function.

Write variables:
On the function parameters, etc., click to select the function over, the upper right corner of the function will be presented in the use of the instructions, as shown in the figure below:
➢ Reading variables:
The scripting system is given the ability to access internal script variables across scripts, based on the set_system and get_system functions.