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