PIStudio Manual
Search…
⌃K

9.1 Script type

Introduction
Script is applied to realize complex control functions. HMI compile software provide powerful function, simple operation, reliable script system, the features of script are list as follow:
1) Similar to BASIC grammatical structure;
BASIC work as the first computer language for the general public, it is easy and efficient to use.
2) Support all of program logic control structures;
Software script supports three logic control structures: order, condition, loops. It could realize complexity procedures.
3) Powerful function; Functions of script are divided into two types: system and custom function.
  • System function: the functions that system has been predefined for users.
  • Custom function: users could define a function and apply to all scripts.
  1. 1.
    Support variety of data format;
Script supports integer, floating, BCD code, byte, string and etc.
Scripts have two types of running
1) Background script: Run independently during start project, screen updates have no influence and valid of all scripts.
2) Screen script: Only run under the designated screen. Screen script start running until screen is closed or switched.
And both screen and background have four modes for script
Property
Description
Initialize
The script would be executed once during loading project.
Close
The script would be run once during closing HMI project.
Timing
The script would run under certain conditions after the HMI is started, until the condition ends.
Bit trigger
Script would be repeat executed when meet the condition of bit trigger.

Initialize

Introduction
Initialize script divided into screen initialize script and background initialize script. Screen initialize script runs once during the initialization of screen; background initialize script runs during the loading of project.
Operating procedures
  1. 1.
    Click [Background script] in project manager to enter script editor screen, or click [Screen script] in right click menu of screen to enter script editor screen;
  1. 1.
    Double click [initialize] to open script edit window, as below shows;
  1. 1.
    Enter scripts in edit window;

Close

Introduction
Close script divided into screen close script and background close script. Screen close script runs once During the destroying of screen because of closing or switching; background close script runs during the closind of project (such as restart HMI, into HMI setup).
Operating procedures
  1. 1.
    Click [Background script] in project manager to enter script editor screen, or click [Screen script] in right click menu of screen to enter script editor screen;
  2. 2.
    Double click [Close] to open script edit window;
  3. 3.
    Enter scripts in edit window;

Timing

Introduction
The script would run for a designated time interval.
Operating procedures of creating one
1) Click [Background script] in project manager to enter script editor screen, or click [Screen script] in right click menu of screen to enter script editor screen;
2) Double click [Timing], it would pop-up below setting window;
Property
Description
Cycle
Script runs at designated time interval, unit is 10 ms.
Ok
Script created.
Cancel
Cancel the current script setting.
3) Enter scripts in edit window;
Operating procedures of editing
1) Click [Background script] in project manager to enter script editor screen, or click [Screen script] in right click menu of screen to enter script editor screen;
2) Select [Timing], and click [
] to modify the script execution interval;
3) Double click selected [Timing] to open editing window;
Operating procedures of deleting
1) Click [Background script] in project manager to enter script editor screen, or click [Screen script] in right click menu of screen to enter script editor screen;
2) Select [Timing], and click [
] to change interval of script, it pops-up above window
3) Select [Yes] to execute operation or select [No] to cancel operation;
Note:
The maximum number of timing script for each screen or background is 32.

Trigger bit

Introduction
Trigger control script is that software will check whether the designated bit meet trigger condition every 20ms. Script execute once condition is met until project closed.
Operating procedures of creating one
1) Click [Background script] in project manager to enter script editor screen, or click [Screen script] in right click menu of screen to enter script editor screen;
2) Double click [Trigger bit], it pops-up below setting window;
Bit address: It sets trigger address for script;
Condition: detailed information as below shows;
Condition
Description
TRUE
Script execute once the bit value is TRUE, it checks trigger bit every 20 ms;
FALSE
Script execute once the bit value is FALSE, it checks trigger bit every 20 ms;
Bit changed
Execute once the trigger bit switches state;
Rising
Script execute once the bit value from FALSE to TRUE, it checks trigger bit every 20 ms;
Falling
Script execute once the bit value from TURE to FALSE, it checks trigger bit every 20 ms;
3) Set trigger bit and condition, click [OK] to open editing window;
Operating procedures of editing
1) Click [Background script] in project manager to enter script editor screen, or click [Screen script] in right click menu of screen to enter script editor screen;
2) Select [Trigger script], and click [
] to change trigger bit and condition;
3) Double click selected [Trigger script] to open editing window;
Operating procedures of deleting
1) Click [Background script] in project manager to enter script editor screen, or click [Screen script] in right click menu of screen to enter script editor screen;
2) Select [Trigger script], and click [
] to change interval of script, it pops-up below window
3) Select [Yes] to execute operation or select [No] to cancel operation;
Note:
The maximum number of trigger script for each screen or background is 32.

Background Function

Introduction
Global function is a collection of codes; it can be called in any script. The method reference system function;
Operating procedures
1) Double click [Background function] in project manager;
2) Set parameters;
Property
Description
Function name
Function name could not be the same as existing.
Return type
None, string, integer, float.
Parameter 1
The name of parameter 1.
Operating procedures of editing
1) Click [Background function] in project manager to enter script editor screen;
2) Select Function name, and click [
] to change parameters;
3) Double click selected [Trigger script] to open editing window;
Operating procedures of deleting
1) Click [Background function] in project manager to enter script editor screen;
2) Select Function name, and click [
] to change interval of script, it pops-up below window
3) Select [Yes] to execute operation or select [No] to cancel operation;
Note:
The maximum parameters for each function are 4, and parameter name can't be unique;