EventHelix.com: CASE Tools; Real-time and Embedded System Design; Object Oriented Design EventStudio 2.0: System Engineering CASE ToolEventStudio 2.5
Sequence diagram based system design and modeling
Home   What's New   EventStudio 2.5   Real-time Mantra   Thought Projects   Contact Us
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Hierarchical_State_Machine Class Reference

#include <Hierarchical_State_Machine.h>

Collaboration diagram for Hierarchical_State_Machine:

Collaboration graph
[legend]
List of all members.

Detailed Description

This is an example of state machine implementation using Hierarchical State Machines.

For details refer to the article on Hierarchical State Machines

In conventional state machine design, all states are considered at the same level. The design does not capture the commonality that exists among states. In real life, many states handle most messages in similar fashion and differ only in handling of few key messages. Even when the actual handling differs, there is still some commonality. Hierarchical state machine design captures the commonality by organizing the states as a hierarchy. The states at the higher level in hierarchy perform the common message handling, while the lower level states inherit the commonality from higher level ones and perform the state specific functions. This examples explores hierarchichal state machines using an example of a hardware unit that can be in the following states:

Definition at line 32 of file Hierarchical_State_Machine.h.

Public Member Functions

void On_Message (const Message *p_Message)
 Receive methods and invoke the handler for the currently active state.


Private Member Functions

void Next_State (Unit_State &r_State)
 This private method changes the state for the state machine.


Private Attributes

Unit_Statep_Current_State
 Pointer to the current state.


Static Private Attributes

Active Active_State
 Static declaration of Active state. Static declarations share the same states across multiple instances.

Standby Standby_State
 Static declaration of Standby state.

Suspect Suspect_State
 Static declaration of Suspect state.

Failed Failed_State
 Static declaration of Failed State.


Member Function Documentation

void Hierarchical_State_Machine::Next_State Unit_Stater_State  ) [private]
 

This private method changes the state for the state machine.

The p_Current_State variable is updated with the new state

Parameters:
r_State Reference to the desired next state

Definition at line 169 of file Hierarchical_State_Machine.h.

00170 {
00171     p_Current_State = &r_State;
00172 }

void Hierarchical_State_Machine::On_Message const Message * p_Message  ) 
 

Receive methods and invoke the handler for the currently active state.

Note that p_Current_State has already been set to the current state.

Parameters:
p_Message Pointer to the message being processed.

Definition at line 17 of file Hierarchical_State_Machine.cpp.

00018 {
00019     switch (p_Message->GetType())
00020     {
00021     case Message::FAULT_TRIGGER:
00022         p_Current_State->On_Fault_Trigger(*this, p_Message);
00023         break;
00024 
00025     case Message::SWITCHOVER:
00026         p_Current_State->On_Switchover(*this, p_Message);
00027         break;
00028 
00029     case Message::DIAGNOSTICS_PASSED:
00030         p_Current_State->On_Diagnostics_Passed(*this, p_Message);
00031         break;
00032 
00033     case Message::DIAGNOSTICS_FAILED:
00034         p_Current_State->On_Diagnostics_Failed(*this, p_Message);
00035         break;
00036 
00037     case Message::OPERATOR_INSERVICE:
00038         p_Current_State->On_Operator_Inservice(*this, p_Message);
00039         break;
00040 
00041     default:
00042         assert(false);
00043         break;
00044     }
00045 }


The documentation for this class was generated from the following files:
Generated on Sun Feb 13 21:30:28 2005 for Object Oriented Design Examples by doxygen 1.3.4
 Home   What's New   EventStudio 2.5   Real-time Mantra   Thought Projects   Contact Us
Copyright © 2000-2005 EventHelix.com Inc. All Rights Reserved.