gp-pro ex quick start guides d-script & global d-script...pftr07_cls01revb introduction ¾the...

25
PFTR07_CLS01REVB GP GP - - Pro EX Quick Start Guides Pro EX Quick Start Guides D-Script & Global D-Script 1

Upload: others

Post on 03-Aug-2021

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

GPGP--Pro EX Quick Start GuidesPro EX Quick Start Guides

D-Script & Global D-Script

1

Page 2: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

D-Script

Overview:– This chapter explains how to use D-Script and Global D-Script

to enhance custom operation in GP-Pro EX.

Objective:– At the end of this chapter you can:

• Add, Edit and Remove (Global) D-Scripts• Identify the differences between D-Script and Global D-Script• Create Custom Functions• Use basic operators• Find advanced Script functions

Page 3: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Introduction

The script language in GP-Pro EX is calledD-Script. It can be further divided in:– D-Script

• A D-Script only work when the base or window screen it was created on is active.

– Global D-Script• D-Script that works anywhere in the project

– Extended Script• D-Script use specifically to communicate to external devices

using ASCII character transmission• Extended Script is covered in dedicated chapter

Page 4: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Editing Scripts

Global D-Scripts can be created at any time by selecting the Global D-Script icon or by using the Common Settings > Global D-Script menu. Up to 32 Global D-Script can be used.D-Scripts can be created when a base or Window screen is opened in theeditor by selecting its icon or viathe Parts > D-Script menu. D-Scripts are displayed at thebottom of a screenin the editor

Page 5: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Script Editor Components

Workspaces Status Area

Trigger Condition

Script Data Type

Address Entry

Formula Area

Tabbed Script DisplayToolbar

Page 6: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Example

D-Scripts uses assignment based statements.The result of an action is stored in the leftmost address in the statement.This example shows a simple up counter with a 1 second triggerincrementing LS20by 1 until it reaches100 after which it will reset to 0

Page 7: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Trigger Condition

The following script triggers can be used:– Continuous

• Always active, as fast as possible after higher priority processes are completed each processing cycle

– Timer• Runs every 1 to 65535 Seconds

– Bit On / Off / Toggle• Runs when Bit turns On, Off or any state change

– Expression True / False• Runs when an expression becomes true or becomes false.

(edge trigger, not a “while” trigger)

Page 8: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Formula Window

Functions are entered in the Formula WindowThe message area can display warning and script error messages that refer to a specific row number in the formula area.Use the “Input Address” link to enter a Device/PLC, Internal or Variable addressUse // to enter a commentanywhere in the script.

Page 9: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Custom Functions

User Defined Functions can be created in any script and reused in any other script.The Call function is used to triggera function.Functions helpscript editing. Use for recurringor 32bit functionsin mostly 16 BitScripts.

Page 10: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Tool Box

Use the Tool Box workspace to enter the correct syntax for commonly used expressions.Click any item in the list to place it at the cursor location in the active formulawindow.

Page 11: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

If /else / endif Statements

Use the Tool Box to enter the full If / Endif or If/Else/Endif syntax in the formula window.TIP: Typing “If” in the formula window will automatically create the correct syntax.Up to 8 If (else) statements can be nested.

//Nested If Statement Exampleif([w:[ML1000_DF1]N007:000] <= 100){

[b:[ML1000_DF1]B003:000/00] = 1if([b:[ML1000_DF1]B003:010/05] == 0){

[w:[#INTERNAL]LS0100] = 12345}endif

}else{

[b:[ML1000_DF1]B003:005/00] = 0}endif

Page 12: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Loop statements

Use the Tool Box to enter the correct Loop syntax.TIP: typing Loop will also create the statementA Temp address has to be selected for each loop, assign a number to the Temp address before the loop statement.Note that the loopcounts down, notup (100, 99, etc)

//Loop Example[t:0000] = 100loop([t:0000]){

if([w:[ML1000_DF1]N007:000] <> 1000){

[w:[ML1000_DF1]N007:000] = [w:[ML1000_DF1]N007:000] + 1}else{

break}endif

}endloop

Page 13: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Function Workspace

The function workspace is divided in the Function List and User Defined Functions section.The Function List gives access to advanced D-Script operationsThe User Defined Functions areais used to call, display and edit customfunctions that can be reused in anyscript.

Page 14: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Functions – Draw Instructions

The Circle, Dot, Line and Rectangle functions draw the selected object on the active screen.Most setting can be replaced by an address.The Call Screen function loads the specified screen number on top of the currently active screen. (If it is the same screen thisacts like a refresh)Call Screen is a drawing function:active parts (like switches) will bedisplayed on the active screen as adrawing, not as an active part.

Page 15: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Functions – Memory Operations

Offset Address:– Writes the result of an expression to an offset of the

selected destination address.Compare Memory:– Compares ranges of registers.– Useful for comparing loaded vs edited

recipesCompare Memory (Variable):– Same as compare memory but all

parameters can be assigned duringruntime.

Page 16: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Functions – Memory Operations

Ring Shift Memory:– Cycle through values in an address range, moving

each value into the next address in the range. The value in the highest address will be stored in the lowest address in the range

Search Memory:– Sets a range of addresses as search

item and searches for a match in a second range of addresses for this item

Initialize Memory:– Set a range of addresses to a specified

value in a single command.

Page 17: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Functions – Memory Operations

Initialize Memory (Variable):– Like Initialize Memory but all parameters can be

assigned during runtime.Shift Memory:– Like Ring Shift Memory but the values

are not moved from the highest to thelowest address. The data will “fall off”

Page 18: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Functions – SIO Port Options

SIO Port Operation functions can be used to send and receive ASCII characters when the Script I/O Settings in System Settings are set to D-Script/Global D-Script.This function is covered in the Extendedscript module

Page 19: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Functions – Bit Operations

The “Bit Settings” and “Clear Bit” functions are rarely used, to set or reset a Bit address the following expressions are quicker to create: [bit address] = 1 //Bit Set[bit address] = 0 //Bit ResetThe “Bit Toggle” function is a time saving statement that will invert thespecified bit.

Page 20: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Functions – CF Card & USB Operations

Using the CF File and USB File functions custom CSV files can be saved to and read from a connected CF Card or USB MemoryThis extremely powerful function can be used to create custom report files or a fully customized logging system if thesampling data feature does not fullycover the applications requirements.

Page 21: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Functions – Printer Instructions

Use the Send function in the Printer Operation list to send data to an attached printer.The PRN_CTRL and PRN_STAT labels can be used to catch and clear printer errors

Page 22: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Functions – Other

The Debug Function allows you to add direct output to the AGP screen. Output can be Text, a register value or the value of a temp address.Debug statements can be left in thescript, simply turn the function offto prevent output to the screen oron when debugging scripts.Note: Start App & Exit functions are forWinGP only.(not covered in this module)

Page 23: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

D-Script List

The D-Script List contains all scripts configured for the current Base or Window screen or all Global D-Scripts.Use the D-Script List workspace to open multiple scripts. Each script will bedisplayed as a tab in the editor.

Page 24: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Search & Replace Workspace

Use the Search Workspace to find and or replace text in any open script in the Script Editor.

Page 25: GP-Pro EX Quick Start Guides D-Script & Global D-Script...PFTR07_CLS01REVB Introduction ¾The script language in GP-Pro EX is called D-Script. ¾It can be further divided in: – D-Script

PFTR07_CLS01REVB

Questions

Please refer to the Reference Manual that is installed along with GPPRO-EX.

Manuals are also available on-line at:

http://www.hmisource.com/otasuke/download/manual/

For further support please e-mail: [email protected]

Or call: +1 734 429-4971