org.primordion.xholon.base
Class StateMachineEntity

java.lang.Object
  extended byorg.primordion.xholon.base.Xholon
      extended byorg.primordion.xholon.base.StateMachineEntity
All Implemented Interfaces:
CeBehavior, CeStateMachineEntity, IStateMachineEntity, IXholon
Direct Known Subclasses:
ObservableStateMachineEntity

public class StateMachineEntity
extends Xholon
implements IStateMachineEntity, CeBehavior, CeStateMachineEntity

A state machine entity is any XholonClass that has to do with state machines.

Since:
0.1 (Created on Sep 25, 2005) Note from August 28, 2007: Two very similar types of state machines are now supported: (1) UML2 state machine, as transformed from a UML model created using a UML modeling tool. This is the type that's been supported all along. There are no changes. (2) Xholon state machine, as specified in StateMachine_Xholon.dtd. This type is easier to create manually. The entire state machine is specified in a CompositeStructureHierarchy.xml file. It uses states inside of states, rather than states inside of regions. It uses transitions inside of states, rather than transitions inside of regions.
Author:
Ken Webb
See Also:
IStateMachineEntity

Field Summary
static int ACTIVITYID_NONE
           
static int CNPT_OUTGOING1
           
static int CNPT_OUTGOING10
           
static int CNPT_OUTGOING2
           
static int CNPT_OUTGOING3
           
static int CNPT_OUTGOING4
           
static int CNPT_OUTGOING5
           
static int CNPT_OUTGOING6
           
static int CNPT_OUTGOING7
           
static int CNPT_OUTGOING8
           
static int CNPT_OUTGOING9
           
static int CNPT_TARGET
           
 int guardActivityId
           
static int MAX_ACTIVE_SUBSTATES
           
static int MAX_TRIGGERS
           
static boolean PRINT_ACTIVE_SUBSTATE
           
 java.lang.String roleName
           
 java.lang.String uid
           
 
Fields inherited from class org.primordion.xholon.base.Xholon
DEFAULT_LEVEL, interaction, interactionsEnabled
 
Fields inherited from interface org.primordion.xholon.base.IXholon
DEFAULT_SIZE_MSG_Q, NINCLUDE_PSC, NINCLUDE_PSx, NINCLUDE_PxC, NINCLUDE_Pxx, NINCLUDE_xSC, NINCLUDE_xSx, NINCLUDE_xxC, NINCLUDE_xxx
 
Fields inherited from interface org.primordion.xholon.common.mechanism.CeBehavior
BehaviorCE, OpaqueBehaviorCE
 
Fields inherited from interface org.primordion.xholon.common.mechanism.CeStateMachineEntity
ActivityCE, ConnectionPointReferenceCE, DeferrableTriggerCE, DoActivityCE, EntryActivityCE, ExitActivityCE, FinalStateCE, GuardCE, PseudostateCE, PseudostateChoiceCE, PseudostateDeepHistoryCE, PseudostateEntryPointCE, PseudostateExitPointCE, PseudostateForkCE, PseudostateInitialCE, PseudostateJoinCE, PseudostateJunctionCE, PseudostateShallowHistoryCE, PseudostateTerminateCE, RegionCE, StateCE, StateMachineCE, StateMachineEntityCE, TargetCE, TransitionCE, TransitionExternalCE, TransitionInternalCE, TransitionLocalCE, TriggerCE, VertexCE
 
Constructor Summary
StateMachineEntity()
          Constructor.
 
Method Summary
 void act()
          Do some action during this time step.
 void configure()
          Perform some action, typically once at start up; MAY be overridden.
 void doStateMachine(Message msg)
          Execute an instance of a state machine.
 int getActivityId()
          Return the activity ID of a transition.
 int getDoActivityId()
          Return the do activity ID of a state.
 int getEntryActivityId()
          Return the entry activity ID of a state.
 int getExitActivityId()
          Return the exit activity ID of a state.
 int getGuardActivityId()
          Return the guard activity ID of a transition.
static int getMaxPorts()
          Get the maximum number of ports for any xholon in the model.
 IXholon getOwningXholon()
          Return the Xholon that owns the state machine that this IStateMachineEntity is a part of.
 IXholon getPort(int cnptNum)
          Get the port that corresponds to this index (0 indexed).
 java.lang.String getRoleName()
          Get name of the role played by this Xholon within a specific context.
 int getTrigger(int trigNum)
          Return a specified trigger for a transition.
 java.lang.String getUid()
          Get globally unique ID.
 double getVal()
          Get the value of a "double" maintained by this xholon instance.
 void initialize()
          Initialize the tree node.
