openETCS
case study for the European Train Control System developed for the authors dissertation
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
oETCS::DF::CEVCStateMachine::CEVCState Class Reference

EVC state class executed by the EVC state machine. More...

#include <EVCStateMachine.h>

Collaboration diagram for oETCS::DF::CEVCStateMachine::CEVCState:
Collaboration graph

Classes

class  CDataFlow
 data flow class for executing data flows and embedded control flows More...

Public Member Functions

void AddDataFlow (const std::string &ApplicationLevel, CDataFlow *const pDataFlow) throw ()
 register a new data flow object
void AddTransition (oETCS::DF::CTransition *const pTransition) throw ()
 register a new transition object
 CEVCState (CEVCStateMachine *const pParent) throw ()
 general constructor
::std::vector< CDataFlow * > GetCurrentDataFlow () const throw ()
 gets the current data flow
::std::vector
< oETCS::DF::CTransition * > 
GetTransitions () const throw ()
 gets all transisiton objects in this state
bool IsActiveFlow (oETCS::DF::CAbstractFlow *const pFlow) const throw ()
 returns true, if a CFlowobjects is active in an EVC state
bool IsActiveFunctionBlock (oETCS::DF::CFunctionBlock *const pFunctionBlock) const throw ()
 returns true, if a CFunctionBlock objects is active in an EVC state
bool IsRunning () const throw ()
 returns the running flag
void Start () throw (::oETCS::DF::Error::CException)
 starts the permanent execution of the related data flow
void Stop () throw ()
 stops the execution the data flow by the underlying CFunctionBlock objects
virtual ~CEVCState () throw ()
 destructor

Public Attributes

CEVCStateMachine *const m_pParent
 pointer to the parent EVC state machine

Private Member Functions

void DataFlowThread (const unsigned int &iIndex) throw ()
 thread method/function for executing one data flow

Private Attributes

::std::condition_variable m_Barrier
 condition variable as barrier for data flow syncronisation
bool m_bStateLevelSwitch
 flag for a state and/or level switch within the EVC state machine
::std::vector< CDataFlow * > m_CurrentDataFlow
 vector of pointers to the currently executed data flows
::std::vector
< ::oETCS::DF::Error::CException
m_DataFlowExceptions
 vector of exception thrown by data flow exections within threads
::std::map< std::string,::std::vector
< CDataFlow * > > 
m_DataFlows
 map of vectors of data flows in a certain EVC state indexed by the related application level
unsigned int m_iLockedThreads
 number of currently locked threads.
::std::vector< ::std::thread * > m_Threads
 vector of thread objects for data flow execution
::std::vector
< oETCS::DF::CTransition * > 
m_Transitions
 vector with pointers to all state transition within the current data flow
::std::vector< const
oETCS::DF::CEVCTransition * > 
m_TransitionStack
 vector with pointers to EVC transition objects, which were activated

Friends

class oETCS::DF::CEVCCondition
class oETCS::DF::CLevelCondition

Detailed Description

EVC state class executed by the EVC state machine.

Is a nested class to gain direct access to its parent class.

Definition at line 79 of file EVCStateMachine.h.

Constructor & Destructor Documentation

oETCS::DF::CEVCStateMachine::CEVCState::CEVCState ( CEVCStateMachine *const  pParent) throw ()

general constructor

Parameterises the EVC state with all constant members. The EVC state object takes over the posession of all variables/memory passed by pointer.

Parameters
[in]pParentpointer to the parent EVC state machine object

Definition at line 223 of file EVCStateMachine.cpp.

References oETCS::DF::CEVCStateMachine::AddState(), and m_pParent.

Here is the call graph for this function:

oETCS::DF::CEVCStateMachine::CEVCState::~CEVCState ( ) throw ()
virtual

destructor

Definition at line 245 of file EVCStateMachine.cpp.

References IsRunning(), m_DataFlows, m_Transitions, and Stop().

Here is the call graph for this function:

Member Function Documentation

void oETCS::DF::CEVCStateMachine::CEVCState::AddDataFlow ( const std::string &  ApplicationLevel,
CDataFlow *const  pDataFlow 
) throw ()

register a new data flow object

Parameters
[in]ApplicationLevelliteral name of the related application level
[in]pDataFlowpointer to the data flow object to be registered

Definition at line 570 of file EVCStateMachine.cpp.

References m_DataFlows.

void oETCS::DF::CEVCStateMachine::CEVCState::AddTransition ( oETCS::DF::CTransition *const  pTransition) throw ()

