Script Engine

Z-Tool

Script Engine

Script Engine is a predefined global object, which can be accessed anywhere in a script.  The name of the Script Engine is ZEngine. Script Engine contains the following members

Methods

Complete(bool status)

Quit current script with complete status.  Passed or failed result was produced.

 

Parameters

   status: true for passed, false for failed

 

Example

    ZEngine.Complete(true);

Pause()

Pause current script until a key is pressed.

 

Example

    ZEngine.Pause();

Pause(int milliseconds)

Pause current script for specified number of milliseconds

 

Parameters

    milliseconds: number of milliseconds to pause

 

Example

    ZEngine.Pause(1000);

Send(string deviceName, object message)

Send the specified message to the specified device

 

Parameters

    deviceName:  name of the device.  Name is defined in Settings -> Alias field

    message:  message to be sent

 

Example

    var req : SYS_VERSION = new SYS_VERSION();

    ZEngine.Send("Device1", req);

WriteLog(string textMsg)

Display the specified text on the Script Window log panel

 

Parmeters

    textMsg:  text message to be displayed

 

Example

    ZEngine.WriteLog("The quick brown fox jumped over the lazy dog");

Events

OnMessageZPI1(string deviceName,

                              ZPI1.MESSAGE_ID messageID,

                              Object msg)

Subscribe to Script Engine to receive incoming messages.  Used for old Serial Interface format.  To subscribe, use ZEngine.add_OnMessageZPI1(this.MessageHandler).  To unsubscribe use ZEngine.remove_OnMessageZPI1(this.MessageHandler)

 

Parameters

    deviceName:  name of device which message is coming from

    messageID:  ID of the message

    msg:  received message

 

Example

    ZEngine.add_OnMessageZPI1(this.MessageHandler);

    function MessageHandler(zportName:String, id:MESSAGE_ID, msg:Object)

    {

    }

OnMessageZPI2(string deviceName,

                              ZPI2.MESSAGE_ID messageID,

                              Object msg)

Subscribe to Script Engine to receive incoming messages.  Used for new Serial Interface format.  To subscribe, use ZEngine.add_OnMessageZPI2(this.MessageHandler).  To unsubscribe use ZEngine.remove_OnMessageZPI2(this.MessageHandler)

 

Parameters

    deviceName:  name of device which message is coming from

    messageID:  ID of the message

    msg:  received message

 

Example

    ZEngine.add_OnMessageZPI2(this.MessageHandler);

    function MessageHandler(zportName:String, id:MESSAGE_ID, msg:Object)

    {

    }