To find out which statechart's state is currently active, use the statechart's getState() or getActiveSimpleState() function. Both functions do the same - they return the current active simple state of the statechart.
For instance, to get the current active state of the agent's statechart from the action of the agent's event or some other element, call:
To check whether an agent is currently in some particular state of its statechart, you can use the statechart's isStateActive() function. The function returns true if the specified state is currently active, and false otherwise.
You can also use the inState() function of the agent for the same purpose.
In the code of this agent-truck (and in actions of any elements defined on its diagram), simply call inState(Moving).
When you call this function from the code of the truck's owner (e.g., from Main), start the function call with referring to this agent-truck:
How can we improve this article?