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