register a new transition object

Parameters
[in]pTransitionpointer to the transition object to be registered

Definition at line 587 of file EVCStateMachine.cpp.

References m_Transitions.

void oETCS::DF::CEVCStateMachine::CEVCState::DataFlowThread ( const unsigned int &  iIndex) throw ()
private

thread method/function for executing one data flow

Parameters
[in]iIndexindex corresponding to the vector referenced by m_pCurrentDataFlow

Definition at line 604 of file EVCStateMachine.cpp.

References __DATA_FLOW_SAMPLE_TIME__, m_Barrier, oETCS::DF::CEnteredTrigger::m_bEnteredState, m_bStateLevelSwitch, m_CurrentDataFlow, m_DataFlowExceptions, m_iLockedThreads, oETCS::DF::CEVCStateMachine::m_pCurrentState, m_pParent, m_Threads, and m_TransitionStack.

Referenced by Start().

Here is the caller graph for this function:

std::vector< oETCS::DF::CEVCStateMachine::CEVCState::CDataFlow * > oETCS::DF::CEVCStateMachine::CEVCState::GetCurrentDataFlow ( ) const throw ()

gets the current data flow

Returns
vector with pointers to all independent data flow objects

Definition at line 558 of file EVCStateMachine.cpp.

References m_CurrentDataFlow.

Referenced by oETCS::DF::CCondition::Calculate(), and oETCS::DF::CEVCStateMachine::GetCurrentDMI().

Here is the caller graph for this function:

std::vector< oETCS::DF::CTransition * > oETCS::DF::CEVCStateMachine::CEVCState::GetTransitions ( ) const throw ()

gets all transisiton objects in this state

Returns
vector with pointers to transition objects

Definition at line 546 of file EVCStateMachine.cpp.

References m_Transitions.

Referenced by oETCS::DF::CCondition::Calculate().

Here is the caller graph for this function:

bool oETCS::DF::CEVCStateMachine::CEVCState::IsActiveFlow ( oETCS::DF::CAbstractFlow *const  pFlow) const throw ()

returns true, if a CFlowobjects is active in an EVC state

Parameters
[in]pFlowpointer to the concrete CFlow object to be testetd
Returns
active state flag

Definition at line 520 of file EVCStateMachine.cpp.

References m_CurrentDataFlow.

bool oETCS::DF::CEVCStateMachine::CEVCState::IsActiveFunctionBlock ( oETCS::DF::CFunctionBlock *const  pFunctionBlock) const throw ()

returns true, if a CFunctionBlock objects is active in an EVC state

Parameters
[in]pFunctionBlockpointer to a function block object to be testetd
Returns
active state flag

Definition at line 494 of file EVCStateMachine.cpp.

References m_CurrentDataFlow.

Referenced by oETCS::DF::CEVCStateMachine::CEVCState::CDataFlow::IsActiveFunctionBlock().

Here is the caller graph for this function:

bool oETCS::DF::CEVCStateMachine::CEVCState::IsRunning ( ) const throw ()

returns the running flag

Returns
true, if is executing

Definition at line 482 of file EVCStateMachine.cpp.

References m_CurrentDataFlow.

Referenced by Start(), oETCS::DF::CEVCStateMachine::Start(), Stop(), oETCS::DF::CEVCStateMachine::Stop(), ~CEVCState(), and oETCS::DF::CEVCStateMachine::~CEVCStateMachine().

Here is the caller graph for this function:

void oETCS::DF::CEVCStateMachine::CEVCState::Start ( ) throw (::oETCS::DF::Error::CException)

starts the permanent execution of the related data flow

If the number of independent CDataFLow objects for the current application level is greater than 1, this method will start for each additional group a additinal thread, while this method always is blocking. If a CEVCState is executed under the same parent CEVCStateMachine object, this will be stopped before by its CEVCState::Stop() method.

Definition at line 290 of file EVCStateMachine.cpp.

References DataFlowThread(), IsRunning(), oETCS::DF::CEnteredTrigger::m_bEnteredState, m_bStateLevelSwitch, oETCS::DF::CEVCStateMachine::m_CurrentApplicationLevel, m_CurrentDataFlow, m_DataFlowExceptions, m_DataFlows, m_iLockedThreads, m_pParent, m_Threads, and oETCS::DF::CEVCStateMachine::Notify().

Referenced by oETCS::DF::CEVCStateMachine::StateThread().

Here is the call graph for this function:

Here is the caller graph for this function:

