java.lang.Object
com.pauware.pauware_engine.Core.AbstractState
com.pauware.pauware_engine.Core.AbstractStateMachine
- All Implemented Interfaces:
Manageable
,Manageable_base
- Direct Known Subclasses:
StateMachine
public abstract class AbstractStateMachine extends AbstractState implements Manageable
This abstract class represents the general notion of State Machine in
UML. Use of this class occurs through the following subclass:
StateMachine
.
Compatibility: Java 9.
- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.pauware.pauware_engine.Core.AbstractState
AbstractState._Cross_over
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_current_state
This field records the state of a state machine computed within of a run-to-completion step.protected java.util.Vector<Transition>
_eliminated_transitions
This field records, during a run-to-completion cycle, the transitions to be eliminated.protected java.util.Map<Transition,java.lang.Object[]>
_execution
This field represents all of the eligible transitions of a given run-to-completion cycle.protected java.util.ArrayList<AbstractStateMachine_listener>
_listeners
This field records listeners, if any, for the software component that owns the state machine.protected boolean
_show_on_system_out
This field records the chosen verbose mode associated with the state machine.protected java.util.Map<Transition,java.util.Map<java.lang.String,java.util.Map<AbstractGuard,java.util.Vector<AbstractAction>>>>
_transitions
This field represents all of the cached transitions of the state machine.protected static java.lang.String
_Undefined
This class variable is a constant value which represents the fact that the state machine's current state is not yet defined.protected java.lang.StringBuffer
_verbose
This field records the result of an event occurrence processing within a run-to-completion step.static boolean
Compute_invariants
This class variable is a constant value that activates the calculation of state invariants.static boolean
Don_t_compute_invariants
This class variable is a constant value that disactivates the calculation of state invariants.static boolean
Don_t_show_on_system_out
This class variable is a constant value which represents the fact that the verbose mode for event processing is not activated.static boolean
Show_on_system_out
This class variable is a constant value which represents the fact that the verbose mode for event processing is activated.Fields inherited from class com.pauware.pauware_engine.Core.AbstractState
_active, _allowed_events, _AND, _do, _entry, _exit, _inputState, _invariant, _left, _Left_parenthesis, _name, _node, _outputState, _PlantUML_entry_point, _PlantUML_exit_point, _PlantUML_state, _PlantUML_state_entry_point, _PlantUML_state_exit_point, _PlantUML_transition, _PlantUML_transition_, _PlantUML_transition_execution, _right, _Right_parenthesis, _xor, Activated_state_display_message, Allow_header_text, Allowed_event_display_message, Completion, Disactivated_state_display_message, Do_activity_display_message, Do_header_text, Entry_action_display_message, Entry_header_text, Exit_action_display_message, Exit_header_text, Invariant_header_text, Neutral_character, No_reentrance, Pseudo_event, Pseudo_state, Reentrance, Sequence_character, State_name_separator, Textual_view_subject_separator
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractStateMachine()
This constructor creates a father for two composedAbstractStateMachine
instances.AbstractStateMachine(AbstractState s, java.lang.String name)
This constructor amounts to callingAbstractStateMachine(s,name,AbstractStateMachine.Don_t_show_on_system_out)
.AbstractStateMachine(AbstractState s, java.lang.String name, boolean show_on_system_out)
This constructor first creates and initializes a state machine; It next triggers all entry actions associated with all the explicit and implicit default input states of the state machine.AbstractStateMachine(AbstractState s, java.lang.String name, boolean show_on_system_out, AbstractStateMachine_listener listener)
This constructor amounts to callingAbstractStateMachine(s,name,show_on_system_out)
plus the definition of a state machine's listener.AbstractStateMachine(AbstractState s, java.lang.String name, boolean show_on_system_out, AbstractStateMachine_listener listener1, AbstractStateMachine_listener listener2)
Doc. -
Method Summary
Modifier and Type Method Description protected void
activate(AbstractState from, AbstractState to, java.lang.StringBuffer verbose)
Internal use only; This method is called during a run-to-completion cycle.void
add_listener(AbstractStateMachine_listener listener)
This method adds a listener to the state machine; this method MUST be called AFTER the state machine has started.java.lang.String
async_current_state()
Management facility: this method is offered by a software component, which implements theManageable_base
interface.void
completion()
Completion transitions (i.e., those without any event label) are automatically triggered when reaching output states.protected void
disactivate(AbstractState from, AbstractState to, java.lang.StringBuffer verbose)
Internal use only; This method is called during a run-to-completion cycle.boolean
equals(java.lang.Object s)
This method is used when anAbstractStateMachine
is put in a map data structure as a key.void
fires(java.lang.String event, AbstractState from, AbstractState to)
This method amounts to callingfires(event,from,to,true);
.void
fires(java.lang.String event, AbstractState from, AbstractState to, boolean guard)
This method amounts to callingfires(event,from,to,guard,null,null);
.void
fires(java.lang.String event, AbstractState from, AbstractState to, boolean guard, java.lang.Object object, java.lang.String action)
This method amounts to callingfires(event,from,to,guard,object,action,null);
.void
fires(java.lang.String event, AbstractState from, AbstractState to, boolean guard, java.lang.Object object, java.lang.String action, java.lang.Object[] args)
This method amounts to callingfires(event,from,to,guard,object,action,args,AbstractState.No_reentrance);
.void
fires(java.lang.String event, AbstractState from, AbstractState to, boolean guard, java.lang.Object object, java.lang.String action, java.lang.Object[] args, byte reentrance_mode)
This method amounts to callingfires(event,from,to,null,"true",object,action,args,reentrance_mode);
ifguard
istrue
,fires(event,from,to,null,"false",object,action,args,reentrance_mode);
otherwise.void
fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action)
This method amounts to callingfires(event,from,to,guard_object,guard_action,null,null);
.void
fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args)
This method amounts to callingfires(event,from,to,guard_object,guard_action,guard_args,null,null,null);
.void
fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args, java.lang.Object object, java.lang.String action)
This method amounts to callingfires(event,from,to,guard_object,guard_action,guard_args,object,action,null);
.void
fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args, java.lang.Object object, java.lang.String action, java.lang.Object[] args)
This method amounts to callingfires(event,from,to,guard_object,guard_action,guard_args,object,action,args,AbstractState.No_reentrance);
.void
fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args, java.lang.Object object, java.lang.String action, java.lang.Object[] args, byte reentrance_mode)
This method creates and registers (caches) a transition labeled with an event name in a state machine (see: UML State Machine Diagrams formalism).void
fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object object, java.lang.String action)
This method amounts to callingfires(event,from,to,guard_object,guard_action,object,action,null);
.void
fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object object, java.lang.String action, java.lang.Object[] args)
This method amounts to callingfires(event,from,to,guard_object,guard_action,null,object,action,args,AbstractState.No_reentrance);
.int
hashCode()
This method is used when anAbstractStateMachine
is put in a map data structure as a key.boolean
in_state(java.lang.String name)
Management facility: this method is offered by a software component, which implements theManageable_base
interface.void
remove_listener(AbstractStateMachine_listener listener)
This method removes a listener of the state machine; this method MUST be called BEFORE the state machine has stopped.boolean
root()
This method answers the question: is this state the most outer state of the state machine? The answer is alwaystrue
for an instance of theAbstractStateMachine
type.void
run_to_completion(java.lang.String event)
This method amounts to callingrun_to_completion(event,AbstractStateMachine.Don_t_compute_invariants);
void
run_to_completion(java.lang.String event, boolean compute_invariants)
This method is the key mechanism of the PauWare software; It moves a state machine from one stable consistent context to another.void
start()
This method launches a state machine.void
stop()
This method stops a state machine.java.lang.String
to_PlantUML()
For visualization purposes only: this method is used by the PauWare2Web tool to compute the state machine's visualization graph.void
to_state(java.lang.String name)
Management facility: this method is offered by a software component, which implements theManageable_base
interface.java.lang.String
to_UML(java.lang.String event, Transition transition, AbstractGuard guard)
For visualization purposes only: this method may be used by the PauWare2Web tool.void
unfires(java.lang.String event, AbstractState from, AbstractState to, boolean guard, java.lang.Object object, java.lang.String action, java.lang.Object[] args, byte reentrance_mode)
This method unregisters a transition labeled with an event name in a state machine (see: UML State Machine Diagrams formalism).java.lang.String
verbose()
Management facility: this method is offered by a software component, which implements theManageable_base
interface.Methods inherited from class com.pauware.pauware_engine.Core.AbstractState
_compute_state_views, _cross_over, action, active, activity, allowedEvent, allowedEvent, allowedEvent, allowedEvent, allowedEvent, allowedEvent, allowedEvent, allowedEvent, allowedEvent, allowedEvent, allowedEvent, allowedEvent, ancestor, and, and, brother, Clean_up, commonSuperWith, createFather, current_state, deep_history, deepStateInvariant, doActivity, doActivity, entry, exit, fictitious, get_allowed_events_label, get_do_label, get_invariant_label, guard, hasForSuperState, inputState, is_deep_history, is_shallow_history, isAndWith, isInputState, isOutputState, isXorWith, leaf, lookup, name, name, outputState, reset_entryAction, reset_entryAction, reset_entryAction, reset_exitAction, reset_exitAction, reset_exitAction, set_completion, set_entryAction, set_entryAction, set_entryAction, set_exitAction, set_exitAction, set_exitAction, shallow_history, shallowStateInvariant, stateInvariant, stateInvariant, verify, xor
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.pauware.pauware_engine.Core.Manageable_base
current_state, name
-
Field Details
-
Don_t_compute_invariants
public static final boolean Don_t_compute_invariantsThis class variable is a constant value that disactivates the calculation of state invariants. -
Compute_invariants
public static final boolean Compute_invariantsThis class variable is a constant value that activates the calculation of state invariants. -
Don_t_show_on_system_out
public static final boolean Don_t_show_on_system_outThis class variable is a constant value which represents the fact that the verbose mode for event processing is not activated. -
Show_on_system_out
public static final boolean Show_on_system_outThis class variable is a constant value which represents the fact that the verbose mode for event processing is activated. -
_show_on_system_out
protected boolean _show_on_system_outThis field records the chosen verbose mode associated with the state machine.- See Also:
Don_t_show_on_system_out
,Show_on_system_out
-
_execution
This field represents all of the eligible transitions of a given run-to-completion cycle. ThisMap
instance is empty at the beginning of a run-to-completion cycle. -
_eliminated_transitions
This field records, during a run-to-completion cycle, the transitions to be eliminated. Eliminated transitions are the transitions overridden by other similar ones bound to substates. They are also those inhibited by allowed events. -
_transitions
protected java.util.Map<Transition,java.util.Map<java.lang.String,java.util.Map<AbstractGuard,java.util.Vector<AbstractAction>>>> _transitionsThis field represents all of the cached transitions of the state machine. -
_listeners
This field records listeners, if any, for the software component that owns the state machine. -
_Undefined
protected static final java.lang.String _UndefinedThis class variable is a constant value which represents the fact that the state machine's current state is not yet defined.- See Also:
in_state(String)
, Constant Field Values
-
_current_state
protected java.lang.String _current_stateThis field records the state of a state machine computed within of a run-to-completion step. -
_verbose
protected java.lang.StringBuffer _verboseThis field records the result of an event occurrence processing within a run-to-completion step.- See Also:
Don_t_show_on_system_out
,Show_on_system_out
-
-
Constructor Details
-
AbstractStateMachine
protected AbstractStateMachine()This constructor creates a father for two composedAbstractStateMachine
instances.- Since:
- ver. 1.2
- See Also:
AbstractState.createFather()
-
AbstractStateMachine
This constructor amounts to callingAbstractStateMachine(s,name,AbstractStateMachine.Don_t_show_on_system_out)
. It supports the composition ofAbstractStateMachine
instances (a.k.a.vertical composition) since ver. 1.2.- Parameters:
s
-name
-- Throws:
State_exception
-
AbstractStateMachine
public AbstractStateMachine(AbstractState s, java.lang.String name, boolean show_on_system_out) throws State_exceptionThis constructor first creates and initializes a state machine; It next triggers all entry actions associated with all the explicit and implicit default input states of the state machine. Running this constructor therefore implies that all resources, used by the state machine in entry actions, are available and in an appropriate status. Use of this class occurs through the following subclass:StateMachine
. Example of a user-definedStack
software component:
AbstractStateMachine _Stack;
...
_Stack = new StateMachine(_Empty.xor(_Not_empty),"Stack");- Parameters:
s
- A state object resulting from a XOR-based state composition or an AND-based state compositionname
- A name assigned to the state machine. The name of the software component type running this state machine is preferred for this parametershow_on_system_out
- Iftrue
, this parameter activates the verbose mode of a run-to-completion cycle (for tests only)- Throws:
State_exception
-
AbstractStateMachine
public AbstractStateMachine(AbstractState s, java.lang.String name, boolean show_on_system_out, AbstractStateMachine_listener listener) throws State_exceptionThis constructor amounts to callingAbstractStateMachine(s,name,show_on_system_out)
plus the definition of a state machine's listener.- Parameters:
s
-name
-show_on_system_out
-listener
- The state machine's listener is first initialized in receiving the state machine itself (for display purposes for instance) Next, it is informed of the state machine's status changes at the time when each run-to-completion cycle is finished.- Throws:
State_exception
- See Also:
AbstractStateMachine(AbstractState,String,boolean)
,add_listener(AbstractStateMachine_listener)
-
AbstractStateMachine
public AbstractStateMachine(AbstractState s, java.lang.String name, boolean show_on_system_out, AbstractStateMachine_listener listener1, AbstractStateMachine_listener listener2) throws State_exceptionDoc. required- Throws:
State_exception
-
-
Method Details
-
add_listener
This method adds a listener to the state machine; this method MUST be called AFTER the state machine has started. A typical use of this method is when a viewer is added in order to graphically simulate a state machine as follows:_Programmable_thermostat.add_listener(new com.pauware.PauWare2Web.PauWare2Web_client());
- Parameters:
listener
-- Throws:
State_exception
- See Also:
start()
,remove_listener(AbstractStateMachine_listener)
-
remove_listener
This method removes a listener of the state machine; this method MUST be called BEFORE the state machine has stopped.- Parameters:
listener
-- Throws:
State_exception
- See Also:
stop()
,add_listener(AbstractStateMachine_listener)
-
completion
Completion transitions (i.e., those without any event label) are automatically triggered when reaching output states.- Throws:
State_exception
- Since:
- ver. 1.3
-
activate
protected void activate(AbstractState from, AbstractState to, java.lang.StringBuffer verbose) throws State_exceptionInternal use only; This method is called during a run-to-completion cycle.- Parameters:
from
-to
-verbose
-- Throws:
State_exception
- See Also:
run_to_completion(String,boolean)
-
disactivate
protected void disactivate(AbstractState from, AbstractState to, java.lang.StringBuffer verbose) throws State_exceptionInternal use only; This method is called during a run-to-completion cycle.- Throws:
State_exception
- See Also:
run_to_completion(String,boolean)
-
root
public boolean root()This method answers the question: is this state the most outer state of the state machine? The answer is alwaystrue
for an instance of theAbstractStateMachine
type.- Overrides:
root
in classAbstractState
- Returns:
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,true);
.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, boolean guard) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,guard,null,null);
.- Parameters:
event
-from
-to
-guard
-- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, boolean guard, java.lang.Object object, java.lang.String action) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,guard,object,action,null);
.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, boolean guard, java.lang.Object object, java.lang.String action, java.lang.Object[] args) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,guard,object,action,args,AbstractState.No_reentrance);
.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, boolean guard, java.lang.Object object, java.lang.String action, java.lang.Object[] args, byte reentrance_mode) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,null,"true",object,action,args,reentrance_mode);
ifguard
istrue
,fires(event,from,to,null,"false",object,action,args,reentrance_mode);
otherwise.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,guard_object,guard_action,null,null);
.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,guard_object,guard_action,guard_args,null,null,null);
.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object object, java.lang.String action) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,guard_object,guard_action,object,action,null);
.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args, java.lang.Object object, java.lang.String action) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,guard_object,guard_action,guard_args,object,action,null);
.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object object, java.lang.String action, java.lang.Object[] args) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,guard_object,guard_action,null,object,action,args,AbstractState.No_reentrance);
.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args, java.lang.Object object, java.lang.String action, java.lang.Object[] args) throws Transition_based_exceptionThis method amounts to callingfires(event,from,to,guard_object,guard_action,guard_args,object,action,args,AbstractState.No_reentrance);
.- Throws:
Transition_based_exception
-
fires
public void fires(java.lang.String event, AbstractState from, AbstractState to, java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args, java.lang.Object object, java.lang.String action, java.lang.Object[] args, byte reentrance_mode) throws Transition_based_exceptionThis method creates and registers (caches) a transition labeled with an event name in a state machine (see: UML State Machine Diagrams formalism).- Parameters:
event
- The name of the event labeling the transitionfrom
- The state being the origin of the transitionto
- The state being the end of the transitionguard_object
- The object in charge of executing the guard (if any)guard_action
- The name of the action to be executed in order to establish the guard's evaluation; This is required * * * * * * * * * * * ifguard_object
is usedguard_args
- The arguments (if any) of the action which represents the guardobject
- The object in charge of executing the action, if any, triggered by the event; Multiple actions require multiple use of this methodaction
- The name of the action to be executed; This is required * ifobject
is usedargs
- The arguments of the action to be executed * * * * * * * * * ornull
reentrance_mode
- A flag value which is equal toAbstractState.Reentrance
orAbstractState.No_reentrance
; This value enables or disables the reentrance_mode mode of communication for the action to be executed- Throws:
Transition_based_exception
-
unfires
public void unfires(java.lang.String event, AbstractState from, AbstractState to, boolean guard, java.lang.Object object, java.lang.String action, java.lang.Object[] args, byte reentrance_mode) throws Transition_based_exceptionThis method unregisters a transition labeled with an event name in a state machine (see: UML State Machine Diagrams formalism).- Parameters:
event
- The name of the event labeling the transitionfrom
- The state being the origin of the transitionto
- The state being the end of the transitionguard
- Only simple guards are supported at this timeobject
- The object in charge of executing the action, if any, triggered by the event; Multiple actions require multiple use of this methodaction
- The name of the action to be executed; This is required * ifobject
is usedargs
- The arguments of the action to be executed * * * * * * * * * ornull
reentrance_mode
- A flag value which is equal toAbstractState.Reentrance
orAbstractState.No_reentrance
; This value enables or disables the reentrance_mode mode of communication for the action to be executed- Throws:
Transition_based_exception
-
run_to_completion
This method amounts to callingrun_to_completion(event,AbstractStateMachine.Don_t_compute_invariants);
- Parameters:
event
-- Throws:
State_exception
-
run_to_completion
public void run_to_completion(java.lang.String event, boolean compute_invariants) throws State_exceptionThis method is the key mechanism of the PauWare software; It moves a state machine from one stable consistent context to another.- Parameters:
event
- The name of the event to be processed (null
means no effect); Only transitions labeled and registered with this event name are processed (see: thefires(String,AbstractState,AbstractState,Object,String,Object[],Object,String,Object[],byte)
method)compute_invariants
- This mode triggers the calculation of invariants- Throws:
State_exception
-
start
This method launches a state machine.- Throws:
State_exception
-
stop
This method stops a state machine.- Throws:
State_exception
-
async_current_state
public java.lang.String async_current_state()Management facility: this method is offered by a software component, which implements theManageable_base
interface.- Specified by:
async_current_state
in interfaceManageable_base
- Returns:
-
in_state
public boolean in_state(java.lang.String name)Management facility: this method is offered by a software component, which implements theManageable_base
interface.- Specified by:
in_state
in interfaceManageable_base
- Returns:
- See Also:
Manageable_base
-
to_state
Management facility: this method is offered by a software component, which implements theManageable_base
interface.- Specified by:
to_state
in interfaceManageable
- Parameters:
name
- The name of the state to which the state machine goes to.- Throws:
State_exception
- See Also:
AbstractState.set_entryAction(Object,String,Object[],byte)
,AbstractState.set_exitAction(Object,String,Object[],byte)
,AbstractState.reset_entryAction(Object,String,Object[],byte)
,AbstractState.reset_exitAction(Object,String,Object[],byte)
-
verbose
public java.lang.String verbose()Management facility: this method is offered by a software component, which implements theManageable_base
interface.- Specified by:
verbose
in interfaceManageable_base
- Returns:
-
equals
public boolean equals(java.lang.Object s)This method is used when anAbstractStateMachine
is put in a map data structure as a key.- Overrides:
equals
in classjava.lang.Object
- Parameters:
s
-
-
hashCode
public int hashCode()This method is used when anAbstractStateMachine
is put in a map data structure as a key.- Overrides:
hashCode
in classjava.lang.Object
-
to_UML
For visualization purposes only: this method may be used by the PauWare2Web tool.- Parameters:
event
-transition
-guard
-- Returns:
-
to_PlantUML
public java.lang.String to_PlantUML()For visualization purposes only: this method is used by the PauWare2Web tool to compute the state machine's visualization graph.- Returns:
- Since:
- ver. 1.3
-