Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

id767236619

...

id767236637

...

id767236617

On this page

Table of Contents
maxLevel4

...

Creating a signal instance

You can create Signal Instances by using the following

...

APIs. You can create the signal by specifying its name, its Qualified name, or you can pass the Signal object.

Code Block
languagetext

...

ALH.createSignal(

...

"name")

...

ALH.createSignal(

...

signal)

The following example demonstrates how to create a Signal Instance:

Code Block
languagetext
ALH.createSignal("start");
ALH.

...

createSignal("statemachine::signals::start");
ALH.createSignal(s);

...

            // if 's' is an instance of a Signal.

The parameter of this API can be either a String or a Signal. If it is a String, the system will find a Signal whose name or qualified name contains the String.

Sending a signal instance to a specific target object

You can send

...

Signal Instances by using the following APIs. You must specify the Signal (either by specifying the Signal Name or the Signal Instance) and the Target (either by specifying the Target Name or the Target Object). Optionally, you can specify the Port Name from which the signal is sent. In this case, the target is the owner of the port. 

Code Block
languagetext

...

ALH.sendSignal(

...

"name", 

...

target)

...

ALH.sendSignal(

...

"name", 

...

"targetName")

...

ALH.sendSignal(

...

signal, 

...

target)

...

ALH.sendSignal(

...

signal, 

...

"targetName")

...

ALH.sendSignal(

...

"name", target, 

...

"portName")

...

ALH.sendSignal(

...

signal, 

...

target, 

...

 "portName")

The conditions that apply when creating an Instance are as follows:

  • If a signal name contains "::", it will find the signal from a qualified name. The signal will be found if its qualified name

...

  • ends with signalName.
  • If

...

  • a target is an instance of an fUML Object

...

  • ,

...

  • the signal is sent to

...

  • it directly.
  • If

...

  • a target is an instance of a String, there are two possible cases as follows:
    • It will find the target object(s) from all waiting objects whose part/property names match the

...

    • "targetName".
    • It will find the target object(s) through

...

    • connectors,

...

    • if the "targetName" is the name of the

...

    • port.

The following example shows how to send a specific signal to a specific target object in ALH API

Code Block
languagetext
ALH.sendSignal("play", o);

...

                          // "o" references to a target object.
ALH.sendSignal("system::play", o);

...

                 // Find a signal using a qualified name.
ALH.sendSignal("play", "Speaker");

...

                // Send signal to property with name "Speaker".
ALH.sendSignal("play", 

...

Player

...

, "out2");

...

        // "Player" is an object, and "out2" is a port name owned by that object.

All parameters must not be null. Otherwise, the ScriptEngine errors will be thrown.

Getting the last signal instance from a runtime object

You can use the following API to retrieve the last signal instance from a runtime object. It is equivalent to $signal$.

...

Code Block
languagetext

...

ALH.getLastSignal(Object

...

)

The following code fragment shows how to get the last signal instance in the event pool of a specified object using ALH API

Code Block
languagetext
ALH.getLastSignal(

...

self);

...

It returns the Instance of the following

Tip

To access any property from the last received signal, you can use predefined variable "sig_ + property name". For example, you can use "sig_speed" to get the speed property of the last received signal

...

languagetext

...

.