|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xj.anylogic.engine.Statechart
public class Statechart
Statechart - the most advanced construct to describe event- and time-driven
behavior. Statechart has states and transitions. Transitions may be triggered
by timeouts or rates, messages received by the statechart, and conditions.
Transition execution may lead to a state change where a new set of transitions
becomes active. States in the statechart may be hierarchical, i.e. contain other
states and transitions. The actual structure of state diagram is stored in the
active object.
There are two ways to send a message to the statechart:
- call receiveMessage() method, and
- call fireEvent() method.
receiveMessage() assumes no queuing for incoming messages. If the received message
cannot immediately cause scheduling of a transition, it is discarded. Therefore,
if, for example, there are two transitions: one (from state S0 to S1) triggered by
message A, and another (from S1 to S2) triggered by message B, and the statechart
receives messages A and B at the same time while in the state S0, only first
transition will be taken, and message B will be discarded. This is different to
AnyLogic 5.
fireEvent() supports queuing for incoming messages and has exactly same semantics
as in AnyLogic 5. The message added to the queue by fireEvent() can be consumed
either immediately or after a number of zero-time steps of the statechart, otherwise
it will be discarded. In the example above both transitions will be taken if the
messages A and B are received via fireEvent() method.
Using fireEvent() is less efficient than using receiveMessage() both time and
memory-wise, so if you do care and are sure that no "chains" of zero-time
message-triggered transitions can happen, use receiveMessage().
Memory: sizeof(Object) + 18 bytes + sizeof(array with concurrently active transitions)
+ sizeof(message queue)
| Constructor Summary | |
|---|---|
Statechart(ActiveObject ao,
short maxat)
Constructs the statechart object. |
|
| Method Summary | |
|---|---|
void |
fireEvent(java.lang.Object msg)
Adds a message to the statechart queue. |
ActiveObject |
getActiveObject()
Returns the active object that owns the statechart. |
short |
getActiveSimpleState()
Returns the currenly active simple state of the statechart |
java.lang.String |
getFullName()
Returns the name of the statechart prefixed by the full name of its active object. |
java.lang.String |
getName()
Returns the name of the statechart as specified by the user |
boolean |
isStateActive(short state)
Returns true if the statechart is at the specified state, i.e. exactly in the state for a simple state and in one of its inner states for a composite state. |
void |
onChange()
Should be called if the statechart has at least one transition of type Condition or Rate when something changes in the active object and probably rate changes or condition becomes true. |
void |
onDestroy()
Should be called when the statechart is destroyed, e.g. when the owner active object is destroyed or when statechart comes to final state. |
boolean |
receiveMessage(int msg)
Same as receiveMessage(Object) but with an integer as message. |
boolean |
receiveMessage(java.lang.Object msg)
Posts a message to the statechart without queueing: the message is either immediately consumed (if there is a matching transition active) or is discarded. |
void |
restoreOwner(java.lang.Object owner)
This method normally should not be called by user This method restores owner of this object The method is used in snapshot saving/loading |
void |
setActiveState_xjal(short st)
This method is shouldn't be called by user (is public due to technical reasons) |
void |
start()
Should be called when the active object starts. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Statechart(ActiveObject ao,
short maxat)
ao - active object where this statechart belongs tomaxat - maximum possible number of concurrently active transitions| Method Detail |
|---|
public java.lang.String getName()
public java.lang.String getFullName()
public java.lang.String toString()
toString in class java.lang.Objectpublic ActiveObject getActiveObject()
public boolean receiveMessage(java.lang.Object msg)
msg - the message posted to the statechart
public boolean receiveMessage(int msg)
receiveMessage(Object) but with an integer as message.
msg - the integer posted to the statechart
public boolean isStateActive(short state)
state - the state
public short getActiveSimpleState()
public void fireEvent(java.lang.Object msg)
msg - the message received by the statechartpublic void start()
public void setActiveState_xjal(short st)
public void onChange()
public void onDestroy()
public void restoreOwner(java.lang.Object owner)
restoreOwner in interface com.xj.anylogic.engine.internal.Childowner - owner of this object, usually ActiveObject,
Experiment or
ShapeGroup
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||