static void initializeStateMachines()
          Initialize all state machines.
 boolean isActiveSubState()
          Is this a currently active sub state of some other state or of the state machine as a whole?
 void notifyActiveSubStates()
          Notify the existence of all currently active sub states.
 void postConfigure()
          Perform some action, typically once at start up; MAY be overridden.
static void setMaxPorts(int mPorts)
          Set the maximum number of ports for any xholon in the model.
 void setPorts()
          Set ports, by creating an array of ports.
 void setRoleName(java.lang.String roleName)
          Set name of the role played by this Xholon within a specific context.
 void setUid(java.lang.String uid)
          Set globally unique ID.
 void terminate()
          Terminate a UML2 state machine, and optionally terminate the xholon that owns the state machine.
 java.lang.String toString()
           
 
Methods inherited from class org.primordion.xholon.base.Xholon
appendChild, appendChild, appendChild, cleanup, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextId, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPreviousSibling, getRootNode, getSiblings, getSizeMessageQ, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, resetNextId, sendMessage, sendMessage, sendMessage, setAttributeVal, setFactory, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setSizeMessageQ, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, treeSize, writeXml
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.primordion.xholon.base.IXholon
appendChild, appendChild, appendChild, cleanup, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPreviousSibling, getRootNode, getSiblings, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, sendMessage, sendMessage, sendMessage, setAttributeVal, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, treeSize, writeXml
 

Field Detail

CNPT_OUTGOING1

public static final int CNPT_OUTGOING1
See Also:
Constant Field Values

CNPT_OUTGOING2

public static final int CNPT_OUTGOING2
See Also:
Constant Field Values

CNPT_OUTGOING3

public static final int CNPT_OUTGOING3
See Also:
Constant Field Values

CNPT_OUTGOING4

public static final int CNPT_OUTGOING4
See Also:
Constant Field Values

CNPT_OUTGOING5

public static final int CNPT_OUTGOING5
See Also:
Constant Field Values

CNPT_OUTGOING6

public static final int CNPT_OUTGOING6
See Also:
Constant Field Values

CNPT_OUTGOING7

public static final int CNPT_OUTGOING7
See Also:
Constant Field Values

CNPT_OUTGOING8

public static final int CNPT_OUTGOING8
See Also:
Constant Field Values

CNPT_OUTGOING9

public static final int CNPT_OUTGOING9
See Also:
Constant Field Values

CNPT_OUTGOING10

public static final int CNPT_OUTGOING10
See Also:
Constant Field Values

CNPT_TARGET

public static final int CNPT_TARGET
See Also:
Constant Field Values

ACTIVITYID_NONE

public static final int ACTIVITYID_NONE
See Also:
Constant Field Values

MAX_ACTIVE_SUBSTATES

public static int MAX_ACTIVE_SUBSTATES

MAX_TRIGGERS

public static int MAX_TRIGGERS

PRINT_ACTIVE_SUBSTATE

public static final boolean PRINT_ACTIVE_SUBSTATE

roleName

public java.lang.String roleName

uid

public java.lang.String uid

guardActivityId

public int guardActivityId
Constructor Detail

StateMachineEntity

public StateMachineEntity()
Constructor.

Method Detail

initialize

public void initialize()
Description copied from interface: IXholon
Initialize the tree node. Typically this is only used to re-initialize a node, such as when it is reused through the TreeNodeFactoryStatic.

Specified by:
initialize in interface IXholon
Overrides:
initialize in class Xholon

isActiveSubState

public boolean isActiveSubState()
Description copied from interface: IStateMachineEntity
Is this a currently active sub state of some other state or of the state machine as a whole?

Specified by:
isActiveSubState in interface IStateMachineEntity
Returns:
true or false

getOwningXholon

public IXholon getOwningXholon()
Description copied from interface: IStateMachineEntity
Return the Xholon that owns the state machine that this IStateMachineEntity is a part of.

Specified by:
getOwningXholon in interface IStateMachineEntity
Returns:
An instance of IXholon.

setMaxPorts

public static void setMaxPorts(int mPorts)
Set the maximum number of ports for any xholon in the model.

Parameters:
mPorts - Maximum number of ports.

getMaxPorts

public static int getMaxPorts()
Get the maximum number of ports for any xholon in the model.

Returns:
Maximum number of ports.

getPort

public IXholon getPort(int cnptNum)
Description copied from interface: IXholon
Get the port that corresponds to this index (0 indexed).

Specified by:
getPort in interface IXholon
Overrides:
getPort in class Xholon

getVal

public double getVal()
Description copied from interface: IXholon
Get the value of a "double" maintained by this xholon instance. If a class that implements this interface does not maintain such a value, it should return 0.0 This method can be used in place of getVal_double()

Specified by:
getVal in interface IXholon
Overrides:
getVal in class Xholon

setRoleName

