41 m_FunctionBlocks(FunctionBlocks),
44 m_pFaultState(pFaultState)
48 m_pParent->AddDataFlow(ApplicationLevel,
this);
89 for (x = 0; x < NUMBER_FUNCTION_BLOCKS && !bFound; x++)
95 if (!bFound && dynamic_cast< ::oETCS::DF::CControlFlow* >(
m_FunctionBlocks[x]) != 0)
126 bFound = (pFlow == *f);
134 if (!bFound && dynamic_cast< ::oETCS::DF::CControlFlow* >(*fb) !=
nullptr)
162 for (x = 0; x < NUMBER_FUNCTION_BLOCKS; x++)
168 if (dynamic_cast< ::oETCS::DF::CComBlockIn* >(
m_FunctionBlocks[x]) !=
nullptr)
183 catch (const ::oETCS::DF::Error::CException& Exception)
186 #ifdef __DEBUG_OUTPUT__
188 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CDataFlow::Execute() ----> exception in function block object " << x << ::std::endl;
201 ::std::cerr <<
"Error while executing data flow: " << Exception.what() <<
" in " << __FILE__ <<
" at line " << __LINE__ << ::std::endl;
210 ::std::cerr <<
"Error while executing data flow, but now fault state available: " << Exception.what() <<
" in " << __FILE__ <<
" at line " << __LINE__ << ::std::endl;
273 for (x = 0; x < y->second.size(); x++)
340 #ifdef __DEBUG_OUTPUT__
342 ::std::cerr << std::this_thread::get_id() <<
" " <<
"StateThread ----> new state object started " <<
this << ::std::endl;
346 catch (const ::std::bad_alloc&)
369 catch (const ::std::exception& Exception)
371 #ifdef __DEBUG_OUTPUT__
373 ::std::cerr << std::this_thread::get_id() <<
" " <<
"StateThread ----> uncaught ::std::exception " << Exception.what() << ::std::endl;
389 #ifdef __DEBUG_OUTPUT__
391 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CEVCState::Start() -----> waiting for thread " << y << ::std::endl;
402 #ifdef __DEBUG_OUTPUT__
404 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CEVCState::Start() -----> deleted thread " << y << ::std::endl;
444 #ifdef __DEBUG_OUTPUT__
446 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CEVCState::Stop() called " << ::std::endl;
452 #ifdef __DEBUG_OUTPUT__
454 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CEVCState::Stop() -----> waiting for this EVC state " <<
this << ::std::endl;
461 ::std::this_thread::yield();
468 #ifdef __DEBUG_OUTPUT__
470 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CEVCState::Stop() -----> # threads after waiting " <<
m_Threads.size() << ::std::endl;
504 for (x = 0; x < NUMBER_DATA_FLOWS && !bActive; x++)
530 for (x = 0; x < NUMBER_DATA_FLOWS && !bActive; x++)
577 m_DataFlows[ApplicationLevel].push_back(pDataFlow);
608 ::std::unique_lock< ::std::mutex > Lock(Mutex);
609 ::std::chrono::time_point< ::std::chrono::high_resolution_clock,
610 ::std::chrono::duration<
long long,
611 ::std::chrono::high_resolution_clock::duration::period > > StartTime;
612 ::std::chrono::duration<
long long,
613 ::std::chrono::high_resolution_clock::duration::period > SleepTime;
614 const ::std::chrono::duration<
long long,
615 ::std::chrono::high_resolution_clock::duration::period > SAMPLE_TIME(::std::chrono::microseconds(
__DATA_FLOW_SAMPLE_TIME__));
616 const ::oETCS::DF::CEVCTransition* pStateTransition(0);
642 StartTime = ::std::chrono::high_resolution_clock::now();
652 #ifdef __DEBUG_OUTPUT__
654 ::std::cerr << std::this_thread::get_id() <<
" " <<
"DataFlowThread ----> # executed data flow " << iIndex << ::std::endl;
658 catch (const ::oETCS::DF::Error::CException& Exception)
661 ::std::cerr <<
"Error while executing data flow # " << iIndex <<
": " << Exception.what() <<
" in " << __FILE__ <<
" at line " << __LINE__ << ::std::endl;
672 #ifdef __DEBUG_OUTPUT__
674 ::std::cerr << std::this_thread::get_id() <<
" " <<
"DataFlowThread ----> # locked threads " <<
m_iLockedThreads <<
" # threads " <<
m_Threads.size() << ::std::endl;
700 if (pStateTransition->GetStartState() !=
this)
703 ::std::cerr <<
"In file " << __FILE__ <<
" at line " << __LINE__ <<
": activated transition object has false start state" << ::std::endl;
710 #ifdef __DEBUG_OUTPUT__
712 ::std::cerr << std::this_thread::get_id() <<
" " <<
"DataFlowThread ----> switch to new state object " <<
m_pParent->
m_pCurrentState << ::std::endl;
745 SleepTime = SAMPLE_TIME - (::std::chrono::high_resolution_clock::now() - StartTime);
748 if (SleepTime.count() >= 0 )
751 ::std::this_thread::sleep_for(SleepTime);
757 ::std::cerr <<
"In file " << __FILE__ <<
" in line " << __LINE__ <<
": sample time exceeded in thread" << std::endl;
762 StartTime += SAMPLE_TIME;
766 #ifdef __DEBUG_OUTPUT__
768 ::std::cerr << std::this_thread::get_id() <<
" " <<
"DataFlowThread ----> execution self stopped (end of while)" << ::std::endl;
854 if (pFunctionBlock != 0)
888 if (pTransition != 0)
939 if (pDMIObserver !=
nullptr)
960 if (pDMIObserver !=
nullptr)
966 if (*o == pDMIObserver)
1041 return (pCurrentDMI);
1057 if (pStartState == 0)
1141 #ifdef __DEBUG_OUTPUT__
1143 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CEVCStateMachine::Stop() called " << ::std::endl;
1155 #ifdef __DEBUG_OUTPUT__
1157 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CEVCStateMachine::Stop() -----> waiting for thread" << ::std::endl;
1171 #ifdef __DEBUG_OUTPUT__
1173 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CEVCStateMachine::Stop() -----> all stopped" << ::std::endl;
1211 #ifdef __DEBUG_OUTPUT__
1213 ::std::cerr << std::this_thread::get_id() <<
" " <<
"StateThread ----> about to start state in level " <<
m_CurrentApplicationLevel << ::std::endl;
1222 catch (const ::oETCS::DF::Error::CException& Exception)
1228 ::std::cerr <<
"Error while executing current EVC state: " << Exception.what() <<
" in " << __FILE__ <<
" at line " << __LINE__ <<
" and no fault state available!" << ::std::endl;
1232 #ifdef __DEBUG_OUTPUT__
1234 ::std::cerr << std::this_thread::get_id() <<
" " <<
"StateThread ----> execution of current state stopped" << ::std::endl;
1246 :m_pCondition(pCondition),
1247 m_pStartState(pStartState),
1248 m_pTargetState(pTargetState),
1249 m_iPriority(iPriority)
1253 m_pStartState->m_pParent->AddTransition(
this);
1276 return (m_pCondition);
1288 return (m_pStartState);
1300 return (m_pTargetState);
1312 return (m_iPriority);
1321 :m_pStateMachine(pStateMachine)
1325 if (pStateMachine !=
nullptr)
1328 m_pStateMachine->AddFunctionBlock(
this);
1362 :m_pStateMachine(pStateMachine)
1400 if (m_pStateMachine->GetActiveState() ==
nullptr || m_pStateMachine->GetActiveState()->IsActiveFlow(
this))
1403 switch (Value.GetLastInputType())
1407 m_pInput->m_bBoolInput = Value.m_bBoolInput();
1414 m_pInput->m_dDoubleInput = Value.m_dDoubleInput();
1421 m_pInput->m_DoubleArrayInput = Value.m_DoubleArrayInput();
1428 m_pInput->m_iIntInput = Value.m_iIntInput();
1435 m_pInput->m_StringInput = Value.m_StringInput();
1463 m_bLevelSwitch(
false),
1464 m_TargetApplicationLevel(ApplicationLevel)
1490 if (m_bLevelSwitch())
1494 m_pStateMachine->m_CurrentApplicationLevel = m_TargetApplicationLevel;
1496 #ifdef __DEBUG_OUTPUT__
1498 ::std::cerr << std::this_thread::get_id() <<
" " <<
"CLevelCondition::Calculate() -----> set new application level: " << m_pStateMachine->m_CurrentApplicationLevel << ::std::endl;
1502 m_pStateMachine->GetActiveState()->m_bStateLevelSwitch =
true;
1540 const unsigned int NUMBER_TRANSITIONS(m_pStateMachine->GetTransitions().size());
1547 for (x = 0; x < NUMBER_TRANSITIONS && !bFound; x++)
1550 if (m_pStateMachine->GetTransitions()[x]->GetCondition() ==
this && m_pStateMachine->GetTransitions()[x]->GetStartState() == m_pStateMachine->GetActiveState())
1553 m_pStateMachine->GetActiveState()->m_TransitionStack.push_back(m_pStateMachine->GetTransitions()[x]);
1566 m_bGuard.IsModified();
1584 CDMISubject::CDMISubject(const ::std::vector< oETCS::DF::CDMIInput * >& Inputs, const ::std::vector< oETCS::DF::CDMIOutput * >& Outputs)
throw()
1609 :m_pStateMachine(pStateMachine)
1619 ::std::ostream& operator<<(::std::ostream & OutStream, const ::std::vector< double >& Vector)
throw()
1622 decltype (Vector.begin()) x;
1631 for (x = Vector.begin(); x != Vector.end(); x++)
1634 OutStream << *x <<
"; ";