1 // SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowBase_OutNode.cxx
25 // Author : Jean Rahuel, CEA
31 #include "DataFlowExecutor_OutNode.hxx"
33 #include "Graph_Impl.hxx"
35 // Implementation de la classe GraphEditor::GraphControl
37 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
39 // static const char *ComponentName = "SalomeSuperVisionComponent" ;
42 extern char ** _ArgV ;
44 GraphExecutor::OutNode::OutNode() {
50 _ControlState = SUPERV::VoidState ;
51 _State = SUPERV::UnKnownState ;
52 _PyInitialized = false ;
53 pthread_mutex_init( &_MutexWait , NULL ) ;
54 pthread_mutex_init( &_PyMutexWait , NULL ) ;
55 if ( pthread_cond_init( &_EventWait , NULL ) ) {
56 perror("pthread_cond_init( &_EventWait , NULL )") ;
59 if ( pthread_cond_init( &_JoinWait , NULL ) ) {
60 perror("pthread_cond_init( &_JoinWait , NULL )") ;
65 GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB,
66 SALOME_NamingService* ptrNamingService ,
67 const char *DataFlowName ,
68 const char * DebugFileName ,
69 const SUPERV::KindOfNode aKindOfNode ) {
70 // Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
71 Set_prof_debug( ORB , DebugFileName ) ;
72 cdebug_in << "GraphEditor::OutNode::OutNode(" << DataFlowName << " , " << aKindOfNode << ")" << endl;
73 if ( aKindOfNode == SUPERV::DataFlowGraph ) {
75 // _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;
76 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName ,
77 _prof_debug , _fdebug ) ;
79 else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
80 // _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;;
81 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName ,
82 _prof_debug , _fdebug ) ;
83 _Graph = _StreamGraph ;
89 _ControlState = SUPERV::VoidState ;
90 _State = SUPERV::UnKnownState ;
91 _PyInitialized = false ;
92 _Orb = CORBA::ORB::_duplicate( ORB ) ;
93 pthread_mutex_init( &_MutexWait , NULL ) ;
94 pthread_mutex_init( &_PyMutexWait , NULL ) ;
95 if ( pthread_cond_init( &_EventWait , NULL ) ) {
96 perror("pthread_cond_init( &_EventWait , NULL )") ;
99 if ( pthread_cond_init( &_JoinWait , NULL ) ) {
100 perror("pthread_cond_init( &_JoinWait , NULL )") ;
103 cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
106 GraphExecutor::OutNode::OutNode(
108 SALOME_NamingService* ptrNamingService ,
109 const SALOME_ModuleCatalog::Service& DataFlowService ,
110 const char *DataFlowComponentName ,
111 const char *DataFlowInterfaceName ,
112 const char *DataFlowName ,
113 const SUPERV::KindOfNode DataFlowkind ,
114 const SUPERV::SDate DataFlowFirstCreation ,
115 const SUPERV::SDate DataFlowLastModification ,
116 const char * DataFlowEditorRelease ,
117 const char * DataFlowAuthor ,
118 const char * DataFlowComputer ,
119 const char * DataFlowComment ,
120 const char * DebugFileName ) {
121 // Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
122 // DataFlowInterfaceName , DataFlowName , DataFlowkind ,
123 // DataFlowFirstCreation , DataFlowLastModification ,
124 // DataFlowEditorRelease , DataFlowAuthor ,
125 // DataFlowComputer , DataFlowComment , DebugFileName ) {
126 Set_prof_debug( ORB , DebugFileName ) ;
128 cdebug_in << "GraphEditor::OutNode::OutNode(" << DataFlowName << " , " << DataFlowkind << ")" << endl;
129 if ( DataFlowkind == SUPERV::DataFlowGraph ) {
130 _StreamGraph = NULL ;
131 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
132 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
133 DataFlowFirstCreation , DataFlowLastModification ,
134 DataFlowEditorRelease , DataFlowAuthor ,
135 DataFlowComputer , DataFlowComment ,
136 _prof_debug , _fdebug ) ;
137 // DataFlowComputer , DataFlowComment , DebugFileName ) ;
139 else if ( DataFlowkind == SUPERV::DataStreamGraph ) {
140 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
141 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
142 DataFlowFirstCreation , DataFlowLastModification ,
143 DataFlowEditorRelease , DataFlowAuthor ,
144 DataFlowComputer , DataFlowComment ,
145 _prof_debug , _fdebug ) ;
146 _Graph = _StreamGraph ;
149 _Executable = false ;
152 _ControlState = SUPERV::VoidState ;
153 _State = SUPERV::UnKnownState ;
154 _PyInitialized = false ;
155 _Orb = CORBA::ORB::_duplicate( ORB ) ;
156 pthread_mutex_init( &_MutexWait , NULL ) ;
157 pthread_mutex_init( &_PyMutexWait , NULL ) ;
158 if ( pthread_cond_init( &_EventWait , NULL ) ) {
159 perror("pthread_cond_init( &_EventWait , NULL )") ;
162 if ( pthread_cond_init( &_JoinWait , NULL ) ) {
163 perror("pthread_cond_init( &_JoinWait , NULL )") ;
168 GraphExecutor::OutNode::~OutNode() {
171 void GraphExecutor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB ,
172 const char * DebugFileName ) {
173 _Graph_prof_debug = 0 ;
174 if ( DebugFileName ) {
175 _fdebug = new ofstream( DebugFileName );
176 SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ;
177 MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
181 bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph &aDataFlow ) {
182 bool RetVal = false ;
183 RetVal = LoadInfo( aDataFlow.Info ) ;
184 if ( Graph()->ServiceName() != NULL ) {
185 // MESSAGE( "GraphExecutor::OutNode::LoadDataFlow" );
187 RetVal = LoadNodes( aDataFlow.Nodes ) ;
189 RetVal = LoadLinks( aDataFlow.Links ) ;
192 RetVal = LoadDatas( aDataFlow.Datas ) ;
195 cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadDatas Error."
200 cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadLinks Error."
205 cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadNodes Error."
210 cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadInfo Error."
215 cdebug << "GraphExecutor::OutNode::LoadDataFlow ServiceName Error." << endl ;
220 bool GraphExecutor::OutNode::LoadXml( const char* myFileName ) {
221 bool RetVal = false ;
222 GraphBase::SGraph aDataFlow ;
223 if ( Graph()->LoadXml( _Orb , myFileName , aDataFlow ) ) {
224 RetVal = LoadDataFlow( aDataFlow ) ;
225 // if ( aConstructor && RetVal )
226 // RetVal = Name( aDataFlow.Info.theName.c_str() ) ;
231 bool GraphExecutor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
232 cdebug << "GraphExecutor::OutNode::LoadInfo _StreamGraph " << _StreamGraph << endl ;
233 // ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
234 Graph()->Name( aDataFlowInfo.theName.c_str() ) ;
235 Graph()->Kind( aDataFlowInfo.theKind ) ;
236 if ( Graph()->IsDataStreamNode() ) {
237 StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ;
239 Graph()->DataService( _Orb , aDataFlowInfo.theService , _prof_debug , _fdebug ) ;
240 Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ;
241 Graph()->LastModification( aDataFlowInfo.theLastModification ) ;
242 Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
243 Graph()->Author( aDataFlowInfo.theAuthor.c_str() ) ;
244 // Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ;
245 Graph()->Comment( aDataFlowInfo.theComment.c_str() ) ;
246 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
247 // Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
251 bool GraphExecutor::OutNode::LoadNodes(const GraphBase::ListOfNodes &aListOfNodes ) {
253 GraphExecutor::InNode * anInNode ;
254 cdebug << "GraphExecutor::OutNode::LoadNodes" << endl ;
256 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
257 GraphBase::SNode aNode = aListOfNodes[ i ] ;
258 anInNode = AddNode( aNode.theService ,
259 aNode.theListOfFuncName ,
260 aNode.theListOfPythonFunctions ,
261 aNode.theComponentName.c_str() ,
262 aNode.theInterfaceName.c_str() , aNode.theName.c_str() ,
264 aNode.theFirstCreation , aNode.theLastModification ,
265 aNode.theEditorRelease.c_str() ,
266 aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
267 aNode.theComment.c_str() ,
268 aNode.theCoords.theX , aNode.theCoords.theY ) ;
273 if ( anInNode->IsOneOfInLineNodes() ) {
274 anInNode->GraphExecutor::InNode::InLineNode()->DefPortsOfNode(
275 _Orb , aNode.theService , anInNode->NamePtr() ,
277 _prof_debug , _fdebug ) ;
279 // GraphBase::ComputingNode * theNode = Graph()->GetChangeGraphNode( aNode.theName.c_str() ) ;
282 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
283 GraphBase::InPort * anInPort ;
284 anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
285 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
286 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
287 SUPERV::DataStreamParameter ) ;
288 ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema ,
289 aNode.theListOfInDataStreams[ j ].theKindOfInterpolation ,
290 aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ;
292 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
293 GraphBase::OutPort * anOutPort ;
294 anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
295 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
296 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
297 SUPERV::DataStreamParameter ) ;
298 ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ;
302 // theNode->DataStreamInPortsNumber( aNode.theDataStreamInArgsNumber ) ;
303 // theNode->DataStreamOutPortsNumber( aNode.theDataStreamOutArgsNumber ) ;
304 // cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name()
305 // << " InPortsSize " << theNode->GetNodeInPortsSize()
306 // << " OutPortsSize " << theNode->GetNodeOutPortsSize()
307 // << " DataStreamInPortsNumber " << aNode.theDataStreamInArgsNumber
308 // << " DataStreamOutPortsNumber " << aNode.theDataStreamOutArgsNumber
311 // if ( aNode.theDataStreamInArgsNumber ) { // -1 because of Gates
312 // for ( j = theNode->GetNodeInPortsSize() - aNode.theDataStreamInArgsNumber - 1 ; j < theNode->GetNodeInPortsSize() - 1 ; j++ ) {
313 // cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name()
314 // << " InPort " << theNode->GetChangeNodeInPort( j )->PortName()
315 // << " Kind( DataStreamParameter)" << endl ;
316 // theNode->GetChangeNodeInPort( j )->Kind( SUPERV::DataStreamParameter ) ;
319 // if ( aNode.theDataStreamOutArgsNumber ) {
320 // int withgate = 1 ;
321 // if ( theNode->IsLoopNode() || theNode->IsEndLoopNode() ) {
324 // for ( j = theNode->GetNodeOutPortsSize() - aNode.theDataStreamOutArgsNumber - withgate ; j < theNode->GetNodeOutPortsSize() - withgate ; j++ ) {
325 // cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name()
326 // << " OutPort " << theNode->GetChangeNodeOutPort( j )->PortName()
327 // << " Kind( DataStreamParameter)" << endl ;
328 // theNode->GetChangeNodeOutPort( j )->Kind( SUPERV::DataStreamParameter ) ;
332 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
333 GraphBase::SNode aNode = aListOfNodes[ i ] ;
334 anInNode = (GraphExecutor::InNode * ) Graph()->GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
335 cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name() << " IsOneOfGOTONodes "
336 << anInNode->IsOneOfGOTONodes() << " " << aNode.theCoupledNode.c_str() << endl ;
337 if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
338 GraphBase::GOTONode * aCoupledNode ;
339 aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetGraphNode( aNode.theName.c_str() ) ;
340 aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ;
346 bool GraphExecutor::OutNode::LoadLinks(const GraphBase::ListOfLinks &aListOfLinks ) {
348 cdebug << "GraphExecutor::OutNode::LoadLinks " << aListOfLinks.size()
351 for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
352 GraphBase::SLink aLink = aListOfLinks[ i ] ;
353 RetVal = Graph()->AddLink( aLink.FromNodeName.c_str() ,
354 aLink.FromServiceParameterName.c_str() ,
355 aLink.ToNodeName.c_str() ,
356 aLink.ToServiceParameterName.c_str() ,
358 // aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
365 bool GraphExecutor::OutNode::LoadDatas(const GraphBase::ListOfLinks &aListOfDatas ) {
367 cdebug << "GraphExecutor::OutNode::LoadDatas " << aListOfDatas.size()
370 for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
371 GraphBase::SLink aLink = aListOfDatas[ i ] ;
372 if ( !strcmp( aLink.FromNodeName.c_str() , Graph()->Name() ) )
373 RetVal = Graph()->AddInputData( aLink.ToNodeName.c_str() ,
374 aLink.ToServiceParameterName.c_str() ,
376 // aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
377 else if ( !strcmp( aLink.ToNodeName.c_str() , Graph()->Name() ) ) {
378 RetVal = Graph()->AddOutputData( aLink.FromNodeName.c_str() ,
379 aLink.FromServiceParameterName.c_str() ,
381 // aLink.aLinkValue.Value ,
382 // aLink.aLinkValue.Kind ) ;
383 Graph()->AddLink( aLink.FromNodeName.c_str() , (GraphBase::ComputingNode *) this ) ;
386 cdebug << "GraphExecutor::OutNode::LoadDatas Error " << aLink.FromNodeName
387 << " and " << aLink.ToNodeName << " differents from " << Graph()->Name()
397 GraphExecutor::InNode *GraphExecutor::OutNode::AddNode(
398 const SALOME_ModuleCatalog::Service& NodeService ,
399 GraphBase::ListOfFuncName aFuncName ,
400 GraphBase::ListOfPythonFunctions aPythonFunction ,
401 const char * NodeComponentName ,
402 const char * NodeInterfaceName ,
403 const char * NodeName ,
404 const SUPERV::KindOfNode NodeKindOfNode ,
405 const SUPERV::SDate NodeFirstCreation ,
406 const SUPERV::SDate NodeLastModification ,
407 const char * NodeEditorRelease ,
408 const char * NodeAuthor ,
409 const char * NodeComputer ,
410 const char * NodeComment ,
413 cdebug_in << "GraphExecutor::OutNode::AddNode(" << NodeComponentName << " , "
414 << NodeName << ")" << endl;
415 GraphExecutor::InNode *Nd = NULL ;
416 Nd = new GraphExecutor::InNode( _Orb, Graph()->NamingService() , NodeService ,
417 NodeComponentName , NodeInterfaceName ,
418 NodeName , NodeKindOfNode ,
419 aFuncName , aPythonFunction ,
420 NodeFirstCreation , NodeLastModification ,
421 NodeEditorRelease , NodeAuthor ,
422 NodeComputer , NodeComment , false , NodeX , NodeY ,
423 _prof_debug , _fdebug ) ;
424 Graph()->AddNode( Nd->ComputingNode() ) ;
425 cdebug_out << "GraphExecutor::OutNode::AddNode" << endl;
430 bool GraphExecutor::OutNode::AddInputData( const char* ToNodeName1 ,
431 const char* ToParameterName1 ,
432 const char* ToNodeName2 ,
433 const char* ToParameterName2 ) {
434 cdebug_in << "GraphExecutor::OutNode::AddInputData" << endl;
435 bool RetVal = Graph()->AddInputData( ToNodeName1 ,
439 cdebug_out << "GraphExecutor::OutNode::AddInputData" << endl;
444 bool GraphExecutor::OutNode::Valid() {
445 cdebug_in << "GraphExecutor::OutNode::Valid" << endl;
450 _Executable = false ;
452 if ( !Graph()->CreateService() ) {
453 cdebug << "This DataFlow has invalid type(s)." << endl ;
457 if ( !Graph()->Sort() ) {
458 cdebug << "This DataFlow is not valid." << endl ;
464 Graph()->InLineServices() ;
466 Graph()->ComputingNodes() ;
470 cdebug_out << "GraphExecutor::OutNode::Valid" << endl;
475 bool GraphExecutor::OutNode::Executable() {
477 cdebug_in << "GraphExecutor::OutNode::Executable" << endl;
481 if ( Graph()->DataServerNodes() )
484 cdebug << "This DataFlow is not executable." << endl ;
485 _Executable = false ;
488 cdebug_out << "GraphExecutor::OutNode::Executable" << endl;
492 bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
493 bool RetVal = false ;
494 cdebug_in << "GraphExecutor::OutNode::Run" << endl;
496 if ( Executable() ) {
497 _ControlState = SUPERV::VoidState ;
498 _SuspendedThreads = 0 ;
499 Graph()->ThreadNo( pthread_self() ) ;
501 _JustStarted = true ;
503 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
504 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ;
505 if ( !PyInitialized() && anInNode->IsOneOfInLineNodes() ) {
506 if ( !Py_IsInitialized() ) {
508 PySys_SetArgv( _ArgC , _ArgV ) ;
510 anInNode->InitPython() ;
511 PyInitialized( true ) ;
513 anInNode->InitialState( this ) ;
514 if ( anInNode->IsOneOfInLineNodes() ) {
515 anInNode->InitPythonFunctions( false ) ;
518 // One more time because inline nodes may share one definition of the same function
519 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
520 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ;
521 if ( anInNode->IsOneOfInLineNodes() ) {
522 if ( !anInNode->InitPythonFunctions( true ) ) {
523 cdebug << "GraphExecutor::OutNode::Run InitPythonFunctions ERROR "
524 << anInNode->Name() << endl ;
530 cdebug << "Execution starting GraphExecutor::Action_DataOk_RunService Node "
531 << Graph()->Name() << endl ;
533 PushEvent( NULL , GraphExecutor::ReadyEvent ,
534 SUPERV::DataReadyState ) ;
535 State( SUPERV::DataReadyState ) ;
537 for ( i = 0 ; i < Graph()->HeadNodesSize() ; i++ ) {
538 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->HeadNodes( i )->GetInNode() ;
539 if ( anInNode->State() != SUPERV::DataReadyState ) {
540 cdebug << "GraphExecutor::OutNode::Run inconsistency State of Node "
541 << anInNode->Name() << " : " << anInNode->State() << endl ;
542 cdebug_out << "GraphExecutor::OutNode::Run State ERROR" << endl ;
545 // PushEvent( anInNode , GraphExecutor::ReadyEvent ,
546 // SUPERV::DataReadyState ) ;
547 anInNode->CreateNewThread( true ) ;
548 anInNode->DataFromNode( Graph()->Name() ) ;
550 anInNode->State( SUPERV::DataWaitingState ) ;
551 anInNode->ControlState( SUPERV::ToSuspendStartState ) ;
552 if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
553 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) ERROR Node "
554 << anInNode->Name() << endl ;
555 cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
558 anInNode->SuspendedWait() ;
560 else if ( !anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ) {
561 cdebug << "InNode::SendEvent( ExecuteEvent ) ERROR Node "
562 << anInNode->Name() << endl ;
563 cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
567 anInNode->RunningWait() ;
572 PushEvent( NULL , GraphExecutor::SuspendedReadyEvent ,
573 SUPERV::SuspendedReadyState ) ;
576 PushEvent( NULL , GraphExecutor::ExecutingEvent ,
577 SUPERV::ExecutingState ) ;
578 if (AutomatonState() == SUPERV::DataReadyState) {
579 State( SUPERV::ExecutingState ) ;
583 astr << "Graph " << Graph()->Name() << " is running" ;
584 Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
588 PushEvent( NULL , GraphExecutor::NoDataReadyEvent ,
589 SUPERV::DataUndefState ) ;
592 cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
596 bool GraphExecutor::OutNode::Run( const char * aNodeName ,
597 const char * AtNodeName ,
598 const bool AndSuspend ) {
599 bool RetVal = false ;
600 cdebug_in << "GraphExecutor::OutNode::Run( " << aNodeName << " , "
601 << AtNodeName << " , " << AndSuspend << ")" << endl;
602 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode() ;
604 RetVal = anInNode->ReStart( AtNodeName , AndSuspend ) ;
606 cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
610 void GraphExecutor::OutNode::CheckAllDone() {
612 cdebug_in << "GraphExecutor::OutNode::CheckAllDone " << endl;
613 SUPERV::AutomatonState OutNodeState = SUPERV::SuccessedState ;
614 SUPERV::AutomatonState InNodeState ;
615 bool AllDone = true ;
617 for ( j = 0 ; j < Graph()->QueueNodesSize() ; j++ ) {
618 InNodeState = ( (GraphExecutor::InNode * ) Graph()->QueueNodes( j )->GetInNode() )->State() ;
620 << ( (GraphExecutor::InNode * ) Graph()->QueueNodes( j )->GetInNode() )->Name()
621 << " " << theAutomaton->StateName( InNodeState ) << endl ;
622 if ( InNodeState != SUPERV::SuccessedState &&
623 InNodeState != SUPERV::ErroredState &&
624 InNodeState != SUPERV::DataWaitingState ) {
627 if ( InNodeState != SUPERV::SuccessedState &&
628 InNodeState != SUPERV::DataWaitingState &&
629 InNodeState != SUPERV::DataReadyState ) {
630 OutNodeState = InNodeState ;
634 if( _Threads == 0 && _SuspendedThreads == 0 ) {
635 if ( OutNodeState != SUPERV::ErroredState ) {
636 OutNodeState = SUPERV::SuccessedState ;
645 for ( j = 0 ; j < Graph()->GraphNodesSize() ; j++ ) {
646 GraphExecutor::InNode * aNode ;
647 aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( j )->GetInNode() ;
648 SUPERV::GraphState aState = AutomatonGraphState( aNode->State() ) ;
649 cdebug << "GraphExecutor::OutNode::CheckAllDone " << aNode->Name() << " "
650 << theAutomaton->StateName( aNode->State() ) << " CreateNewThread " << aNode->CreateNewThread()
652 if ( aState == SUPERV::ErrorState ||
653 aState == SUPERV::SuspendErroredState ||
654 aState == SUPERV::KillState ||
655 aState == SUPERV::StopState ) {
656 OutNodeState = aNode->State() ;
657 State( OutNodeState ) ;
659 else if ( aState == SUPERV::ReadyState ||
660 aState == SUPERV::SuspendReadyState ||
661 aState == SUPERV::RunningState ||
662 aState == SUPERV::SuspendDoneState ||
663 aState == SUPERV::SuspendErroredState ||
664 aState == SUPERV::ReRunState ||
665 aState == SUPERV::ReStartState ||
666 aState == SUPERV::SuspendState ) {
669 aNode->SuspendedAction() ;
670 aNode->DoneAction() ;
672 // PushEvent AFTER State and _Done ! ...
673 if ( alivenodes == 0 ) {
674 State( OutNodeState ) ;
676 _JustStarted = false ;
678 PushEvent( NULL , GraphExecutor::EndExecuteEvent ,
681 // PyInitialized( false ) ;
685 MESSAGE("================================================================================") ;
686 MESSAGE( Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
688 MESSAGE("================================================================================") ;
689 cdebug << "================================================================================" << endl ;
690 cdebug << Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
691 << EventQSize() << endl ;
692 cdebug << "================================================================================" << endl ;
694 astr << "Graph " << Graph()->Name() << " is done : "
695 << theAutomaton->StateName( AutomatonState() ) ;
696 Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
697 //cout << Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
698 // << EventQSize() << endl ;
700 cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << IsDone()
701 << " GraphAutomatonState " << theAutomaton->StateName( AutomatonState() )
702 << " State " << State() << " Threads " << _Threads << " SuspendedThreads "
703 << _SuspendedThreads << " EventQSize " << EventQSize() << endl ;
706 void GraphExecutor::OutNode::PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) {
707 // if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
708 // cdebug << "GraphExecutor::OutNode::PThreadLock " << pthread_self() << " " << aMutex << " "
709 // << errmsg << endl ;
711 if ( pthread_mutex_lock( aMutex ) ) {
715 // if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
716 // cdebug << "GraphExecutor::OutNode::PThreadLocked " << pthread_self() << " " << aMutex << " "
717 // << errmsg << endl ;
721 void GraphExecutor::OutNode::PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) {
722 // if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
723 // cdebug << " GraphExecutor::OutNode::PThreadUnLock " << pthread_self() << " " << aMutex << " "
724 // << errmsg << endl ;
726 if ( pthread_mutex_unlock( aMutex ) ) {
732 void GraphExecutor::OutNode::PyThreadLock() {
733 // cout << " GraphExecutor::OutNode::PyThreadLock " << pthread_self() << endl ;
734 if ( pthread_mutex_lock( &_PyMutexWait ) ) {
735 perror( "GraphExecutor::OutNode::PyThreadLock" ) ;
738 theAutomaton->PyLock() ;
739 // cout << " GraphExecutor::OutNode::PyThreadLocked " << pthread_self() << endl ;
742 void GraphExecutor::OutNode::PyThreadUnLock() {
743 // cout << " GraphExecutor::OutNode::PyThreadUnLock " << pthread_self() << endl ;
744 if ( pthread_mutex_unlock( &_PyMutexWait ) ) {
745 perror( "GraphExecutor::OutNode::PyThreadUnLock" ) ;
748 theAutomaton->PyUnLock() ;
749 // cout << " GraphExecutor::OutNode::PyThreadUnLocked " << pthread_self() << endl ;
752 void GraphExecutor::OutNode::NewThread() {
753 if ( pthread_mutex_lock( &_MutexWait ) ) {
754 perror("pthread_mutex_lock _NewThread") ;
758 cdebug << "NewThread : " << _Threads << " running threads "
759 << _SuspendedThreads << " suspended threads"
761 if ( pthread_mutex_unlock( &_MutexWait ) ) {
762 perror("pthread_mutex_unlock _NewThread") ;
767 void GraphExecutor::OutNode::ExitThread() {
768 if ( pthread_mutex_lock( &_MutexWait ) ) {
769 perror("pthread_mutex_lock _ExitThread") ;
773 theAutomaton->JoinThread( pthread_self() ) ;
774 if ( pthread_cond_signal( &_JoinWait ) ) {
775 perror("ExitThread pthread_cond_signal ") ;
777 cdebug << "ExitThread : " << _Threads << " running threads "
778 << _SuspendedThreads << " suspended threads"
780 if ( pthread_mutex_unlock( &_MutexWait ) ) {
781 perror("pthread_mutex_unlock _ExitThread") ;
784 if ( _Threads == 0 && _SuspendedThreads == 0 ) {
787 theAutomaton->Executed() ;
791 void GraphExecutor::OutNode::JoinedWait() {
792 if ( pthread_mutex_lock( &_MutexWait ) ) {
793 perror("pthread_mutex_lock JoinedWait") ;
797 if ( pthread_cond_wait( &_JoinWait , &_MutexWait ) ) {
798 perror("JoinedWait pthread_cond_wait ") ;
801 if ( pthread_mutex_unlock( &_MutexWait ) ) {
802 perror("pthread_mutex_unlock JoinedWait") ;
807 void GraphExecutor::OutNode::SuspendThread() {
808 if ( pthread_mutex_lock( &_MutexWait ) ) {
809 perror("pthread_mutex_lock _SuspendThread") ;
812 _SuspendedThreads += 1 ;
813 cdebug << "SuspendThread : " << _Threads << " running threads "
814 << _SuspendedThreads << " suspended threads"
816 if ( pthread_mutex_unlock( &_MutexWait ) ) {
817 perror("pthread_mutex_unlock _SuspendThread") ;
820 if ( IsSuspended() ) {
821 PushEvent( NULL , GraphExecutor::SuspendEvent , SUPERV::SuspendedState ) ;
824 void GraphExecutor::OutNode::ResumeThread() {
825 if ( pthread_mutex_lock( &_MutexWait ) ) {
826 perror("pthread_mutex_lock _ResumeThread") ;
829 _SuspendedThreads -= 1 ;
830 cdebug << "ResumeThread : " << _Threads << " running threads "
831 << _SuspendedThreads << " suspended threads"
833 if ( pthread_mutex_unlock( &_MutexWait ) ) {
834 perror("pthread_mutex_unlock _ResumeThread") ;
839 long GraphExecutor::OutNode::Thread( const char * aNodeName ) {
841 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode() ;
843 RetVal = anInNode->ThreadNo() ;
848 SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent ) {
849 SUPERV::GraphEvent aGraphEvent ;
851 case GraphExecutor::UndefinedEvent : {
852 aGraphEvent = SUPERV::UndefinedEvent ;
855 case GraphExecutor::NewThreadEvent : {
856 aGraphEvent = SUPERV::NewThreadEvent ;
859 case GraphExecutor::SuspendEvent : {
860 aGraphEvent = SUPERV::SuspendEvent ;
863 case GraphExecutor::ResumeEvent : {
864 aGraphEvent = SUPERV::ResumeEvent ;
867 case GraphExecutor::KillEvent : {
868 aGraphEvent = SUPERV::KillEvent ;
871 case GraphExecutor::StopEvent : {
872 aGraphEvent = SUPERV::StopEvent ;
875 case GraphExecutor::ExecuteEvent : {
876 aGraphEvent = SUPERV::RunningEvent ;
879 case GraphExecutor::SuccessEvent : {
880 aGraphEvent = SUPERV::DoneEvent ;
883 case GraphExecutor::ErrorEvent : {
884 aGraphEvent = SUPERV::ErroredEvent ;
887 case GraphExecutor::ReStartEvent : {
888 aGraphEvent = SUPERV::ReRunEvent ;
891 case GraphExecutor::ReStartAndSuspendEvent : {
892 aGraphEvent = SUPERV::ReStartEvent ;
895 case GraphExecutor::NoDataReadyEvent : {
896 aGraphEvent = SUPERV::WaitingEvent ;
899 case GraphExecutor::SomeDataReadyEvent : {
900 aGraphEvent = SUPERV::WaitingEvent ;
903 case GraphExecutor::NotAllDataReadyEvent : {
904 aGraphEvent = SUPERV::WaitingEvent ;
907 case GraphExecutor::AllDataReadyEvent : {
908 aGraphEvent = SUPERV::ReadyEvent ;
911 case GraphExecutor::ReadyEvent : {
912 aGraphEvent = SUPERV::ReadyEvent ;
915 case GraphExecutor::SuspendedReadyEvent : {
916 aGraphEvent = SUPERV::SuspendEvent ;
919 case GraphExecutor::ResumedReadyEvent : {
920 aGraphEvent = SUPERV::ResumeEvent ;
923 case GraphExecutor::KilledReadyEvent : {
924 aGraphEvent = SUPERV::KillEvent ;
927 case GraphExecutor::StoppedReadyEvent : {
928 aGraphEvent = SUPERV::StopEvent ;
931 case GraphExecutor::ExecutingEvent : {
932 aGraphEvent = SUPERV::RunningEvent ;
935 case GraphExecutor::SuspendedExecutingEvent : {
936 aGraphEvent = SUPERV::SuspendEvent ;
939 case GraphExecutor::ResumedExecutingEvent : {
940 aGraphEvent = SUPERV::ResumeEvent ;
943 case GraphExecutor::KilledExecutingEvent : {
944 aGraphEvent = SUPERV::KillEvent ;
947 case GraphExecutor::StoppedExecutingEvent : {
948 aGraphEvent = SUPERV::StopEvent ;
951 case GraphExecutor::SuccessedExecutingEvent : {
952 aGraphEvent = SUPERV::DoneEvent ;
955 case GraphExecutor::ErroredExecutingEvent : {
956 aGraphEvent = SUPERV:: ErroredEvent;
959 case GraphExecutor::SuspendedSuccessedEvent : {
960 aGraphEvent = SUPERV::SuspendEvent ;
963 case GraphExecutor::SuspendedErroredEvent : {
964 aGraphEvent = SUPERV::SuspendEvent ;
967 case GraphExecutor::ResumedSuccessedEvent : {
968 aGraphEvent = SUPERV::ResumeEvent ;
971 case GraphExecutor::ResumedErroredEvent : {
972 aGraphEvent = SUPERV::ResumeEvent ;
975 case GraphExecutor::KilledEvent : {
976 aGraphEvent = SUPERV::KillEvent ;
979 case GraphExecutor::StoppedEvent : {
980 aGraphEvent = SUPERV::StopEvent ;
983 case GraphExecutor::ReStartedEvent : {
984 aGraphEvent = SUPERV::ReRunEvent ;
987 case GraphExecutor::ReStartedAndSuspendEvent : {
988 aGraphEvent = SUPERV::ReStartEvent ;
991 case GraphExecutor::EndExecuteEvent : {
992 aGraphEvent = SUPERV::DoneEvent ;
996 cdebug << " GraphExecutor::OutNode::AutomatonGraphEvent Error Undefined Event : "
998 aGraphEvent = SUPERV::UndefinedEvent ;
1001 return aGraphEvent ;
1004 SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(SUPERV::AutomatonState aState ) {
1005 SUPERV::GraphState aGraphState ;
1007 case SUPERV::UnKnownState : {
1008 aGraphState = SUPERV::UndefinedState ;
1011 case SUPERV::DataUndefState : {
1012 aGraphState = SUPERV::UndefinedState ;
1015 case SUPERV::DataWaitingState : {
1016 aGraphState = SUPERV::WaitingState ;
1019 case SUPERV::DataReadyState : {
1020 aGraphState = SUPERV::ReadyState ;
1023 case SUPERV::SuspendedReadyState : {
1024 aGraphState = SUPERV::SuspendReadyState ;
1027 case SUPERV::ResumedReadyState : {
1028 aGraphState = SUPERV::ReadyState ;
1031 case SUPERV::KilledReadyState : {
1032 aGraphState = SUPERV::KillState ;
1035 case SUPERV::StoppedReadyState : {
1036 aGraphState = SUPERV::StopState ;
1039 case SUPERV::ExecutingState : {
1040 aGraphState = SUPERV::RunningState ;
1043 case SUPERV::SuspendedExecutingState : {
1044 aGraphState = SUPERV::SuspendState ;
1047 case SUPERV::ResumedExecutingState : {
1048 aGraphState = SUPERV::RunningState ;
1051 case SUPERV::KilledExecutingState : {
1052 aGraphState = SUPERV::KillState ;
1055 case SUPERV::StoppedExecutingState : {
1056 aGraphState = SUPERV::StopState ;
1059 case SUPERV::SuccessedExecutingState : {
1060 aGraphState = SUPERV::DoneState ;
1063 case SUPERV::ErroredExecutingState : {
1064 aGraphState = SUPERV::ErrorState ;
1067 case SUPERV::SuspendedSuccessedState : {
1068 aGraphState = SUPERV::SuspendDoneState ;
1071 case SUPERV::SuspendedErroredState : {
1072 aGraphState = SUPERV::SuspendErroredState ;
1075 case SUPERV::ResumedSuccessedState : {
1076 aGraphState = SUPERV::DoneState ;
1079 case SUPERV::ResumedErroredState : {
1080 aGraphState = SUPERV::ErrorState ;
1083 case SUPERV::KilledSuccessedState : {
1084 aGraphState = SUPERV::KillState ;
1087 case SUPERV::KilledErroredState : {
1088 aGraphState = SUPERV::KillState ;
1091 case SUPERV::StoppedSuccessedState : {
1092 aGraphState = SUPERV::StopState ;
1095 case SUPERV::StoppedErroredState : {
1096 aGraphState = SUPERV::StopState ;
1099 case SUPERV::SuccessedState : {
1100 aGraphState = SUPERV::DoneState ;
1103 case SUPERV::ErroredState : {
1104 aGraphState = SUPERV::ErrorState ;
1107 case SUPERV::SuspendedState : {
1108 aGraphState = SUPERV::SuspendState ;
1111 case SUPERV::KilledState : {
1112 aGraphState = SUPERV::KillState ;
1115 case SUPERV::StoppedState : {
1116 aGraphState = SUPERV::StopState ;
1119 case SUPERV::ReRunnedState : {
1120 aGraphState = SUPERV::ReRunState ;
1123 case SUPERV::ReStartedState : {
1124 aGraphState = SUPERV::ReStartState ;
1128 cdebug << " GraphExecutor::OutNode::AutomatonGraphState Error Undefined State : "
1129 << aGraphState << endl ;
1130 aGraphState = SUPERV::UndefinedState ;
1133 return aGraphState ;
1136 int GraphExecutor::OutNode::GetListSize() {
1137 return _EventNodes.size();
1140 bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode ,
1141 GraphExecutor::NodeEvent anEvent ,
1142 SUPERV::AutomatonState aState ) {
1143 // cdebug_in << "PushEvent Threads " << Threads() << " SuspendedThreads "
1144 // << SuspendedThreads() << endl ;
1145 if ( pthread_mutex_lock( &_MutexWait ) ) {
1146 perror("PushEvent pthread_mutex_lock ") ;
1150 _EventNodes.push_back( aNode->Name() ) ;
1153 _EventNodes.push_back( Graph()->Name() ) ;
1155 _Events.push_back( anEvent ) ;
1156 _States.push_back( aState ) ;
1157 pthread_cond_broadcast( &_EventWait );
1159 // cdebug << aNode->ThreadNo() << " PushEvent " << aNode->Name() ;
1160 // cdebug << " " << aNode->Automaton()->EventName( anEvent )
1161 // << " " << aNode->Automaton()->StateName( aState )
1162 // << " ControleState "
1163 // << aNode->Automaton()->ControlStateName( aNode->ControlState() ) ;
1166 // cdebug << "PushEvent " << Graph()->Name() ;
1167 // cdebug << " " << theAutomaton->EventName( anEvent ) << " "
1168 // << theAutomaton->StateName( aState ) ;
1170 // cdebug_out << "PushEvent Threads " << Threads() << " SuspendedThreads "
1171 // << SuspendedThreads() << endl ;
1173 if ( _EventNodes.size() > 101 ) {
1174 while ( _EventNodes.size() > 31 ) {
1175 _EventNodes.pop_front() ;
1176 _Events.pop_front() ;
1177 _States.pop_front() ;
1181 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1182 perror("PushEvent pthread_mutex_unlock ") ;
1188 bool GraphExecutor::OutNode::StateWait( SUPERV::GraphState aState ) {
1192 bool GraphExecutor::OutNode::Event( char ** aNodeName ,
1193 SUPERV::GraphEvent & anEvent ,
1194 SUPERV::GraphState & aState ,
1197 int SuspendedThreadsNumber ;
1198 if ( _EventNodes.size() > 0 ) {
1199 cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
1201 if ( pthread_mutex_lock( &_MutexWait ) ) {
1202 perror("EventLoop pthread_mutex_lock ") ;
1205 _JustStarted = false ;
1206 ThreadsNumber = Threads() ;
1207 SuspendedThreadsNumber = SuspendedThreads() ;
1208 bool RetVal = ( ThreadsNumber - SuspendedThreadsNumber) != 0 ||
1209 _EventNodes.size() > 0 ;
1210 char * NodeName = "" ;
1211 GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
1212 SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
1213 anEvent = SUPERV::UndefinedEvent ;
1214 aState = SUPERV::UndefinedState ;
1215 if ( ( Done() || IsKilled() || IsStopped() ) && _EventNodes.size() == 0 ) {
1216 // cdebug << "EventLoop Done()/IsKilled()/IsStopped() && _EventNodes.size() == 0" << endl ;
1219 else if ( !WithWait && _EventNodes.size() == 0 ) {
1220 anEvent = SUPERV::NoEvent ;
1221 aState = SUPERV::NoState ;
1224 else if ( RetVal ) {
1225 while ( !IsSuspended() && _EventNodes.size() == 0 ) {
1226 // cdebug << "EventLoop pthread_cond_wait _EventWait" << endl ;
1227 pthread_cond_wait( &_EventWait , &_MutexWait );
1228 // cdebug << "EventLoop pthread_cond_waited _EventWait"
1229 // << " _EventNodes.size() " << _EventNodes.size() << endl ;
1231 if ( _EventNodes.size() ) {
1232 ThreadsNumber = Threads() ;
1233 NodeName = _EventNodes.front() ;
1234 _EventNodes.pop_front() ;
1235 theEvent = _Events.front() ;
1236 anEvent = AutomatonGraphEvent( theEvent ) ;
1237 _Events.pop_front() ;
1238 theState = _States.front() ;
1239 aState = AutomatonGraphState( theState ) ;
1240 _States.pop_front() ;
1243 *aNodeName = NodeName ;
1244 if ( IsSuspended() && _EventNodes.size() == 0 ) {
1247 if ( anEvent != SUPERV::NoEvent ) {
1248 // cdebug << pthread_self() << "EventLoop "
1249 // << NodeName << " " << theAutomaton->StateName( theState )
1250 // << " _EventNodes.size() " << _EventNodes.size()
1251 // << " Threads " << Threads() << " SuspendedThreads "
1252 // << SuspendedThreads() << " RetVal " << RetVal << endl ;
1254 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1255 perror("EventLoop pthread_mutex_lock ") ;
1258 if ( _EventNodes.size() > 0 ) {
1259 cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
1264 bool GraphExecutor::OutNode::EventW( char ** aNodeName ,
1265 SUPERV::GraphEvent & anEvent ,
1266 SUPERV::GraphState & aState ) {
1269 aState = SUPERV::UndefinedState ;
1271 aState != SUPERV::SuspendReadyState &&
1272 aState != SUPERV::RunningState &&
1273 aState != SUPERV::SuspendDoneState &&
1274 aState != SUPERV::SuspendErroredState ) {
1275 NodeName = Graph()->Name() ;
1276 while ( sts && !strcmp( NodeName , Graph()->Name() ) ) {
1277 sts = EventWait( aNodeName , anEvent , aState ) ;
1278 NodeName = *aNodeName ;
1284 bool GraphExecutor::OutNode::EventWait( char ** aNodeName ,
1285 SUPERV::GraphEvent & anEvent ,
1286 SUPERV::GraphState & aState ) {
1287 if ( pthread_mutex_lock( &_MutexWait ) ) {
1288 perror("EventW pthread_mutex_lock ") ;
1292 int SuspendedThreadsNumber ;
1293 ThreadsNumber = Threads() ;
1294 SuspendedThreadsNumber = SuspendedThreads() ;
1295 bool RetVal = ( ThreadsNumber - SuspendedThreadsNumber) != 0 ||
1296 _EventNodes.size() > 0 ;
1297 cdebug << "--> EventW RetVal " << RetVal << endl ;
1298 char * NodeName = "" ;
1299 GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
1300 SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
1301 anEvent = SUPERV::UndefinedEvent ;
1302 aState = SUPERV::UndefinedState ;
1303 if ( IsDone() && _EventNodes.size() == 0 ) {
1304 cdebug << "EventW IsDone() && _EventNodes.size() == 0" << endl ;
1307 else if ( RetVal ) {
1308 GraphExecutor::InNode * aNode = NULL ;
1309 while ( aNode == NULL && RetVal ) {
1310 NodeName = _EventNodes.front() ;
1311 theEvent = _Events.front() ;
1312 anEvent = AutomatonGraphEvent( theEvent ) ;
1313 theState = _States.front() ;
1314 aState = AutomatonGraphState( theState ) ;
1316 if ( _JustStarted ) {
1317 _JustStarted = false ;
1320 _EventNodes.pop_front() ;
1321 _Events.pop_front() ;
1322 _States.pop_front() ;
1325 aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode()) ;
1326 cdebug << "EventW Previous Node " << NodeName << " ThreadsNumber "
1328 << " _EventNodes.size() " << _EventNodes.size() << " "
1329 << theAutomaton->StateName( theState )
1330 << " Threads " << Threads() << " SuspendedThreads "
1331 << SuspendedThreads() << endl ;
1334 else if ( IsDone() && _EventNodes.size() == 0 ) {
1335 cdebug << "EventW IsDone() && _EventNodes.size() == 0" << endl ;
1339 cdebug << "EventW Not InNode " << NodeName
1340 << " _EventNodes.size() " << _EventNodes.size() << endl ;
1341 while ( _EventNodes.size() == 0 ) {
1342 pthread_cond_wait( &_EventWait , &_MutexWait );
1344 cdebug << "EventW pthread_cond_waited Not InNode " << NodeName
1345 << " _EventNodes.size() " << _EventNodes.size() << endl ;
1350 if ( aState == SUPERV::SuspendState ||
1351 aState == SUPERV::SuspendReadyState ||
1352 aState == SUPERV::SuspendDoneState ||
1353 aState == SUPERV::SuspendErroredState ) {
1354 aNode->ControlState( SUPERV::ToSuspendState ) ;
1355 if ( aNode->IsSuspended() ) {
1356 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1357 perror("EventW pthread_mutex_lock ") ;
1360 cdebug << "EventW " << aNode->Name() << " ResumeAction" << endl ;
1361 aNode->ResumeAction( GraphExecutor::ToResumeEvent ) ;
1362 cdebug << "EventW " << aNode->Name() << " ResumedAction" << endl ;
1363 if ( pthread_mutex_lock( &_MutexWait ) ) {
1364 perror("EventW pthread_mutex_lock ") ;
1369 cdebug << "EventW inconsistent SuspendState" << endl ;
1374 if ( aNode->IsDone() ) {
1378 cdebug << "EventW NOT SuspendedState _EventNodes.size() "
1379 << _EventNodes.size() << endl ;
1384 cdebug << "EventW " << aNode->Name() << " pthread_cond_wait" << endl ;
1385 while ( _EventNodes.size() == 0 ) {
1386 pthread_cond_wait( &_EventWait , &_MutexWait );
1388 ThreadsNumber = Threads() ;
1389 NodeName = _EventNodes.front() ;
1390 theEvent = _Events.front() ;
1391 anEvent = AutomatonGraphEvent( theEvent ) ;
1392 theState = _States.front() ;
1393 aState = AutomatonGraphState( theState ) ;
1397 *aNodeName = NodeName ;
1398 cdebug << "<-- EventW RetVal " << RetVal << " " << NodeName
1399 << " Threads " << Threads() << " SuspendedThreads "
1400 << SuspendedThreads()
1401 << " _EventNodes.size() " << _EventNodes.size()
1402 << " " << theAutomaton->EventName( theEvent ) << " "
1403 << theAutomaton->StateName( theState ) << endl ;
1404 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1405 perror("EventW pthread_mutex_lock ") ;
1410 long GraphExecutor::OutNode::EventQSize() {
1411 return _EventNodes.size() ;
1414 void GraphExecutor::OutNode::EventList() {
1415 if ( pthread_mutex_lock( &_MutexWait ) ) {
1416 perror("EventList pthread_mutex_lock ") ;
1419 list< char * >::iterator itEventNodes = _EventNodes.begin() ;
1420 list< GraphExecutor::NodeEvent >::iterator itEvents = _Events.begin() ;
1421 list< SUPERV::AutomatonState >::iterator itStates = _States.begin() ;
1422 while ( itEventNodes != _EventNodes.end() ) {
1423 cdebug << pthread_self() << "EVENTSTACK "
1424 << *itEventNodes << " " << *itEvents << " "
1425 << theAutomaton->StateName( *itStates )
1426 << " Threads " << Threads() << " SuspendedThreads " << SuspendedThreads() << endl ;
1431 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1432 perror("EventList pthread_mutex_lock ") ;
1437 void GraphExecutor::OutNode::State(SUPERV::AutomatonState aState ) {
1438 // cdebug << "GraphExecutor::OutNode::State " << Graph()->Name() << " "
1439 // << theAutomaton->StateName( AutomatonGraphState( _State ) ) << " ---> "
1440 // << theAutomaton->StateName( AutomatonGraphState( aState ) ) << endl ;
1444 SUPERV::GraphState GraphExecutor::OutNode::State() {
1445 // cdebug_in << "GraphExecutor::OutNode::State" << endl;
1446 // cdebug_out << "GraphExecutor::OutNode::State" << endl ;
1447 // cdebug << "GraphExecutor::OutNode::State GraphState "
1448 // << theAutomaton->StateName( AutomatonGraphState( _State ) ) << endl ;
1449 return AutomatonGraphState( _State ) ;
1452 SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ) {
1453 // cdebug_in << "GraphExecutor::OutNode::State " << NodeName << endl;
1454 SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
1455 const GraphBase::ComputingNode * aCNode = Graph()->GetGraphNode( NodeName ) ;
1457 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *)aCNode->GetInNode() ;
1459 aret = anInNode->State() ;
1460 // cdebug << "GraphExecutor::OutNode::State( " << NodeName << " ) "
1461 // << theAutomaton->StateName( AutomatonGraphState( aret ) ) << endl ;
1464 // cdebug_out << "GraphExecutor::OutNode::State" << endl ;
1465 return AutomatonGraphState( aret ) ;
1468 SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ,
1469 const char * ServiceParameterName ) {
1470 // cdebug_in << "GraphExecutor::OutNode::State " << NodeName << " "
1471 // << ServiceParameterName<< endl;
1472 SUPERV::GraphState aret = Graph()->PortState( NodeName , ServiceParameterName ) ;
1473 // cdebug_out << "GraphExecutor::OutNode::State" << endl ;
1477 SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState() {
1478 // cdebug_in << "GraphExecutor::OutNode::AutomatonState" << endl;
1479 // cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
1483 SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState( const char * NodeName ) {
1484 // cdebug_in << "GraphExecutor::OutNode::AutomatonState " << NodeName << endl;
1485 SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
1486 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1488 aret = anInNode->State() ;
1489 // cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
1493 SUPERV::ControlState GraphExecutor::OutNode::ControlState() {
1494 // cdebug_in << "GraphExecutor::OutNode::ControlState" << endl;
1495 // cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ;
1496 return _ControlState ;
1499 SUPERV::ControlState GraphExecutor::OutNode::ControlState( const char * NodeName ) {
1500 // cdebug_in << "GraphExecutor::OutNode::ControlState " << NodeName << endl;
1501 SUPERV::ControlState aret = SUPERV::VoidState ;
1502 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1504 aret = anInNode->ControlState() ;
1505 // cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ;
1509 void GraphExecutor::OutNode::ControlClear() {
1510 // cdebug_in << "GraphExecutor::OutNode::ControlClear" << endl;
1511 // cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ;
1512 _ControlState = SUPERV::VoidState;
1515 void GraphExecutor::OutNode::ControlClear( const char * NodeName ) {
1516 // cdebug_in << "GraphExecutor::OutNode::ControlClear " << NodeName << endl;
1517 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1519 anInNode->ControlClear() ;
1520 // cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ;
1523 bool GraphExecutor::OutNode::IsWaiting() {
1524 // cdebug_in << "GraphExecutor::OutNode::IsWaiting" << endl;
1525 // cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
1529 bool GraphExecutor::OutNode::IsReady() {
1530 // cdebug_in << "GraphExecutor::OutNode::IsReady" << endl;
1531 // cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
1535 bool GraphExecutor::OutNode::IsRunning() {
1536 // cdebug_in << "GraphExecutor::OutNode::IsRunning" << endl;
1537 // cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
1541 bool GraphExecutor::OutNode::IsDone() {
1542 // cdebug_in << "GraphExecutor::OutNode::IsDone" << endl;
1543 // cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
1544 return ( Done() || IsKilled() || IsStopped() ) ;
1547 bool GraphExecutor::OutNode::IsSuspended() {
1548 // cdebug_in << "GraphExecutor::OutNode::IsSuspended" << endl;
1550 if ( _SuspendedThreads == _Threads ) {
1553 // cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
1557 bool GraphExecutor::OutNode::IsKilled() {
1558 // cdebug_in << "GraphExecutor::OutNode::IsKilled" << endl;
1560 if ( AutomatonGraphState( _State ) == SUPERV::KillState ) {
1563 // cdebug_out << "GraphExecutor::OutNode::IsKilled" << endl ;
1567 bool GraphExecutor::OutNode::IsStopped() {
1568 // cdebug_in << "GraphExecutor::OutNode::IsStopped" << endl;
1570 if ( AutomatonGraphState( _State ) == SUPERV::StopState ) {
1573 // cdebug_out << "GraphExecutor::OutNode::IsStopped" << endl ;
1577 bool GraphExecutor::OutNode::IsWaiting( const char * NodeName ) {
1579 // cdebug_in << "GraphExecutor::OutNode::IsWaiting " << NodeName << endl;
1580 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1582 aret = anInNode->IsWaiting() ;
1584 // cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
1588 bool GraphExecutor::OutNode::IsReady( const char * NodeName ) {
1590 // cdebug_in << "GraphExecutor::OutNode::IsReady " << NodeName << endl;
1591 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1593 aret = anInNode->IsReady() ;
1595 // cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
1599 bool GraphExecutor::OutNode::IsRunning( const char * NodeName ) {
1601 // cdebug_in << "GraphExecutor::OutNode::IsRunning " << NodeName << endl;
1602 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1604 aret = anInNode->IsRunning() ;
1606 // cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
1610 bool GraphExecutor::OutNode::IsDone( const char * NodeName ) {
1612 // cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << endl;
1613 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1615 aret = anInNode->IsDone() ;
1617 // cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
1621 bool GraphExecutor::OutNode::IsSuspended( const char * NodeName ) {
1623 // cdebug_in << "GraphExecutor::OutNode::IsSuspended " << NodeName << endl;
1624 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1626 aret = anInNode->IsSuspended() ;
1628 // cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
1632 bool GraphExecutor::OutNode::IsDone( const char * NodeName ,
1633 const char * ServiceParameterName ) {
1634 // cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << " "
1635 // << ServiceParameterName<< endl;
1636 bool aret = Graph()->PortDone( NodeName , ServiceParameterName ) ;
1637 // cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
1641 bool GraphExecutor::OutNode::ContainerKill() {
1642 bool RetVal = true ;
1643 cdebug_in << "GraphExecutor::OutNode::ContainerKill" << endl;
1644 _ControlState = SUPERV::ToSuspendState ;
1646 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1647 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1648 bool sts = aNode->ContainerKill() ;
1649 if ( sts && aNode->IsKilled() ) {
1650 cdebug << aNode->Name() << " killed" << endl ;
1652 else if ( aNode->IsWaiting() || aNode->IsDone() ) {
1653 cdebug << aNode->Name() << " not killed : "
1654 << theAutomaton->StateName( aNode->State() ) << endl ;
1657 cdebug << aNode->Name() << " cannot be killed : "
1658 << theAutomaton->StateName( aNode->State() ) << endl ;
1662 if ( !RetVal || Threads() != 0 ) {
1663 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1664 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1665 if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
1666 aNode->KilledAction() ;
1671 State( SUPERV::KilledState ) ;
1672 cdebug_out << "GraphExecutor::OutNode::ContainerKill" << endl ;
1676 bool GraphExecutor::OutNode::Suspend() {
1678 cdebug_in << "GraphExecutor::OutNode::Suspend" << endl;
1679 // _ControlState = SUPERV::ToSuspendState ;
1681 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1682 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1683 bool sts = aNode->Suspend() ;
1684 if ( sts && aNode->IsSuspended() ) {
1686 cdebug << aNode->Name() << " Suspended" << endl ;
1688 else if ( aNode->IsWaiting() || aNode->IsDone() ) {
1689 cdebug << aNode->Name() << " not Suspended : "
1690 << theAutomaton->StateName( aNode->State() ) << endl ;
1694 cdebug << aNode->Name() << " cannot be Suspended : "
1695 << theAutomaton->StateName( aNode->State() ) << endl ;
1699 State( SUPERV::SuspendedState ) ;
1700 MESSAGE("================================================================================") ;
1701 MESSAGE( Graph()->Name() << " IS SUSPENDED" ) ;
1702 MESSAGE("================================================================================") ;
1705 MESSAGE("================================================================================") ;
1706 MESSAGE( Graph()->Name() << " IS NOT SUSPENDED" ) ;
1707 MESSAGE("================================================================================") ;
1709 cdebug_out << "GraphExecutor::OutNode::Suspend" << theAutomaton->StateName( State() ) << endl ;
1713 bool GraphExecutor::OutNode::Resume() {
1715 cdebug_in << "GraphExecutor::OutNode::Resume" << endl;
1716 if ( IsSuspended() ) {
1717 State( SUPERV::ExecutingState ) ;
1719 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1720 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1721 aNode->ControlState( SUPERV::VoidState ) ;
1722 if ( aNode->IsSuspended() ) {
1723 cdebug << aNode->Name() << "->Resume " << theAutomaton->StateName( aNode->State() )
1725 if ( aNode->Resume() ) {
1726 cdebug << aNode->Name() << " Resumed " << theAutomaton->StateName( aNode->State() )
1731 cdebug << aNode->Name() << " Resume failed"
1732 << theAutomaton->StateName( aNode->State() ) << endl ;
1736 cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() )
1742 cdebug << Graph()->Name() << " not suspended " << theAutomaton->StateName( State() ) << endl ;
1745 MESSAGE("================================================================================") ;
1746 MESSAGE( Graph()->Name() << " IS RESUMED" ) ;
1747 MESSAGE("================================================================================") ;
1750 MESSAGE("================================================================================") ;
1751 MESSAGE( Graph()->Name() << " IS NOT RESUMED" ) ;
1752 MESSAGE("================================================================================") ;
1754 cdebug_out << "GraphExecutor::OutNode::Resume" << theAutomaton->StateName( State() ) << " " << RetVal << endl ;
1758 bool GraphExecutor::OutNode::Kill() {
1759 bool RetVal = true ;
1760 cdebug_in << "GraphExecutor::OutNode::Kill" << endl;
1761 _ControlState = SUPERV::ToSuspendState ;
1763 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1764 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1765 bool sts = aNode->Kill() ;
1766 if ( sts && aNode->IsKilled() ) {
1767 cdebug << aNode->Name() << " killed" << endl ;
1769 else if ( aNode->IsWaiting() || aNode->IsDone() ) {
1770 cdebug << aNode->Name() << " not killed : "
1771 << theAutomaton->StateName( aNode->State() ) << endl ;
1774 cdebug << aNode->Name() << " cannot be killed : "
1775 << theAutomaton->StateName( aNode->State() ) << endl ;
1779 if ( !RetVal || Threads() != 0 ) {
1780 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1781 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
1782 if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
1783 cdebug << aNode->Name() << " not killed : "
1784 << theAutomaton->StateName( aNode->State() ) << " " << aNode->Name() << "->"
1785 << "KilledAction()" << endl ;
1786 aNode->KilledAction() ;
1791 State( SUPERV::KilledState ) ;
1793 MESSAGE("================================================================================") ;
1794 MESSAGE( Graph()->Name() << " IS KILLED" ) ;
1795 MESSAGE("================================================================================") ;
1798 MESSAGE("================================================================================") ;
1799 MESSAGE( Graph()->Name() << " IS NOT KILLED" ) ;
1800 MESSAGE("================================================================================") ;
1802 cdebug_out << "GraphExecutor::OutNode::Kill" << endl ;
1806 bool GraphExecutor::OutNode::Stop() {
1807 bool RetVal = false ;
1808 cdebug_in << "GraphExecutor::OutNode::Stop" << endl;
1810 cdebug_out << "GraphExecutor::OutNode::Stop" << endl ;
1812 MESSAGE("================================================================================") ;
1813 MESSAGE( Graph()->Name() << " IS STOPPED" ) ;
1814 MESSAGE("================================================================================") ;
1818 bool GraphExecutor::OutNode::ReRun() {
1819 bool RetVal = false ;
1820 cdebug_in << "GraphExecutor::OutNode::ReRun" << endl;
1821 if ( IsSuspended() ) {
1823 cdebug_out << "GraphExecutor::OutNode::ReRun" << endl ;
1826 bool GraphExecutor::OutNode::ReStart() {
1827 bool RetVal = false ;
1828 cdebug_in << "GraphExecutor::OutNode::ReStart" << endl;
1829 if ( IsSuspended() ) {
1831 cdebug_out << "GraphExecutor::OutNode::ReStart" << endl ;
1835 bool GraphExecutor::OutNode::ReadyWait() {
1836 cdebug_in << "GraphExecutor::OutNode::ReadyWait" << endl;
1838 if ( pthread_mutex_lock( &_MutexWait ) ) {
1839 perror("pthread_mutex_lock _ReadyWait") ;
1845 pthread_cond_wait( &_EventWait , &_MutexWait );
1848 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1849 perror("pthread_mutex_lock _ReadyWait") ;
1852 cdebug_out << "GraphExecutor::OutNode::ReadyWait" << endl ;
1856 bool GraphExecutor::OutNode::RunningWait() {
1857 cdebug_in << "GraphExecutor::OutNode::RunningWait" << endl;
1859 if ( pthread_mutex_lock( &_MutexWait ) ) {
1860 perror("pthread_mutex_lock _RunningWait") ;
1863 aret = IsRunning() ;
1865 cdebug << "RunningWait pthread_cond_wait _EventWait" << endl;
1866 pthread_cond_wait( &_EventWait , &_MutexWait );
1867 aret = IsRunning() ;
1868 cdebug << "RunningWait pthread_cond_waited _EventWait " << aret << endl;
1870 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1871 perror("pthread_mutex_lock _RunningWait") ;
1874 cdebug_out << "GraphExecutor::OutNode::RunningWait " << aret << endl ;
1878 bool GraphExecutor::OutNode::DoneWait() {
1879 cdebug_in << "GraphExecutor::OutNode::DoneWait" << endl;
1881 if ( pthread_mutex_lock( &_MutexWait ) ) {
1882 perror("pthread_mutex_lock _DoneWait") ;
1886 while ( !aret && !IsSuspended() && IsRunning() ) {
1887 cdebug << "DoneWait pthread_cond_wait _EventWait" << endl;
1888 pthread_cond_wait( &_EventWait , &_MutexWait );
1890 cdebug << "DoneWait pthread_cond_waited _EventWait " << aret << endl;
1892 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1893 perror("pthread_mutex_lock _DoneWait") ;
1896 cdebug_out << "GraphExecutor::OutNode::DoneWait " << aret << endl ;
1900 bool GraphExecutor::OutNode::SuspendedWait() {
1901 cdebug_in << "GraphExecutor::OutNode::SuspendedWait" << endl;
1903 if ( pthread_mutex_lock( &_MutexWait ) ) {
1904 perror("pthread_mutex_lock _SuspendedWait") ;
1907 aret = IsSuspended() ;
1908 while ( !aret && !IsDone() ) {
1909 pthread_cond_wait( &_EventWait , &_MutexWait );
1910 aret = IsSuspended() ;
1912 if ( pthread_mutex_unlock( &_MutexWait ) ) {
1913 perror("pthread_mutex_lock _SuspendedWait") ;
1916 cdebug_out << "GraphExecutor::OutNode::SuspendedWait" << endl ;
1920 bool GraphExecutor::OutNode::ReadyWait( const char * NodeName ) {
1922 cdebug_in << "GraphExecutor::OutNode::ReadyWait " << NodeName << endl;
1923 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1925 aret = anInNode->ReadyWait() ;
1927 cdebug_out << "GraphExecutor::OutNode::ReadyWait" << endl ;
1931 bool GraphExecutor::OutNode::RunningWait( const char * NodeName ) {
1933 cdebug_in << "GraphExecutor::OutNode::RunningWait " << NodeName << endl;
1934 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1936 aret = anInNode->RunningWait() ;
1938 cdebug_out << "GraphExecutor::OutNode::RunningWait" << endl ;
1942 bool GraphExecutor::OutNode::DoneWait( const char * NodeName ) {
1944 cdebug_in << "GraphExecutor::OutNode::DoneWait " << NodeName << endl;
1945 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1947 aret = anInNode->DoneWait() ;
1949 cdebug_out << "GraphExecutor::OutNode::DoneWait" << endl ;
1953 bool GraphExecutor::OutNode::SuspendedWait( const char * NodeName ) {
1955 cdebug_in << "GraphExecutor::OutNode::SuspendedWait " << NodeName << endl;
1956 GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
1958 aret = anInNode->SuspendedWait() ;
1960 cdebug_out << "GraphExecutor::OutNode::SuspendedWait" << endl ;
1964 long GraphExecutor::OutNode::LastLevelDone() {
1967 for ( i = 0 ; i <= Graph()->LevelMax() ; i++ ) {
1968 for ( j = 0 ; j <= Graph()->NodesNumber( i ) ; j++ ) {
1969 GraphBase::ComputingNode * aNode = Graph()->SortedNodes( i , j ) ;
1970 if ( !IsDone( aNode->Name() ) ) {
1974 if ( j != Graph()->NodesNumber( i ) + 1 )
1982 const CORBA::Any *GraphExecutor::OutNode::GetInData( const char * NodeName ,
1983 const char * ServiceParameterName ) {
1984 // cdebug_in << "GraphExecutor::OutNode::GetInData " << NodeName << " "
1985 // << ServiceParameterName << endl ;
1986 const CORBA::Any * retdata = Graph()->PortInData( NodeName , ServiceParameterName ) ;
1987 // cdebug_out << "GraphExecutor::OutNode::GetInData" << endl ;
1991 const CORBA::Any *GraphExecutor::OutNode::GetOutData( const char * NodeName ,
1992 const char * ServiceParameterName ) {
1993 // cdebug_in << "GraphExecutor::OutNode::GetOutData " << NodeName << " "
1994 // << ServiceParameterName << endl ;
1995 const CORBA::Any * retdata = Graph()->PortOutData( NodeName , ServiceParameterName ) ;
1996 // cdebug_out << "GraphExecutor::OutNode::GetOutData" << endl ;
2000 const long GraphExecutor::OutNode::CpuUsed() {
2001 return Graph()->CpuUsed() ;
2004 const long GraphExecutor::OutNode::CpuUsed( const char * aNodeName ) {
2005 GraphBase::ComputingNode * aNode = Graph()->GetChangeGraphNode( aNodeName ) ;
2007 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aNode->GetInNode() ;
2009 return anInNode->CpuUsed() ;