GraphExecutor::InNode ** _aReStartNode ,
bool & _PyFuncRunned ,
PyObject ** _MyPyRunMethod ,
- pthread_mutex_t &_MutexDataWait ,
- bool &_DataWait ,
+// pthread_mutex_t &_MutexDataWait ,
+// bool &_DataWait ,
+ pthread_mutex_t &_MutexDataReady ,
pthread_mutex_t &_MutexWait ,
pthread_cond_t &_ReadyWait ,
pthread_cond_t &_RunningWait ,
*_aReStartNode = NULL ;
_PyFuncRunned = false ;
*_MyPyRunMethod = NULL ;
- pthread_mutex_init( &_MutexDataWait , NULL ) ;
- _DataWait = false ;
+// pthread_mutex_init( &_MutexDataWait , NULL ) ;
+// _DataWait = false ;
+ pthread_mutex_init( &_MutexDataReady , NULL ) ;
pthread_mutex_init( &_MutexWait , NULL ) ;
if ( pthread_cond_init( &_ReadyWait , NULL ) ) {
perror("pthread_cond_init( &_ReadyWait , NULL )") ;
&_aReStartNode ,
_PyFuncRunned ,
&_MyPyRunMethod ,
- _MutexDataWait ,
- _DataWait ,
+// _MutexDataWait ,
+// _DataWait ,
+ _MutexDataReady ,
_MutexWait ,
_ReadyWait ,
_RunningWait ,
&_aReStartNode ,
_PyFuncRunned ,
&_MyPyRunMethod ,
- _MutexDataWait ,
- _DataWait ,
+// _MutexDataWait ,
+// _DataWait ,
+ _MutexDataReady ,
_MutexWait ,
_ReadyWait ,
_RunningWait ,
GraphExecutor::InNode::~InNode() {
}
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+#if 0
void GraphExecutor::InNode::LockDataWait() {
// cdebug_in << "GraphExecutor::InNode::LockDataWait " << endl ;
if ( pthread_mutex_lock( &_MutexDataWait ) ) {
}
// cdebug_out << "GraphExecutor::InNode::UnLockDataWait " << endl ;
}
+#endif
+
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+void GraphExecutor::InNode::LockDataReady() {
+// cdebug_in << pthread_self() << "/" << ThreadNo()
+// << "GraphExecutor::InNode::LockDataReady : " << Name() << " _MutexDataReadyLocked "
+// << _MutexDataReadyLocked << " HasAllDataReady " << HasAllDataReady() << endl ;
+ if ( pthread_mutex_lock( &_MutexDataReady ) ) {
+ perror("MutexDataReady pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ _MutexDataReadyLocked = true ;
+// cdebug_out << pthread_self() << "/" << ThreadNo()
+// << "GraphExecutor::InNode::LockDataReady : " << Name() << endl ;
+}
+void GraphExecutor::InNode::UnLockDataReady() {
+// cdebug_in << pthread_self() << "/" << ThreadNo()
+// << "GraphExecutor::InNode::UnLockDataReady : " << Name() << " _MutexDataReadyLocked "
+// << _MutexDataReadyLocked << " HasAllDataReady " << HasAllDataReady() << endl ;
+ if ( pthread_mutex_unlock( &_MutexDataReady ) ) {
+ perror("MutexDataReady pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+ _MutexDataReadyLocked = false ;
+// cdebug_out << pthread_self() << "/" << ThreadNo()
+// << "GraphExecutor::InNode::UnLockDataReady : " << Name() << endl ;
+}
Engines::Component_var GraphExecutor::InNode::Component() const {
if ( IsFactoryNode() ) {
bool GraphExecutor::InNode::Ping() {
-// cdebug_in << "GraphExecutor::InNode::Ping" << endl;
- bool RetVal ;
+ cdebug_in << "GraphExecutor::InNode::Ping" << endl;
+ bool RetVal = true ;
if ( IsFactoryNode() ) {
RetVal = !CORBA::is_nil( _FactoryNode->Component() ) ;
if ( RetVal ) {
RetVal = false ;
}
}
+ else {
+ cdebug << "GraphExecutor::InNode::Ping Component ObjRef is NIL" << endl;
+ }
}
-// cdebug_out << "GraphExecutor::InNode::Ping" << endl ;
+ cdebug_out << "GraphExecutor::InNode::Ping" << endl ;
return RetVal ;
}
int i;
_ControlState = SUPERV::VoidState ;
CreateNewThread( false ) ;
- CreateNewThreadIf( false ) ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// CreateNewThreadIf( false ) ;
+ HasAllDataReady( false ) ;
_SuspendSync = false ;
_ResumeSync = false ;
_InitLoop = false ;
GetChangeNodeOutPort(i)->PortState( SUPERV::ReadyState ) ;
GetChangeNodeOutPort(i)->PortDone( true ) ;
}
- else if ( i != 0 || !IsGOTONode() ) {
+//JR Debug 01.07.2005 :
+// else if ( i != 0 || !IsGOTONode() ) {
+ else {
GetChangeNodeOutPort(i)->PortState( SUPERV::WaitingState ) ;
GetChangeNodeOutPort(i)->PortDone( false ) ;
}
}
- int Pc = GetNodeInPortsSize() ;
+ int InPortsCount = GetNodeInPortsSize() ;
for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
- const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
+ GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
+ anInPort->PortState( SUPERV::WaitingState ) ;
GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
if ( IsHeadNode() && IsLoopNode() && anInPort->IsLoop() ) {
anOutPort->PortStatus( DataConnected );
CORBA::Any anAny = CORBA::Any() ;
//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
anAny <<= (long ) 1 ;
- anOutPort->Value( anAny ) ;
+ anOutPort->SetValue( anAny ) ;
_InitLoop = true ;
cdebug << "InPort" << i << " " << anInPort->PortName() << " " << anInPort->PortStatus()
<< " OutPort " << anOutPort->PortStatus() << theAutomaton->StateName( anOutPort->PortState() )
<< " Gate HeadNode" << endl ;
}
else {
- cdebug << Name() << " IsHeadNode " << IsHeadNode() << " InPort" << i << " " << anInPort->PortName()
- << " " << anInPort->PortStatus() << endl ;
+ cdebug << Name() << " IsHeadNode " << IsHeadNode() << " InPort" << i << " "
+ << anInPort->PortName() << " " << anInPort->PortStatus() << endl ;
}
if ( anInPort->IsGate() && anOutPort == NULL ) {
- Pc-- ;
- cdebug << "InPort" << i << " " << anInPort->PortName() << " Not connected Pc " << Pc << endl ;
+ InPortsCount-- ;
+ cdebug << "InPort" << i << " " << anInPort->PortName() << " Not connected InPortsCount "
+ << InPortsCount << endl ;
}
else if ( anOutPort ) {
if ( anOutPort->IsDataConnected() || anOutPort->IsDataStream() ) {
- Pc-- ;
+ InPortsCount-- ;
anOutPort->PortState( SUPERV::ReadyState ) ;
anOutPort->PortDone( true ) ;
cdebug << "InPort" << i << " " << anInPort->PortName() << " " << anInPort->PortStatus()
- << " " << theAutomaton->StateName( anOutPort->PortState() ) << " Pc " << Pc << endl ;
+ << " " << theAutomaton->StateName( anOutPort->PortState() ) << " InPortsCount "
+ << InPortsCount << endl ;
}
else if ( anOutPort->IsPortConnected() ) {
anOutPort->PortState( SUPERV::WaitingState ) ;
anOutPort->PortDone( false ) ;
- cdebug << "InPort" << i << " " << anInPort->PortName() << " " << " " << anInPort->PortStatus()
- << " " << theAutomaton->StateName( anOutPort->PortState() ) << " Pc " << Pc << endl ;
+ cdebug << "InPort" << i << " " << anInPort->PortName() << " " << " "
+ << anInPort->PortStatus()
+ << " " << theAutomaton->StateName( anOutPort->PortState() ) << " InPortsCount "
+ << InPortsCount << endl ;
}
else {
cdebug << "InPort" << i << " " << anInPort->PortName() << " " << anInPort->PortStatus()
<< " OutPort " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
- << theAutomaton->StateName( anOutPort->PortState() ) << " Pc " << Pc << endl ;
+ << theAutomaton->StateName( anOutPort->PortState() ) << " InPortsCount "
+ << InPortsCount << endl ;
}
}
else {
cdebug << "InPort" << i << " " << anInPort->PortName() << " " << " " << anInPort->PortStatus()
- << " no corresponding OutPort Pc " << Pc << endl ;
+ << " no corresponding OutPort InPortsCount " << InPortsCount << endl ;
}
if ( anOutPort ) {
if ( !anOutPort->IsDataStream() || anInPort->IsDataStream() ) {
}
}
- _currentState = Pc > 0 ? GraphExecutor::DataWaitingState
+ _currentState = InPortsCount > 0 ? GraphExecutor::DataWaitingState
: GraphExecutor::DataReadyState ;
- if ( Pc == GetNodeInPortsSize() ) {
+ if ( InPortsCount == GetNodeInPortsSize() ) {
_OutNode->PushEvent( this , GraphExecutor::NoDataReadyEvent ,
_currentState ) ;
}
- else if ( Pc != 0 ) {
+ else if ( InPortsCount != 0 ) {
_OutNode->PushEvent( this , GraphExecutor::SomeDataReadyEvent ,
_currentState ) ;
}
<< " " << GetNodeOutPort(i)->Kind() << endl ;
}
- cdebug << "CurrentState = " << theAutomaton->StateName( _currentState )
- << endl;
-
- cdebug_out << "GraphExecutor::InNode::InitialState" << endl;
+ cdebug_out << "GraphExecutor::InNode::InitialState Node " << Name() << " CurrentState = "
+ << theAutomaton->StateName( _currentState ) << " HasAllDataReady "
+ << HasAllDataReady() << endl;
}
bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
cdebug_in << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " WithErr " << WithErr
<< " PyFuncRunned() " << PyFuncRunned() << endl;
bool Err = false ;
+ bool OneErr ;
if ( !PyFuncRunned() && IsOneOfInLineNodes() ) {
if ( IsLoopNode() ) {
PyObject * PyRunMethod = InLineNode()->PyRunMethod() ;
PyObject * PyMoreMethod = NULL ;
PyObject * PyNextMethod = NULL ;
if ( PyRunMethod ) {
+ OneErr = false ;
}
else {
PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
InLineNode()->PythonFunction() ,
- Err ) ;
+ OneErr ) ;
InLineNode()->PyRunMethod( PyRunMethod ) ;
}
- if ( !Err ) {
- PyMoreMethod = LoopNode()->PyMoreMethod() ;
- if ( PyMoreMethod ) {
- }
- else {
- PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() ,
- LoopNode()->MorePythonFunction() ,
- Err ) ;
- LoopNode()->PyMoreMethod( PyMoreMethod ) ;
- }
+ Err = Err || OneErr ;
+ if ( OneErr && WithErr ) {
+ string anErrorMessage = string( "Error while declaring the Python function " ) +
+ string( LoopNode()->PyFuncName() ) + string( " in Node " ) +
+ string( Name() ) ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
}
- if ( !Err ) {
- PyNextMethod = LoopNode()->PyNextMethod() ;
- if ( PyNextMethod ) {
- }
- else {
- PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() ,
- LoopNode()->NextPythonFunction() ,
- Err ) ;
- LoopNode()->PyNextMethod( PyNextMethod ) ;
- }
+ PyMoreMethod = LoopNode()->PyMoreMethod() ;
+ if ( PyMoreMethod ) {
+ OneErr = false ;
+ }
+ else {
+ PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() ,
+ LoopNode()->MorePythonFunction() ,
+ OneErr ) ;
+ LoopNode()->PyMoreMethod( PyMoreMethod ) ;
+ }
+ Err = Err || OneErr ;
+ if ( OneErr && WithErr ) {
+ string anErrorMessage = string( "Error while declaring the Python function " ) +
+ string( LoopNode()->PyMoreName() ) + string( " in Node " ) +
+ string( Name() ) ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ }
+ PyNextMethod = LoopNode()->PyNextMethod() ;
+ if ( PyNextMethod ) {
+ OneErr = false ;
}
- cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod(Init) " << PyRunMethod
- << " PyMoreMethod " << PyMoreMethod << " PyNextMethod " << PyNextMethod << endl;
+ else {
+ PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() ,
+ LoopNode()->NextPythonFunction() ,
+ OneErr ) ;
+ LoopNode()->PyNextMethod( PyNextMethod ) ;
+ }
+ Err = Err || OneErr ;
+ if ( OneErr && WithErr ) {
+ string anErrorMessage = string( "Error while declaring the Python function " ) +
+ string( LoopNode()->PyNextName() ) + string( " in Node " ) +
+ string( Name() ) ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ }
+ cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod(Init) "
+ << PyRunMethod << " PyMoreMethod " << PyMoreMethod << " PyNextMethod " << PyNextMethod
+ << endl;
}
else if ( IsInLineNode() || IsSwitchNode() ) {
PyObject * PyRunMethod = InLineNode()->PyRunMethod() ;
if ( PyRunMethod ) {
+ OneErr = false ;
}
else {
PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
InLineNode()->PythonFunction() ,
- Err ) ;
+ OneErr ) ;
InLineNode()->PyRunMethod( PyRunMethod ) ;
}
+ Err = Err || OneErr ;
+ if ( OneErr && WithErr ) {
+ string anErrorMessage = string( "Error while declaring the Python function " ) +
+ string( InLineNode()->PyFuncName() ) + string( " in Node " ) +
+ string( Name() ) ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ }
cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl;
}
else if ( ( IsEndLoopNode() || IsEndSwitchNode() || IsGOTONode() ) &&
(*InLineNode()->PythonFunction()).length() ) {
PyObject * PyRunMethod = InLineNode()->PyRunMethod() ;
if ( PyRunMethod ) {
+ OneErr = false ;
}
else {
PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
InLineNode()->PythonFunction() ,
- Err ) ;
+ OneErr ) ;
InLineNode()->PyRunMethod( PyRunMethod ) ;
}
+ Err = Err || OneErr ;
+ if ( OneErr && WithErr ) {
+ string anErrorMessage = string( "Error while declaring the Python function " ) +
+ string( InLineNode()->PyFuncName() ) + string( " in Node " ) +
+ string( Name() ) ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ }
cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl;
}
}
const long GraphExecutor::InNode::CpuUsed( bool tot ) {
CORBA::Long cpu = 0 ;
+// cdebug_in << "GraphExecutor::InNode::CpuUsed( " << tot << " ) " << Name() << endl ;
// cout << "Begin CpuUsed " << Name() << " CpuUsed : " << cpu << " State "
// << theAutomaton->StateName( _currentState ) << endl ;
-// cdebug_in << "GraphExecutor::InNode::CpuUsed( " << tot << " )" << Name() << endl ;
if ( IsOneOfInLineNodes() ) {
// cdebug << "CpuUsed " << Name() << " --> PyCpuUsed()" << endl ;
// cout << "CpuUsed " << Name() << " --> PyCpuUsed()" << endl ;
cpu = Component()->CpuUsed_impl() ;
}
catch ( ... ) {
- cdebug << "CpuUsed " << Name() << " --> Component()->CpuUsed_impl() ERROR catched " << endl ;
+ cdebug << "CpuUsed " << Name() << " --> Component()->CpuUsed_impl() ERROR catched "
+ << endl ;
State( GraphExecutor::ErroredState ) ;
_OutNode->State( GraphExecutor::ErroredState ) ;
- cpu = 0 ;
+ cpu = -1 ;
}
}
+ else {
+ cdebug << "CpuUsed " << Name() << " Component() is NIL" << endl ;
+ cpu = -1 ;
+ }
}
// cdebug_out << "GraphExecutor::InNode::CpuUsed " << Name() << " CpuUsed : " << cpu << endl ;
// cout << "End CpuUsed " << Name() << " CpuUsed : " << cpu << " State "
PyObject * _MyPyRunMethod ;
bool _createNewThread ;
- bool _createNewThreadIf ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// bool _createNewThreadIf ;
int _RewindStack ;
GraphExecutor::AutomatonState _OldState ;
GraphExecutor::AutomatonState _currentState ;
SUPERV::ControlState _ControlState ;
GraphExecutor::AutomatonState _NextState ;
GraphExecutor::StateEventAction _NextAction ;
+
+ pthread_mutex_t _MutexDataReady ;
+ bool _MutexDataReadyLocked ;
+ bool _HasAllDataReady ;
+
bool _PyFuncRunned ;
bool _Loading ;
- pthread_mutex_t _MutexDataWait ;
- bool _DataWait ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// pthread_mutex_t _MutexDataWait ;
+// bool _DataWait ;
pthread_mutex_t _MutexWait ;
bool & Err ) ;
void RemovePyDynInvoke( char * PyFuncName ) ;
- void LockDataWait() ;
- void UnLockDataWait() ;
- bool IsLockedDataWait() { return _DataWait ; } ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// void LockDataWait() ;
+// void UnLockDataWait() ;
+// bool IsLockedDataWait() { return _DataWait ; } ;
+ void LockDataReady() ;
+ void UnLockDataReady() ;
+ void HasAllDataReady( bool hasAllDataReady ) {
+// cdebug << "Executor::InNode::HasAllDataReady( " << hasAllDataReady
+// << " ) " << Name() << " previous _HasAllDataReady " << _HasAllDataReady
+// << endl ;
+ _HasAllDataReady = hasAllDataReady ; } ;
+ bool HasAllDataReady() const {
+ return _HasAllDataReady ; }
bool Ping() ;
bool ContainerKill() ;
void CreateNewThread( bool k_create ) {
// cdebug << Name() << " CreateNewThread " << k_create << endl ;
_createNewThread = k_create ; } ;
- void CreateNewThreadIf( bool k_create ) {
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// void CreateNewThreadIf( bool k_create ) {
// cdebug << Name() << " CreateNewThreadIf( " << k_create << " )" << endl ;
- _createNewThreadIf = k_create ; } ;
+// _createNewThreadIf = k_create ; } ;
bool CreateNewThread() { return _createNewThread ; } ;
- bool CreateNewThreadIf() { return _createNewThreadIf ; } ;
+// bool CreateNewThreadIf() { return _createNewThreadIf ; } ;
void NewThread( pthread_t aThread ) ;
void ExitThread() ;
void RewindStack( int aRewindStack ) { _RewindStack = aRewindStack ; } ;
int DataReady_KillAction() ;
int DataReady_StopAction() ;
int DataReady_ExecuteAction() ;
+ int DataReady_ExecuteActionInLineNodes( ServicesAnyData * InParametersList ,
+ ServicesAnyData * OutParametersList ) ; int DataReady_ExecuteActionLoopNodes( ServicesAnyData * InParametersList ,
+ ServicesAnyData * OutParametersList ,
+ bool & CopyInOut ) ;
void DynInvoke( Engines::Component_ptr obj,
const char *method,
ServicesAnyData * inParams, int nInParams,
int Executing_KillAction() ;
int Executing_StopAction() ;
int Executing_SuccessAction() ;
- int Executing_ErrorAction() ;
+// int Executing_ErrorAction() ;
+ int Errored_ExecutingAction() ;
int Successed_SuccessAction() ;
bool SendSomeDataReady( char * FromNodeName ) ;
int Errored_ErrorAction() ;
bool OutParametersSet( bool Err , SUPERV::GraphState PortState ,
int nOutParams ,
ServicesAnyData * OutParametersList ) ;
+ void SetOutPortsOfInportsOfEndSwitch( GraphBase::OutPort * anOutPort ,
+ const char * anEndSwitchNodeName ) ;
void coutbegin() ;
void coutexit() ;
} ;
+
#endif