Salome HOME
NRI : Merge from V1_2.
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_OutNode.cxx
1 using namespace std;
2 //=============================================================================
3 // File      : DataFlowBase_OutNode.cxx
4 // Created   : 2002
5 // Author    : Jean Rahuel, CEA
6 // Project   : SALOME
7 // $Header:
8 //=============================================================================
9
10 #include "DataFlowExecutor_OutNode.hxx"
11
12 // Implementation de la classe GraphEditor::GraphControl
13
14 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
15
16 static const char *ComponentName = "SalomeSuperVisionComponent" ;
17
18 extern int _ArgC ;
19 extern char ** _ArgV ;
20
21 GraphExecutor::OutNode::OutNode() :
22                Graph() {
23   _Valid = false ;
24   _Executable = false ;
25   _Done = false ;
26   _Threads = 0 ;
27   _ControlState = SUPERV::VoidState ;
28   _State = SUPERV::UnKnownState ;
29   _PyInitialized = false ;
30   pthread_mutex_init( &_MutexWait , NULL ) ;
31   if ( pthread_cond_init( &_EventWait , NULL ) ) {
32     perror("pthread_cond_init( &_EventWait , NULL )") ;
33     exit( 0 ) ;
34   }
35   if ( pthread_cond_init( &_JoinWait , NULL ) ) {
36     perror("pthread_cond_init( &_JoinWait , NULL )") ;
37     exit( 0 ) ;
38   }
39 }
40
41 GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, 
42                                  SALOME_NamingService* ptrNamingService ,
43                                  const char *DataFlowName ,
44                                  const char * DebugFileName ) :
45                Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
46   cdebug_in << "GraphEditor::OutNode::OutNode(" << DataFlowName << ")" << endl;
47   _Valid = false ;
48   _Executable = false ;
49   _Done = false ;
50   _Threads = 0 ;
51   _ControlState = SUPERV::VoidState ;
52   _State = SUPERV::UnKnownState ;
53   _PyInitialized = false ;
54   _Orb = CORBA::ORB::_duplicate( ORB ) ;
55   pthread_mutex_init( &_MutexWait , NULL ) ;
56   if ( pthread_cond_init( &_EventWait , NULL ) ) {
57     perror("pthread_cond_init( &_EventWait , NULL )") ;
58     exit( 0 ) ;
59   }
60   if ( pthread_cond_init( &_JoinWait , NULL ) ) {
61     perror("pthread_cond_init( &_JoinWait , NULL )") ;
62     exit( 0 ) ;
63   }
64   cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
65 }
66
67 GraphExecutor::OutNode::OutNode(
68                CORBA::ORB_ptr ORB, 
69                SALOME_NamingService* ptrNamingService ,
70                const SALOME_ModuleCatalog::Service& DataFlowService ,
71                const char *DataFlowComponentName ,
72                const char *DataFlowInterfaceName ,
73                const char *DataFlowName ,
74                const SUPERV::KindOfNode DataFlowkind ,
75                const SUPERV::SDate DataFlowFirstCreation ,
76                const SUPERV::SDate DataFlowLastModification ,
77                const char * DataFlowEditorRelease ,
78                const char * DataFlowAuthor ,
79                const char * DataFlowComputer ,
80                const char * DataFlowComment ,
81                const char * DebugFileName ) :
82                Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
83                       DataFlowInterfaceName , DataFlowName , DataFlowkind ,
84                       DataFlowFirstCreation , DataFlowLastModification  ,
85                       DataFlowEditorRelease , DataFlowAuthor ,
86                       DataFlowComputer , DataFlowComment , DebugFileName ) {
87   _Valid = false ;
88   _Executable = false ;
89   _Done = false ;
90   _Threads = 0 ;
91   _ControlState = SUPERV::VoidState ;
92   _State = SUPERV::UnKnownState ;
93   _PyInitialized = false ;
94   _Orb = CORBA::ORB::_duplicate( ORB ) ;
95   pthread_mutex_init( &_MutexWait , NULL ) ;
96   if ( pthread_cond_init( &_EventWait , NULL ) ) {
97     perror("pthread_cond_init( &_EventWait , NULL )") ;
98     exit( 0 ) ;
99   }
100   if ( pthread_cond_init( &_JoinWait , NULL ) ) {
101     perror("pthread_cond_init( &_JoinWait , NULL )") ;
102     exit( 0 ) ;
103   }
104 }
105
106 GraphExecutor::OutNode::~OutNode() {
107 }
108
109 bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph &aDataFlow ) {
110   bool RetVal = false ;
111   RetVal = LoadInfo( aDataFlow.Info ) ;
112   if ( GraphBase::Service::ServiceName() != NULL ) {
113 //    MESSAGE( "GraphExecutor::OutNode::LoadDataFlow" );
114     if ( RetVal ) {
115       RetVal = LoadNodes( aDataFlow.Nodes ) ;
116       if ( RetVal ) {
117         RetVal = LoadLinks( aDataFlow.Links ) ;
118         if ( RetVal ) {
119           IsValid() ;
120           RetVal = LoadDatas( aDataFlow.Datas ) ;
121           IsExecutable() ;
122           if ( !RetVal) {
123             cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadDatas Error."
124                    << endl ;
125           }
126         }
127         else {
128           cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadLinks Error."
129                << endl ;
130         }
131       }
132       else {
133         cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadNodes Error."
134              << endl ;
135       }
136     }
137     else {
138       cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadInfo Error."
139            << endl ;
140     }
141   }
142   else {
143     cdebug << "GraphExecutor::OutNode::LoadDataFlow ServiceName Error." << endl ;
144   }
145   return RetVal ;
146 }
147
148 bool GraphExecutor::OutNode::LoadXml( const char* myFileName ) {
149   bool RetVal = false ;
150   GraphBase::SGraph aDataFlow ;
151   if ( GraphBase::Graph::LoadXml( _Orb , myFileName , aDataFlow ) ) {
152     RetVal = LoadDataFlow( aDataFlow ) ;
153 //    if ( aConstructor && RetVal )
154 //      RetVal = Name( aDataFlow.Info.theName.c_str() ) ;
155   }
156   return RetVal ;
157
158
159 bool GraphExecutor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
160   cdebug << "GraphExecutor::OutNode::LoadInfo" << endl ;
161 //  ComponentName( aDataFlowInfo.theComponentName.c_str()  ) ;
162   Name( aDataFlowInfo.theName.c_str()  ) ;
163   Kind( aDataFlowInfo.theKind ) ;
164   DataService( _Orb , aDataFlowInfo.theService , Graph_prof_debug() , Graph_fdebug() ) ;
165   FirstCreation( aDataFlowInfo.theFirstCreation ) ;
166   LastModification( aDataFlowInfo.theLastModification ) ;
167   EditorRelease( aDataFlowInfo.theEditorRelease.c_str()  ) ;
168   Author( aDataFlowInfo.theAuthor.c_str()   ) ;
169 //  Computer( aDataFlowInfo.theContainer.c_str()  ) ;
170   Comment( aDataFlowInfo.theComment.c_str()  ) ;
171 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
172 //  Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
173   return true ;
174 }
175
176 bool GraphExecutor::OutNode::LoadNodes(const GraphBase::ListOfNodes &aListOfNodes ) {
177   bool RetVal = true ;
178   GraphExecutor::InNode * anInNode ;
179   cdebug << "GraphExecutor::OutNode::LoadNodes" << endl ;
180   int i ;
181   for ( i = 0 ; i < aListOfNodes.size() ; i++ ) {
182     GraphBase::SNode aNode = aListOfNodes[ i ] ;
183     anInNode = AddNode( aNode.theService ,
184                         aNode.theListOfFuncName ,
185                         aNode.theListOfPythonFunctions ,
186                         aNode.theComponentName.c_str() ,
187                         aNode.theInterfaceName.c_str()  , aNode.theName.c_str() ,
188                         aNode.theKind ,
189                         aNode.theFirstCreation , aNode.theLastModification ,
190                         aNode.theEditorRelease.c_str() ,
191                         aNode.theAuthor.c_str()  , aNode.theContainer.c_str() ,
192                         aNode.theComment.c_str() ,
193                         aNode.theCoords.theX , aNode.theCoords.theY ) ;
194     if ( !anInNode ) {
195       RetVal = false ;
196       break ;
197     }
198     if ( anInNode->IsOneOfInLineNodes() ) {
199       anInNode->GraphExecutor::InNode::InLineNode()->DefPortsOfNode(
200                                 _Orb , aNode.theService , anInNode->NamePtr() ,
201                                 anInNode->Kind() ,
202                                 Graph_prof_debug() , Graph_fdebug() ) ;
203 #if 0
204       GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
205       GraphBase::LoopNode * aLNode = NULL ;
206       if ( aINode->IsLoopNode() ) {
207         aLNode = anInNode->LoopNode() ;
208         aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
209                                    *aNode.theListOfPythonFunctions[ 0 ] ) ;
210         aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
211                                        *aNode.theListOfPythonFunctions[ 1 ] ) ;
212         aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
213                                        *aNode.theListOfPythonFunctions[ 2 ] ) ;
214       }
215       else if ( aINode->IsInLineNode() || aINode->IsGOTONode() ||
216                 aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
217         aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
218                                    *aNode.theListOfPythonFunctions[ 0 ] ) ;
219       }
220 #endif
221     }
222 #if 0
223     if ( aNode.theListOfParameters.size() ) { // BusPorts ...
224       int j ;
225       for ( j = 0 ; j < aNode.theListOfParameters.size() ; j++ ) {
226         GraphBase::InPort * InputPort = anInNode->AddInPort(
227                aNode.theListOfParameters[ j ].theInParameter.Parametername ,
228                aNode.theListOfParameters[ j ].theInParameter.Parametertype ) ;
229         GraphBase::OutPort * OutputPort = anInNode->AddOutPort(
230                aNode.theListOfParameters[ j ].theOutParameter.Parametername ,
231                aNode.theListOfParameters[ j ].theOutParameter.Parametertype ) ;
232         anInNode->InOutPort( InputPort , OutputPort ) ;
233       }
234     }
235 #endif
236   }
237   for ( i = 0 ; i < aListOfNodes.size() ; i++ ) {
238     GraphBase::SNode aNode = aListOfNodes[ i ] ;
239     anInNode = (GraphExecutor::InNode * ) GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
240     cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name() << "IsOneOfGOTONodes "
241            << anInNode->IsOneOfGOTONodes() << " " << aNode.theCoupledNode.c_str() << endl ;
242     if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
243       GraphBase::GOTONode * aCoupledNode ;
244       aCoupledNode = (GraphBase::GOTONode * ) GetGraphNode( aNode.theName.c_str() ) ;
245       aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ; 
246     }
247   }
248   return RetVal ;
249 }
250
251 bool GraphExecutor::OutNode::LoadLinks(const GraphBase::ListOfLinks &aListOfLinks ) {
252   bool RetVal = true ;
253   cdebug << "GraphExecutor::OutNode::LoadLinks " << aListOfLinks.size()
254          << endl ;
255   int i ;
256   for ( i = 0 ; i < aListOfLinks.size() ; i++ ) {
257     GraphBase::SLink aLink = aListOfLinks[ i ] ;
258     RetVal = AddLink( aLink.FromNodeName.c_str() ,
259                       aLink.FromServiceParameterName.c_str() ,
260                       aLink.ToNodeName.c_str() ,
261                       aLink.ToServiceParameterName.c_str() ,
262                       aLink.aLinkValue ) ;
263 //                      aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
264     if ( !RetVal )
265       break ;
266   }
267   return RetVal ;
268 }
269
270 bool GraphExecutor::OutNode::LoadDatas(const GraphBase::ListOfLinks &aListOfDatas ) {
271   bool RetVal = true ;
272   cdebug << "GraphExecutor::OutNode::LoadDatas " << aListOfDatas.size()
273          << endl ;
274   int i ;
275   for ( i = 0 ; i < aListOfDatas.size() ; i++ ) {
276     GraphBase::SLink aLink = aListOfDatas[ i ] ;
277     if ( !strcmp( aLink.FromNodeName.c_str() , Name() ) )
278       RetVal = GraphBase::Graph::AddInputData( aLink.ToNodeName.c_str() ,
279                                                aLink.ToServiceParameterName.c_str() ,
280                                                aLink.aLinkValue ) ;
281 //                        aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
282     else if ( !strcmp( aLink.ToNodeName.c_str() , Name() ) ) {
283       RetVal = AddOutputData( aLink.FromNodeName.c_str() ,
284                               aLink.FromServiceParameterName.c_str() ,
285                               aLink.aLinkValue ) ;
286 //                              aLink.aLinkValue.Value ,
287 //                              aLink.aLinkValue.Kind ) ;
288       AddLink( aLink.FromNodeName.c_str() , (GraphBase::ComputingNode *) this ) ;
289     }
290     else {
291       cdebug << "GraphExecutor::OutNode::LoadDatas Error " << aLink.FromNodeName
292            << " and " << aLink.ToNodeName << " differents from " << Name()
293            << endl ;
294       RetVal = false ;
295     }
296     if ( !RetVal )
297       break ;
298   }
299   return RetVal ;
300 }
301
302 GraphExecutor::InNode *GraphExecutor::OutNode::AddNode(
303                       const SALOME_ModuleCatalog::Service& NodeService ,
304                       GraphBase::ListOfFuncName aFuncName ,
305                       GraphBase::ListOfPythonFunctions aPythonFunction ,
306                       const char * NodeComponentName ,
307                       const char * NodeInterfaceName ,
308                       const char * NodeName ,
309                       const SUPERV::KindOfNode NodeKindOfNode ,
310                       const SUPERV::SDate NodeFirstCreation ,
311                       const SUPERV::SDate NodeLastModification  ,
312                       const char * NodeEditorRelease ,
313                       const char * NodeAuthor ,
314                       const char * NodeComputer ,
315                       const char * NodeComment ,
316                       const int NodeX ,
317                       const int NodeY ) {
318   cdebug_in << "GraphExecutor::OutNode::AddNode(" << NodeComponentName << " , "
319             << NodeName << ")" << endl;
320   GraphExecutor::InNode *Nd = NULL ;
321   Nd = new GraphExecutor::InNode( _Orb, NamingService() , NodeService ,
322                                   NodeComponentName , NodeInterfaceName ,
323                                   NodeName , NodeKindOfNode ,
324                                   aFuncName , aPythonFunction ,
325                                   NodeFirstCreation , NodeLastModification ,
326                                   NodeEditorRelease , NodeAuthor ,
327                                   NodeComputer , NodeComment , false , NodeX , NodeY ,
328                                   Graph_prof_debug() , Graph_fdebug() ) ;
329   GraphBase::Graph::AddNode( Nd->ComputingNode() ) ;
330   cdebug_out << "GraphExecutor::OutNode::AddNode" << endl;
331   return Nd ;
332 }
333
334
335 bool GraphExecutor::OutNode::AddInputData( const char* ToNodeName1 ,
336                                            const char* ToParameterName1 ,
337                                            const char* ToNodeName2 ,
338                                            const char* ToParameterName2 ) {
339   cdebug_in << "GraphExecutor::OutNode::AddInputData" << endl;
340   bool RetVal = GraphBase::Graph::AddInputData( ToNodeName1 ,
341                                                 ToParameterName1 ,
342                                                 ToNodeName2 ,
343                                                 ToParameterName2 ) ;
344   cdebug_out << "GraphExecutor::OutNode::AddInputData" << endl;
345   _Valid = false ;
346   return RetVal ;
347 }
348
349 bool GraphExecutor::OutNode::Valid() {
350   cdebug_in << "GraphExecutor::OutNode::Valid" << endl;
351
352   if ( _Valid )
353     return true ;
354
355   _Executable = false ;
356
357   CreateService() ;
358
359   if ( !Sort() ) {
360     cdebug << "This DataFlow is not valid." << endl ;
361     return false ;
362   }
363
364 //  CreateService() ;
365
366   InLineServices() ;
367
368   ComputingNodes() ;
369   
370   _Valid = true ;
371
372   cdebug_out << "GraphExecutor::OutNode::Valid" << endl;
373   return _Valid ;
374 }
375
376
377 bool GraphExecutor::OutNode::Executable() {
378
379   cdebug_in << "GraphExecutor::OutNode::Executable" << endl;
380   if ( !IsValid() )
381     return false ;
382
383   if ( DataServerNodes() )
384     _Executable = true ;
385   else {
386     cdebug << "This DataFlow is not executable." << endl ;
387     _Executable = false ;
388   }
389
390   cdebug_out << "GraphExecutor::OutNode::Executable" << endl;
391   return _Executable ;
392 }
393
394 bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
395   bool RetVal = false ;
396   cdebug_in << "GraphExecutor::OutNode::Run" << endl;
397
398   if ( Executable() ) {
399     _ControlState = SUPERV::VoidState ;
400     _SuspendedThreads = 0 ;
401     ThreadNo( pthread_self() ) ;
402     Done( false ) ;
403     _JustStarted = true ;
404     int i ;
405     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
406       GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) GraphNodes( i )->GetInNode() ;
407       if ( !PyInitialized() && anInNode->IsOneOfInLineNodes() ) {
408         if ( !Py_IsInitialized() ) {
409 //          Py_Initialize() ;
410           PySys_SetArgv( _ArgC , _ArgV ) ;
411         }
412         anInNode->InitPython() ;
413         PyInitialized( true ) ;
414       }
415       anInNode->InitialState( this ) ;
416     }
417
418     cdebug << "Execution starting GraphExecutor::Action_DataOk_RunService Node "
419            << Name() << endl ;
420
421     PushEvent( NULL , GraphExecutor::ReadyEvent ,
422                SUPERV::DataReadyState ) ; 
423     State( SUPERV::DataReadyState ) ;
424
425     for ( i = 0 ; i < HeadNodesSize() ; i++ ) {
426       GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) HeadNodes( i )->GetInNode() ;
427       if ( anInNode->State() != SUPERV::DataReadyState ) {
428         cdebug << "GraphExecutor::OutNode::Run inconsistency State of Node "
429              << anInNode->Name() << " : " << anInNode->State() << endl ;
430         return false ;
431       }
432 //      PushEvent( anInNode , GraphExecutor::ReadyEvent ,
433 //                 SUPERV::DataReadyState ) ; 
434       anInNode->CreateNewThread( true ) ;
435       anInNode->DataFromNode( Name() ) ;
436       if ( AndSuspend ) {
437         anInNode->State( SUPERV::DataWaitingState ) ;
438         anInNode->ControlState( SUPERV::ToSuspendStartState ) ;
439         if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
440           cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
441                  << anInNode->Name() << endl ;
442           return false ;
443         }
444         anInNode->SuspendedWait() ;
445       }
446       else if ( !anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ) {
447         cdebug << "InNode::SendEvent( RunningEvent ) Node "
448                << anInNode->Name() << endl ;
449         return false ;
450       }
451       else {
452         anInNode->RunningWait() ;
453       }
454     }
455
456     if ( AndSuspend ) {
457       PushEvent( NULL , GraphExecutor::SuspendedReadyEvent ,
458                  SUPERV::SuspendedReadyState ) ; 
459     }
460     else {
461       PushEvent( NULL , GraphExecutor::ExecutingEvent ,
462                  SUPERV::ExecutingState ) ; 
463       if (AutomatonState() == SUPERV::DataReadyState) {
464           State( SUPERV::ExecutingState ) ;
465       };
466     }
467
468     RetVal = true ;
469   }
470   else {
471     PushEvent( NULL , GraphExecutor::NoDataReadyEvent ,
472                SUPERV::DataUndefState ) ; 
473   }
474
475   cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
476   return RetVal ;
477 }
478
479 bool GraphExecutor::OutNode::Run( const char * aNodeName ,
480                                   const char * AtNodeName ,
481                                   const bool AndSuspend ) {
482   bool RetVal = false ;
483   cdebug_in << "GraphExecutor::OutNode::Run( " << aNodeName << " , "
484             << AtNodeName << " , " << AndSuspend << ")" << endl;
485   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode() ;
486   if ( anInNode ) {
487     RetVal = anInNode->ReStart( AtNodeName , AndSuspend ) ;
488   }
489   cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
490   return RetVal ;
491 }
492
493 void GraphExecutor::OutNode::CheckAllDone() {
494   int j ;
495   cdebug_in << "GraphExecutor::OutNode::CheckAllDone " << endl;
496   SUPERV::AutomatonState OutNodeState = SUPERV::SuccessedState ;
497   SUPERV::AutomatonState InNodeState ;
498   bool AllDone = true ;
499   if ( !_Done ) {
500     for ( j = 0 ; j < QueueNodesSize() ; j++ ) {
501       InNodeState = ( (GraphExecutor::InNode * ) QueueNodes( j )->GetInNode() )->State() ;
502       cdebug << j << ". "
503              << ( (GraphExecutor::InNode * ) QueueNodes( j )->GetInNode() )->Name()
504              << " " << theAutomaton->StateName( InNodeState ) << endl ;
505       if ( InNodeState != SUPERV::SuccessedState &&
506            InNodeState != SUPERV::ErroredState &&
507            InNodeState != SUPERV::DataWaitingState ) {
508         AllDone = false ;
509       }
510       if ( InNodeState != SUPERV::SuccessedState ) {
511         OutNodeState = InNodeState ;
512       }
513     }
514     if ( AllDone ) {
515       if( _Threads == 0 && _SuspendedThreads == 0 ) {
516         if ( OutNodeState != SUPERV::ErroredState ) {
517           OutNodeState = SUPERV::SuccessedState ;
518         }
519       }
520       else {
521         AllDone = false ;
522       }
523     }
524     if ( AllDone ) {
525       State( OutNodeState ) ;
526       _Done = true ;
527       _JustStarted = false ;
528       for ( j = 0 ; j < GraphNodesSize()  ; j++ ) {
529         GraphExecutor::InNode * aNode ;
530         aNode = (GraphExecutor::InNode * ) GraphNodes( j )->GetInNode() ;
531         SUPERV::GraphState aState = AutomatonGraphState( aNode->State() ) ;
532         cdebug << "GraphExecutor::OutNode::CheckAllDone " << aNode->Name() << " "
533                << theAutomaton->StateName( aNode->State() ) << " :" << endl ;
534         if ( aState == SUPERV::ErrorState ||
535              aState == SUPERV::SuspendErroredState ||
536              aState == SUPERV::KillState ||
537              aState == SUPERV::StopState ) {
538           OutNodeState = aNode->State() ;
539         }
540         aNode->SuspendedAction() ;
541         aNode->DoneAction() ;
542       }
543 // PushEvent AFTER State and _Done ! ...
544       PushEvent( NULL , GraphExecutor::EndExecuteEvent ,
545                  OutNodeState ) ;
546 //      Py_Finalize() ;
547 //      PyInitialized( false ) ;
548     }
549   }
550   cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << _Done
551              << " GraphAutomatonState " << theAutomaton->StateName( AutomatonState() )
552              << " State " << State() << " Threads " << _Threads << " SuspendedThreads "
553              << _SuspendedThreads << endl ;
554 }
555
556 void GraphExecutor::OutNode::PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) {
557 //  if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
558 //    cdebug << "GraphExecutor::OutNode::PThreadLock " << pthread_self() << " " << aMutex << " "
559 //           << errmsg << endl ;
560 //  }
561   if ( pthread_mutex_lock( aMutex ) ) {
562     perror( errmsg ) ;
563     exit( 0 ) ;
564   }
565 //  if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
566 //    cdebug << "GraphExecutor::OutNode::PThreadLocked " << pthread_self() << " " << aMutex << " "
567 //           << errmsg << endl ;
568 //  }
569 }
570
571 void GraphExecutor::OutNode::PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) {
572 //  if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
573 //    cdebug << " GraphExecutor::OutNode::PThreadUnLock " << pthread_self() << " " << aMutex << " "
574 //           << errmsg << endl ;
575 //  }
576   if ( pthread_mutex_unlock( aMutex ) ) {
577     perror( errmsg ) ;
578     exit( 0 ) ;
579   }
580 }
581
582 void GraphExecutor::OutNode::PThreadLock() {
583   cout << " GraphExecutor::OutNode::PThreadLock " << pthread_self() << endl ;
584   if ( pthread_mutex_lock( &_MutexWait ) ) {
585     perror( "GraphExecutor::OutNode::PThreadLock" ) ;
586     exit( 0 ) ;
587   }
588   cout << " GraphExecutor::OutNode::PThreadLocked " << pthread_self() << endl ;
589 }
590
591 void GraphExecutor::OutNode::PThreadUnLock() {
592   cout << " GraphExecutor::OutNode::PThreadUnLock " << pthread_self() << endl ;
593   if ( pthread_mutex_unlock( &_MutexWait ) ) {
594     perror( "GraphExecutor::OutNode::PThreadUnLock" ) ;
595     exit( 0 ) ;
596   }
597   cout << " GraphExecutor::OutNode::PThreadUnLocked " << pthread_self() << endl ;
598 }
599
600 void GraphExecutor::OutNode::NewThread() {
601   if ( pthread_mutex_lock( &_MutexWait ) ) {
602     perror("pthread_mutex_lock _NewThread") ;
603     exit( 0 ) ;
604   }
605   _Threads += 1 ;
606   cdebug << "NewThread : " << _Threads << " running threads "
607          << _SuspendedThreads << " suspended threads"
608          << endl ;
609   if ( pthread_mutex_unlock( &_MutexWait ) ) {
610     perror("pthread_mutex_unlock _NewThread") ;
611     exit( 0 ) ;
612   }
613 }
614 void GraphExecutor::OutNode::ExitThread() {
615   if ( pthread_mutex_lock( &_MutexWait ) ) {
616     perror("pthread_mutex_lock _ExitThread") ;
617     exit( 0 ) ;
618   }
619   _Threads -= 1 ;
620   theAutomaton->JoinThread( pthread_self() ) ;
621   if ( pthread_cond_signal( &_JoinWait ) ) {
622     perror("ExitThread pthread_cond_signal ") ;
623   }
624   cdebug << "ExitThread : " << _Threads << " running threads "
625          << _SuspendedThreads << " suspended threads"
626          << endl ;
627   if ( pthread_mutex_unlock( &_MutexWait ) ) {
628     perror("pthread_mutex_unlock _ExitThread") ;
629     exit( 0 ) ;
630   }
631   if ( _Threads == 0 && _SuspendedThreads == 0 ) {
632     CheckAllDone() ;
633   }
634 }
635 void GraphExecutor::OutNode::JoinedWait() {
636   if ( pthread_mutex_lock( &_MutexWait ) ) {
637     perror("pthread_mutex_lock JoinedWait") ;
638     exit( 0 ) ;
639   }
640   while ( _Threads ) {
641     if ( pthread_cond_wait( &_JoinWait , &_MutexWait ) ) {
642       perror("JoinedWait pthread_cond_wait ") ;
643     }
644   }
645   if ( pthread_mutex_unlock( &_MutexWait ) ) {
646     perror("pthread_mutex_unlock JoinedWait") ;
647     exit( 0 ) ;
648   }
649 }
650 void GraphExecutor::OutNode::SuspendThread() {
651   if ( pthread_mutex_lock( &_MutexWait ) ) {
652     perror("pthread_mutex_lock _SuspendThread") ;
653     exit( 0 ) ;
654   }
655   _SuspendedThreads += 1 ;
656   cdebug << "SuspendThread : " << _Threads << " running threads "
657          << _SuspendedThreads << " suspended threads"
658          << endl ;
659   if ( pthread_mutex_unlock( &_MutexWait ) ) {
660     perror("pthread_mutex_unlock _SuspendThread") ;
661     exit( 0 ) ;
662   }
663   if ( IsSuspended() ) {
664     PushEvent( NULL , GraphExecutor::SuspendEvent , SUPERV::SuspendedState ) ;
665   }
666 }
667 void GraphExecutor::OutNode::ResumeThread() {
668   if ( pthread_mutex_lock( &_MutexWait ) ) {
669     perror("pthread_mutex_lock _ResumeThread") ;
670     exit( 0 ) ;
671   }
672   _SuspendedThreads -= 1 ;
673   cdebug << "ResumeThread : " << _Threads << " running threads "
674          << _SuspendedThreads << " suspended threads"
675          << endl ;
676   if ( pthread_mutex_unlock( &_MutexWait ) ) {
677     perror("pthread_mutex_unlock _ResumeThread") ;
678     exit( 0 ) ;
679   }
680 }
681
682 long GraphExecutor::OutNode::Thread( const char * aNodeName ) {
683   long RetVal = 0 ;
684   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode() ;
685   if ( anInNode ) {
686     RetVal = anInNode->ThreadNo() ;
687   }
688   return RetVal ;
689 }
690
691 SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent ) {
692   SUPERV::GraphEvent aGraphEvent ;
693   switch ( anEvent ) {
694   case GraphExecutor::UndefinedEvent : {
695     aGraphEvent = SUPERV::UndefinedEvent ;
696     break ;
697   }
698   case GraphExecutor::NewThreadEvent : {
699     aGraphEvent = SUPERV::NewThreadEvent ;
700     break ;
701   }
702   case GraphExecutor::SuspendEvent : {
703     aGraphEvent = SUPERV::SuspendEvent ;
704     break ;
705   }
706   case GraphExecutor::ResumeEvent : {
707     aGraphEvent = SUPERV::ResumeEvent ;
708     break ;
709   }
710   case GraphExecutor::KillEvent : {
711     aGraphEvent = SUPERV::KillEvent ;
712     break ;
713   }
714   case GraphExecutor::StopEvent : {
715     aGraphEvent = SUPERV::StopEvent ;
716     break ;
717   }
718   case GraphExecutor::ExecuteEvent : {
719     aGraphEvent = SUPERV::RunningEvent ;
720     break ;
721   }
722   case GraphExecutor::SuccessEvent : {
723     aGraphEvent = SUPERV::DoneEvent ;
724     break ;
725   }
726   case GraphExecutor::ErrorEvent : {
727     aGraphEvent = SUPERV::ErroredEvent ;
728     break ;
729   }
730   case GraphExecutor::ReStartEvent : {
731     aGraphEvent = SUPERV::ReRunEvent ;
732     break ;
733   }
734   case GraphExecutor::ReStartAndSuspendEvent : {
735     aGraphEvent = SUPERV::ReStartEvent ;
736     break ;
737   }
738   case GraphExecutor::NoDataReadyEvent : {
739     aGraphEvent = SUPERV::WaitingEvent ;
740     break ;
741   }
742   case GraphExecutor::SomeDataReadyEvent : {
743     aGraphEvent = SUPERV::WaitingEvent ;
744     break ;
745   }
746   case GraphExecutor::NotAllDataReadyEvent : {
747     aGraphEvent = SUPERV::WaitingEvent ;
748     break ;
749   }
750   case GraphExecutor::AllDataReadyEvent : {
751     aGraphEvent = SUPERV::ReadyEvent ;
752     break ;
753   }
754   case GraphExecutor::ReadyEvent : {
755     aGraphEvent = SUPERV::ReadyEvent ;
756     break ;
757   }
758   case GraphExecutor::SuspendedReadyEvent : {
759     aGraphEvent = SUPERV::SuspendEvent ;
760     break ;
761   }
762   case GraphExecutor::ResumedReadyEvent : {
763     aGraphEvent = SUPERV::ResumeEvent ;
764     break ;
765   }
766   case GraphExecutor::KilledReadyEvent : {
767     aGraphEvent = SUPERV::KillEvent ;
768     break ;
769   }
770   case GraphExecutor::StoppedReadyEvent : {
771     aGraphEvent = SUPERV::StopEvent ;
772     break ;
773   }
774   case GraphExecutor::ExecutingEvent : {
775     aGraphEvent = SUPERV::RunningEvent ;
776     break ;
777   }
778   case GraphExecutor::SuspendedExecutingEvent : {
779     aGraphEvent = SUPERV::SuspendEvent ;
780     break ;
781   }
782   case GraphExecutor::ResumedExecutingEvent : {
783     aGraphEvent = SUPERV::ResumeEvent ;
784     break ;
785   }
786   case GraphExecutor::KilledExecutingEvent : {
787     aGraphEvent = SUPERV::KillEvent ;
788     break ;
789   }
790   case GraphExecutor::StoppedExecutingEvent : {
791     aGraphEvent = SUPERV::StopEvent ;
792     break ;
793   }
794   case GraphExecutor::SuccessedExecutingEvent : {
795     aGraphEvent = SUPERV::DoneEvent ;
796     break ;
797   }
798   case GraphExecutor::ErroredExecutingEvent : {
799     aGraphEvent = SUPERV:: ErroredEvent;
800     break ;
801   }
802   case GraphExecutor::SuspendedSuccessedEvent : {
803     aGraphEvent = SUPERV::SuspendEvent ;
804     break ;
805   }
806   case GraphExecutor::SuspendedErroredEvent : {
807     aGraphEvent = SUPERV::SuspendEvent ;
808     break ;
809   }
810   case GraphExecutor::ResumedSuccessedEvent : {
811     aGraphEvent = SUPERV::ResumeEvent ;
812     break ;
813   }
814   case GraphExecutor::ResumedErroredEvent : {
815     aGraphEvent = SUPERV::ResumeEvent ;
816     break ;
817   }
818   case GraphExecutor::KilledEvent : {
819     aGraphEvent = SUPERV::KillEvent ;
820     break ;
821   }
822   case GraphExecutor::StoppedEvent : {
823     aGraphEvent = SUPERV::StopEvent ;
824     break ;
825   }
826   case GraphExecutor::ReStartedEvent : {
827     aGraphEvent = SUPERV::ReRunEvent ;
828     break ;
829   }
830   case GraphExecutor::ReStartedAndSuspendEvent : {
831     aGraphEvent = SUPERV::ReStartEvent ;
832     break ;
833   }
834   case GraphExecutor::EndExecuteEvent : {
835     aGraphEvent = SUPERV::DoneEvent ;
836     break ;
837   }
838   default : {
839     cdebug << " GraphExecutor::OutNode::AutomatonGraphEvent Error Undefined Event : "
840            << anEvent << endl ;
841     aGraphEvent = SUPERV::UndefinedEvent ;
842   }
843   }
844   return aGraphEvent ;
845 }
846
847 SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(SUPERV::AutomatonState aState ) {
848   SUPERV::GraphState aGraphState ;
849   switch ( aState ) {
850   case SUPERV::UnKnownState : {
851     aGraphState = SUPERV::UndefinedState ;
852     break ;
853   }
854   case SUPERV::DataUndefState : {
855     aGraphState = SUPERV::UndefinedState ;
856     break ;
857   }
858   case SUPERV::DataWaitingState : {
859     aGraphState = SUPERV::WaitingState ;
860     break ;
861   }
862   case SUPERV::DataReadyState : {
863     aGraphState = SUPERV::ReadyState ;
864     break ;
865   }
866   case SUPERV::SuspendedReadyState : {
867     aGraphState = SUPERV::SuspendReadyState ;
868     break ;
869   }
870   case SUPERV::ResumedReadyState : {
871     aGraphState = SUPERV::ReadyState ;
872     break ;
873   }
874   case SUPERV::KilledReadyState : {
875     aGraphState = SUPERV::KillState ;
876     break ;
877   }
878   case SUPERV::StoppedReadyState : {
879     aGraphState = SUPERV::StopState ;
880     break ;
881   }
882   case SUPERV::ExecutingState : {
883     aGraphState = SUPERV::RunningState ;
884     break ;
885   }
886   case SUPERV::SuspendedExecutingState : {
887     aGraphState = SUPERV::SuspendState ;
888     break ;
889   }
890   case SUPERV::ResumedExecutingState : {
891     aGraphState = SUPERV::RunningState ;
892     break ;
893   }
894   case SUPERV::KilledExecutingState : {
895     aGraphState = SUPERV::KillState ;
896     break ;
897   }
898   case SUPERV::StoppedExecutingState : {
899     aGraphState = SUPERV::StopState ;
900     break ;
901   }
902   case SUPERV::SuccessedExecutingState : {
903     aGraphState = SUPERV::DoneState ;
904     break ;
905   }
906   case SUPERV::ErroredExecutingState : {
907     aGraphState = SUPERV::ErrorState ;
908     break ;
909   }
910   case SUPERV::SuspendedSuccessedState : {
911     aGraphState = SUPERV::SuspendDoneState ;
912     break ;
913   }
914   case SUPERV::SuspendedErroredState : {
915     aGraphState = SUPERV::SuspendErroredState ;
916     break ;
917   }
918   case SUPERV::ResumedSuccessedState : {
919     aGraphState = SUPERV::DoneState ;
920     break ;
921   }
922   case SUPERV::ResumedErroredState : {
923     aGraphState = SUPERV::ErrorState ;
924     break ;
925   }
926   case SUPERV::KilledSuccessedState : {
927     aGraphState = SUPERV::KillState ;
928     break ;
929   }
930   case SUPERV::KilledErroredState : {
931     aGraphState = SUPERV::KillState ;
932     break ;
933   }
934   case SUPERV::StoppedSuccessedState : {
935     aGraphState = SUPERV::StopState ;
936     break ;
937   }
938   case SUPERV::StoppedErroredState : {
939     aGraphState = SUPERV::StopState ;
940     break ;
941   }
942   case SUPERV::SuccessedState : {
943     aGraphState = SUPERV::DoneState ;
944     break ;
945   }
946   case SUPERV::ErroredState : {
947     aGraphState = SUPERV::ErrorState ;
948     break ;
949   }
950   case SUPERV::SuspendedState : {
951     aGraphState = SUPERV::SuspendState ;
952     break ;
953   }
954   case SUPERV::KilledState : {
955     aGraphState = SUPERV::KillState ;
956     break ;
957   }
958   case SUPERV::StoppedState : {
959     aGraphState = SUPERV::StopState ;
960     break ;
961   }
962   case SUPERV::ReRunnedState : {
963     aGraphState = SUPERV::ReRunState ;
964     break ;
965   }
966   case SUPERV::ReStartedState : {
967     aGraphState = SUPERV::ReStartState ;
968     break ;
969   }
970   default : {
971     cdebug << " GraphExecutor::OutNode::AutomatonGraphState Error Undefined State : "
972            << aGraphState << endl ;
973     aGraphState = SUPERV::UndefinedState ;
974   }
975   }
976   return aGraphState ;
977 }
978
979 bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode ,
980                                         GraphExecutor::NodeEvent anEvent ,
981                                         SUPERV::AutomatonState aState ) {
982 //  cdebug_in << "PushEvent Threads " << Threads() << " SuspendedThreads "
983 //            << SuspendedThreads() << endl ;
984   if ( pthread_mutex_lock( &_MutexWait ) ) {
985     perror("PushEvent pthread_mutex_lock ") ;
986     exit( 0 ) ;
987   }
988   if ( aNode ) {
989     _EventNodes.push_back( aNode->Name() ) ;
990   }
991   else {
992     _EventNodes.push_back( Name() ) ;
993   }
994   _Events.push_back( anEvent ) ;
995   _States.push_back( aState ) ;
996   pthread_cond_broadcast( &_EventWait );
997   if ( aNode ) {
998 //    cdebug << aNode->ThreadNo() << " PushEvent " << aNode->Name() ;
999 //    cdebug << " " << aNode->Automaton()->EventName( anEvent )
1000 //           << " " << aNode->Automaton()->StateName( aState )
1001 //           << " ControleState "
1002 //           << aNode->Automaton()->ControlStateName( aNode->ControlState() ) ;
1003   }
1004   else {
1005 //    cdebug << "PushEvent " << Name() ;
1006 //    cdebug << " " << theAutomaton->EventName( anEvent ) << " "
1007 //           << theAutomaton->StateName( aState ) ;
1008   }
1009 //  cdebug_out << "PushEvent Threads " << Threads() << " SuspendedThreads "
1010 //             << SuspendedThreads() << endl ;
1011   if ( pthread_mutex_unlock( &_MutexWait ) ) {
1012     perror("PushEvent pthread_mutex_unlock ") ;
1013     exit( 0 ) ;
1014   }
1015 }
1016
1017 bool GraphExecutor::OutNode::StateWait( SUPERV::GraphState aState ) {
1018 }
1019
1020 bool GraphExecutor::OutNode::Event( char ** aNodeName ,
1021                                     SUPERV::GraphEvent & anEvent ,
1022                                     SUPERV::GraphState & aState ,
1023                                     bool WithWait ) {
1024   int ThreadsNumber ;
1025   int SuspendedThreadsNumber ;
1026   if ( pthread_mutex_lock( &_MutexWait ) ) {
1027     perror("EventLoop pthread_mutex_lock ") ;
1028     exit( 0 ) ;
1029   }
1030   _JustStarted = false ;
1031   ThreadsNumber = Threads() ;
1032   SuspendedThreadsNumber = SuspendedThreads() ;
1033   bool RetVal = ( ThreadsNumber - SuspendedThreadsNumber) != 0 ||
1034                 _EventNodes.size() > 0 ;
1035   char * NodeName = "" ;
1036   GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
1037   SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
1038   anEvent = SUPERV::UndefinedEvent ;
1039   aState = SUPERV::UndefinedState ;
1040   if ( ( IsDone() || IsKilled() || IsStopped() ) && _EventNodes.size() == 0 ) {
1041     cdebug << "EventLoop IsDone()/IsKilled()/IsStopped() && _EventNodes.size() == 0" << endl ;
1042     RetVal = false ;
1043   }
1044   else if ( !WithWait && _EventNodes.size() == 0 ) {
1045     anEvent = SUPERV::NoEvent ;
1046     aState = SUPERV::NoState ;
1047     RetVal = true ;
1048   }
1049   else if ( RetVal ) {
1050     while ( !IsSuspended() && _EventNodes.size() == 0 ) {
1051       cdebug << "EventLoop pthread_cond_wait _EventWait" << endl ;
1052       pthread_cond_wait( &_EventWait , &_MutexWait );
1053       cdebug << "EventLoop pthread_cond_waited _EventWait"
1054              << " _EventNodes.size() " << _EventNodes.size() << endl ;
1055     }
1056     if ( _EventNodes.size() ) {
1057       ThreadsNumber = Threads() ;
1058       NodeName = _EventNodes.front() ;
1059       _EventNodes.pop_front() ;
1060       theEvent = _Events.front() ;
1061       anEvent = AutomatonGraphEvent( theEvent ) ;
1062       _Events.pop_front() ;
1063       theState = _States.front() ;
1064       aState = AutomatonGraphState( theState ) ;
1065       _States.pop_front() ;
1066     }
1067   }
1068   *aNodeName = NodeName ;
1069   if ( IsSuspended() && _EventNodes.size() == 0 ) {
1070     RetVal = false ;
1071   }
1072   if ( anEvent != SUPERV::NoEvent ) {
1073     cdebug << pthread_self() << "EventLoop "
1074            << NodeName << " " << theAutomaton->StateName( theState )
1075            << " _EventNodes.size() " << _EventNodes.size()
1076            << " Threads " << Threads() << " SuspendedThreads "
1077            << SuspendedThreads() << " RetVal " << RetVal << endl ;
1078   }
1079   if ( pthread_mutex_unlock( &_MutexWait ) ) {
1080     perror("EventLoop pthread_mutex_lock ") ;
1081     exit( 0 ) ;
1082   }
1083   return RetVal ;
1084 }
1085
1086 bool GraphExecutor::OutNode::EventW( char ** aNodeName ,
1087                                      SUPERV::GraphEvent & anEvent ,
1088                                      SUPERV::GraphState & aState ) {
1089   bool sts = true ;
1090   char * NodeName ;
1091   aState = SUPERV::UndefinedState ;
1092   while ( sts &&
1093           aState != SUPERV::SuspendReadyState &&
1094           aState != SUPERV::RunningState &&
1095           aState != SUPERV::SuspendDoneState &&
1096           aState != SUPERV::SuspendErroredState ) {
1097     NodeName = Name() ;
1098     while ( sts && !strcmp( NodeName , Name() ) ) {
1099       sts = EventWait( aNodeName , anEvent , aState ) ;
1100       NodeName = *aNodeName ;
1101     }
1102   }
1103   return sts ;
1104 }
1105
1106 bool GraphExecutor::OutNode::EventWait( char ** aNodeName ,
1107                                         SUPERV::GraphEvent & anEvent ,
1108                                         SUPERV::GraphState & aState ) {
1109   if ( pthread_mutex_lock( &_MutexWait ) ) {
1110     perror("EventW pthread_mutex_lock ") ;
1111     exit( 0 ) ;
1112   }
1113   int ThreadsNumber ;
1114   int SuspendedThreadsNumber ;
1115   ThreadsNumber = Threads() ;
1116   SuspendedThreadsNumber = SuspendedThreads() ;
1117   bool RetVal = ( ThreadsNumber - SuspendedThreadsNumber) != 0 ||
1118                 _EventNodes.size() > 0 ;
1119   cdebug << "--> EventW RetVal " << RetVal << endl ;
1120   char * NodeName = "" ;
1121   GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
1122   SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
1123   anEvent = SUPERV::UndefinedEvent ;
1124   aState = SUPERV::UndefinedState ;
1125   if ( IsDone() && _EventNodes.size() == 0 ) {
1126     cdebug << "EventW IsDone() && _EventNodes.size() == 0" << endl ;
1127     RetVal = 0 ;
1128   }
1129   else if ( RetVal ) {
1130     GraphExecutor::InNode * aNode = NULL ;
1131     while ( aNode == NULL && RetVal ) {
1132       NodeName = _EventNodes.front() ;
1133       theEvent = _Events.front() ;
1134       anEvent = AutomatonGraphEvent( theEvent ) ;
1135       theState = _States.front() ;
1136       aState = AutomatonGraphState( theState ) ;
1137
1138       if ( _JustStarted ) {
1139         _JustStarted = false ;
1140       }
1141       else {
1142         _EventNodes.pop_front() ;
1143         _Events.pop_front() ;
1144         _States.pop_front() ;
1145       }
1146
1147       aNode = ((GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode()) ;
1148       cdebug << "EventW Previous Node " << NodeName << " ThreadsNumber "
1149              << ThreadsNumber
1150              << " _EventNodes.size() " << _EventNodes.size() << " "
1151              << theAutomaton->StateName( theState )
1152              << " Threads " << Threads() << " SuspendedThreads "
1153              << SuspendedThreads() << endl ;
1154       if ( aNode ) {
1155       }
1156       else if ( IsDone() && _EventNodes.size() == 0 ) {
1157         cdebug << "EventW IsDone() && _EventNodes.size() == 0" << endl ;
1158         RetVal = 0 ;
1159       }
1160       else {
1161         cdebug << "EventW Not InNode " << NodeName
1162                << " _EventNodes.size() " << _EventNodes.size() << endl ;
1163         while ( _EventNodes.size() == 0 ) {
1164           pthread_cond_wait( &_EventWait , &_MutexWait );
1165         }
1166         cdebug << "EventW pthread_cond_waited Not InNode " << NodeName
1167                << " _EventNodes.size() " << _EventNodes.size() << endl ;
1168       }
1169     }
1170
1171     if ( aNode ) {
1172       if ( aState == SUPERV::SuspendState ||
1173            aState == SUPERV::SuspendReadyState ||
1174            aState == SUPERV::SuspendDoneState ||
1175            aState == SUPERV::SuspendErroredState ) {
1176         aNode->ControlState( SUPERV::ToSuspendState ) ;
1177         if ( aNode->IsSuspended() ) {
1178           if ( pthread_mutex_unlock( &_MutexWait ) ) {
1179             perror("EventW pthread_mutex_lock ") ;
1180             exit( 0 ) ;
1181           }
1182           cdebug << "EventW " << aNode->Name() << " ResumeAction" << endl ;
1183           aNode->ResumeAction( GraphExecutor::ToResumeEvent ) ;
1184           cdebug << "EventW " << aNode->Name() << " ResumedAction" << endl ;
1185           if ( pthread_mutex_lock( &_MutexWait ) ) {
1186             perror("EventW pthread_mutex_lock ") ;
1187             exit( 0 ) ;
1188           }
1189         }
1190         else {
1191           cdebug << "EventW inconsistent SuspendState" << endl ;
1192           RetVal = false ; 
1193         }
1194       }
1195       else {
1196         if ( aNode->IsDone() ) {
1197           RetVal = true ;
1198         }
1199         else {
1200           cdebug << "EventW NOT SuspendedState _EventNodes.size() "
1201                  << _EventNodes.size() << endl ;
1202           RetVal = true ;
1203         }
1204       }
1205       if ( RetVal ) {
1206         cdebug << "EventW " << aNode->Name() << " pthread_cond_wait" << endl ;
1207         while ( _EventNodes.size() == 0 ) {
1208           pthread_cond_wait( &_EventWait , &_MutexWait );
1209         }
1210         ThreadsNumber = Threads() ;
1211         NodeName = _EventNodes.front() ;
1212         theEvent = _Events.front() ;
1213         anEvent = AutomatonGraphEvent( theEvent ) ;
1214         theState = _States.front() ;
1215         aState = AutomatonGraphState( theState ) ;
1216       }
1217     }
1218   }
1219   *aNodeName = NodeName ;
1220   cdebug << "<-- EventW RetVal " << RetVal << " " << NodeName
1221          << " Threads " << Threads() << " SuspendedThreads "
1222          << SuspendedThreads()
1223          << " _EventNodes.size() " << _EventNodes.size()
1224          << " " << theAutomaton->EventName( theEvent ) << " "
1225          << theAutomaton->StateName( theState ) << endl ;
1226   if ( pthread_mutex_unlock( &_MutexWait ) ) {
1227     perror("EventW pthread_mutex_lock ") ;
1228     exit( 0 ) ;
1229   }
1230   return RetVal ;
1231 }
1232
1233 void GraphExecutor::OutNode::State(SUPERV::AutomatonState aState ) {
1234   _State = aState ;
1235 }
1236
1237 SUPERV::GraphState GraphExecutor::OutNode::State() {
1238 //  cdebug_in << "GraphExecutor::OutNode::State" << endl;
1239 //  cdebug_out << "GraphExecutor::OutNode::State" << endl ;
1240 //  cdebug << "GraphExecutor::OutNode::State GraphState "
1241 //         << theAutomaton->StateName( AutomatonGraphState( _State ) ) << endl ;
1242   return AutomatonGraphState( _State ) ;
1243 }
1244
1245 SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ) {
1246 //  cdebug_in << "GraphExecutor::OutNode::State " << NodeName << endl;
1247   SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
1248   const GraphBase::ComputingNode * aCNode =  GetGraphNode( NodeName ) ;
1249   if ( aCNode ) {
1250     GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *)aCNode->GetInNode() ;
1251     if ( anInNode ) {
1252       aret = anInNode->State() ;
1253       cdebug << "GraphExecutor::OutNode::State( " << NodeName << " ) "
1254              << theAutomaton->StateName( AutomatonGraphState( aret ) ) << endl ;
1255     }
1256   }
1257 //  cdebug_out << "GraphExecutor::OutNode::State" << endl ;
1258   return AutomatonGraphState( aret ) ;
1259 }
1260
1261 SUPERV::GraphState GraphExecutor::OutNode::State(
1262                                     const char * NodeName ,
1263                                     const char * ServiceParameterName )  {
1264 //  cdebug_in << "GraphExecutor::OutNode::State " << NodeName << " "
1265 //            << ServiceParameterName<< endl;
1266   SUPERV::GraphState aret =
1267                     PortState( NodeName , ServiceParameterName ) ;
1268 //  cdebug_out << "GraphExecutor::OutNode::State" << endl ;
1269   return aret ;
1270 }
1271
1272 SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState() {
1273 //  cdebug_in << "GraphExecutor::OutNode::AutomatonState" << endl;
1274 //  cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
1275   return _State ;
1276 }
1277
1278 SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState( const char * NodeName ) {
1279 //  cdebug_in << "GraphExecutor::OutNode::AutomatonState " << NodeName << endl;
1280   SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
1281   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1282   if ( anInNode )
1283     aret = anInNode->State() ;
1284 //  cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
1285   return aret ;
1286 }
1287
1288 SUPERV::ControlState GraphExecutor::OutNode::ControlState() {
1289 //  cdebug_in << "GraphExecutor::OutNode::ControlState" << endl;
1290 //  cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ;
1291   return _ControlState ;
1292 }
1293
1294 SUPERV::ControlState GraphExecutor::OutNode::ControlState( const char * NodeName ) {
1295 //  cdebug_in << "GraphExecutor::OutNode::ControlState " << NodeName << endl;
1296   SUPERV::ControlState aret = SUPERV::VoidState ;
1297   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1298   if ( anInNode )
1299     aret = anInNode->ControlState() ;
1300 //  cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ;
1301   return aret ;
1302 }
1303
1304 void GraphExecutor::OutNode::ControlClear() {
1305 //  cdebug_in << "GraphExecutor::OutNode::ControlClear" << endl;
1306 //  cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ;
1307   _ControlState = SUPERV::VoidState;
1308 }
1309
1310 void GraphExecutor::OutNode::ControlClear( const char * NodeName ) {
1311 //  cdebug_in << "GraphExecutor::OutNode::ControlClear " << NodeName << endl;
1312   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1313   if ( anInNode )
1314     anInNode->ControlClear() ;
1315 //  cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ;
1316 }
1317
1318 bool GraphExecutor::OutNode::IsWaiting() {
1319 //  cdebug_in << "GraphExecutor::OutNode::IsWaiting" << endl;
1320 //  cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
1321   return !_Done ;
1322 }
1323
1324 bool GraphExecutor::OutNode::IsReady() {
1325 //  cdebug_in << "GraphExecutor::OutNode::IsReady" << endl;
1326 //  cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
1327   return !_Done ;
1328 }
1329
1330 bool GraphExecutor::OutNode::IsRunning() {
1331 //  cdebug_in << "GraphExecutor::OutNode::IsRunning" << endl;
1332 //  cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
1333   return !_Done ;
1334 }
1335
1336 bool GraphExecutor::OutNode::IsDone() {
1337 //  cdebug_in << "GraphExecutor::OutNode::IsDone" << endl;
1338 //  cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
1339   return ( _Done || IsKilled() || IsStopped() ) ;
1340 }
1341
1342 bool GraphExecutor::OutNode::IsSuspended() {
1343 //  cdebug_in << "GraphExecutor::OutNode::IsSuspended" << endl;
1344   bool aret = false ;
1345   if ( _SuspendedThreads == _Threads ) {
1346     aret = true ;
1347   }
1348 //  cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
1349   return aret ;
1350 }
1351
1352 bool GraphExecutor::OutNode::IsKilled() {
1353 //  cdebug_in << "GraphExecutor::OutNode::IsKilled" << endl;
1354   bool aret = false ;
1355   if ( AutomatonGraphState( _State ) == SUPERV::KillState ) {
1356     aret = true ;
1357   }
1358 //  cdebug_out << "GraphExecutor::OutNode::IsKilled" << endl ;
1359   return aret ;
1360 }
1361
1362 bool GraphExecutor::OutNode::IsStopped() {
1363 //  cdebug_in << "GraphExecutor::OutNode::IsStopped" << endl;
1364   bool aret = false ;
1365   if ( AutomatonGraphState( _State ) == SUPERV::StopState ) {
1366     aret = true ;
1367   }
1368 //  cdebug_out << "GraphExecutor::OutNode::IsStopped" << endl ;
1369   return aret ;
1370 }
1371
1372 bool GraphExecutor::OutNode::IsWaiting( const char * NodeName ) {
1373   bool aret = false ;
1374 //  cdebug_in << "GraphExecutor::OutNode::IsWaiting " << NodeName << endl;
1375   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1376   if ( anInNode ) {
1377     aret = anInNode->IsWaiting() ;
1378   }
1379 //  cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
1380   return aret ;
1381 }
1382
1383 bool GraphExecutor::OutNode::IsReady( const char * NodeName ) {
1384   bool aret = false ;
1385 //  cdebug_in << "GraphExecutor::OutNode::IsReady " << NodeName << endl;
1386   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1387   if ( anInNode ) {
1388     aret = anInNode->IsReady() ;
1389   }
1390 //  cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
1391   return aret ;
1392 }
1393
1394 bool GraphExecutor::OutNode::IsRunning( const char * NodeName ) {
1395   bool aret = false ;
1396 //  cdebug_in << "GraphExecutor::OutNode::IsRunning " << NodeName << endl;
1397   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1398   if ( anInNode ) {
1399     aret = anInNode->IsRunning() ;
1400   }
1401 //  cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
1402   return aret ;
1403 }
1404
1405 bool GraphExecutor::OutNode::IsDone( const char * NodeName ) {
1406   bool aret = false ;
1407 //  cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << endl;
1408   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1409   if ( anInNode ) {
1410     aret = anInNode->IsDone() ;
1411   }
1412 //  cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
1413   return aret ;
1414 }
1415
1416 bool GraphExecutor::OutNode::IsSuspended( const char * NodeName ) {
1417   bool aret = false ;
1418 //  cdebug_in << "GraphExecutor::OutNode::IsSuspended " << NodeName << endl;
1419   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1420   if ( anInNode ) {
1421     aret = anInNode->IsSuspended() ;
1422   }
1423 //  cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
1424   return aret ;
1425 }
1426
1427 bool GraphExecutor::OutNode::IsDone( const char * NodeName ,
1428                                      const char * ServiceParameterName )  {
1429 //  cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << " "
1430 //            << ServiceParameterName<< endl;
1431   bool aret = PortDone( NodeName , ServiceParameterName ) ;
1432 //  cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
1433   return aret ;
1434 }
1435
1436 bool GraphExecutor::OutNode::ContainerKill() {
1437   bool RetVal = true ;
1438   cdebug_in << "GraphExecutor::OutNode::ContainerKill" << endl;
1439   _ControlState = SUPERV::ToSuspendState ;
1440   int i ;
1441   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1442     GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
1443     bool sts = aNode->ContainerKill() ;
1444     if ( sts && aNode->IsKilled() ) {
1445       cdebug << aNode->Name() << " killed" << endl ;
1446     }
1447     else if ( aNode->IsWaiting() || aNode->IsDone() ) {
1448       cdebug << aNode->Name() << " not killed : "
1449              << theAutomaton->StateName( aNode->State() ) << endl ;
1450     }
1451     else {
1452       cdebug << aNode->Name() << " cannot be killed : "
1453              << theAutomaton->StateName( aNode->State() ) << endl ;
1454       RetVal = false ;
1455     }
1456   }
1457   if ( !RetVal || Threads() != 0 ) {
1458     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1459       GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
1460       if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
1461         aNode->KilledAction() ;
1462       }
1463     }
1464     RetVal = true ;
1465   }
1466   State( SUPERV::KilledState ) ;
1467   cdebug_out << "GraphExecutor::OutNode::ContainerKill" << endl ;
1468   return RetVal ;
1469 }
1470
1471 bool GraphExecutor::OutNode::Suspend() {
1472   bool RetVal = false ;
1473   cdebug_in << "GraphExecutor::OutNode::Suspend" << endl;
1474   _ControlState = SUPERV::ToSuspendState ;
1475   int i ;
1476   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1477     GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
1478     bool sts = aNode->Suspend() ;
1479     if ( sts && aNode->IsSuspended() ) {
1480       cdebug << aNode->Name() << " Suspend" << endl ;
1481     }
1482     else if ( aNode->IsWaiting() || aNode->IsDone() ) {
1483       cdebug << aNode->Name() << " not Suspended : "
1484              << theAutomaton->StateName( aNode->State() ) << endl ;
1485     }
1486     else {
1487       cdebug << aNode->Name() << " cannot be Suspended : "
1488              << theAutomaton->StateName( aNode->State() ) << endl ;
1489       RetVal = false ;
1490     }
1491   }
1492   State( SUPERV::SuspendedState ) ;
1493   cdebug_out << "GraphExecutor::OutNode::Suspend" << endl ;
1494   return RetVal ;
1495 }
1496 bool GraphExecutor::OutNode::Resume() {
1497   bool RetVal = false ;
1498   cdebug_in << "GraphExecutor::OutNode::Resume" << endl;
1499   cdebug_out << "GraphExecutor::OutNode::Resume" << endl ;
1500   return RetVal ;
1501 }
1502
1503 bool GraphExecutor::OutNode::Kill() {
1504   bool RetVal = true ;
1505   cdebug_in << "GraphExecutor::OutNode::Kill" << endl;
1506   _ControlState = SUPERV::ToSuspendState ;
1507   int i ;
1508   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1509     GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
1510     bool sts = aNode->Kill() ;
1511     if ( sts && aNode->IsKilled() ) {
1512       cdebug << aNode->Name() << " killed" << endl ;
1513     }
1514     else if ( aNode->IsWaiting() || aNode->IsDone() ) {
1515       cdebug << aNode->Name() << " not killed : "
1516              << theAutomaton->StateName( aNode->State() ) << endl ;
1517     }
1518     else {
1519       cdebug << aNode->Name() << " cannot be killed : "
1520              << theAutomaton->StateName( aNode->State() ) << endl ;
1521       RetVal = false ;
1522     }
1523   }
1524   if ( !RetVal || Threads() != 0 ) {
1525     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1526       GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
1527       if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
1528         aNode->KilledAction() ;
1529       }
1530     }
1531     RetVal = true ;
1532   }
1533   State( SUPERV::KilledState ) ;
1534   cdebug_out << "GraphExecutor::OutNode::Kill" << endl ;
1535   return RetVal ;
1536 }
1537
1538 bool GraphExecutor::OutNode::Stop() {
1539   bool RetVal = false ;
1540   cdebug_in << "GraphExecutor::OutNode::Stop" << endl;
1541   Kill() ;
1542   cdebug_out << "GraphExecutor::OutNode::Stop" << endl ;
1543   return RetVal ;
1544 }
1545 bool GraphExecutor::OutNode::ReRun() {
1546   bool RetVal = false ;
1547   cdebug_in << "GraphExecutor::OutNode::ReRun" << endl;
1548   if ( IsSuspended() ) {
1549   }
1550   cdebug_out << "GraphExecutor::OutNode::ReRun" << endl ;
1551   return RetVal ;
1552 }
1553 bool GraphExecutor::OutNode::ReStart() {
1554   bool RetVal = false ;
1555   cdebug_in << "GraphExecutor::OutNode::ReStart" << endl;
1556   if ( IsSuspended() ) {
1557   }
1558   cdebug_out << "GraphExecutor::OutNode::ReStart" << endl ;
1559   return RetVal ;
1560 }
1561
1562 bool GraphExecutor::OutNode::ReadyWait() {
1563   cdebug_in << "GraphExecutor::OutNode::ReadyWait" << endl;
1564   bool aret ;
1565   if ( pthread_mutex_lock( &_MutexWait ) ) {
1566     perror("pthread_mutex_lock _ReadyWait") ;
1567     exit( 0 ) ;
1568   }
1569   aret = IsReady() ;
1570   if ( !aret ) {
1571     Suspend() ;
1572     pthread_cond_wait( &_EventWait , &_MutexWait );
1573     aret = IsReady() ;
1574   }
1575   if ( pthread_mutex_unlock( &_MutexWait ) ) {
1576     perror("pthread_mutex_lock _ReadyWait") ;
1577     exit( 0 ) ;
1578   }
1579   cdebug_out << "GraphExecutor::OutNode::ReadyWait" << endl ;
1580   return aret ;
1581 }
1582
1583 bool GraphExecutor::OutNode::RunningWait() {
1584   cdebug_in << "GraphExecutor::OutNode::RunningWait" << endl;
1585   bool aret ;
1586   if ( pthread_mutex_lock( &_MutexWait ) ) {
1587     perror("pthread_mutex_lock _RunningWait") ;
1588     exit( 0 ) ;
1589   }
1590   aret = IsRunning() ;
1591   if ( !aret ) {
1592     cdebug << "RunningWait pthread_cond_wait _EventWait" << endl;
1593     pthread_cond_wait( &_EventWait , &_MutexWait );
1594     aret = IsRunning() ;
1595     cdebug << "RunningWait pthread_cond_waited _EventWait " << aret << endl;
1596   }
1597   if ( pthread_mutex_unlock( &_MutexWait ) ) {
1598     perror("pthread_mutex_lock _RunningWait") ;
1599     exit( 0 ) ;
1600   }
1601   cdebug_out << "GraphExecutor::OutNode::RunningWait " << aret << endl ;
1602   return aret ;
1603 }
1604
1605 bool GraphExecutor::OutNode::DoneWait() {
1606   cdebug_in << "GraphExecutor::OutNode::DoneWait" << endl;
1607   bool aret ;
1608   if ( pthread_mutex_lock( &_MutexWait ) ) {
1609     perror("pthread_mutex_lock _DoneWait") ;
1610     exit( 0 ) ;
1611   }
1612   aret = IsDone() ;
1613   while ( !aret && !IsSuspended() ) {
1614     cdebug << "DoneWait pthread_cond_wait _EventWait" << endl;
1615     pthread_cond_wait( &_EventWait , &_MutexWait );
1616     aret = IsDone() ;
1617     cdebug << "DoneWait pthread_cond_waited _EventWait " << aret << endl;
1618   }
1619   if ( pthread_mutex_unlock( &_MutexWait ) ) {
1620     perror("pthread_mutex_lock _DoneWait") ;
1621     exit( 0 ) ;
1622   }
1623   cdebug_out << "GraphExecutor::OutNode::DoneWait " << aret << endl ;
1624   return aret ;
1625 }
1626
1627 bool GraphExecutor::OutNode::SuspendedWait() {
1628   cdebug_in << "GraphExecutor::OutNode::SuspendedWait" << endl;
1629   bool aret ;
1630   if ( pthread_mutex_lock( &_MutexWait ) ) {
1631     perror("pthread_mutex_lock _SuspendedWait") ;
1632     exit( 0 ) ;
1633   }
1634   aret = IsSuspended() ;
1635   while ( !aret && !_Done ) {
1636     pthread_cond_wait( &_EventWait , &_MutexWait );
1637     aret = IsSuspended() ;
1638   }
1639   if ( pthread_mutex_unlock( &_MutexWait ) ) {
1640     perror("pthread_mutex_lock _SuspendedWait") ;
1641     exit( 0 ) ;
1642   }
1643   cdebug_out << "GraphExecutor::OutNode::SuspendedWait" << endl ;
1644   return aret ;
1645 }
1646
1647 bool GraphExecutor::OutNode::ReadyWait( const char * NodeName ) {
1648   bool aret = false ;
1649   cdebug_in << "GraphExecutor::OutNode::ReadyWait " << NodeName << endl;
1650   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1651   if ( anInNode ) {
1652     aret = anInNode->ReadyWait() ;
1653   }
1654   cdebug_out << "GraphExecutor::OutNode::ReadyWait" << endl ;
1655   return aret ;
1656 }
1657
1658 bool GraphExecutor::OutNode::RunningWait( const char * NodeName ) {
1659   bool aret = false ;
1660   cdebug_in << "GraphExecutor::OutNode::RunningWait " << NodeName << endl;
1661   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1662   if ( anInNode ) {
1663     aret = anInNode->RunningWait() ;
1664   }
1665   cdebug_out << "GraphExecutor::OutNode::RunningWait" << endl ;
1666   return aret ;
1667 }
1668
1669 bool GraphExecutor::OutNode::DoneWait( const char * NodeName ) {
1670   bool aret = false ;
1671   cdebug_in << "GraphExecutor::OutNode::DoneWait " << NodeName << endl;
1672   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1673   if ( anInNode ) {
1674     aret = anInNode->DoneWait() ;
1675   }
1676   cdebug_out << "GraphExecutor::OutNode::DoneWait" << endl ;
1677   return aret ;
1678 }
1679
1680 bool GraphExecutor::OutNode::SuspendedWait( const char * NodeName ) {
1681   bool aret = false ;
1682   cdebug_in << "GraphExecutor::OutNode::SuspendedWait " << NodeName << endl;
1683   GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
1684   if ( anInNode ) {
1685     aret = anInNode->SuspendedWait() ;
1686   }
1687   cdebug_out << "GraphExecutor::OutNode::SuspendedWait" << endl ;
1688   return aret ;
1689 }
1690
1691 long GraphExecutor::OutNode::LastLevelDone() {
1692   int RetVal = -1 ;
1693   int i , j ;
1694   for ( i = 0 ; i <= LevelMax() ; i++ ) {
1695     for ( j = 0 ; j <= NodesNumber( i ) ; j++ ) {
1696       GraphBase::ComputingNode * aNode = SortedNodes( i , j ) ;
1697       if ( !IsDone( aNode->Name() ) ) {
1698         break ;
1699       }
1700     }
1701     if ( j != NodesNumber( i ) + 1 )
1702       break ;
1703     RetVal = i ;
1704   }
1705   return RetVal ;
1706 }
1707
1708
1709 const CORBA::Any *GraphExecutor::OutNode::GetInData(
1710                               const char * NodeName ,
1711                               const char * ServiceParameterName ) {
1712 //  cdebug_in << "GraphExecutor::OutNode::GetInData " << NodeName << " "
1713 //            << ServiceParameterName << endl ;
1714   const CORBA::Any * retdata = PortInData( NodeName , ServiceParameterName ) ;
1715 //  cdebug_out << "GraphExecutor::OutNode::GetInData" << endl ;
1716   return retdata ;
1717 }
1718
1719 const CORBA::Any *GraphExecutor::OutNode::GetOutData(
1720                               const char * NodeName ,
1721                               const char * ServiceParameterName ) {
1722 //  cdebug_in << "GraphExecutor::OutNode::GetOutData " << NodeName << " "
1723 //            << ServiceParameterName << endl ;
1724   const CORBA::Any * retdata = PortOutData( NodeName , ServiceParameterName ) ;
1725 //  cdebug_out << "GraphExecutor::OutNode::GetOutData" << endl ;
1726   return retdata ;
1727 }
1728