36 CControlFlow::CState::CState(
oETCS::DF::CControlFlow *
const pParent,
const std::string & StateName, const ::std::vector< oETCS::DF::CFunctionBlock * >& FunctionBlocks, const ::std::vector< oETCS::DF::CAbstractFlow * >& Flows,
const bool & bIsFinal,
const bool & bIsInitial)
throw()
41 m_FunctionBlocks(FunctionBlocks),
49 pParent->AddState(
this, bIsInitial);
75 const unsigned int NUMBER_FUNCTION_BLOCKS(m_FunctionBlocks.size());
80 for (x = 0; x < NUMBER_FUNCTION_BLOCKS && !bFound; x++)
83 bFound = (m_FunctionBlocks[x] == pFunctionBlock);
86 if (!bFound && dynamic_cast< ::oETCS::DF::CControlFlow* >(m_FunctionBlocks[x]) != 0)
108 decltype (m_Flows.begin()) f;
109 decltype (m_FunctionBlocks.begin()) fb;
114 for (f = m_Flows.begin(); f != m_Flows.end() && not bFound; f++)
117 bFound = (*f == pFlow);
122 for (fb = m_FunctionBlocks.begin(); fb != m_FunctionBlocks.end() && not bFound; fb++)
125 if (!bFound && dynamic_cast< ::oETCS::DF::CControlFlow* >(*fb) != 0)
147 const unsigned int NUMBER_FUNCTION_BLOCKS(m_FunctionBlocks.size());
153 #ifdef __DEBUG_OUTPUT__
155 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CState::Execute()() ----> method entered of state " << this->m_Name << ::std::endl;
160 for (x = 0; x < NUMBER_FUNCTION_BLOCKS; x++)
162 #ifdef __DEBUG_OUTPUT__
164 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CState::Execute()() ----> about to execute function block " << x << ::std::endl;
168 m_FunctionBlocks[x]->Calculate();
174 if (!m_TransitionStack.empty())
177 pTransition = m_TransitionStack[0];
180 for (x = 0; x < m_TransitionStack.size(); x++)
183 if (pTransition->GetPriority() < m_TransitionStack[x]->GetPriority())
186 pTransition = m_TransitionStack[x];
193 m_pParent->m_pCurrentState = pTransition->GetTargetState();
195 #ifdef __DEBUG_OUTPUT__
197 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CState::Execute()() ----> executed transition to new state " << m_pParent->m_pCurrentState << ::std::endl;
206 m_pParent->m_pCurrentState = 0;
208 #ifdef __DEBUG_OUTPUT__
210 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CState::Execute()() ----> final state reached" << ::std::endl;
216 catch (const ::oETCS::DF::Error::CException&)
351 const unsigned int NUMBER_RUNNING_OUTPUTS(
m_IsRunning.size());
356 #ifdef __DEBUG_OUTPUT__
358 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CControlFlow::Calculate() ----> method entered " << ::std::endl;
367 #ifdef __DEBUG_OUTPUT__
369 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CControlFlow::Calculate() ----> (re)started control flow with initial state " <<
m_pCurrentState << ::std::endl;
377 #ifdef __DEBUG_OUTPUT__
379 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CControlFlow::Calculate() ----> about to execute current state " <<
m_pCurrentState << ::std::endl;
382 for (x = 0; x < NUMBER_STATE_OUTPUTS; x++)
395 catch (const ::oETCS::DF::Error::CException&)
405 for (x = 0; x < NUMBER_RUNNING_OUTPUTS; x++)