public void setRoleName(java.lang.String roleName)
Description copied from interface: IXholon
Set name of the role played by this Xholon within a specific context.

Specified by:
setRoleName in interface IXholon
Overrides:
setRoleName in class Xholon

getRoleName

public java.lang.String getRoleName()
Description copied from interface: IXholon
Get name of the role played by this Xholon within a specific context.

Specified by:
getRoleName in interface IXholon
Overrides:
getRoleName in class Xholon

setUid

public void setUid(java.lang.String uid)
Description copied from interface: IXholon
Set globally unique ID.

Specified by:
setUid in interface IXholon
Overrides:
setUid in class Xholon

getUid

public java.lang.String getUid()
Description copied from interface: IXholon
Get globally unique ID.

Specified by:
getUid in interface IXholon
Overrides:
getUid in class Xholon

getTrigger

public int getTrigger(int trigNum)
Description copied from interface: IStateMachineEntity
Return a specified trigger for a transition.

Specified by:
getTrigger in interface IStateMachineEntity
Parameters:
trigNum - The numeric id of the trigger.
Returns:
The value of the trigger.

getActivityId

public int getActivityId()
Description copied from interface: IStateMachineEntity
Return the activity ID of a transition.

Specified by:
getActivityId in interface IStateMachineEntity
Returns:
An activity ID.

getEntryActivityId

public int getEntryActivityId()
Description copied from interface: IStateMachineEntity
Return the entry activity ID of a state.

Specified by:
getEntryActivityId in interface IStateMachineEntity
Returns:
An entry activity ID.

getExitActivityId

public int getExitActivityId()
Description copied from interface: IStateMachineEntity
Return the exit activity ID of a state.

Specified by:
getExitActivityId in interface IStateMachineEntity
Returns:
An exit activity ID.

getDoActivityId

public int getDoActivityId()
Description copied from interface: IStateMachineEntity
Return the do activity ID of a state.

Specified by:
getDoActivityId in interface IStateMachineEntity
Returns:
A do activity ID.

getGuardActivityId

public int getGuardActivityId()
Description copied from interface: IStateMachineEntity
Return the guard activity ID of a transition.

Specified by:
getGuardActivityId in interface IStateMachineEntity
Returns:
A guard activity ID.

setPorts

public void setPorts()
Description copied from interface: IXholon
Set ports, by creating an array of ports. A port is a reference to a Xholon somewhere else in the tree.

Specified by:
setPorts in interface IXholon
Overrides:
setPorts in class Xholon

configure

public void configure()
Description copied from interface: IXholon
Perform some action, typically once at start up; MAY be overridden. Recursive; application should call this only for root.

Specified by:
configure in interface IXholon
Overrides:
configure in class Xholon

postConfigure

public void postConfigure()
Description copied from interface: IXholon
Perform some action, typically once at start up; MAY be overridden. Recursive; application should call this only for root.

Specified by:
postConfigure in interface IXholon
Overrides:
postConfigure in class Xholon

initializeStateMachines

public static void initializeStateMachines()
Initialize all state machines. This can only be done after all links between xholons have been set up. Otherwise some initial transitions will be unable to send initial messages.


act

public void act()
Description copied from interface: IXholon
Do some action during this time step. Typically all nodes in the tree will do their pre-actions (optional), then all will do their actions, and then all will do their post-actions (optional).

Specified by:
act in interface IXholon
Overrides:
act in class Xholon

doStateMachine

public void doStateMachine(Message msg)
Description copied from interface: IStateMachineEntity
Execute an instance of a state machine.

Specified by:
doStateMachine in interface IStateMachineEntity
Parameters:
msg - An incoming message that contains a signal, optional data, and that identifies the sender and receiver of the message.

terminate

public void terminate()
Description copied from interface: IXholon
Terminate a UML2 state machine, and optionally terminate the xholon that owns the state machine. The UML 2.1.1 specification states (section 15.3.8): "Entering a terminate pseudostate implies that the execution of this state machine by means of its context object is terminated. The state machine does not exit any states nor does it perform any exit actions other than those associated with the transition leading to the terminate pseudostate. Entering a terminate pseudostate is equivalent to invoking a DestroyObjectAction." The same action is performed if a state machine reaches its top level FinalState.

Specified by:
terminate in interface IXholon
Overrides:
terminate in class Xholon

notifyActiveSubStates

public void notifyActiveSubStates()
Description copied from interface: IStateMachineEntity
Notify the existence of all currently active sub states. This is intended to be called from Interaction, to notify it of all initial lowest level active states, in which case it will be normally called on a StateMachine node. It could be called by any external entity to notify it of all currently active states.

Specified by:
notifyActiveSubStates in interface IStateMachineEntity

toString

public java.lang.String toString()
Overrides:
toString in class Xholon