1 // SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowBase_OutNode.cxx
25 // Author : Jean Rahuel, CEA
31 #include "DataFlowExecutor_OutNode.hxx"
33 #include "Graph_Impl.hxx"
35 // Implementation de la classe GraphEditor::GraphControl
37 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
39 // static const char *ComponentName = "SalomeSuperVisionComponent" ;
42 extern char ** _ArgV ;
44 GraphExecutor::OutNode::OutNode() {
50 _ControlState = SUPERV::VoidState ;
51 _State = SUPERV::UnKnownState ;
52 _PyInitialized = false ;
53 pthread_mutex_init( &_MutexWait , NULL ) ;
54 pthread_mutex_init( &_PyMutexWait , NULL ) ;
55 if ( pthread_cond_init( &_EventWait , NULL ) ) {
56 perror("pthread_cond_init( &_EventWait , NULL )") ;
59 if ( pthread_cond_init( &_JoinWait , NULL ) ) {
60 perror("pthread_cond_init( &_JoinWait , NULL )") ;
65 GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB,
66 SALOME_NamingService* ptrNamingService ,
67 const char *DataFlowName ,
68 const char * DebugFileName ,
69 const SUPERV::KindOfNode aKindOfNode ) {
70 // Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
71 Set_prof_debug( ORB , DebugFileName ) ;
72 cdebug_in << "GraphEditor::OutNode::OutNode(" << DataFlowName << " , " << aKindOfNode << ")" << endl;
73 if ( aKindOfNode == SUPERV::DataFlowGraph ) {
75 // _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;
76 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName ,
77 _prof_debug , _fdebug ) ;
79 else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
80 // _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;;
81 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName ,
82 _prof_debug , _fdebug ) ;
83 _Graph = _StreamGraph ;
89 _ControlState = SUPERV::VoidState ;
90 _State = SUPERV::UnKnownState ;
91 _PyInitialized = false ;
92 _Orb = CORBA::ORB::_duplicate( ORB ) ;
93 pthread_mutex_init( &_MutexWait , NULL ) ;
94 pthread_mutex_init( &_PyMutexWait , NULL ) ;
95 if ( pthread_cond_init( &_EventWait , NULL ) ) {
96 perror("pthread_cond_init( &_EventWait , NULL )") ;
99 if ( pthread_cond_init( &_JoinWait , NULL ) ) {
100 perror("pthread_cond_init( &_JoinWait , NULL )") ;
103 cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
106 GraphExecutor::OutNode::OutNode(
108 SALOME_NamingService* ptrNamingService ,
109 const SALOME_ModuleCatalog::Service& DataFlowService ,
110 const char *DataFlowComponentName ,
111 const char *DataFlowInterfaceName ,
112 const char *DataFlowName ,
113 const SUPERV::KindOfNode DataFlowkind ,
114 const SUPERV::SDate DataFlowFirstCreation ,
115 const SUPERV::SDate DataFlowLastModification ,
116 const char * DataFlowEditorRelease ,
117 const char * DataFlowAuthor ,
118 const char * DataFlowComputer ,
119 const char * DataFlowComment ,
120 const char * DebugFileName ) {
121 // Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
122 // DataFlowInterfaceName , DataFlowName , DataFlowkind ,
123 // DataFlowFirstCreation , DataFlowLastModification ,
124 // DataFlowEditorRelease , DataFlowAuthor ,
125 // DataFlowComputer , DataFlowComment , DebugFileName ) {
126 Set_prof_debug( ORB , DebugFileName ) ;
128 cdebug_in << "GraphEditor::OutNode::OutNode(" << DataFlowName << " , " << DataFlowkind << ")" << endl;
129 if ( DataFlowkind == SUPERV::DataFlowGraph ) {
130 _StreamGraph = NULL ;
131 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
132 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
133 DataFlowFirstCreation , DataFlowLastModification ,
134 DataFlowEditorRelease , DataFlowAuthor ,
135 DataFlowComputer , DataFlowComment ,
136 _prof_debug , _fdebug ) ;
137 // DataFlowComputer , DataFlowComment , DebugFileName ) ;
139 else if ( DataFlowkind == SUPERV::DataStreamGraph ) {
140 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
141 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
142 DataFlowFirstCreation , DataFlowLastModification ,
143 DataFlowEditorRelease , DataFlowAuthor ,
144 DataFlowComputer , DataFlowComment ,
145 _prof_debug , _fdebug ) ;
146 _Graph = _StreamGraph ;
149 _Executable = false ;
152 _ControlState = SUPERV::VoidState ;
153 _State = SUPERV::UnKnownState ;
154 _PyInitialized = false ;
155 _Orb = CORBA::ORB::_duplicate( ORB ) ;
156 pthread_mutex_init( &_MutexWait , NULL ) ;
157 pthread_mutex_init( &_PyMutexWait , NULL ) ;
158 if ( pthread_cond_init( &_EventWait , NULL ) ) {
159 perror("pthread_cond_init( &_EventWait , NULL )") ;
162 if ( pthread_cond_init( &_JoinWait , NULL ) ) {
163 perror("pthread_cond_init( &_JoinWait , NULL )") ;
168 GraphExecutor::OutNode::~OutNode() {
171 void GraphExecutor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB ,
172 const char * DebugFileName ) {
173 _Graph_prof_debug = 0 ;
174 if ( DebugFileName ) {
175 _fdebug = new ofstream( DebugFileName );
176 SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ;
177 MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
181 bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph &aDataFlow ) {
182 bool RetVal = false ;
183 RetVal = LoadInfo( aDataFlow.Info ) ;
184 if ( Graph()->ServiceName() != NULL ) {
185 // MESSAGE( "GraphExecutor::OutNode::LoadDataFlow" );
187 RetVal = LoadNodes( aDataFlow.Nodes ) ;
189 RetVal = LoadLinks( aDataFlow.Links ) ;
192 RetVal = LoadDatas( aDataFlow.Datas ) ;
195 cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadDatas Error."
200 cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadLinks Error."
205 cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadNodes Error."
210 cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadInfo Error."
215 cdebug << "GraphExecutor::OutNode::LoadDataFlow ServiceName Error." << endl ;
220 bool GraphExecutor::OutNode::LoadXml( const char* myFileName ) {
221 bool RetVal = false ;
222 GraphBase::SGraph aDataFlow ;
223 if ( Graph()->LoadXml( _Orb , myFileName , aDataFlow ) ) {
224 RetVal = LoadDataFlow( aDataFlow ) ;
225 // if ( aConstructor && RetVal )
226 // RetVal = Name( aDataFlow.Info.theName.c_str() ) ;
231 bool GraphExecutor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
232 cdebug << "GraphExecutor::OutNode::LoadInfo _StreamGraph " << _StreamGraph << endl ;
233 // ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
234 Graph()->Name( aDataFlowInfo.theName.c_str() ) ;
235 Graph()->Kind( aDataFlowInfo.theKind ) ;
236 if ( Graph()->IsDataStreamNode() ) {
237 StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ;
239 Graph()->DataService( _Orb , aDataFlowInfo.theService , _prof_debug , _fdebug ) ;
240 Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ;
241 Graph()->LastModification( aDataFlowInfo.theLastModification ) ;
242 Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
243 Graph()->Author( aDataFlowInfo.theAuthor.c_str() ) ;
244 // Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ;
245 Graph()->Comment( aDataFlowInfo.theComment.c_str() ) ;
246 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
247 // Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
251 bool GraphExecutor::OutNode::LoadNodes(const GraphBase::ListOfNodes &aListOfNodes ) {
253 GraphExecutor::InNode * anInNode ;
254 cdebug << "GraphExecutor::OutNode::LoadNodes" << endl ;
256 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
257 GraphBase::SNode aNode = aListOfNodes[ i ] ;
258 anInNode = AddNode( aNode.theService ,
259 aNode.theListOfFuncName ,
260 aNode.theListOfPythonFunctions ,
261 aNode.theComponentName.c_str() ,
262 aNode.theInterfaceName.c_str() , aNode.theName.c_str() ,
264 aNode.theFirstCreation , aNode.theLastModification ,
265 aNode.theEditorRelease.c_str() ,
266 aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
267 aNode.theComment.c_str() ,
268 aNode.theCoords.theX , aNode.theCoords.theY ) ;
273 if ( anInNode->IsOneOfInLineNodes() ) {
274 anInNode->GraphExecutor::InNode::InLineNode()->DefPortsOfNode(
275 _Orb , aNode.theService , anInNode->NamePtr() ,
277 _prof_debug , _fdebug ) ;
279 // GraphBase::ComputingNode * theNode = Graph()->GetChangeGraphNode( aNode.theName.c_str() ) ;
282 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
283 GraphBase::InPort * anInPort ;
284 anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
285 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
286 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
287 SUPERV::DataStreamParameter ) ;
288 ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema ,
289 aNode.theListOfInDataStreams[ j ].theKindOfInterpolation ,
290 aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ;
292 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
293 GraphBase::OutPort * anOutPort ;
294 anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
295 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
296 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
297 SUPERV::DataStreamParameter ) ;
298 ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ;
302 // theNode->DataStreamInPortsNumber( aNode.theDataStreamInArgsNumber ) ;
303 // theNode->DataStreamOutPortsNumber( aNode.theDataStreamOutArgsNumber ) ;
304 // cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name()
305 // << " InPortsSize " << theNode->GetNodeInPortsSize()
306 // << " OutPortsSize " << theNode->GetNodeOutPortsSize()
307 // << " DataStreamInPortsNumber " << aNode.theDataStreamInArgsNumber
308 // << " DataStreamOutPortsNumber " << aNode.theDataStreamOutArgsNumber
311 // if ( aNode.theDataStreamInArgsNumber ) { // -1 because of Gates
312 // for ( j = theNode->GetNodeInPortsSize() - aNode.theDataStreamInArgsNumber - 1 ; j < theNode->GetNodeInPortsSize() - 1 ; j++ ) {
313 // cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name()
314 // << " InPort " << theNode->GetChangeNodeInPort( j )->PortName()
315 // << " Kind( DataStreamParameter)" << endl ;
316 // theNode->GetChangeNodeInPort( j )->Kind( SUPERV::DataStreamParameter ) ;
319 // if ( aNode.theDataStreamOutArgsNumber ) {
320 // int withgate = 1 ;
321 // if ( theNode->IsLoopNode() || theNode->IsEndLoopNode() ) {
324 // for ( j = theNode->GetNodeOutPortsSize() - aNode.theDataStreamOutArgsNumber - withgate ; j < theNode->GetNodeOutPortsSize() - withgate ; j++ ) {
325 // cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name()
326 // << " OutPort " << theNode->GetChangeNodeOutPort( j )->PortName()
327 // << " Kind( DataStreamParameter)" << endl ;
328 // theNode->GetChangeNodeOutPort( j )->Kind( SUPERV::DataStreamParameter ) ;
332 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
333 GraphBase::SNode aNode = aListOfNodes[ i ] ;
334 anInNode = (GraphExecutor::InNode * ) Graph()->GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
335 cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name() << " IsOneOfGOTONodes "
336 << anInNode->IsOneOfGOTONodes() << " " << aNode.theCoupledNode.c_str() << endl ;
337 if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
338 GraphBase::GOTONode * aCoupledNode ;
339 aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetGraphNode( aNode.theName.c_str() ) ;
340 aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ;
346 bool GraphExecutor::OutNode::LoadLinks(const GraphBase::ListOfLinks &aListOfLinks ) {
348 cdebug << "GraphExecutor::OutNode::LoadLinks " << aListOfLinks.size()
351 for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
352 GraphBase::SLink aLink = aListOfLinks[ i ] ;
353 RetVal = Graph()->AddLink( aLink.FromNodeName.c_str() ,
354 aLink.FromServiceParameterName.c_str() ,
355 aLink.ToNodeName.c_str() ,
356 aLink.ToServiceParameterName.c_str() ,
358 // aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
365 bool GraphExecutor::OutNode::LoadDatas(const GraphBase::ListOfLinks &aListOfDatas ) {
367 cdebug << "GraphExecutor::OutNode::LoadDatas " << aListOfDatas.size()
370 for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
371 GraphBase::SLink aLink = aListOfDatas[ i ] ;
372 if ( !strcmp( aLink.FromNodeName.c_str() , Graph()->Name() ) )
373 RetVal = Graph()->AddInputData( aLink.ToNodeName.c_str() ,
374 aLink.ToServiceParameterName.c_str() ,
376 // aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
377 else if ( !strcmp( aLink.ToNodeName.c_str() , Graph()->Name() ) ) {
378 RetVal = Graph()->AddOutputData( aLink.FromNodeName.c_str() ,
379 aLink.FromServiceParameterName.c_str() ,
381 // aLink.aLinkValue.Value ,
382 // aLink.aLinkValue.Kind ) ;
383 Graph()->AddLink( aLink.FromNodeName.c_str() , (GraphBase::ComputingNode *) this ) ;
386 cdebug << "GraphExecutor::OutNode::LoadDatas Error " << aLink.FromNodeName
387 << " and " << aLink.ToNodeName << " differents from " << Graph()->Name()
397 GraphExecutor::InNode *GraphExecutor::OutNode::AddNode(
398 const SALOME_ModuleCatalog::Service& NodeService ,
399 GraphBase::ListOfFuncName aFuncName ,
400 GraphBase::ListOfPythonFunctions aPythonFunction ,
401 const char * NodeComponentName ,
402 const char * NodeInterfaceName ,
403 const char * NodeName ,
404 const SUPERV::KindOfNode NodeKindOfNode ,
405 const SUPERV::SDate NodeFirstCreation ,
406 const SUPERV::SDate NodeLastModification ,
407 const char * NodeEditorRelease ,
408 const char * NodeAuthor ,
409 const char * NodeComputer ,
410 const char * NodeComment ,
413 cdebug_in << "GraphExecutor::OutNode::AddNode(" << NodeComponentName << " , "
414 << NodeName << ")" << endl;
415 GraphExecutor::InNode *Nd = NULL ;
416 Nd = new GraphExecutor::InNode( _Orb, Graph()->NamingService() , NodeService ,
417 NodeComponentName , NodeInterfaceName ,
418 NodeName , NodeKindOfNode ,
419 aFuncName , aPythonFunction ,
420 NodeFirstCreation , NodeLastModification ,
421 NodeEditorRelease , NodeAuthor ,
422 NodeComputer , NodeComment , false , NodeX , NodeY ,
423 _prof_debug , _fdebug ) ;
424 Graph()->AddNode( Nd->ComputingNode() ) ;
425 cdebug_out << "GraphExecutor::OutNode::AddNode" << endl;
430 bool GraphExecutor::OutNode::AddInputData( const char* ToNodeName1 ,
431 const char* ToParameterName1 ,
432 const char* ToNodeName2 ,
433 const char* ToParameterName2 ) {
434 cdebug_in << "GraphExecutor::OutNode::AddInputData" << endl;
435 bool RetVal = Graph()->AddInputData( ToNodeName1 ,
439 cdebug_out << "GraphExecutor::OutNode::AddInputData" << endl;
444 bool GraphExecutor::OutNode::Valid() {
445 cdebug_in << "GraphExecutor::OutNode::Valid" << endl;
450 _Executable = false ;
452 if ( !Graph()->CreateService() ) {
453 cdebug << "This DataFlow has invalid type(s)." << endl ;
456 int SubStreamGraphsNumber = 0 ;
457 if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
458 cdebug << "This DataFlow is not valid." << endl ;
461 if ( Graph()->IsDataStreamNode() ) {
462 StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
467 Graph()->InLineServices() ;
469 Graph()->ComputingNodes() ;
473 cdebug_out << "GraphExecutor::OutNode::Valid" << endl;
478 bool GraphExecutor::OutNode::Executable() {
480 cdebug_in << "GraphExecutor::OutNode::Executable" << endl;
484 if ( Graph()->DataServerNodes() )
487 cdebug << "This DataFlow is not executable." << endl ;
488 _Executable = false ;
491 cdebug_out << "GraphExecutor::OutNode::Executable" << endl;
495 bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
496 bool RetVal = false ;
497 cdebug_in << "GraphExecutor::OutNode::Run" << endl;
499 if ( Executable() ) {
500 _ControlState = SUPERV::VoidState ;
501 _SuspendedThreads = 0 ;
502 Graph()->ThreadNo( pthread_self() ) ;
504 _JustStarted = true ;
506 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
507 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ;
508 if ( !PyInitialized() && anInNode->IsOneOfInLineNodes() ) {
509 if ( !Py_IsInitialized() ) {
511 PySys_SetArgv( _ArgC , _ArgV ) ;
513 anInNode->InitPython() ;
514 PyInitialized( true ) ;
516 anInNode->InitialState( this ) ;
517 if ( anInNode->IsOneOfInLineNodes() ) {
518 anInNode->InitPythonFunctions( false ) ;
521 // One more time because inline nodes may share one definition of the same function
522 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
523 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ;
524 if ( anInNode->IsOneOfInLineNodes() ) {
525 if ( !anInNode->InitPythonFunctions( true ) ) {
526 cdebug << "GraphExecutor::OutNode::Run InitPythonFunctions ERROR "
527 << anInNode->Name() << endl ;
533 cdebug << "Execution starting GraphExecutor::Action_DataOk_RunService Node "
534 << Graph()->Name() << endl ;
536 PushEvent( NULL , GraphExecutor::ReadyEvent ,
537 SUPERV::DataReadyState ) ;
538 State( SUPERV::DataReadyState ) ;
540 for ( i = 0 ; i < Graph()->HeadNodesSize() ; i++ ) {
541 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->HeadNodes( i )->GetInNode() ;
542 if ( anInNode->State() != SUPERV::DataReadyState ) {
543 cdebug << "GraphExecutor::OutNode::Run inconsistency State of Node "
544 << anInNode->Name() << " : " << anInNode->State() << endl ;
545 cdebug_out << "GraphExecutor::OutNode::Run State ERROR" << endl ;
548 // PushEvent( anInNode , GraphExecutor::ReadyEvent ,
549 // SUPERV::DataReadyState ) ;
550 anInNode->CreateNewThread( true ) ;
551 anInNode->DataFromNode( Graph()->Name() ) ;
553 anInNode->State( SUPERV::DataWaitingState ) ;
554 anInNode->ControlState( SUPERV::ToSuspendStartState ) ;
555 if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
556 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) ERROR Node "
557 << anInNode->Name() << endl ;
558 cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
561 anInNode->SuspendedWait() ;
563 else if ( !anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ) {
564 cdebug << "InNode::SendEvent( ExecuteEvent ) ERROR Node "
565 << anInNode->Name() << endl ;
566 cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
570 anInNode->RunningWait() ;
575 PushEvent( NULL , GraphExecutor::SuspendedReadyEvent ,
576 SUPERV::SuspendedReadyState ) ;
579 PushEvent( NULL , GraphExecutor::ExecutingEvent ,
580 SUPERV::ExecutingState ) ;
581 if (AutomatonState() == SUPERV::DataReadyState) {
582 State( SUPERV::ExecutingState ) ;
586 astr << "Graph " << Graph()->Name() << " is running" ;
587 Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
591 PushEvent( NULL , GraphExecutor::NoDataReadyEvent ,
592 SUPERV::DataUndefState ) ;
595 cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
599 bool GraphExecutor::OutNode::Run( const char * aNodeName ,
600 const char * AtNodeName ,
601 const bool AndSuspend ) {
602 bool RetVal = false ;
603 cdebug_in << "GraphExecutor::OutNode::Run( " << aNodeName << " , "
604 << AtNodeName << " , " << AndSuspend << ")" << endl;
605 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode() ;
607 RetVal = anInNode->ReStart( AtNodeName , AndSuspend ) ;
609 cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
613 void GraphExecutor::OutNode::CheckAllDone() {
615 cdebug_in << "GraphExecutor::OutNode::CheckAllDone " << endl;
616 SUPERV::AutomatonState OutNodeState = SUPERV::SuccessedState ;
617 SUPERV::AutomatonState InNodeState ;
618 bool AllDone = true ;
620 for ( j = 0 ; j < Graph()->QueueNodesSize() ; j++ ) {
621 InNodeState = ( (GraphExecutor::InNode * ) Graph()->QueueNodes( j )->GetInNode() )->State() ;
623 << ( (GraphExecutor::InNode * ) Graph()->QueueNodes( j )->GetInNode() )->Name()
624 << " " << theAutomaton->StateName( InNodeState ) << endl ;
625 if ( InNodeState != SUPERV::SuccessedState &&
626 InNodeState != SUPERV::ErroredState &&
627 InNodeState != SUPERV::DataWaitingState ) {
630 if ( InNodeState != SUPERV::SuccessedState &&
631 InNodeState != SUPERV::DataWaitingState &&
632 InNodeState != SUPERV::DataReadyState ) {
633 OutNodeState = InNodeState ;
637 if( _Threads == 0 && _SuspendedThreads == 0 ) {
638 if ( OutNodeState != SUPERV::ErroredState ) {
639 OutNodeState = SUPERV::SuccessedState ;
648 for ( j = 0 ; j < Graph()->GraphNodesSize() ; j++ ) {
649 GraphExecutor::InNode * aNode ;
650 aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( j )->GetInNode() ;
651 SUPERV::GraphState aState = AutomatonGraphState( aNode->State() ) ;
652 cdebug << "GraphExecutor::OutNode::CheckAllDone " << aNode->Name() << " "
653 << theAutomaton->StateName( aNode->State() ) << " CreateNewThread " << aNode->CreateNewThread()
655 if ( aState == SUPERV::ErrorState ||
656 aState == SUPERV::SuspendErroredState ||
657 aState == SUPERV::KillState ||
658 aState == SUPERV::StopState ) {
659 OutNodeState = aNode->State() ;
660 State( OutNodeState ) ;
662 else if ( aState == SUPERV::ReadyState ||
663 aState == SUPERV::SuspendReadyState ||
664 aState == SUPERV::RunningState ||
665 aState == SUPERV::SuspendDoneState ||
666 aState == SUPERV::SuspendErroredState ||
667 aState == SUPERV::ReRunState ||
668 aState == SUPERV::ReStartState ||
669 aState == SUPERV::SuspendState ) {
672 aNode->SuspendedAction() ;
673 aNode->DoneAction() ;
675 // PushEvent AFTER State and _Done ! ...
676 if ( alivenodes == 0 ) {
677 State( OutNodeState ) ;
679 _JustStarted = false ;
681 PushEvent( NULL , GraphExecutor::EndExecuteEvent ,
684 // PyInitialized( false ) ;
688 MESSAGE("================================================================================") ;
689 MESSAGE( Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
691 MESSAGE("================================================================================") ;
692 cdebug << "================================================================================" << endl ;
693 cdebug << Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
694 << EventQSize() << endl ;
695 cdebug << "================================================================================" << endl ;
697 astr << "Graph " << Graph()->Name() << " is done : "
698 << theAutomaton->StateName( AutomatonState() ) ;
699 Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
700 //cout << Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
701 // << EventQSize() << endl ;
703 cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << IsDone()
704 << " GraphAutomatonState " << theAutomaton->StateName( AutomatonState() )
705 << " State " << State() << " Threads " << _Threads << " SuspendedThreads "
706 << _SuspendedThreads << " EventQSize " << EventQSize() << endl ;
709 void GraphExecutor::OutNode::PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) {
710 // if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
711 // cdebug << "GraphExecutor::OutNode::PThreadLock " << pthread_self() << " " << aMutex << " "
712 // << errmsg << endl ;
714 if ( pthread_mutex_lock( aMutex ) ) {
718 // if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
719 // cdebug << "GraphExecutor::OutNode::PThreadLocked " << pthread_self() << " " << aMutex << " "
720 // << errmsg << endl ;
724 void GraphExecutor::OutNode::PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) {
725 // if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
726 // cdebug << " GraphExecutor::OutNode::PThreadUnLock " << pthread_self() << " " << aMutex << " "
727 // << errmsg << endl ;
729 if ( pthread_mutex_unlock( aMutex ) ) {
735 void GraphExecutor::OutNode::PyThreadLock() {
736 // cout << " GraphExecutor::OutNode::PyThreadLock " << pthread_self() << endl ;
737 if ( pthread_mutex_lock( &_PyMutexWait ) ) {
738 perror( "GraphExecutor::OutNode::PyThreadLock" ) ;
741 theAutomaton->PyLock() ;
742 // cout << " GraphExecutor::OutNode::PyThreadLocked " << pthread_self() << endl ;
745 void GraphExecutor::OutNode::PyThreadUnLock() {
746 // cout << " GraphExecutor::OutNode::PyThreadUnLock " << pthread_self() << endl ;
747 if ( pthread_mutex_unlock( &_PyMutexWait ) ) {
748 perror( "GraphExecutor::OutNode::PyThreadUnLock" ) ;
751 theAutomaton->PyUnLock() ;
752 // cout << " GraphExecutor::OutNode::PyThreadUnLocked " << pthread_self() << endl ;
755 void GraphExecutor::OutNode::NewThread() {
756 if ( pthread_mutex_lock( &_MutexWait ) ) {
757 perror("pthread_mutex_lock _NewThread") ;
761 cdebug << "NewThread : " << _Threads << " running threads "
762 << _SuspendedThreads << " suspended threads"
764 if ( pthread_mutex_unlock( &_MutexWait ) ) {
765 perror("pthread_mutex_unlock _NewThread") ;
770 void GraphExecutor::OutNode::ExitThread() {
771 if ( pthread_mutex_lock( &_MutexWait ) ) {
772 perror("pthread_mutex_lock _ExitThread") ;
776 theAutomaton->JoinThread( pthread_self() ) ;
777 if ( pthread_cond_signal( &_JoinWait ) ) {
778 perror("ExitThread pthread_cond_signal ") ;
780 cdebug << "ExitThread : " << _Threads << " running threads "
781 << _SuspendedThreads << " suspended threads"
783 if ( pthread_mutex_unlock( &_MutexWait ) ) {
784 perror("pthread_mutex_unlock _ExitThread") ;
787 if ( _Threads == 0 && _SuspendedThreads == 0 ) {
790 theAutomaton->Executed() ;
794 void GraphExecutor::OutNode::JoinedWait() {
795 if ( pthread_mutex_lock( &_MutexWait ) ) {
796 perror("pthread_mutex_lock JoinedWait") ;
800 if ( pthread_cond_wait( &_JoinWait , &_MutexWait ) ) {
801 perror("JoinedWait pthread_cond_wait ") ;
804 if ( pthread_mutex_unlock( &_MutexWait ) ) {
805 perror("pthread_mutex_unlock JoinedWait") ;
810 void GraphExecutor::OutNode::SuspendThread() {
811 if ( pthread_mutex_lock( &_MutexWait ) ) {
812 perror("pthread_mutex_lock _SuspendThread") ;
815 _SuspendedThreads += 1 ;
816 cdebug << "SuspendThread : " << _Threads << " running threads "
817 << _SuspendedThreads << " suspended threads"
819 if ( pthread_mutex_unlock( &_MutexWait ) ) {
820 perror("pthread_mutex_unlock _SuspendThread") ;
823 if ( IsSuspended() ) {
824 PushEvent( NULL , GraphExecutor::SuspendEvent , SUPERV::SuspendedState ) ;
827 void GraphExecutor::OutNode::ResumeThread() {
828 if ( pthread_mutex_lock( &_MutexWait ) ) {
829 perror("pthread_mutex_lock _ResumeThread") ;
832 _SuspendedThreads -= 1 ;
833 cdebug << "ResumeThread : " << _Threads << " running threads "
834 << _SuspendedThreads << " suspended threads"
836 if ( pthread_mutex_unlock( &_MutexWait ) ) {
837 perror("pthread_mutex_unlock _ResumeThread") ;
842 long GraphExecutor::OutNode::Thread( const char * aNodeName ) {
844 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode() ;
846 RetVal = anInNode->ThreadNo() ;
851 SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent ) {
852 SUPERV::GraphEvent aGraphEvent ;
854 case GraphExecutor::UndefinedEvent : {
855 aGraphEvent = SUPERV::UndefinedEvent ;
858 case GraphExecutor::NewThreadEvent : {
859 aGraphEvent = SUPERV::NewThreadEvent ;
862 case GraphExecutor::SuspendEvent : {
863 aGraphEvent = SUPERV::SuspendEvent ;
866 case GraphExecutor::ResumeEvent : {
867 aGraphEvent = SUPERV::ResumeEvent ;
870 case GraphExecutor::KillEvent : {
871 aGraphEvent = SUPERV::KillEvent ;
874 case GraphExecutor::StopEvent : {
875 aGraphEvent = SUPERV::StopEvent ;
878 case GraphExecutor::ExecuteEvent : {
879 aGraphEvent = SUPERV::RunningEvent ;
882 case GraphExecutor::SuccessEvent : {
883 aGraphEvent = SUPERV::DoneEvent ;
886 case GraphExecutor::ErrorEvent : {
887 aGraphEvent = SUPERV::ErroredEvent ;
890 case GraphExecutor::ReStartEvent : {
891 aGraphEvent = SUPERV::ReRunEvent ;
894 case GraphExecutor::ReStartAndSuspendEvent : {
895 aGraphEvent = SUPERV::ReStartEvent ;
898 case GraphExecutor::NoDataReadyEvent : {
899 aGraphEvent = SUPERV::WaitingEvent ;
902 case GraphExecutor::SomeDataReadyEvent : {
903 aGraphEvent = SUPERV::WaitingEvent ;
906 case GraphExecutor::NotAllDataReadyEvent : {
907 aGraphEvent = SUPERV::WaitingEvent ;
910 case GraphExecutor::AllDataReadyEvent : {
911 aGraphEvent = SUPERV::ReadyEvent ;
914 case GraphExecutor::ReadyEvent : {
915 aGraphEvent = SUPERV::ReadyEvent ;
918 case GraphExecutor::SuspendedReadyEvent : {
919 aGraphEvent = SUPERV::SuspendEvent ;
922 case GraphExecutor::ResumedReadyEvent : {
923 aGraphEvent = SUPERV::ResumeEvent ;
926 case GraphExecutor::KilledReadyEvent : {
927 aGraphEvent = SUPERV::KillEvent ;
930 case GraphExecutor::StoppedReadyEvent : {
931 aGraphEvent = SUPERV::StopEvent ;
934 case GraphExecutor::ExecutingEvent : {
935 aGraphEvent = SUPERV::RunningEvent ;
938 case GraphExecutor::SuspendedExecutingEvent : {
939 aGraphEvent = SUPERV::SuspendEvent ;
942 case GraphExecutor::ResumedExecutingEvent : {
943 aGraphEvent = SUPERV::ResumeEvent ;
946 case GraphExecutor::KilledExecutingEvent : {
947 aGraphEvent = SUPERV::KillEvent ;
950 case GraphExecutor::StoppedExecutingEvent : {
951 aGraphEvent = SUPERV::StopEvent ;
954 case GraphExecutor::SuccessedExecutingEvent : {
955 aGraphEvent = SUPERV::DoneEvent ;
958 case GraphExecutor::ErroredExecutingEvent : {
959 aGraphEvent = SUPERV:: ErroredEvent;
962 case GraphExecutor::SuspendedSuccessedEvent : {
963 aGraphEvent = SUPERV::SuspendEvent ;
966 case GraphExecutor::SuspendedErroredEvent : {
967 aGraphEvent = SUPERV::SuspendEvent ;
970 case GraphExecutor::ResumedSuccessedEvent : {
971 aGraphEvent = SUPERV::ResumeEvent ;
974 case GraphExecutor::ResumedErroredEvent : {
975 aGraphEvent = SUPERV::ResumeEvent ;
978 case GraphExecutor::KilledEvent : {
979 aGraphEvent = SUPERV::KillEvent ;
982 case GraphExecutor::StoppedEvent : {
983 aGraphEvent = SUPERV::StopEvent ;
986 case GraphExecutor::ReStartedEvent : {
987 aGraphEvent = SUPERV::ReRunEvent ;
990 case GraphExecutor::ReStartedAndSuspendEvent : {
991 aGraphEvent = SUPERV::ReStartEvent ;
994 case GraphExecutor::EndExecuteEvent : {
995 aGraphEvent = SUPERV::DoneEvent ;
999 cdebug << " GraphExecutor::OutNode::AutomatonGraphEvent Error Undefined Event : "
1000 << anEvent << endl ;
1001 aGraphEvent = SUPERV::UndefinedEvent ;
1004 return aGraphEvent ;
1007 SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(SUPERV::AutomatonState aState ) {
1008 SUPERV::GraphState aGraphState ;
1010 case SUPERV::UnKnownState : {
1011 aGraphState = SUPERV::UndefinedState ;
1014 case SUPERV::DataUndefState : {
1015 aGraphState = SUPERV::UndefinedState ;
1018 case SUPERV::DataWaitingState : {
1019 aGraphState = SUPERV::WaitingState ;
1022 case SUPERV::DataReadyState : {
1023 aGraphState = SUPERV::ReadyState ;
1026 case SUPERV::SuspendedReadyState : {
1027 aGraphState = SUPERV::SuspendReadyState ;
1030 case SUPERV::ResumedReadyState : {
1031 aGraphState = SUPERV::ReadyState ;
1034 case SUPERV::KilledReadyState : {
1035 aGraphState = SUPERV::KillState ;
1038 case SUPERV::StoppedReadyState : {
1039 aGraphState = SUPERV::StopState ;
1042 case SUPERV::ExecutingState : {
1043 aGraphState = SUPERV::RunningState ;
1046 case SUPERV::SuspendedExecutingState : {
1047 aGraphState = SUPERV::SuspendState ;
1050 case SUPERV::ResumedExecutingState : {
1051 aGraphState = SUPERV::RunningState ;
1054 case SUPERV::KilledExecutingState : {
1055 aGraphState = SUPERV::KillState ;
1058 case SUPERV::StoppedExecutingState : {
1059 aGraphState = SUPERV::StopState ;
1062 case SUPERV::SuccessedExecutingState : {
1063 aGraphState = SUPERV::DoneState ;
1066 case SUPERV::ErroredExecutingState : {
1067 aGraphState = SUPERV::ErrorState ;
1070 case SUPERV::SuspendedSuccessedState : {
1071 aGraphState = SUPERV::SuspendDoneState ;
1074 case SUPERV::SuspendedErroredState : {
1075 aGraphState = SUPERV::SuspendErroredState ;
1078 case SUPERV::ResumedSuccessedState : {
1079 aGraphState = SUPERV::DoneState ;
1082 case SUPERV::ResumedErroredState : {
1083 aGraphState = SUPERV::ErrorState ;
1086 case SUPERV::KilledSuccessedState : {
1087 aGraphState = SUPERV::KillState ;
1090 case SUPERV::KilledErroredState : {
1091 aGraphState = SUPERV::KillState ;
1094 case SUPERV::StoppedSuccessedState : {
1095 aGraphState = SUPERV::StopState ;
1098 case SUPERV::StoppedErroredState : {
1099 aGraphState = SUPERV::StopState ;
1102 case SUPERV::SuccessedState : {
1103 aGraphState = SUPERV::DoneState ;
1106 case SUPERV::ErroredState : {
1107 aGraphState = SUPERV::ErrorState ;
1110 case SUPERV::SuspendedState : {
1111 aGraphState = SUPERV::SuspendState ;
1114 case SUPERV::KilledState : {
1115 aGraphState = SUPERV::KillState ;
1118 case SUPERV::StoppedState : {
1119 aGraphState = SUPERV::StopState ;
1122 case SUPERV::ReRunnedState : {
1123 aGraphState = SUPERV::ReRunState ;
1126 case SUPERV::ReStartedState : {
1127 aGraphState = SUPERV::ReStartState ;
1131 cdebug << " GraphExecutor::OutNode::AutomatonGraphState Error Undefined State : "
1132 << aGraphState << endl ;
1133 aGraphState = SUPERV::UndefinedState ;
1136 return aGraphState ;
1139 int GraphExecutor::OutNode::GetListSize() {
1140 return _EventNodes.size();
1143 bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode ,
1144 GraphExecutor::NodeEvent anEvent ,
1145 SUPERV::AutomatonState aState ) {
1146 // cdebug_in << "PushEvent Threads " << Threads() << " SuspendedThreads "
1147 // << SuspendedThreads() << endl ;
1148 if ( pthread_mutex_lock( &_MutexWait ) ) {
1149 perror("PushEvent pthread_mutex_lock ") ;
1153 _EventNodes.push_back( aNode->Name() ) ;
1156 _EventNodes.push_back( Graph()->Name() ) ;
1158 _Events.push_back( anEvent ) ;
1159 _States.push_back( aState ) ;
1160 pthread_cond_broadcast( &_EventWait );
1162 // cdebug << aNode->ThreadNo() << " PushEvent " << aNode->Name() ;
1163 // cdebug << " " << aNode->Automaton()->EventName( anEvent )
1164 // << " " << aNode->Automaton()->StateName( aState )
1165 // << " ControleState "
1166 // << aNode->Automaton()->ControlStateName( aNode->ControlState() ) ;
1169 // cdebug << "PushEvent " << Graph()->Name() ;
1170 // cdebug << " " << theAutomaton->EventName( anEvent ) << " "
1171 // << theAutomaton->StateName( aState ) ;
1173 // cdebug_out << "PushEvent Threads " << Threads() << " SuspendedThreads "
1174 // << SuspendedThreads() << endl ;
1176 if ( _EventNodes.size() > 101 ) {
1177 while ( _EventNodes.size() > 31 ) {
1178 _EventNodes.pop_front() ;
1179 _Events.pop_front() ;
1180 _States.pop_front() ;
1184 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1185 perror("PushEvent pthread_mutex_unlock ") ;
1191 bool GraphExecutor::OutNode::StateWait( SUPERV::GraphState aState ) {
1195 bool GraphExecutor::OutNode::Event( char ** aNodeName ,
1196 SUPERV::GraphEvent & anEvent ,
1197 SUPERV::GraphState & aState ,
1200 int SuspendedThreadsNumber ;
1201 if ( _EventNodes.size() > 0 ) {
1202 cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
1204 if ( pthread_mutex_lock( &_MutexWait ) ) {
1205 perror("EventLoop pthread_mutex_lock ") ;
1208 _JustStarted = false ;
1209 ThreadsNumber = Threads() ;
1210 SuspendedThreadsNumber = SuspendedThreads() ;
1211 bool RetVal = ( ThreadsNumber - SuspendedThreadsNumber) != 0 ||
1212 _EventNodes.size() > 0 ;
1213 char * NodeName = "" ;
1214 GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
1215 SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
1216 anEvent = SUPERV::UndefinedEvent ;
1217 aState = SUPERV::UndefinedState ;
1218 if ( ( Done() || IsKilled() || IsStopped() ) && _EventNodes.size() == 0 ) {
1219 // cdebug << "EventLoop Done()/IsKilled()/IsStopped() && _EventNodes.size() == 0" << endl ;
1222 else if ( !WithWait && _EventNodes.size() == 0 ) {
1223 anEvent = SUPERV::NoEvent ;
1224 aState = SUPERV::NoState ;
1227 else if ( RetVal ) {
1228 while ( !IsSuspended() && _EventNodes.size() == 0 ) {
1229 // cdebug << "EventLoop pthread_cond_wait _EventWait" << endl ;
1230 pthread_cond_wait( &_EventWait , &_MutexWait );
1231 // cdebug << "EventLoop pthread_cond_waited _EventWait"
1232 // << " _EventNodes.size() " << _EventNodes.size() << endl ;
1234 if ( _EventNodes.size() ) {
1235 ThreadsNumber = Threads() ;
1236 NodeName = _EventNodes.front() ;
1237 _EventNodes.pop_front() ;
1238 theEvent = _Events.front() ;
1239 anEvent = AutomatonGraphEvent( theEvent ) ;
1240 _Events.pop_front() ;
1241 theState = _States.front() ;
1242 aState = AutomatonGraphState( theState ) ;
1243 _States.pop_front() ;
1246 *aNodeName = NodeName ;
1247 if ( IsSuspended() && _EventNodes.size() == 0 ) {
1250 if ( anEvent != SUPERV::NoEvent ) {
1251 // cdebug << pthread_self() << "EventLoop "
1252 // << NodeName << " " << theAutomaton->StateName( theState )
1253 // << " _EventNodes.size() " << _EventNodes.size()
1254 // << " Threads " << Threads() << " SuspendedThreads "
1255 // << SuspendedThreads() << " RetVal " << RetVal << endl ;
1257 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1258 perror("EventLoop pthread_mutex_lock ") ;
1261 if ( _EventNodes.size() > 0 ) {
1262 cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
1267 bool GraphExecutor::OutNode::EventW( char ** aNodeName ,
1268 SUPERV::GraphEvent & anEvent ,
1269 SUPERV::GraphState & aState ) {
1272 aState = SUPERV::UndefinedState ;
1274 aState != SUPERV::SuspendReadyState &&
1275 aState != SUPERV::RunningState &&
1276 aState != SUPERV::SuspendDoneState &&
1277 aState != SUPERV::SuspendErroredState ) {
1278 NodeName = Graph()->Name() ;
1279 while ( sts && !strcmp( NodeName , Graph()->Name() ) ) {
1280 sts = EventWait( aNodeName , anEvent , aState ) ;
1281 NodeName = *aNodeName ;
1287 bool GraphExecutor::OutNode::EventWait( char ** aNodeName ,
1288 SUPERV::GraphEvent & anEvent ,
1289 SUPERV::GraphState & aState ) {
1290 if ( pthread_mutex_lock( &_MutexWait ) ) {
1291 perror("EventW pthread_mutex_lock ") ;
1295 int SuspendedThreadsNumber ;
1296 ThreadsNumber = Threads() ;
1297 SuspendedThreadsNumber = SuspendedThreads() ;
1298 bool RetVal = ( ThreadsNumber - SuspendedThreadsNumber) != 0 ||
1299 _EventNodes.size() > 0 ;
1300 cdebug << "--> EventW RetVal " << RetVal << endl ;
1301 char * NodeName = "" ;
1302 GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
1303 SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
1304 anEvent = SUPERV::UndefinedEvent ;
1305 aState = SUPERV::UndefinedState ;
1306 if ( IsDone() && _EventNodes.size() == 0 ) {
1307 cdebug << "EventW IsDone() && _EventNodes.size() == 0" << endl ;
1310 else if ( RetVal ) {
1311 GraphExecutor::InNode * aNode = NULL ;
1312 while ( aNode == NULL && RetVal ) {
1313 NodeName = _EventNodes.front() ;
1314 theEvent = _Events.front() ;
1315 anEvent = AutomatonGraphEvent( theEvent ) ;
1316 theState = _States.front() ;
1317 aState = AutomatonGraphState( theState ) ;
1319 if ( _JustStarted ) {
1320 _JustStarted = false ;
1323 _EventNodes.pop_front() ;
1324 _Events.pop_front() ;
1325 _States.pop_front() ;
1328 aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode()) ;
1329 cdebug << "EventW Previous Node " << NodeName << " ThreadsNumber "
1331 << " _EventNodes.size() " << _EventNodes.size() << " "
1332 << theAutomaton->StateName( theState )
1333 << " Threads " << Threads() << " SuspendedThreads "
1334 << SuspendedThreads() << endl ;
1337 else if ( IsDone() && _EventNodes.size() == 0 ) {
1338 cdebug << "EventW IsDone() && _EventNodes.size() == 0" << endl ;
1342 cdebug << "EventW Not InNode " << NodeName
1343 << " _EventNodes.size() " << _EventNodes.size() << endl ;
1344 while ( _EventNodes.size() == 0 ) {
1345 pthread_cond_wait( &_EventWait , &_MutexWait );
1347 cdebug << "EventW pthread_cond_waited Not InNode " << NodeName
1348 << " _EventNodes.size() " << _EventNodes.size() << endl ;
1353 if ( aState == SUPERV::SuspendState ||
1354 aState == SUPERV::SuspendReadyState ||
1355 aState == SUPERV::SuspendDoneState ||
1356 aState == SUPERV::SuspendErroredState ) {
1357 aNode->ControlState( SUPERV::ToSuspendState ) ;
1358 if ( aNode->IsSuspended() ) {
1359 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1360 perror("EventW pthread_mutex_lock ") ;
1363 cdebug << "EventW " << aNode->Name() << " ResumeAction" << endl ;
1364 aNode->ResumeAction( GraphExecutor::ToResumeEvent ) ;
1365 cdebug << "EventW " << aNode->Name() << " ResumedAction" << endl ;
1366 if ( pthread_mutex_lock( &_MutexWait ) ) {
1367 perror("EventW pthread_mutex_lock ") ;
1372 cdebug << "EventW inconsistent SuspendState" << endl ;
1377 if ( aNode->IsDone() ) {
1381 cdebug << "EventW NOT SuspendedState _EventNodes.size() "
1382 << _EventNodes.size() << endl ;
1387 cdebug << "EventW " << aNode->Name() << " pthread_cond_wait" << endl ;
1388 while ( _EventNodes.size() == 0 ) {
1389 pthread_cond_wait( &_EventWait , &_MutexWait );
1391 ThreadsNumber = Threads() ;
1392 NodeName = _EventNodes.front() ;
1393 theEvent = _Events.front() ;
1394 anEvent = AutomatonGraphEvent( theEvent ) ;
1395 theState = _States.front() ;
1396 aState = AutomatonGraphState( theState ) ;
1400 *aNodeName = NodeName ;
1401 cdebug << "<-- EventW RetVal " << RetVal << " " << NodeName
1402 << " Threads " << Threads() << " SuspendedThreads "
1403 << SuspendedThreads()
1404 << " _EventNodes.size() " << _EventNodes.size()
1405 << " " << theAutomaton->EventName( theEvent ) << " "
1406 << theAutomaton->StateName( theState ) << endl ;
1407 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1408 perror("EventW pthread_mutex_lock ") ;
1413 long GraphExecutor::OutNode::EventQSize() {
1414 return _EventNodes.size() ;
1417 void GraphExecutor::OutNode::EventList() {
1418 if ( pthread_mutex_lock( &_MutexWait ) ) {
1419 perror("EventList pthread_mutex_lock ") ;
1422 list< char * >::iterator itEventNodes = _EventNodes.begin() ;
1423 list< GraphExecutor::NodeEvent >::iterator itEvents = _Events.begin() ;
1424 list< SUPERV::AutomatonState >::iterator itStates = _States.begin() ;
1425 while ( itEventNodes != _EventNodes.end() ) {
1426 cdebug << pthread_self() << "EVENTSTACK "
1427 << *itEventNodes << " " << *itEvents << " "
1428 << theAutomaton->StateName( *itStates )
1429 << " Threads " << Threads() << " SuspendedThreads " << SuspendedThreads() << endl ;
1434 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1435 perror("EventList pthread_mutex_lock ") ;
1440 void GraphExecutor::OutNode::State(SUPERV::AutomatonState aState ) {
1441 // cdebug << "GraphExecutor::OutNode::State " << Graph()->Name() << " "
1442 // << theAutomaton->StateName( AutomatonGraphState( _State ) ) << " ---> "
1443 // << theAutomaton->StateName( AutomatonGraphState( aState ) ) << endl ;
1447 SUPERV::GraphState GraphExecutor::OutNode::State() {
1448 // cdebug_in << "GraphExecutor::OutNode::State" << endl;
1449 // cdebug_out << "GraphExecutor::OutNode::State" << endl ;
1450 // cdebug << "GraphExecutor::OutNode::State GraphState "
1451 // << theAutomaton->StateName( AutomatonGraphState( _State ) ) << endl ;
1452 return AutomatonGraphState( _State ) ;
1455 SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ) {
1456 // cdebug_in << "GraphExecutor::OutNode::State " << NodeName << endl;
1457 SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
1458 const GraphBase::ComputingNode * aCNode = Graph()->GetGraphNode( NodeName ) ;
1460 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *)aCNode->GetInNode() ;
1462 aret = anInNode->State() ;
1463 // cdebug << "GraphExecutor::OutNode::State( " << NodeName << " ) "
1464 // << theAutomaton->StateName( AutomatonGraphState( aret ) ) << endl ;
1467 // cdebug_out << "GraphExecutor::OutNode::State" << endl ;
1468 return AutomatonGraphState( aret ) ;
1471 SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ,
1472 const char * ServiceParameterName ) {
1473 // cdebug_in << "GraphExecutor::OutNode::State " << NodeName << " "
1474 // << ServiceParameterName<< endl;
1475 SUPERV::GraphState aret = Graph()->PortState( NodeName , ServiceParameterName ) ;
1476 // cdebug_out << "GraphExecutor::OutNode::State" << endl ;
1480 SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState() {
1481 // cdebug_in << "GraphExecutor::OutNode::AutomatonState" << endl;
1482 // cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
1486 SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState( const char * NodeName ) {
1487 // cdebug_in << "GraphExecutor::OutNode::AutomatonState " << NodeName << endl;
1488 SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
1489 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1491 aret = anInNode->State() ;
1492 // cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
1496 SUPERV::ControlState GraphExecutor::OutNode::ControlState() {
1497 // cdebug_in << "GraphExecutor::OutNode::ControlState" << endl;
1498 // cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ;
1499 return _ControlState ;
1502 SUPERV::ControlState GraphExecutor::OutNode::ControlState( const char * NodeName ) {
1503 // cdebug_in << "GraphExecutor::OutNode::ControlState " << NodeName << endl;
1504 SUPERV::ControlState aret = SUPERV::VoidState ;
1505 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1507 aret = anInNode->ControlState() ;
1508 // cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ;
1512 void GraphExecutor::OutNode::ControlClear() {
1513 // cdebug_in << "GraphExecutor::OutNode::ControlClear" << endl;
1514 // cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ;
1515 _ControlState = SUPERV::VoidState;
1518 void GraphExecutor::OutNode::ControlClear( const char * NodeName ) {
1519 // cdebug_in << "GraphExecutor::OutNode::ControlClear " << NodeName << endl;
1520 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1522 anInNode->ControlClear() ;
1523 // cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ;
1526 bool GraphExecutor::OutNode::IsWaiting() {
1527 // cdebug_in << "GraphExecutor::OutNode::IsWaiting" << endl;
1528 // cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
1532 bool GraphExecutor::OutNode::IsReady() {
1533 // cdebug_in << "GraphExecutor::OutNode::IsReady" << endl;
1534 // cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
1538 bool GraphExecutor::OutNode::IsRunning() {
1539 // cdebug_in << "GraphExecutor::OutNode::IsRunning" << endl;
1540 // cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
1544 bool GraphExecutor::OutNode::IsDone() {
1545 // cdebug_in << "GraphExecutor::OutNode::IsDone" << endl;
1546 // cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
1547 return ( Done() || IsKilled() || IsStopped() ) ;
1550 bool GraphExecutor::OutNode::IsSuspended() {
1551 // cdebug_in << "GraphExecutor::OutNode::IsSuspended" << endl;
1553 if ( _SuspendedThreads == _Threads ) {
1556 // cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
1560 bool GraphExecutor::OutNode::IsKilled() {
1561 // cdebug_in << "GraphExecutor::OutNode::IsKilled" << endl;
1563 if ( AutomatonGraphState( _State ) == SUPERV::KillState ) {
1566 // cdebug_out << "GraphExecutor::OutNode::IsKilled" << endl ;
1570 bool GraphExecutor::OutNode::IsStopped() {
1571 // cdebug_in << "GraphExecutor::OutNode::IsStopped" << endl;
1573 if ( AutomatonGraphState( _State ) == SUPERV::StopState ) {
1576 // cdebug_out << "GraphExecutor::OutNode::IsStopped" << endl ;
1580 bool GraphExecutor::OutNode::IsWaiting( const char * NodeName ) {
1582 // cdebug_in << "GraphExecutor::OutNode::IsWaiting " << NodeName << endl;
1583 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1585 aret = anInNode->IsWaiting() ;
1587 // cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
1591 bool GraphExecutor::OutNode::IsReady( const char * NodeName ) {
1593 // cdebug_in << "GraphExecutor::OutNode::IsReady " << NodeName << endl;
1594 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1596 aret = anInNode->IsReady() ;
1598 // cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
1602 bool GraphExecutor::OutNode::IsRunning( const char * NodeName ) {
1604 // cdebug_in << "GraphExecutor::OutNode::IsRunning " << NodeName << endl;
1605 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1607 aret = anInNode->IsRunning() ;
1609 // cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
1613 bool GraphExecutor::OutNode::IsDone( const char * NodeName ) {
1615 // cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << endl;
1616 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1618 aret = anInNode->IsDone() ;
1620 // cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
1624 bool GraphExecutor::OutNode::IsSuspended( const char * NodeName ) {
1626 // cdebug_in << "GraphExecutor::OutNode::IsSuspended " << NodeName << endl;
1627 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1629 aret = anInNode->IsSuspended() ;
1631 // cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
1635 bool GraphExecutor::OutNode::IsDone( const char * NodeName ,
1636 const char * ServiceParameterName ) {
1637 // cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << " "
1638 // << ServiceParameterName<< endl;
1639 bool aret = Graph()->PortDone( NodeName , ServiceParameterName ) ;
1640 // cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
1644 bool GraphExecutor::OutNode::ContainerKill() {
1645 bool RetVal = true ;
1646 cdebug_in << "GraphExecutor::OutNode::ContainerKill" << endl;
1647 _ControlState = SUPERV::ToSuspendState ;
1649 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1650 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1651 bool sts = aNode->ContainerKill() ;
1652 if ( sts && aNode->IsKilled() ) {
1653 cdebug << aNode->Name() << " killed" << endl ;
1655 else if ( aNode->IsWaiting() || aNode->IsDone() ) {
1656 cdebug << aNode->Name() << " not killed : "
1657 << theAutomaton->StateName( aNode->State() ) << endl ;
1660 cdebug << aNode->Name() << " cannot be killed : "
1661 << theAutomaton->StateName( aNode->State() ) << endl ;
1665 if ( !RetVal || Threads() != 0 ) {
1666 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1667 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1668 if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
1669 aNode->KilledAction() ;
1674 State( SUPERV::KilledState ) ;
1675 cdebug_out << "GraphExecutor::OutNode::ContainerKill" << endl ;
1679 bool GraphExecutor::OutNode::Suspend() {
1681 cdebug_in << "GraphExecutor::OutNode::Suspend" << endl;
1682 // _ControlState = SUPERV::ToSuspendState ;
1684 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1685 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1686 bool sts = aNode->Suspend() ;
1687 if ( sts && aNode->IsSuspended() ) {
1689 cdebug << aNode->Name() << " Suspended" << endl ;
1691 else if ( aNode->IsWaiting() || aNode->IsDone() ) {
1692 cdebug << aNode->Name() << " not Suspended : "
1693 << theAutomaton->StateName( aNode->State() ) << endl ;
1697 cdebug << aNode->Name() << " cannot be Suspended : "
1698 << theAutomaton->StateName( aNode->State() ) << endl ;
1702 State( SUPERV::SuspendedState ) ;
1703 MESSAGE("================================================================================") ;
1704 MESSAGE( Graph()->Name() << " IS SUSPENDED" ) ;
1705 MESSAGE("================================================================================") ;
1708 MESSAGE("================================================================================") ;
1709 MESSAGE( Graph()->Name() << " IS NOT SUSPENDED" ) ;
1710 MESSAGE("================================================================================") ;
1712 cdebug_out << "GraphExecutor::OutNode::Suspend" << theAutomaton->StateName( State() ) << endl ;
1716 bool GraphExecutor::OutNode::Resume() {
1718 cdebug_in << "GraphExecutor::OutNode::Resume" << endl;
1719 if ( IsSuspended() ) {
1720 State( SUPERV::ExecutingState ) ;
1722 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1723 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1724 aNode->ControlState( SUPERV::VoidState ) ;
1725 if ( aNode->IsSuspended() ) {
1726 cdebug << aNode->Name() << "->Resume " << theAutomaton->StateName( aNode->State() )
1728 if ( aNode->Resume() ) {
1729 cdebug << aNode->Name() << " Resumed " << theAutomaton->StateName( aNode->State() )
1734 cdebug << aNode->Name() << " Resume failed"
1735 << theAutomaton->StateName( aNode->State() ) << endl ;
1739 cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() )
1745 cdebug << Graph()->Name() << " not suspended " << theAutomaton->StateName( State() ) << endl ;
1748 MESSAGE("================================================================================") ;
1749 MESSAGE( Graph()->Name() << " IS RESUMED" ) ;
1750 MESSAGE("================================================================================") ;
1753 MESSAGE("================================================================================") ;
1754 MESSAGE( Graph()->Name() << " IS NOT RESUMED" ) ;
1755 MESSAGE("================================================================================") ;
1757 cdebug_out << "GraphExecutor::OutNode::Resume" << theAutomaton->StateName( State() ) << " " << RetVal << endl ;
1761 bool GraphExecutor::OutNode::Kill() {
1762 bool RetVal = true ;
1763 cdebug_in << "GraphExecutor::OutNode::Kill" << endl;
1764 _ControlState = SUPERV::ToSuspendState ;
1766 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1767 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1768 bool sts = aNode->Kill() ;
1769 if ( sts && aNode->IsKilled() ) {
1770 cdebug << aNode->Name() << " killed" << endl ;
1772 else if ( aNode->IsWaiting() || aNode->IsDone() ) {
1773 cdebug << aNode->Name() << " not killed : "
1774 << theAutomaton->StateName( aNode->State() ) << endl ;
1777 cdebug << aNode->Name() << " cannot be killed : "
1778 << theAutomaton->StateName( aNode->State() ) << endl ;
1782 if ( !RetVal || Threads() != 0 ) {
1783 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1784 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1785 if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
1786 cdebug << aNode->Name() << " not killed : "
1787 << theAutomaton->StateName( aNode->State() ) << " " << aNode->Name() << "->"
1788 << "KilledAction()" << endl ;
1789 aNode->KilledAction() ;
1794 State( SUPERV::KilledState ) ;
1796 MESSAGE("================================================================================") ;
1797 MESSAGE( Graph()->Name() << " IS KILLED" ) ;
1798 MESSAGE("================================================================================") ;
1801 MESSAGE("================================================================================") ;
1802 MESSAGE( Graph()->Name() << " IS NOT KILLED" ) ;
1803 MESSAGE("================================================================================") ;
1805 cdebug_out << "GraphExecutor::OutNode::Kill" << endl ;
1809 bool GraphExecutor::OutNode::Stop() {
1810 bool RetVal = false ;
1811 cdebug_in << "GraphExecutor::OutNode::Stop" << endl;
1813 cdebug_out << "GraphExecutor::OutNode::Stop" << endl ;
1815 MESSAGE("================================================================================") ;
1816 MESSAGE( Graph()->Name() << " IS STOPPED" ) ;
1817 MESSAGE("================================================================================") ;
1821 bool GraphExecutor::OutNode::ReRun() {
1822 bool RetVal = false ;
1823 cdebug_in << "GraphExecutor::OutNode::ReRun" << endl;
1824 if ( IsSuspended() ) {
1826 cdebug_out << "GraphExecutor::OutNode::ReRun" << endl ;
1829 bool GraphExecutor::OutNode::ReStart() {
1830 bool RetVal = false ;
1831 cdebug_in << "GraphExecutor::OutNode::ReStart" << endl;
1832 if ( IsSuspended() ) {
1834 cdebug_out << "GraphExecutor::OutNode::ReStart" << endl ;
1838 bool GraphExecutor::OutNode::ReadyWait() {
1839 cdebug_in << "GraphExecutor::OutNode::ReadyWait" << endl;
1841 if ( pthread_mutex_lock( &_MutexWait ) ) {
1842 perror("pthread_mutex_lock _ReadyWait") ;
1848 pthread_cond_wait( &_EventWait , &_MutexWait );
1851 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1852 perror("pthread_mutex_lock _ReadyWait") ;
1855 cdebug_out << "GraphExecutor::OutNode::ReadyWait" << endl ;
1859 bool GraphExecutor::OutNode::RunningWait() {
1860 cdebug_in << "GraphExecutor::OutNode::RunningWait" << endl;
1862 if ( pthread_mutex_lock( &_MutexWait ) ) {
1863 perror("pthread_mutex_lock _RunningWait") ;
1866 aret = IsRunning() ;
1868 cdebug << "RunningWait pthread_cond_wait _EventWait" << endl;
1869 pthread_cond_wait( &_EventWait , &_MutexWait );
1870 aret = IsRunning() ;
1871 cdebug << "RunningWait pthread_cond_waited _EventWait " << aret << endl;
1873 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1874 perror("pthread_mutex_lock _RunningWait") ;
1877 cdebug_out << "GraphExecutor::OutNode::RunningWait " << aret << endl ;
1881 bool GraphExecutor::OutNode::DoneWait() {
1882 cdebug_in << "GraphExecutor::OutNode::DoneWait" << endl;
1884 if ( pthread_mutex_lock( &_MutexWait ) ) {
1885 perror("pthread_mutex_lock _DoneWait") ;
1889 while ( !aret && !IsSuspended() && IsRunning() ) {
1890 cdebug << "DoneWait pthread_cond_wait _EventWait" << endl;
1891 pthread_cond_wait( &_EventWait , &_MutexWait );
1893 cdebug << "DoneWait pthread_cond_waited _EventWait " << aret << endl;
1895 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1896 perror("pthread_mutex_lock _DoneWait") ;
1899 cdebug_out << "GraphExecutor::OutNode::DoneWait " << aret << endl ;
1903 bool GraphExecutor::OutNode::SuspendedWait() {
1904 cdebug_in << "GraphExecutor::OutNode::SuspendedWait" << endl;
1906 if ( pthread_mutex_lock( &_MutexWait ) ) {
1907 perror("pthread_mutex_lock _SuspendedWait") ;
1910 aret = IsSuspended() ;
1911 while ( !aret && !IsDone() ) {
1912 pthread_cond_wait( &_EventWait , &_MutexWait );
1913 aret = IsSuspended() ;
1915 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1916 perror("pthread_mutex_lock _SuspendedWait") ;
1919 cdebug_out << "GraphExecutor::OutNode::SuspendedWait" << endl ;
1923 bool GraphExecutor::OutNode::ReadyWait( const char * NodeName ) {
1925 cdebug_in << "GraphExecutor::OutNode::ReadyWait " << NodeName << endl;
1926 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1928 aret = anInNode->ReadyWait() ;
1930 cdebug_out << "GraphExecutor::OutNode::ReadyWait" << endl ;
1934 bool GraphExecutor::OutNode::RunningWait( const char * NodeName ) {
1936 cdebug_in << "GraphExecutor::OutNode::RunningWait " << NodeName << endl;
1937 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1939 aret = anInNode->RunningWait() ;
1941 cdebug_out << "GraphExecutor::OutNode::RunningWait" << endl ;
1945 bool GraphExecutor::OutNode::DoneWait( const char * NodeName ) {
1947 cdebug_in << "GraphExecutor::OutNode::DoneWait " << NodeName << endl;
1948 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1950 aret = anInNode->DoneWait() ;
1952 cdebug_out << "GraphExecutor::OutNode::DoneWait" << endl ;
1956 bool GraphExecutor::OutNode::SuspendedWait( const char * NodeName ) {
1958 cdebug_in << "GraphExecutor::OutNode::SuspendedWait " << NodeName << endl;
1959 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1961 aret = anInNode->SuspendedWait() ;
1963 cdebug_out << "GraphExecutor::OutNode::SuspendedWait" << endl ;
1967 long GraphExecutor::OutNode::LastLevelDone() {
1970 for ( i = 0 ; i <= Graph()->LevelMax() ; i++ ) {
1971 for ( j = 0 ; j <= Graph()->NodesNumber( i ) ; j++ ) {
1972 GraphBase::ComputingNode * aNode = Graph()->SortedNodes( i , j ) ;
1973 if ( !IsDone( aNode->Name() ) ) {
1977 if ( j != Graph()->NodesNumber( i ) + 1 )
1985 const CORBA::Any *GraphExecutor::OutNode::GetInData( const char * NodeName ,
1986 const char * ServiceParameterName ) {
1987 // cdebug_in << "GraphExecutor::OutNode::GetInData " << NodeName << " "
1988 // << ServiceParameterName << endl ;
1989 const CORBA::Any * retdata = Graph()->PortInData( NodeName , ServiceParameterName ) ;
1990 // cdebug_out << "GraphExecutor::OutNode::GetInData" << endl ;
1994 const CORBA::Any *GraphExecutor::OutNode::GetOutData( const char * NodeName ,
1995 const char * ServiceParameterName ) {
1996 // cdebug_in << "GraphExecutor::OutNode::GetOutData " << NodeName << " "
1997 // << ServiceParameterName << endl ;
1998 const CORBA::Any * retdata = Graph()->PortOutData( NodeName , ServiceParameterName ) ;
1999 // cdebug_out << "GraphExecutor::OutNode::GetOutData" << endl ;
2003 const long GraphExecutor::OutNode::CpuUsed() {
2004 return Graph()->CpuUsed() ;
2007 const long GraphExecutor::OutNode::CpuUsed( const char * aNodeName ) {
2008 GraphBase::ComputingNode * aNode = Graph()->GetChangeGraphNode( aNodeName ) ;
2010 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aNode->GetInNode() ;
2012 return anInNode->CpuUsed() ;