Versions Compared

Key

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

On this page

Table of Contents
maxLevel4

Getting the current State of a runtime object

You can use the following ALH API to get the current State of a specified object. If the object has more than one active State, it returns the first active state. The API returns the instance of the state.

Code Block
languagetext
ALH.getState(object)

The following code fragment shows how to get the current state of a specified object using ALH API:

Code Block
languagetext
ALH.getState(self);
ALH.getState(self).getName()        //To get name of the state instance use .getName()

Checking the State of an object

You can use script to check state of an object. You can use the fUML object syntax, with object.in("stateName"). For example:

  • self.in("Operating");

Alternatively, you can check the state of an object using ALH API. The API returns the Boolean value.

Code Block
languagetext
ALH.inState(object, "stateName")
ALH.inState("stateName")                // Returns true or false.

Unless the object is specified, it will use the current active object, for example:

Code Block
languagetext
if (ALH.inState("Operating")) {
	force=ccForce
} else {
	force = acc*2
}

Checking a visited State

You can use following ALH API to check the visited state. You can check whether a specified State was visited by calling the following command.

Code Block
languagetext
ALH.wasInState("stateName")

The following code fragment shows how to check whether a specified State of State Machine, e.g., State1, was visited through ALH API.

Code Block
languagetext
ALH.wasInState("State1");	// Returns true or false.

Checking if an activity is being simulated

You can use the script to check if an object performs a specific activity. You can use the fUML object syntax with object.performs("activityName"). For example:

  • self.performs("Driving");

Checking if an object is busy

You can use the script to check if an object performing any behavior. You can use the fUML object syntax with object.isBusy(). For example:

  • self.isBusy();