NEW RELEASE! The 2024x Refresh2 Hot Fix 1 was released on May 2, 2025. For more information, see 2024x Refresh2 Hot Fix 1 Version News.

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.

ALH.createSignal("name")
ALH.createSignal(signal)

The following example demonstrates how to create a Signal Instance:

ALH.createSignal("start");
ALH.createSignal("statemachine::signals::start");
ALH.createSignal(s);            // if 's' is an instance of a Signal.

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. 

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

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$.

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

ALH.getLastSignal(self);

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.


Activity

All
Personal filters
All