void oETCS::DF::CEVCStateMachine::CEVCState::Stop ( ) throw ()

stops the execution the data flow by the underlying CFunctionBlock objects

In the case of more than 1 group of independent CDatatFlow objects this method terminates all related threads by wating for the current execution sample to finish.

Definition at line 438 of file EVCStateMachine.cpp.

References IsRunning(), m_bStateLevelSwitch, and m_Threads.

Referenced by oETCS::DF::CEVCStateMachine::Stop(), ~CEVCState(), and oETCS::DF::CEVCStateMachine::~CEVCStateMachine().

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class oETCS::DF::CEVCCondition
friend

Definition at line 394 of file EVCStateMachine.h.

friend class oETCS::DF::CLevelCondition
friend

Definition at line 395 of file EVCStateMachine.h.

Member Data Documentation

::std::condition_variable oETCS::DF::CEVCStateMachine::CEVCState::m_Barrier
private

condition variable as barrier for data flow syncronisation

Definition at line 369 of file EVCStateMachine.h.

Referenced by DataFlowThread().

bool oETCS::DF::CEVCStateMachine::CEVCState::m_bStateLevelSwitch
private

flag for a state and/or level switch within the EVC state machine

Definition at line 318 of file EVCStateMachine.h.

Referenced by DataFlowThread(), oETCS::DF::CEVCStateMachine::CEVCState::CDataFlow::Execute(), Start(), and Stop().

::std::vector< CDataFlow* > oETCS::DF::CEVCStateMachine::CEVCState::m_CurrentDataFlow
private

vector of pointers to the currently executed data flows

Definition at line 362 of file EVCStateMachine.h.

Referenced by DataFlowThread(), GetCurrentDataFlow(), IsActiveFlow(), IsActiveFunctionBlock(), IsRunning(), and Start().

::std::vector< ::oETCS::DF::Error::CException > oETCS::DF::CEVCStateMachine::CEVCState::m_DataFlowExceptions
private

vector of exception thrown by data flow exections within threads

Definition at line 383 of file EVCStateMachine.h.

Referenced by DataFlowThread(), and Start().

::std::map< std::string, ::std::vector< CDataFlow* > > oETCS::DF::CEVCStateMachine::CEVCState::m_DataFlows
private

map of vectors of data flows in a certain EVC state indexed by the related application level

Each vector holds a set of CDataFlow objects for a certain application level, which are independent from each other and therefore can be executed in parallel.

Definition at line 348 of file EVCStateMachine.h.

Referenced by AddDataFlow(), Start(), and ~CEVCState().

unsigned int oETCS::DF::CEVCStateMachine::CEVCState::m_iLockedThreads
private

number of currently locked threads.

Used in combination of m_Barrier to syncronise all data flow threads.

Definition at line 327 of file EVCStateMachine.h.

Referenced by DataFlowThread(), and Start().

CEVCStateMachine* const oETCS::DF::CEVCStateMachine::CEVCState::m_pParent

pointer to the parent EVC state machine

Definition at line 336 of file EVCStateMachine.h.

Referenced by CEVCState(), DataFlowThread(), oETCS::DF::CEVCStateMachine::CEVCState::CDataFlow::Execute(), and Start().

::std::vector< ::std::thread* > oETCS::DF::CEVCStateMachine::CEVCState::m_Threads
private

vector of thread objects for data flow execution

Definition at line 376 of file EVCStateMachine.h.

Referenced by DataFlowThread(), Start(), and Stop().

::std::vector< oETCS::DF::CTransition* > oETCS::DF::CEVCStateMachine::CEVCState::m_Transitions
private

vector with pointers to all state transition within the current data flow

Definition at line 355 of file EVCStateMachine.h.

Referenced by AddTransition(), oETCS::DF::CEVCStateMachine::AddTransition(), GetTransitions(), oETCS::DF::CEVCStateMachine::GetTransitions(), ~CEVCState(), and oETCS::DF::CEVCStateMachine::~CEVCStateMachine().

::std::vector< const oETCS::DF::CEVCTransition* > oETCS::DF::CEVCStateMachine::CEVCState::m_TransitionStack
private

vector with pointers to EVC transition objects, which were activated

Definition at line 390 of file EVCStateMachine.h.

Referenced by DataFlowThread().


The documentation for this class was generated from the following files:

Copyright (C) 2010-2012 Johannes Feuser (feuser@uni-bremen.de)
The openETCS library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
The openETCS library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the openETCS library. If not, see "http://www.gnu.org/licenses/.