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_InNodeThreads.cxx
25 // Author : Jean Rahuel, CEA
40 #include <SALOMEconfig.h>
41 #include CORBA_CLIENT_HEADER(SALOME_Component)
42 //#include "SALOME_NamingService.hxx"
43 #include "SALOME_LifeCycleCORBA.hxx"
45 //#include "DataFlowExecutor_InNode.hxx"
47 #include "DataFlowExecutor_OutNode.hxx"
49 #include "Graph_Impl.hxx"
51 //static char *containerName = "FactoryServer" ;
53 int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {
55 _CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
56 cdebug << pthread_self() << "/" << ThreadNo() << " -->SendEvent Node " << Name()
58 << Automaton()->ControlStateName( ControlState() )
59 << " Event : " << Automaton()->EventName( anEvent )
60 << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack << endl;
63 _NextState = Automaton()->NextState( _OldState , anEvent ) ;
64 if ( _NextState == _OldState ) {
65 cdebug << pthread_self() << "/" << ThreadNo()
66 << " GraphExecutor::InNodeThreads::SendEvent SameStates "
67 << _OldState << endl ;
68 _NextAction = GraphExecutor::VoidAction ;
71 _NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
74 // State( _NextState ) ;
75 // if ( _OldState == SUPERV::SuccessedExecutingState ||
76 // _OldState == SUPERV::ErroredExecutingState ) {
80 cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
81 << Name() << endl << " ControlState : "
82 << Automaton()->ControlStateName( ControlState() ) << endl
83 << " OldState : " << Automaton()->StateName( _OldState ) << endl
84 << " Event : " << Automaton()->EventName( anEvent ) << endl
85 << " NextState : " << Automaton()->StateName( _NextState ) << endl
86 << " Action : " << Automaton()->ActionName( _NextAction ) << endl
87 << " CreateNewThread " << CreateNewThread() << endl
88 << " _RewindStack " << _RewindStack << endl ;
91 cout << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
92 << endl << " ControlState : "
93 << Automaton()->ControlStateName( ControlState() ) << endl
94 << " OldState : " << Automaton()->StateName( _OldState ) << endl
95 << " Event : " << Automaton()->EventName( anEvent ) << endl
96 << " NextState : " << Automaton()->StateName( _NextState ) << endl
97 << " Action : " << Automaton()->ActionName( _NextAction ) << endl
98 << " CreateNewThread " << CreateNewThread() << endl ;
101 int sts = executeAction() ;
103 cdebug << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
104 << " Event : " << Automaton()->EventName( anEvent )
105 << " State : " << Automaton()->StateName( State() )
112 // ReadyAction - RunningAction - DoneAction - SuspendedAction :
113 // for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
114 void GraphExecutor::InNode::ReadyAction() {
115 if ( pthread_mutex_lock( &_MutexWait ) ) {
116 perror("Ready pthread_mutex_lock ") ;
119 cdebug << pthread_self() << "/" << ThreadNo()
120 << "ReadyAction pthread_cond_broadcast _ReadyWait "
122 if ( pthread_cond_broadcast( &_ReadyWait ) ) {
123 perror("Ready pthread_cond_broadcast ") ;
125 if ( pthread_mutex_unlock( &_MutexWait ) ) {
126 perror("Ready pthread_mutex_unlock ") ;
131 void GraphExecutor::InNode::RunningAction() {
132 if ( pthread_mutex_lock( &_MutexWait ) ) {
133 perror("Running pthread_mutex_lock ") ;
136 cdebug << pthread_self() << "/" << ThreadNo()
137 << "RunningAction pthread_cond_broadcast _RunningWait "
139 if ( pthread_cond_broadcast( &_RunningWait ) ) {
140 perror("Running pthread_cond_broadcast ") ;
142 if ( pthread_mutex_unlock( &_MutexWait ) ) {
143 perror("Running pthread_mutex_unlock ") ;
148 void GraphExecutor::InNode::DoneAction() {
149 if ( pthread_mutex_lock( &_MutexWait ) ) {
150 perror("Done pthread_mutex_lock ") ;
153 cdebug << pthread_self() << "/" << ThreadNo()
154 << "DoneAction pthread_cond_broadcast _DoneWait "
156 if ( pthread_cond_broadcast( &_DoneWait ) ) {
157 perror("Done pthread_cond_broadcast ") ;
159 if ( pthread_mutex_unlock( &_MutexWait ) ) {
160 perror("Done pthread_mutex_unlock ") ;
165 void GraphExecutor::InNode::SuspendedAction() {
166 if ( pthread_mutex_lock( &_MutexWait ) ) {
167 perror("Suspended pthread_mutex_lock ") ;
170 cdebug << pthread_self() << "/" << ThreadNo()
171 << "SuspendedAction pthread_cond_broadcast _SuspendedWait "
173 if ( pthread_cond_broadcast( &_SuspendedWait ) ) {
174 perror("Suspended pthread_cond_broadcast ") ;
176 if ( pthread_mutex_unlock( &_MutexWait ) ) {
177 perror("Suspended pthread_mutex_unlock ") ;
182 // SuspendAction <--> { ResumeAction - ReStartAction }
183 GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() {
185 if ( pthread_mutex_lock( &_MutexWait ) ) {
186 perror("Suspend pthread_mutex_lock ") ;
189 if ( !_SuspendSync ) {
190 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
191 << " SuspendAction pthread_cond_wait _SuspendWait "
192 << Automaton()->StateName( State() ) << endl ;
193 _SuspendSync = true ;
194 _OutNode->SuspendThread() ;
195 if ( pthread_cond_wait( &_SuspendWait , &_MutexWait ) ) {
196 perror("SuspendAction pthread_cond_wait ") ;
198 _OutNode->ResumeThread() ;
199 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
200 << " SuspendAction pthread_cond_waited"
201 << Automaton()->StateName( State() ) << endl ;
204 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
205 << " NO SuspendAction pthread_cond_wait"
206 << Automaton()->StateName( State() ) << endl ;
208 // SendEvent( _aResumeEvent ) ; ===> Mutex with myself !
209 _SuspendSync = false ;
210 if ( ControlState() == SUPERV::ToSuspendStartState ||
211 ControlState() == SUPERV::ToSuspendState ) {
212 ControlState( SUPERV::VoidState ) ;
214 if ( pthread_mutex_unlock( &_MutexWait ) ) {
215 perror("SuspendAction pthread_mutex_unlock ") ;
219 SendEvent( _aResumeEvent ) ;
220 // if ( ControlState() == SUPERV::ToSuspendStartState ) {
221 // ControlState( SUPERV::VoidState ) ;
224 if ( pthread_mutex_lock( &_MutexWait ) ) {
225 perror("SuspendAction pthread_mutex_lock ") ;
229 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
230 << " SuspendAction pthread_cond_signal _ResumeWait" << endl ;
231 if ( pthread_cond_signal( &_ResumeWait ) ) {
232 perror("SuspendAction pthread_cond_signal _ResumeWait ") ;
234 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
235 << " SuspendAction pthread_cond_signaled _ResumeWait " << endl ;
238 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
239 << " NO SuspendAction pthread_cond_signal _ResumeWait" << endl ;
242 if ( pthread_mutex_unlock( &_MutexWait ) ) {
243 perror("SuspendAction pthread_mutex_unlock ") ;
246 if ( _aReStartNode ) {
247 cdebug << Name() << " " << Automaton()->StateName( State() )
248 << "aReStartNode : " << _aReStartNode->Name() << " "
249 << Automaton()->StateName( _aReStartNode->State() ) << endl ;
250 _aReStartNode->SendEvent( _aResumeEvent ) ;
253 cdebug << "NO aReStartNode"
254 << Automaton()->StateName( State() ) << endl ;
256 return _aReStartNode ;
259 bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent ) {
261 if ( pthread_mutex_lock( &_MutexWait ) ) {
262 perror("ResumeAction pthread_mutex_lock ") ;
265 _aResumeEvent = aResumeEvent ;
266 if ( _SuspendSync ) {
267 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
268 << " ResumeAction pthread_cond_signal" << endl ;
269 if ( pthread_cond_signal( &_SuspendWait ) ) {
270 perror("ResumeAction pthread_cond_signal ") ;
272 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
273 << " ResumeAction pthread_cond_signaled _SuspendWait " << endl ;
277 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
278 << " NO ResumeAction pthread_cond_signal" << endl ;
279 if ( pthread_self() == ThreadNo() ) {
280 RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
283 _SuspendSync = true ;
284 RetVal = true ; // Il faut tout de meme attendre ci-apres ...
287 if ( pthread_mutex_unlock( &_MutexWait ) ) {
288 perror("ResumeAction pthread_mutex_unlock ") ;
293 if ( pthread_mutex_lock( &_MutexWait ) ) {
294 perror("ResumeAction pthread_mutex_lock ") ;
297 if ( !_ResumeSync ) {
298 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
299 << Name() << " ResumeAction pthread_cond_wait _ResumeWait "
300 << Automaton()->StateName( State() ) << endl ;
302 if ( pthread_cond_wait( &_ResumeWait , &_MutexWait ) ) {
303 perror("ResumeAction pthread_cond_wait ") ;
305 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
306 << Name() << " ResumeAction pthread_cond_waited _ResumeWait"
307 << Automaton()->StateName( State() ) << endl ;
311 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
312 << Name() << " NO ResumeAction pthread_cond_wait _ResumeWait"
313 << Automaton()->StateName( State() ) << endl ;
316 _ResumeSync = false ;
317 if ( pthread_mutex_unlock( &_MutexWait ) ) {
318 perror("ResumeAction pthread_mutex_unlock ") ;
322 cdebug << pthread_self() << "/" << ThreadNo()
323 << "GraphExecutor::InNodeThreads::ResumeAction RetVal " << RetVal << endl ;
327 bool GraphExecutor::InNode::ReStartAction( GraphExecutor::InNode * aReStartNode ,
328 GraphExecutor::NodeEvent anEvent ) {
329 GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
330 _aReStartNode = aReStartNode ;
331 _aReStartEvent = anEvent ;
332 cdebug << pthread_self() << " GraphExecutor::InNodeThreads::ReStartAction from "
333 << Name() << " " << Automaton()->StateName( State() ) << " to "
334 << aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
335 << Automaton()->StateName( aReStartNode->State() ) ;
336 if ( oldReStartNode ) {
337 cdebug << " oldReStartNode " << oldReStartNode->Name() << endl ;
342 return ResumeAction( GraphExecutor::ToReStartEvent ) ;
345 void GraphExecutor::InNode::KilledAction() {
346 if ( pthread_mutex_lock( &_MutexWait ) ) {
347 perror("Killed pthread_mutex_lock ") ;
351 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_wait"
354 if ( pthread_cond_wait( &_KillWait , &_MutexWait ) ) {
355 perror("Killed pthread_cond_wait ") ;
357 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_waited"
361 cdebug << "pthread_cond " << Name() << " NO Killed pthread_cond_wait"
365 if ( pthread_mutex_unlock( &_MutexWait ) ) {
366 perror("Killed pthread_mutex_unlock ") ;
371 void GraphExecutor::InNode::KillAction() {
372 if ( pthread_mutex_lock( &_MutexWait ) ) {
373 perror("Kill pthread_mutex_lock ") ;
377 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signal"
379 // if ( pthread_cond_broadcast( &_KillWait ) ) {
380 if ( pthread_cond_signal( &_KillWait ) ) {
381 perror("Kill pthread_cond_broadcast ") ;
383 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signaled"
387 cdebug << "pthread_cond " << Name() << " NO Kill pthread_cond_signal"
391 if ( pthread_mutex_unlock( &_MutexWait ) ) {
392 perror("Kill pthread_mutex_unlock ") ;
397 void GraphExecutor::InNode::StoppedAction() {
398 if ( pthread_mutex_lock( &_MutexWait ) ) {
399 perror("Stopped pthread_mutex_lock ") ;
402 if ( pthread_cond_wait( &_StopWait , &_MutexWait ) ) {
403 perror("Stopped pthread_cond_wait ") ;
405 if ( pthread_mutex_unlock( &_MutexWait ) ) {
406 perror("Stopped pthread_mutex_unlock ") ;
411 void GraphExecutor::InNode::StopAction() {
412 if ( pthread_mutex_lock( &_MutexWait ) ) {
413 perror("Stop pthread_mutex_lock ") ;
416 if ( pthread_cond_broadcast( &_StopWait ) ) {
417 perror("Stop pthread_cond_broadcast ") ;
419 if ( pthread_mutex_unlock( &_MutexWait ) ) {
420 perror("Stop pthread_mutex_unlock ") ;
425 void GraphExecutor::InNode::ThreadStartedAction() {
426 if ( pthread_mutex_lock( &_MutexWait ) ) {
427 perror("ThreadStarted pthread_mutex_lock ") ;
430 if ( !_ThreadStartedSync ) {
431 cdebug << "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait"
433 _ThreadStartedSync = true ;
434 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
435 perror("ThreadStarted pthread_cond_wait ") ;
437 cdebug << "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited"
441 cdebug << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait"
444 _ThreadStartedSync = false ;
445 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
446 perror("ThreadStart pthread_cond_signal ") ;
449 cdebug << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled"
452 if ( pthread_mutex_unlock( &_MutexWait ) ) {
453 perror("ThreadStarted pthread_mutex_unlock ") ;
458 void GraphExecutor::InNode::ThreadStartAction() {
459 if ( pthread_mutex_lock( &_MutexWait ) ) {
460 perror("ThreadStart pthread_mutex_lock ") ;
463 if ( _ThreadStartedSync ) {
464 cdebug << "pthread_cond " << Name() << " ThreadStart pthread_cond_signal"
466 _ThreadStartedSync = false ;
467 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
468 perror("ThreadStart pthread_cond_broadcast ") ;
470 cdebug << "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled"
474 cdebug << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal"
476 _ThreadStartedSync = true ;
478 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
479 perror("ThreadStarted pthread_cond_wait ") ;
482 cdebug << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited"
485 if ( pthread_mutex_unlock( &_MutexWait ) ) {
486 perror("ThreadStart pthread_mutex_unlock ") ;
491 int GraphExecutor::InNode::executeAction() {
492 int oldRewindStack = ( _RewindStack > 101 ) ;
493 if ( !CreateNewThread() && oldRewindStack ) {
494 cdebug << pthread_self() << "/" << ThreadNo()
495 << " executeAction start Thread _RewindStack " << _RewindStack << " > 101 CreateNewThread "
496 << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
498 CreateNewThread( true ) ;
501 if ( CreateNewThread() ) {
502 CreateNewThread( false ) ;
503 if ( ThreadNo() == 0 ) {
505 cdebug << pthread_self() << "/" << ThreadNo()
506 << " executeAction start Thread _RewindStack " << _RewindStack << " "
507 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
510 int pthread_sts = 1 ;
511 // _OutNode->PushEvent( NULL , GraphExecutor::NewThreadEvent ,
512 // SUPERV::ExecutingState ) ;
513 while ( (pthread_sts = pthread_create(&T, NULL, run_function, this )) ) {
514 char * msg = "Cannot pthread_create " ;
516 cdebug << ThreadNo() << " " << msg << " --> sleep(5)" << endl ;
517 cdebug << ThreadNo() << " PTHREAD_THREADS_MAX : "
518 << PTHREAD_THREADS_MAX << " pthread_create status : " ;
519 if ( pthread_sts == EAGAIN ) {
520 cdebug << "EAGAIN(" << pthread_sts << ")" << endl ;
521 cdebug << "It seems to me that with gdb we are limited to 256 threads because of defunct" << endl ;
524 cdebug << pthread_sts << endl ;
528 pthread_exit( msg ) ;
530 cdebug << pthread_self() << "/" << ThreadNo()
531 << "executeAction has created thread " << T << endl ;
532 ThreadStartedAction() ;
533 cdebug << pthread_self() << "/" << ThreadNo()
534 << "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
538 cdebug << pthread_self() << "/" << ThreadNo()
539 << " executeAction restart Thread _RewindStack " << _RewindStack << " "
540 << Automaton()->StateName( State() ) << " "
541 << Automaton()->ActionName( _NextAction ) << "(" << Name()
542 << ") ReStartAction ==>" << endl;
543 State( SUPERV::SuspendedSuccessedState ) ;
544 if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
545 cdebug << pthread_self() << "/" << ThreadNo()
546 << " executeAction STATE & CALLED "
547 << Automaton()->ActionName( _NextAction ) << "(" << Name()
548 << ") ERROR-DEBUG " << endl;
551 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
552 << Automaton()->ActionName( _NextAction ) << "(" << Name()
558 if ( _CurrentEvent == ExecuteEvent ) {
561 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
562 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
564 return ExecuteAction() ;
569 void GraphExecutor::InNode::coutbegin() {
570 cdebug << ThreadNo() << " " << pthread_self() << " run_function begin"
571 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
573 void GraphExecutor::InNode::coutexit() {
574 cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit _RewindStack " << _RewindStack
575 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
577 void * run_function(void *p) {
578 GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
580 aNode->NewThread( pthread_self() ) ;
581 if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) {
582 perror("pthread_setcanceltype ") ;
585 if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) {
586 perror("pthread_setcancelstate ") ;
589 aNode->ThreadStartAction() ;
590 aNode->ExecuteAction() ;
591 char * msg = new char[40] ;
592 sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
593 strcat( msg , " thread exit" ) ;
595 aNode->ExitThread() ;
598 pthread_exit( (void * ) smsg.c_str() ) ;
602 int GraphExecutor::InNode::ExecuteAction() {
605 // const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
606 // const char * statename = Automaton()->StateName( State() ) ;
607 // const char * nextstatename = Automaton()->StateName( _NextState ) ;
608 // cdebug << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction "
609 // << nextactionname << " " << statename << " NextState "
610 // << nextstatename << endl ;
612 State( _NextState ) ;
613 switch ( _NextAction ) {
614 case GraphExecutor::ErrorAction : {
615 sts = ErrorAction() ;
618 case GraphExecutor::VoidAction : {
622 case GraphExecutor::DataWaiting_SomeDataReadyAction : {
623 sts = DataWaiting_SomeDataReadyAction() ;
626 case GraphExecutor::DataUndef_NotAllDataReadyAction : {
627 sts = DataUndef_NotAllDataReadyAction() ;
630 case GraphExecutor::DataUndef_AllDataReadyAction : {
631 sts = DataUndef_AllDataReadyAction() ;
634 case GraphExecutor::DataReady_SuspendAction : {
635 sts = DataReady_SuspendAction() ;
638 case GraphExecutor::SuspendedReady_ResumeAction : {
639 sts = SuspendedReady_ResumeAction() ;
642 case GraphExecutor::DataReady_KillAction : {
643 sts = DataReady_KillAction() ;
646 case GraphExecutor::DataReady_StopAction : {
647 sts = DataReady_StopAction() ;
650 case GraphExecutor::DataReady_ExecuteAction : {
651 sts = DataReady_ExecuteAction() ;
654 case GraphExecutor::Executing_SuspendAction : {
655 sts = Executing_SuspendAction() ;
658 case GraphExecutor::SuspendedExecuting_ResumeAction : {
659 sts = SuspendedExecuting_ResumeAction() ;
662 case GraphExecutor::Executing_KillAction : {
663 sts = Executing_KillAction() ;
666 case GraphExecutor::Executing_StopAction : {
667 sts = Executing_StopAction() ;
670 case GraphExecutor::Executing_SuccessAction : {
671 sts = Executing_SuccessAction() ;
674 case GraphExecutor::Executing_ErrorAction : {
675 sts = Executing_ErrorAction() ;
678 case GraphExecutor::Successed_SuccessAction : {
679 sts = Successed_SuccessAction() ;
682 case GraphExecutor::Errored_ErrorAction : {
683 sts = Errored_ErrorAction() ;
686 case GraphExecutor::Successed_SuspendAction : {
687 sts = Successed_SuspendAction() ;
690 case GraphExecutor::Errored_SuspendAction : {
691 sts = Errored_SuspendAction() ;
694 case GraphExecutor::SuspendedSuccessed_ResumeAction : {
695 sts = SuspendedSuccessed_ResumeAction() ;
698 case GraphExecutor::SuspendedErrored_ResumeAction : {
699 sts = SuspendedErrored_ResumeAction() ;
702 case GraphExecutor::Successed_KillAction : {
703 sts = Successed_KillAction() ;
706 case GraphExecutor::Errored_KillAction : {
707 sts = Errored_KillAction() ;
710 case GraphExecutor::Successed_StopAction : {
711 sts = Successed_StopAction() ;
714 case GraphExecutor::Errored_StopAction : {
715 sts = Errored_StopAction() ;
718 case GraphExecutor::SuspendedSuccessed_ReStartAction : {
719 sts = SuspendedSuccessed_ReStartAction() ;
722 case GraphExecutor::SuspendedErrored_ReStartAction : {
723 sts = SuspendedErrored_ReStartAction() ;
726 case GraphExecutor::SuspendedSuccessed_ReStartAndSuspendAction : {
727 sts = SuspendedSuccessed_ReStartAndSuspendAction() ;
730 case GraphExecutor::SuspendedErrored_ReStartAndSuspendAction : {
731 sts = SuspendedErrored_ReStartAndSuspendAction() ;
735 cdebug << pthread_self() << "/" << ThreadNo()
736 << " GraphExecutor::InNodeThreads::SendEvent Error Undefined Action : "
737 << _NextAction << endl ;
741 // cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
742 // << Automaton()->ActionName( nextaction ) << endl ;
746 int GraphExecutor::InNode::ErrorAction() {
747 cdebug << pthread_self() << "/" << ThreadNo() << " Automaton ErrorAction Node "
752 int GraphExecutor::InNode::VoidAction() {
753 cdebug << pthread_self() << "/" << ThreadNo() << " VoidAction " << Name() << endl;
758 int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
759 // cdebug << pthread_self() << "/" << ThreadNo()
760 // << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
761 // << " to " << Name() << endl;
765 bool LoopFinished = false ;
766 bool LoopBeginning = false ;
767 bool SwitchFinished = false ;
769 if ( IsEndLoopNode() && !GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
770 LoopFinished = true ; // End of Loop
772 if ( IsLoopNode() && GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
773 LoopBeginning = true ; // Beginning of Loop
775 if ( IsEndSwitchNode() && !GetChangeNodeInGate()->GetOutPort()->BoolValue() ) {
776 SwitchFinished = true ; // End of Switch
778 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
779 << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << endl ;
780 for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
781 GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
782 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
783 if ( anInPort->IsGate() && anOutPort == NULL ) {
785 anInPort->State( SUPERV::ReadyState ) ;
786 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
787 << anInPort->PortName() << " ControlPort inactive." << endl ;
789 else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
790 if ( anInPort->State() == SUPERV::ReadyState ) {
792 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
793 << anInPort->PortName() << " Was Done from "
794 << anOutPort->NodeName() << " " << anOutPort->PortName()
797 if ( GraphBase::Base::_prof_debug ) {
798 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
803 else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
804 anInPort->State( SUPERV::ReadyState ) ;
806 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
807 << anInPort->PortName() << " Was Done from "
808 << anOutPort->NodeName() << " " << anOutPort->PortName()
809 << " LoopBeginning " << LoopBeginning ;
811 if ( GraphBase::Base::_prof_debug ) {
812 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
817 else if ( LoopFinished ) {
818 anInPort->State( SUPERV::ReadyState ) ;
820 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
821 << anInPort->PortName() << " Was Done from "
822 << anOutPort->NodeName() << " " << anOutPort->PortName()
825 if ( GraphBase::Base::_prof_debug ) {
826 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
831 else if ( anInPort->IsGate() && SwitchFinished ) {
832 anInPort->State( SUPERV::ReadyState ) ;
834 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
835 << anInPort->PortName() << " Was Done from "
836 << anOutPort->NodeName() << " " << anOutPort->PortName()
837 << " SwitchFinished" ;
839 if ( GraphBase::Base::_prof_debug ) {
840 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
846 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
847 << anInPort->PortName() << " Was NOT Done from "
848 << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
849 << " " << Automaton()->StateName( State() ) << " DataConnected "
850 << anInPort->IsDataConnected() << " LoopBeginning "
851 << LoopBeginning << endl ;
854 else if ( anInPort->IsGate() ) {
855 const CORBA::Any * theValue = anOutPort->Value() ;
857 (*theValue) >>= GateOpened ;
858 if ( GateOpened != 0 ) {
860 anInPort->State( SUPERV::ReadyState ) ;
861 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
862 << anInPort->PortName() << " Gate is Opened from "
863 << anOutPort->NodeName() << " " << anOutPort->PortName()
866 if ( GraphBase::Base::_prof_debug ) {
867 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
872 else if ( LoopFinished ) {
873 anInPort->State( SUPERV::ReadyState ) ;
874 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
875 << anInPort->PortName() << " GATE IS CLOSED from "
876 << anOutPort->NodeName() << " " << anOutPort->PortName()
879 if ( GraphBase::Base::_prof_debug ) {
880 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
886 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
887 << anInPort->PortName() << " GATE IS CLOSED from "
888 << anOutPort->NodeName() << " " << anOutPort->PortName()
891 if ( GraphBase::Base::_prof_debug ) {
892 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
900 anInPort->State( SUPERV::ReadyState ) ;
901 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
902 << anInPort->PortName() << " is Done from "
903 << anOutPort->NodeName() << " " << anOutPort->PortName() << " " ;
905 if ( GraphBase::Base::_prof_debug ) {
906 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
913 if ( InReady == GetNodeInPortsSize() ) { // All Flags != 0 :
914 res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
916 else { // At least one Flag == 0 :
917 res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
920 cdebug << pthread_self() << "/" << ThreadNo()
921 << " <-- DataWaiting_SomeDataReadyAction " << Name() << endl;
926 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
927 CreateNewThreadIf( false ) ;
928 // cdebug << pthread_self() << " for " << ThreadNo()
929 // << " DataUndef_NotAllDataReadyAction " << Name() << endl;
933 int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
934 // cdebug << pthread_self() << "/" << ThreadNo()
935 // << " --> DataUndef_AllDataReadyAction " << Name()
936 // << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
937 // << IsLockedDataWait() ;
938 if ( IsLockedDataWait() ) {
939 // cdebug << " WOULD DEAD-LOCK" << endl ;
940 return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
943 CreateNewThread( CreateNewThreadIf() ) ;
944 if ( !CreateNewThread() ) {
945 // cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
946 ThreadNo( pthread_self() ) ;
948 _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
949 SUPERV::DataReadyState ) ;
951 SUPERV::ControlState aControl = ControlState() ;
952 switch ( aControl ) {
953 case SUPERV::VoidState : {
954 SendEvent( GraphExecutor::ExecuteEvent ) ;
957 case SUPERV::ToSuspendState : {
958 SendEvent( GraphExecutor::SuspendEvent ) ;
961 case SUPERV::ToSuspendStartState : {
962 SendEvent( GraphExecutor::SuspendEvent ) ;
965 case SUPERV::ToSuspendDoneState : {
966 SendEvent( GraphExecutor::ExecuteEvent ) ;
969 case SUPERV::ToKillState : {
970 SendEvent( GraphExecutor::KillEvent ) ;
973 case SUPERV::ToKillDoneState : {
974 SendEvent( GraphExecutor::ExecuteEvent ) ;
977 case SUPERV::ToStopState : {
978 SendEvent( GraphExecutor::StopEvent ) ;
983 << " GraphExecutor::InNodeThreads::DataUndef_AllDataReadyAction Error Undefined Control : "
984 << aControl << endl ;
988 // cdebug << pthread_self() << "/" << ThreadNo()
989 // << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
993 int GraphExecutor::InNode::DataReady_SuspendAction() {
994 cdebug << pthread_self() << "/" << ThreadNo()
995 << "DataReady_SuspendAction --> Suspend " << Name()
996 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
997 << _OutNode->SuspendedThreads() << endl;
998 _OutNode->PushEvent( this , GraphExecutor::SuspendedReadyEvent ,
999 SUPERV::SuspendedReadyState ) ;
1000 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1001 cdebug << pthread_self() << "/" << ThreadNo()
1002 << "DataReady_SuspendAction Resumed " << Name() << endl;
1003 if ( aReStartNode ) {
1004 _aReStartNode = NULL ;
1005 aReStartNode->SendEvent( _aReStartEvent ) ;
1008 SendEvent( GraphExecutor::ExecuteEvent ) ;
1013 int GraphExecutor::InNode::SuspendedReady_ResumeAction() {
1014 cdebug << pthread_self() << "/" << ThreadNo() << "SuspendedReady_ResumeAction "
1017 _OutNode->PushEvent( this , GraphExecutor::ResumedReadyEvent ,
1018 SUPERV::ResumedReadyState ) ;
1022 int GraphExecutor::InNode::DataReady_KillAction() {
1023 _OutNode->PushEvent( this , GraphExecutor::KilledReadyEvent ,
1024 SUPERV::KilledReadyState ) ;
1026 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_KillAction " << Name()
1027 << " will pthread_exit()" << endl;
1031 int GraphExecutor::InNode::DataReady_StopAction() {
1032 _OutNode->PushEvent( this , GraphExecutor::StoppedReadyEvent ,
1033 SUPERV::StoppedReadyState ) ;
1035 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_StopAction " << Name()
1036 << " will pthread_exit()" << endl;
1042 int GraphExecutor::InNode::DataReady_ExecuteAction() {
1045 // cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
1046 // << Name() << endl;
1047 _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
1048 SUPERV::ExecutingState ) ;
1051 SUPERV::GraphState PortState = SUPERV::ReadyState ;
1052 SUPERV::AutomatonState NewState = SUPERV::DataUndefState ;
1053 GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
1057 int nInParams = GetNodeInPortsSize() ;
1058 ServicesAnyData * InParametersList = new ServicesAnyData[nInParams];
1059 InParametersSet( Err , nInParams , InParametersList ) ;
1061 Engines::Container_var myContainer ;
1062 Engines::Component_var myObjComponent ;
1063 if ( !IsFactoryNode() ) {
1064 // cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
1065 if ( IsComputingNode() ) {
1066 ObjInterface( true ) ;
1067 CORBA::Object_ptr obj ;
1068 InParametersList[0].Value >>= obj ;
1069 CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
1070 myObjComponent = Engines::Component::_narrow( objvar ) ;
1075 else if ( CORBA::is_nil( Component() ) ) {
1076 ostringstream astr ;
1077 astr << "Graph " << _OutNode->Name() << " Node " << Name()
1078 << " : load of component " << ComponentName() << " in container "
1080 _OutNode->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1081 Err = !_OutNode->StartComponent( ThreadNo() , Computer() ,
1082 my_strdup( ComponentName() ) ,
1083 myContainer , myObjComponent ) ;
1084 ObjInterface( false ) ;
1085 SetContainer( myContainer ) ;
1086 SetComponent( myObjComponent ) ;
1089 myContainer = Container() ;
1090 myObjComponent = Component() ;
1091 // cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
1093 myObjComponent->ping() ;
1096 int nOutParams = GetNodeOutPortsSize() ;
1097 ServicesAnyData * OutParametersList = new ServicesAnyData[nOutParams];
1098 InOutParametersSet( nOutParams , OutParametersList ) ;
1100 if ( Err || ControlState() == SUPERV::ToKillState ||
1101 ControlState() == SUPERV::ToKillDoneState ||
1102 ControlState() == SUPERV::ToStopState ) {
1103 cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
1108 ostringstream astr ;
1109 astr << "Graph " << _OutNode->Name() << " Run of Node " << Name() ;
1110 _OutNode->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1111 cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
1112 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1113 cdebug << " , " << InParametersList[ i ].Name << "[kind"
1114 << InParametersList[ i ].Value.type()->kind() << "]" ;
1116 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1117 cdebug << " , " << OutParametersList[ i ].Name << "[kind"
1118 << OutParametersList[ i ].Value.type()->kind() << "]" ;
1120 if ( IsOneOfInLineNodes() ) {
1121 cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
1122 << InLineNode()->PyRunMethod() << " length " << (*InLineNode()->PythonFunction()).length() ;
1124 cdebug << ")" << endl ;
1126 if ( IsOneOfInLineNodes() ) {
1127 bool StsPyDynInvoke = true;
1128 _OutNode->PyThreadLock() ;
1131 // if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
1132 bool CopyInOut = false ;
1133 if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
1134 strlen( InLineNode()->PyFuncName() ) ) {
1135 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1136 // << InLineNode()->PyFuncName()
1137 // << "' IsInLineNode PyDynInvoke" << endl ;
1138 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1139 InLineNode()->PyFuncName() ,
1140 &InParametersList[0] , ServiceInParameter().length() - ComputingNode()->DataStreamInPortsNumber() ,
1141 &OutParametersList[0] , ServiceOutParameter().length() - ComputingNode()->DataStreamOutPortsNumber() ) ;
1143 else if ( IsLoopNode() ) {
1144 bool CopyOutIn = false ;
1145 if ( GetNodeInLoop()->GetOutPort()->BoolValue() && /*InLineNode()->PyRunMethod() &&*/
1146 strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port
1147 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1148 // << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
1150 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1151 InLineNode()->PyFuncName() ,
1152 &InParametersList[1] , ServiceInParameter().length() ,
1153 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1156 else if ( LoopNode()->PyNextMethod() &&
1157 strlen( LoopNode()->PyNextName() ) ){
1158 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1159 // << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
1161 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
1162 LoopNode()->PyNextName() ,
1163 &InParametersList[1] , ServiceInParameter().length() ,
1164 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1167 if ( StsPyDynInvoke && CopyOutIn ) {
1168 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1169 // << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
1170 // << "' Copy of " << ServiceInParameter().length()
1171 // << " OutParameters" << endl ;
1173 for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
1174 InParametersList[i].Value = OutParametersList[i].Value ;
1175 InParametersList[i].Name = OutParametersList[i].Name ;
1177 switch ( InParametersList[i].Value.type()->kind() ) {
1178 case CORBA::tk_string :
1180 InParametersList[i].Value >>= t ;
1181 cdebug << "ArgOut->In" << i << " : "
1182 << InParametersList[i].Name.c_str()
1183 << " Value(string) " << t << endl ;
1185 case CORBA::tk_double :
1187 InParametersList[i].Value >>= d;
1188 cdebug << "ArgOut->In" << i << " : "
1189 << InParametersList[i].Name.c_str()
1190 << " Value(double) " << d << endl ;
1192 case CORBA::tk_long :
1194 InParametersList[i].Value >>= l;
1195 cdebug << "ArgOut->In" << i << " : "
1196 << InParametersList[i].Name.c_str()
1197 << " Value(long) " << l << endl ;
1199 case CORBA::tk_objref :
1200 CORBA::Object_ptr obj ;
1203 InParametersList[i].Value >>= obj ;
1204 retstr = ObjectToString( obj );
1205 cdebug << "ArgOut->In" << i << " : "
1206 << InParametersList[i].Name.c_str()
1207 << " Value(object reference) " << retstr << endl ;
1210 cdebug << "ArgOut->In" << i << " : "
1211 << InParametersList[i].Name.c_str()
1212 << " Value(object reference) Catched ERROR" << endl ;
1216 cdebug << "ArgOut->In" << i << " : "
1217 << InParametersList[i].Name.c_str()
1218 << " Value(other) ERROR" << endl ;
1222 if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
1223 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
1224 LoopNode()->PyMoreName() ,
1225 &InParametersList[1] , ServiceInParameter().length() ,
1226 &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
1232 else if ( !StsPyDynInvoke ) {
1234 cdebug << ThreadNo() << " InLineNode " << Name() << " "
1235 << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
1236 << " Python Dynamic Call Error"
1240 else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
1241 strlen( InLineNode()->PyFuncName() ) ) {
1242 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1243 // << InLineNode()->PyFuncName()
1244 // << "' IsSwitchNode PyDynInvoke" << endl ;
1245 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1246 InLineNode()->PyFuncName() ,
1247 &InParametersList[0] , ServiceInParameter().length() ,
1248 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1250 // else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
1251 else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
1252 strlen( InLineNode()->PyFuncName() ) ) {
1253 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1254 // << InLineNode()->PyFuncName()
1255 // << "' IsGOTONode PyDynInvoke" << endl ;
1256 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1257 InLineNode()->PyFuncName() ,
1258 &InParametersList[0] , ServiceInParameter().length() ,
1259 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1261 // else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
1262 else if ( ( IsEndSwitchNode() ) &&
1263 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1264 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1265 // << InLineNode()->PyFuncName()
1266 // << "' IsSwitchNode PyDynInvoke" << endl ;
1267 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1268 InLineNode()->PyFuncName() ,
1269 &InParametersList[0] , ServiceInParameter().length() ,
1270 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1272 else if ( ( IsEndLoopNode() ) &&
1273 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1274 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1275 // << InLineNode()->PyFuncName()
1276 // << "' IsSwitchNode PyDynInvoke" << endl ;
1277 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1278 InLineNode()->PyFuncName() ,
1279 &InParametersList[0] , ServiceInParameter().length() + 1 ,
1280 &OutParametersList[0] , ServiceOutParameter().length() + 1 ) ;
1282 // else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
1283 if ( InLineNode()->PyRunMethod() == NULL ||
1284 strlen( InLineNode()->PyFuncName() ) == 0 || CopyInOut ) {
1285 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1286 // << " Copy of " << ServiceInParameter().length()
1287 // << " OutParameters" << endl ;
1291 if ( IsLoopNode() || IsEndLoopNode() ) {
1293 argin0 = 1 ; // after DoLoop
1294 if ( IsLoopNode() ) {
1295 OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
1298 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1299 OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
1301 switch ( InParametersList[argin0 + i].Value.type()->kind() ) {
1302 case CORBA::tk_string :
1303 cdebug << "ArgOut->In" << argin0 + i << " : "
1304 << InParametersList[argin0 + i].Name.c_str()
1305 << " Value(string) "
1306 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1308 case CORBA::tk_double :
1309 cdebug << "ArgOut->In" << argin0 + i << " : "
1310 << InParametersList[argin0 + i].Name.c_str()
1311 << " Value(double) "
1312 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1314 case CORBA::tk_long :
1315 cdebug << "ArgOut->In" << argin0 + i << " : "
1316 << InParametersList[argin0 + i].Name.c_str()
1318 << OutParametersList[argout0 + i ].Name.c_str() << endl ;
1320 case CORBA::tk_objref :
1321 cdebug << "ArgOut->In" << argin0 + i << " : "
1322 << InParametersList[argin0 + i].Name.c_str()
1323 << " Value(object reference) "
1324 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1327 cdebug << "ArgOut->In" << argin0 + i << " : "
1328 << InParametersList[argin0 + i].Name.c_str()
1329 << " Value(other) ERROR "
1330 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1335 if ( !StsPyDynInvoke ) {
1337 cdebug << ThreadNo() << " InLineNode " << Name()
1338 << " Python Dynamic Call Error"
1344 cdebug << ThreadNo() << " InLineNode " << Name()
1345 << " Python Dynamic Call Exception catched ERROR"
1349 _OutNode->PyThreadUnLock() ;
1354 cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ;
1355 DynInvoke( myObjComponent, "Names" ,
1356 _OutNode->Name() , Name() ) ;
1359 cdebug << "DynInvoke Names catched ERROR" << endl ;
1361 if ( IsComputingNode() ) {
1362 cdebug << ThreadNo() << " !ObjInterface " << Name()
1363 << " IsComputingNode DynInvoke" << endl ;
1364 cdebug << ServiceInParameter().length()-1 - ComputingNode()->DataStreamInPortsNumber() << " input parameters and "
1365 << ServiceOutParameter().length() - ComputingNode()->DataStreamOutPortsNumber() << " output parameters" << endl ;
1366 DynInvoke( myObjComponent,
1368 &InParametersList[1] , ServiceInParameter().length()-1 - ComputingNode()->DataStreamInPortsNumber() ,
1369 &OutParametersList[0] , ServiceOutParameter().length() - ComputingNode()->DataStreamOutPortsNumber() ) ;
1371 else if ( IsFactoryNode() ) {
1372 cdebug << ThreadNo() << " !ObjInterface " << Name()
1373 << " IsFactoryNode DynInvoke" << endl ;
1374 cdebug << ServiceInParameter().length() - ComputingNode()->DataStreamInPortsNumber() << " input parameters and "
1375 << ServiceOutParameter().length() - ComputingNode()->DataStreamOutPortsNumber() << " output parameters" << endl ;
1376 DynInvoke( myObjComponent,
1378 &InParametersList[0] , ServiceInParameter().length() - ComputingNode()->DataStreamInPortsNumber() ,
1379 &OutParametersList[0] , ServiceOutParameter().length() - ComputingNode()->DataStreamOutPortsNumber() ) ;
1381 // cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
1382 // << myObjComponent->CpuUsed_impl() << endl ;
1386 cdebug << ThreadNo() << " !ObjInterface " << Name()
1387 << " Node(Component) Dynamic Call Exception catched ERROR"
1398 ostringstream astr ;
1399 astr << "Graph " << _OutNode->Name() << " Node " << Name() << " is done : "
1400 << Automaton()->StateName( State() ) ;
1401 _OutNode->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1403 if ( ControlState() == SUPERV::ToKillState ||
1404 ControlState() == SUPERV::ToKillDoneState ||
1405 ControlState() == SUPERV::ToStopState ) {
1406 PortState = SUPERV::ErrorState ;
1407 NewState = SUPERV::KilledState ;
1408 NewEvent = GraphExecutor::KillEvent ;
1411 PortState = SUPERV::ErrorState ;
1412 NewState = SUPERV::ErroredState ;
1413 NewEvent = GraphExecutor::ErrorEvent ;
1417 PortState = SUPERV::ReadyState ;
1418 NewState = SUPERV::DataReadyState ;
1419 NewEvent = GraphExecutor::SuccessEvent ;
1422 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1425 NewEvent = GraphExecutor::ErrorEvent ;
1428 delete [] InParametersList ;
1429 delete [] OutParametersList ;
1432 SendEvent( NewEvent );
1434 // cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
1438 int GraphExecutor::InNode::Executing_SuspendAction() {
1439 _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
1440 SUPERV::SuspendedExecutingState ) ;
1441 cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
1445 int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
1446 cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
1447 SUPERV::AutomatonState next_state ;
1448 next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
1449 _OutNode->NewThread() ; // Only for Threads count
1450 _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
1452 State( next_state ) ;
1456 int GraphExecutor::InNode::Executing_KillAction() {
1457 cdebug << ThreadNo() << " Executing_KillAction " << Name() << endl;
1459 if ( pthread_self() == ThreadNo() ) {
1460 cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
1462 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
1463 SUPERV::KilledExecutingState ) ;
1466 else if ( pthread_cancel( ThreadNo() ) ) {
1467 perror("Executing_KillAction pthread_cancel error") ;
1470 cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
1471 << " pthread_canceled" << endl ;
1473 _OutNode->ExitThread() ;
1474 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
1475 SUPERV::KilledExecutingState ) ;
1480 int GraphExecutor::InNode::Executing_StopAction() {
1481 cdebug << ThreadNo() << " Executing_StopAction " << Name() << endl;
1483 if ( pthread_cancel( ThreadNo() ) ) {
1484 perror("Executing_KillAction pthread_cancel error") ;
1487 cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
1488 << " pthread_canceled" << endl ;
1490 _OutNode->ExitThread() ;
1491 _OutNode->PushEvent( this , GraphExecutor::StoppedExecutingEvent ,
1492 SUPERV::StoppedExecutingState ) ;
1497 int GraphExecutor::InNode::Executing_SuccessAction() {
1498 // cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
1499 _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
1500 SUPERV::SuccessedState ) ;
1501 SUPERV::ControlState aControl = ControlState() ;
1502 switch ( aControl ) {
1503 case SUPERV::VoidState : {
1504 SendEvent( SuccessEvent ) ;
1507 case SUPERV::ToSuspendState : {
1508 SendEvent( SuccessEvent ) ;
1511 case SUPERV::ToSuspendDoneState : {
1512 SendEvent( GraphExecutor::SuspendEvent ) ;
1515 case SUPERV::ToKillState : {
1516 SendEvent( GraphExecutor::KillEvent ) ;
1519 case SUPERV::ToKillDoneState : {
1520 SendEvent( GraphExecutor::KillEvent ) ;
1523 case SUPERV::ToStopState : {
1524 SendEvent( GraphExecutor::StopEvent ) ;
1528 cdebug << ThreadNo()
1529 << " GraphExecutor::InNodeThreads::Executing_SuccessAction Error Undefined Control : "
1530 << aControl << endl ;
1534 // cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
1538 int GraphExecutor::InNode::Executing_ErrorAction() {
1539 cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
1540 _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
1541 SUPERV::ErroredState ) ;
1543 SUPERV::ControlState aControl = ControlState() ;
1544 switch ( aControl ) {
1545 case SUPERV::VoidState : {
1546 SendEvent( ErrorEvent ) ;
1549 case SUPERV::ToSuspendState : {
1550 SendEvent( ErrorEvent ) ;
1553 case SUPERV::ToSuspendDoneState : {
1554 SendEvent( GraphExecutor::SuspendEvent ) ;
1557 case SUPERV::ToKillState : {
1558 SendEvent( GraphExecutor::KillEvent ) ;
1561 case SUPERV::ToKillDoneState : {
1562 SendEvent( GraphExecutor::KillEvent ) ;
1565 case SUPERV::ToStopState : {
1566 SendEvent( GraphExecutor::StopEvent ) ;
1570 cdebug << ThreadNo()
1571 << " GraphExecutor::InNodeThreads::Executing_ErrorAction Error Undefined Control : "
1572 << aControl << endl ;
1576 cdebug << ThreadNo() << " <-- Executing_ErrorAction " << Name() << endl;
1580 // Set SUPERV::WaitingState to all InPorts
1581 void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
1584 bool docdebug = false ;
1585 State( SUPERV::DataWaitingState ) ;
1586 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1587 GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
1588 if ( anInPort->IsGate() ) { // Loop : Open the doors
1589 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1591 CORBA::Any * anAny = new CORBA::Any() ;
1592 *anAny <<= (long ) 1 ;
1593 anOutPort->Value( anAny ) ;
1594 anInPort->State( SUPERV::ReadyState ) ;
1597 else if ( anInPort->State() != SUPERV::WaitingState ) {
1599 // cdebug << ThreadNo()
1600 // << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
1603 if ( !anInPort->IsDataStream() ) {
1604 anInPort->State( SUPERV::WaitingState ) ;
1608 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1609 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
1610 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
1611 if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
1612 !( IsEndLoopNode() && ( anOutPort->IsGate() ||
1613 anOutPort->IsLoop() ) ) &&
1614 !anOutPort->IsDataStream() &&
1615 !anOutPort->ChangeInPorts( j )->IsDataStream() ) {
1616 // cdebug << ThreadNo()
1617 // << " GraphExecutor::InNodeThreads::SetWaitingStates "
1618 // << Name() << "( " << anOutPort->PortName() << " ) --> InPort "
1619 // << anOutPort->ChangeInPorts( j )->PortName() << " from Node "
1620 // << anOutPort->ChangeInPorts( j )->NodeName() << endl;
1621 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ;
1622 if ( aNode != EndNode ) {
1623 aNode->SetWaitingStates( EndNode ) ;
1630 int GraphExecutor::InNode::Successed_SuccessAction() {
1631 // cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
1633 int linkednodesnumber = LinkedNodesSize() ;
1634 GraphExecutor::InNode *firstzeroNode = NULL ;
1635 GraphExecutor::InNode *firsttoNode = NULL ;
1636 GraphExecutor::InNode *toNode ;
1639 list<GraphExecutor::InNode *> SomeDataNodes ;
1643 if ( IsGOTONode() ||
1644 ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
1645 const GraphBase::OutPort * aGateOutPort ;
1646 if ( IsGOTONode() ) {
1647 aGateOutPort = GetNodeOutGate() ;
1650 aGateOutPort = GetNodeOutLoop() ;
1652 for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
1653 const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
1654 GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
1655 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
1656 // << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
1657 aLabelNode->SetWaitingStates( this ) ;
1658 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
1659 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
1660 if ( anInPort->GetOutPort() ) {
1661 // cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
1662 // << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
1666 for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
1667 GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
1668 if ( !aBusParamOutPort->IsGate() ) {
1669 GraphBase::InPort * aBusParamChangeInPort = NULL ;
1670 if ( aBusParamOutPort->IsLoop() ) {
1671 aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
1674 aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
1676 if ( aBusParamChangeInPort ) {
1677 aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
1678 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
1679 // << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
1680 // << aBusParamOutPort->PortName() << endl ;
1681 if ( !aLabelNode->IsLockedDataWait() ) {
1682 res = aLabelNode->SendSomeDataReady( Name() ) ;
1684 if ( firsttoNode == NULL &&
1685 aLabelNode->ThreadNo() == pthread_self() ) {
1686 firsttoNode = aLabelNode ;
1687 // cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
1688 // << aLabelNode->Name() << endl ;
1690 else if ( firstzeroNode == NULL &&
1691 aLabelNode->ThreadNo() == 0 ) {
1692 firstzeroNode = aLabelNode ;
1695 SomeDataNodes.push_back( aLabelNode ) ;
1696 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1697 // << aLabelNode->Name() << " " << SomeDataNodes.size()
1703 // cdebug << ThreadNo()
1704 // << " Successed_SuccessAction Loop to HeadNode "
1705 // << aLabelNode->Name() << " with datas from " << Name() << "("
1706 // << aBusParamOutPort->PortName() << ") to port "
1707 // << aBusParamChangeInPort->PortName() << endl;
1711 // cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
1712 // << " NO port " << aBusParamOutPort->PortName() << " in "
1713 // << aLabelNode->Name() << endl;
1717 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
1718 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
1719 if ( anInPort->GetOutPort() ) {
1720 // cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
1721 // << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
1725 const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
1726 if ( aGateInPort ) {
1727 if ( aGateInPort->GetOutPort() ) {
1728 aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
1730 if ( !aLabelNode->IsLockedDataWait() ) {
1731 res = aLabelNode->SendSomeDataReady( Name() ) ;
1733 if ( firsttoNode == NULL &&
1734 aLabelNode->ThreadNo() == pthread_self() ) {
1735 firsttoNode = aLabelNode ;
1736 // cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
1737 // << aLabelNode->Name() << endl ;
1739 else if ( firstzeroNode == NULL &&
1740 aLabelNode->ThreadNo() == 0 ) {
1741 firstzeroNode = aLabelNode ;
1744 SomeDataNodes.push_back( aLabelNode ) ;
1745 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1746 // << aLabelNode->Name() << " " << SomeDataNodes.size()
1753 cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
1754 << " NO port " << aGateOutPort->PortName() << " in "
1755 << aLabelNode->Name() << endl;
1761 // cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
1762 // << " with " << LinkedNodesSize() << " linked nodes :" ;
1763 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
1764 if ( LinkedNodes( i )->IsDataFlowNode() ) {
1765 linkednodesnumber -= 1 ;
1767 // cdebug << " " << LinkedNodes( i )->Name() ;
1770 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
1771 bool IgnoreForEndLoop = false ;
1772 toNode = (GraphExecutor::InNode *) LinkedNodes( i )->GetInNode() ;
1773 // cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
1774 // << " [" << i << "] " << LinkedNodes( i )->Name() << endl ;
1775 if ( toNode && !toNode->IsDataFlowNode() ) {
1776 if ( IsComputingNode() && toNode->IsInLineNode() ) {
1777 GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
1778 toGateInPort->State( SUPERV::ReadyState ) ;
1779 GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
1780 if ( GateOutPort ) {
1781 GateOutPort->PortStatus( DataConnected );
1782 GateOutPort->State( SUPERV::ReadyState ) ;
1783 GateOutPort->Done( true ) ;
1787 if ( toNode && IsLoopNode() ) {
1788 GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
1789 if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
1790 if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
1791 IgnoreForEndLoop = true ;
1793 else { // toNode is the EndLoopNode
1794 GraphBase::InPort * toLoopInPort ;
1795 toLoopInPort = toNode->GetChangeNodeInLoop() ;
1796 if ( toLoopInPort->State() != SUPERV::ReadyState ) {
1797 toLoopInPort->State( SUPERV::ReadyState ) ;
1802 else if ( toNode && IsSwitchNode() ) {
1804 else if ( toNode && toNode->IsInLineNode() ) {
1806 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
1807 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
1810 if ( toNode && !IgnoreForEndLoop ) {
1811 if ( toNode && toNode->IsLoopNode() ) {
1812 GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
1813 toLoopInPort->State( SUPERV::ReadyState ) ;
1814 GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
1815 LoopOutPort->PortStatus( DataConnected );
1816 LoopOutPort->State( SUPERV::ReadyState ) ;
1817 LoopOutPort->Done( true ) ;
1818 CORBA::Any * anAny = new CORBA::Any() ;
1819 *anAny <<= (long ) 1 ;
1820 LoopOutPort->Value( anAny ) ;
1822 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
1823 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
1826 res = toNode->SendSomeDataReady( Name() ) ;
1828 if ( firsttoNode == NULL &&
1829 toNode->ThreadNo() == pthread_self() ) {
1830 firsttoNode = toNode ;
1831 // cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
1832 // << toNode->Name() << endl ;
1834 else if ( firstzeroNode == NULL &&
1835 toNode->ThreadNo() == 0 ) {
1836 firstzeroNode = toNode ;
1839 SomeDataNodes.push_back( toNode ) ;
1840 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1841 // << toNode->Name() << " " << SomeDataNodes.size() << endl ;
1848 if ( firsttoNode == NULL && firstzeroNode ) {
1849 firsttoNode = firstzeroNode ;
1850 // cdebug << ThreadNo()
1851 // << " Successed_SuccessAction firsttoNode = firstzeroNode "
1854 else if ( firsttoNode && firstzeroNode ) {
1855 SomeDataNodes.push_back( firstzeroNode ) ;
1856 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode "
1857 // << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ;
1860 while ( SomeDataNodes.size() ) {
1861 GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
1862 SomeDataNodes.pop_front() ;
1863 // cdebug << pthread_self() << "/" << ThreadNo()
1864 // << " Successed_SuccessAction pop "
1865 // << SomeDataNodes.size() << " " << aNode->Name() << endl ;
1866 if ( aNode->State() == SUPERV::DataReadyState ) {
1867 aNode->CreateNewThreadIf( true ) ;
1868 aNode->UnLockDataWait() ;
1869 res = aNode->DataUndef_AllDataReadyAction() ;
1872 // cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
1873 // << aNode->Name() << " "
1874 // << Automaton()->StateName( aNode->State() ) << endl ;
1878 if ( firsttoNode ) {
1879 // cdebug << pthread_self() << "/" << ThreadNo()
1880 // << " Successed_SuccessAction start firsttoNode "
1881 // << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
1882 firsttoNode->CreateNewThreadIf( false ) ;
1883 firsttoNode->RewindStack( RewindStack() ) ;
1884 if ( firsttoNode->State() == SUPERV::SuccessedState ) {
1885 // cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
1886 // << " : " << firsttoNode->Name() << " "
1887 // << Automaton()->StateName( firsttoNode->State() )
1888 // << " --> DataWaitingState for Thread "
1889 // << firsttoNode->ThreadNo() << endl ;
1890 firsttoNode->State( SUPERV::DataWaitingState ) ;
1892 // pthread_t OldT = firsttoNode->ThreadNo() ;
1893 firsttoNode->ThreadNo( pthread_self() ) ;
1894 // On continue avec le meme thread
1895 // cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
1896 // << firsttoNode->Name() << "Thread(" << OldT << "-->"
1897 // << firsttoNode->ThreadNo() << ")" << endl ;
1899 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
1900 // << " for " << firsttoNode->Name()
1901 // << " !firsttoNode->CreateNewThreadIf() "
1902 // << !firsttoNode->CreateNewThreadIf()
1903 // << " " << Automaton()->StateName( firsttoNode->State() ) ;
1904 if ( firsttoNode->State() == SUPERV::DataReadyState ) {
1906 firsttoNode->UnLockDataWait() ;
1907 res = firsttoNode->DataUndef_AllDataReadyAction() ;
1910 cdebug << " ERROR " << endl ;
1914 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
1915 // << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
1919 // if ( linkednodesnumber == 0 && firsttoNode == NULL ) {
1920 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodesSize " << LinkedNodesSize()
1921 // << " firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << " CHECK" << endl ;
1922 // _OutNode->CheckAllDone() ;
1925 // cdebug << pthread_self() << "/" << ThreadNo()
1926 // << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
1927 // << linkednodesnumber << endl;
1931 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
1932 bool RetVal = false ;
1933 if ( IsDataFlowNode() ) {
1934 // cdebug << ThreadNo() << " ----> " << Name()
1935 // << " send Result to graph " << Name() << endl;
1938 // cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
1939 // << " send SomeDataReady to " << Name() << " "
1940 // << Automaton()->StateName( State() )
1941 // << " CreateNewThreadIf() " << CreateNewThreadIf()
1942 // << " LockedDataWait " << IsLockedDataWait() << endl;
1944 cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
1945 << " send SomeDataReady to " << Name() << " "
1946 << Automaton()->StateName( State() )
1947 << " CreateNewThreadIf() " << CreateNewThreadIf()
1948 << " LockedDataWait " << IsLockedDataWait() << endl;
1950 if ( State() == SUPERV::SuccessedState ||
1951 State() == SUPERV::SuspendedSuccessedState ||
1952 State() == SUPERV::SuspendedSuccessedToReStartState ) {
1953 // cdebug << ThreadNo() << " " << FromNodeName
1954 // << " : " << Name() << " " << Automaton()->StateName( State() )
1955 // << " --> DataWaitingState for Thread "
1956 // << ThreadNo() << " " << endl ;
1957 State( SUPERV::DataWaitingState ) ;
1960 DataFromNode( FromNodeName ) ;
1961 RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
1969 int GraphExecutor::InNode::Errored_ErrorAction() {
1970 cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
1971 << " will pthread_exit" << endl;
1976 int GraphExecutor::InNode::Successed_SuspendAction() {
1977 cdebug << ThreadNo() << " Successed_SuspendAction -->Suspend " << Name()
1978 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
1979 << _OutNode->SuspendedThreads() << endl;
1980 _OutNode->PushEvent( this , GraphExecutor::SuspendedSuccessedEvent ,
1981 SUPERV::SuspendedSuccessedState ) ;
1983 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1984 cdebug << ThreadNo() << " Successed_SuspendAction Resumed " << Name() ;
1985 if ( aReStartNode ) {
1986 _aReStartNode = NULL ;
1987 cdebug << " for " << aReStartNode->Name() << endl;
1988 aReStartNode->SendEvent( _aReStartEvent ) ;
1992 SendEvent( GraphExecutor::ResumeEvent ) ;
1997 int GraphExecutor::InNode::Errored_SuspendAction() {
1998 cdebug << ThreadNo() << " Errored_SuspendAction -->Suspend " << Name()
1999 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
2000 << _OutNode->SuspendedThreads() << endl;
2001 _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
2002 SUPERV::SuspendedErroredState ) ;
2004 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
2005 cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
2007 if ( aReStartNode ) {
2008 _aReStartNode = NULL ;
2009 aReStartNode->SendEvent( _aReStartEvent ) ;
2012 SendEvent( GraphExecutor::ResumeEvent ) ;
2017 int GraphExecutor::InNode::SuspendedSuccessed_ResumeAction() {
2018 cdebug << ThreadNo() << " SuspendedSuccessed_ResumeAction " << Name() << endl;
2020 _OutNode->PushEvent( this , GraphExecutor::ResumedSuccessedEvent ,
2021 SUPERV::ResumedSuccessedState ) ;
2022 SendEvent( ResumedSuccessedEvent ) ;
2026 int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
2027 cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
2029 _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
2030 SUPERV::ResumedErroredState ) ;
2031 SendEvent( ResumedErroredEvent ) ;
2035 int GraphExecutor::InNode::Successed_KillAction() {
2037 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2038 SUPERV::KilledSuccessedState ) ;
2039 cdebug << ThreadNo() << " Successed_KillAction " << Name() << endl;
2043 int GraphExecutor::InNode::Errored_KillAction() {
2045 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2046 SUPERV::KilledErroredState ) ;
2047 cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
2051 int GraphExecutor::InNode::Successed_StopAction() {
2053 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2054 SUPERV::StoppedSuccessedState ) ;
2055 cdebug << ThreadNo() << " Successed_StopAction " << Name() << endl;
2059 int GraphExecutor::InNode::Errored_StopAction() {
2061 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2062 SUPERV::StoppedErroredState ) ;
2063 cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
2067 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
2068 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2069 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2070 SUPERV::ReStartedState ) ;
2072 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2073 GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
2075 SendEvent( ExecuteEvent ) ;
2076 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2080 int GraphExecutor::InNode::SuspendedErrored_ReStartAction() {
2081 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2082 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2083 SUPERV::ReStartedState ) ;
2085 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2086 GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
2088 SendEvent( ExecuteEvent ) ;
2089 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2093 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAndSuspendAction() {
2094 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2096 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2097 SUPERV::ReStartedState ) ;
2098 State( SUPERV::DataWaitingState ) ;
2100 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2103 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2104 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2108 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2113 int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
2114 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2116 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2117 SUPERV::ReStartedState ) ;
2118 State( SUPERV::DataWaitingState ) ;
2120 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2123 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2124 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2128 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2133 void GraphExecutor::InNode::InParametersSet( bool & Err ,
2135 ServicesAnyData * InParametersList ) {
2137 for ( i = 0 ; i < nInParams ; i++ ) {
2138 ServicesAnyData D = InParametersList[i];
2139 GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
2140 GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
2141 if ( anInPort->IsGate() && theOutPort == NULL ) {
2142 cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
2143 << anInPort->GetServicesParameter().Parametertype
2144 << " is inactive. " << anInPort->Kind() << endl ;
2146 else if ( anInPort->State() == SUPERV::ReadyState ) {
2147 if ( anInPort->IsGate() ) {
2148 CORBA::Any * anAny = new CORBA::Any() ;
2149 *anAny <<= (long ) 0 ;
2150 theOutPort->Value( anAny ) ;
2152 if ( !anInPort->IsDataStream() ) {
2153 anInPort->State( SUPERV::WaitingState ) ;
2155 D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
2156 cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() ;
2157 cdebug << " " << D.Name << " " << anInPort->GetServicesParameter().Parametertype << " : " ;
2158 D.Value = *theOutPort->Value() ; // CORBA::Any
2159 string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
2160 const char * Type = _Type.c_str() ;
2161 switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
2162 case CORBA::tk_string:
2165 cdebug << t << " (string)" ;
2166 if ( !strcmp( Type , "string" ) ) {
2168 else if ( !strcmp( Type , "boolean" ) ) {
2171 sscanf( t , "%ld" , &d ) ;
2173 D.Value <<= (CORBA::Any::from_boolean ) b ;
2174 // theOutPort->Value( D.Value ) ;
2176 else if ( !strcmp( Type , "char" ) ) {
2179 sscanf( t , "%ld" , &d ) ;
2181 D.Value <<= (CORBA::Any::from_char ) c ;
2182 cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
2183 // theOutPort->Value( D.Value ) ;
2185 else if ( !strcmp( Type , "short" ) ) {
2188 sscanf( t , "%ld" , &d ) ;
2191 cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
2192 // theOutPort->Value( D.Value ) ;
2194 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2196 sscanf( t , "%ld" , &l ) ;
2198 cdebug << "string '" << t << " --> long " << l ;
2199 // theOutPort->Value( D.Value ) ;
2201 else if ( !strcmp( Type , "float" ) ) {
2203 sscanf( t , "%lf" , &d ) ;
2206 cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
2207 << setw(25) << setprecision(18) << f ;
2208 // theOutPort->Value( D.Value ) ;
2210 else if ( !strcmp( Type , "double" ) ) {
2212 sscanf( t , "%lf" , &d ) ;
2214 cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
2215 // theOutPort->Value( D.Value ) ;
2217 // else if ( !strcmp( Type , "objref" ) ) {
2219 CORBA::Object_ptr ObjRef ;
2221 ObjRef = StringToObject( t ) ;
2222 D.Value <<= ObjRef ;
2225 D.Value <<= CORBA::Object::_nil() ;
2227 // theOutPort->Value( D.Value ) ;
2230 // cdebug << " (other ERROR)" << endl ;
2232 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2234 case CORBA::tk_long:
2237 cdebug << l << " (long)" << endl ;
2238 if ( !strcmp( Type , "string" ) ) {
2240 sprintf( t , "%ld" , l ) ;
2242 // theOutPort->Value( D.Value ) ;
2244 else if ( !strcmp( Type , "boolean" ) ) {
2247 D.Value <<= (CORBA::Any::from_boolean ) b ;
2248 // theOutPort->Value( D.Value ) ;
2250 else if ( !strcmp( Type , "char" ) ) {
2252 c = (unsigned char ) l ;
2253 D.Value <<= (CORBA::Any::from_char ) c ;
2254 // theOutPort->Value( D.Value ) ;
2256 else if ( !strcmp( Type , "short" ) ) {
2260 // theOutPort->Value( D.Value ) ;
2262 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2264 else if ( !strcmp( Type , "float" ) ) {
2268 // theOutPort->Value( D.Value ) ;
2270 else if ( !strcmp( Type , "double" ) ) {
2274 // theOutPort->Value( D.Value ) ;
2276 // else if ( !strcmp( Type , "objref" ) ) {
2278 D.Value <<= CORBA::Object::_nil() ;
2279 // theOutPort->Value( D.Value ) ;
2282 // cdebug << " (other ERROR)" << endl ;
2284 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2286 case CORBA::tk_double:
2289 cdebug << d << " (double)" << endl ;
2290 if ( !strcmp( Type , "string" ) ) {
2292 sprintf( t , "%lf" , d ) ;
2294 // theOutPort->Value( D.Value ) ;
2296 else if ( !strcmp( Type , "boolean" ) ) {
2299 D.Value <<= (CORBA::Any::from_boolean ) b ;
2300 // theOutPort->Value( D.Value ) ;
2302 else if ( !strcmp( Type , "char" ) ) {
2304 c = (unsigned char ) d ;
2305 D.Value <<= (CORBA::Any::from_char ) c ;
2306 // theOutPort->Value( D.Value ) ;
2308 else if ( !strcmp( Type , "short" ) ) {
2312 // theOutPort->Value( D.Value ) ;
2314 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2318 // theOutPort->Value( D.Value ) ;
2320 else if ( !strcmp( Type , "float" ) ) {
2324 // theOutPort->Value( D.Value ) ;
2326 else if ( !strcmp( Type , "double" ) ) {
2328 // else if ( !strcmp( Type , "objref" ) ) {
2330 D.Value <<= CORBA::Object::_nil() ;
2331 // theOutPort->Value( D.Value ) ;
2334 // cdebug << " (other ERROR)" << endl ;
2336 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2338 case CORBA::tk_objref:
2339 if ( !strcmp( Type , "string" ) ) {
2340 CORBA::Object_ptr ObjRef ;
2343 D.Value >>= ObjRef ;
2344 retstr = ObjectToString( ObjRef ) ;
2345 D.Value <<= retstr ;
2346 // theOutPort->Value( D.Value ) ;
2352 cdebug << "ToString( object ) Catched ERROR" << endl ;
2355 else if ( !strcmp( Type , "boolean" ) ) {
2357 D.Value <<= (CORBA::Any::from_boolean ) b ;
2358 // theOutPort->Value( D.Value ) ;
2360 else if ( !strcmp( Type , "char" ) ) {
2361 unsigned char c = 0 ;
2362 D.Value <<= (CORBA::Any::from_char ) c ;
2363 // theOutPort->Value( D.Value ) ;
2365 else if ( !strcmp( Type , "short" ) ) {
2368 // theOutPort->Value( D.Value ) ;
2370 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2373 // theOutPort->Value( D.Value ) ;
2375 else if ( !strcmp( Type , "float" ) ) {
2378 // theOutPort->Value( D.Value ) ;
2380 else if ( !strcmp( Type , "double" ) ) {
2383 // theOutPort->Value( D.Value ) ;
2385 // else if ( !strcmp( Type , "objref" ) ) {
2387 CORBA::Object_ptr obj ;
2391 retstr = ObjectToString( obj ) ;
2392 cdebug << retstr << endl ;
2398 cdebug << "ToString( object ) Catched ERROR" << endl ;
2402 // cdebug << " (other ERROR)" << endl ;
2404 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2407 cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
2411 cdebug << ThreadNo() << " In" << i << " : wrong state ERROR State "
2412 << anInPort->State() << " NameState "
2413 << Automaton()->StateName( anInPort->State() ) << " PortName "
2414 << anInPort->PortName() << " Parametername "
2415 << anInPort->GetServicesParameter().Parametername << endl ;
2418 InParametersList[i] = D ;
2422 void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
2423 ServicesAnyData * OutParametersList ) {
2425 for ( i = 0 ; i < nOutParams ; i++ ) {
2426 ServicesAnyData D = OutParametersList[i] ;
2428 D.Name = GetChangeNodeOutPort(i)->GetServicesParameter().Parametername;
2429 string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
2430 const char * Type = _Type.c_str() ;
2431 bool OutDone = GetChangeNodeOutPort(i)->Done() ;
2432 cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " Done("
2433 << OutDone << ") " << Type << " : " << endl ;
2434 if ( !strcmp( Type , "string" ) ) {
2435 D.Value <<= (char *) NULL ;
2437 else if ( !strcmp( Type , "boolean" ) ) {
2439 D.Value <<= (CORBA::Any::from_boolean ) b ;
2441 else if ( !strcmp( Type , "char" ) ) {
2442 unsigned char c = 0 ;
2443 D.Value <<= (CORBA::Any::from_char ) c ;
2445 else if ( !strcmp( Type , "short" ) ) {
2449 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2450 D.Value <<= (long ) 0 ;
2452 else if ( !strcmp( Type , "float" ) ) {
2456 else if ( !strcmp( Type , "double" ) ) {
2461 D.Value <<= CORBA::Object::_nil() ;
2464 switch (D.Value.type()->kind()) { // { string , long , double , objref }
2465 case CORBA::tk_string:
2468 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
2470 case CORBA::tk_boolean:
2472 D.Value >>= (CORBA::Any::to_boolean ) b;
2473 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
2475 case CORBA::tk_char:
2477 D.Value >>= (CORBA::Any::to_char ) c;
2478 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
2480 case CORBA::tk_short:
2483 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
2485 case CORBA::tk_long:
2488 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
2490 case CORBA::tk_float:
2493 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
2495 case CORBA::tk_double:
2498 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
2500 case CORBA::tk_objref:
2502 CORBA::Object_ptr obj ;
2505 retstr = ObjectToString( obj ) ;
2506 cdebug << ThreadNo() << retstr << endl ;
2509 cdebug << "ToString( object ) Catched ERROR" << endl ;
2513 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
2516 OutParametersList[i] = D ;
2520 bool GraphExecutor::InNode::OutParametersSet( bool Err ,
2521 SUPERV::GraphState NewState ,
2523 ServicesAnyData * OutParametersList ) {
2524 bool RetVal = true ;
2526 GraphBase::OutPort * aGateOutPort = NULL ;
2527 bool OrSwitch = false ;
2529 GraphBase::OutPort * anOutPort ;
2530 for ( i = 0 ; i < nOutParams ; i++ ) {
2531 anOutPort = GetChangeNodeOutPort(i) ;
2533 anOutPort->State( NewState ) ;
2534 anOutPort->Done( true ) ;
2537 cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
2538 << anOutPort->PortName() << " " << anOutPort->Kind() ;
2539 ServicesAnyData D = OutParametersList[i] ;
2540 switch (D.Value.type()->kind()) { // { string , long , double , objref }
2541 case CORBA::tk_string: {
2544 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
2547 case CORBA::tk_boolean: {
2549 D.Value >>= (CORBA::Any::to_boolean ) b;
2550 long l = (long ) b ;
2552 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
2555 case CORBA::tk_char: {
2557 D.Value >>= (CORBA::Any::to_char ) c;
2558 long l = (long ) c ;
2560 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
2563 case CORBA::tk_short: {
2566 long l = (long ) s ;
2568 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
2571 case CORBA::tk_long: {
2574 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
2577 case CORBA::tk_float: {
2580 double d = (double ) f ;
2582 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
2585 case CORBA::tk_double: {
2588 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
2591 case CORBA::tk_objref: {
2593 CORBA::Object_ptr obj ;
2596 retstr = ObjectToString( obj ) ;
2597 cdebug << ThreadNo() << retstr << endl ;
2600 cdebug << "ToString( object ) Catched ERROR" << endl ;
2605 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
2608 OutParametersList[i] = D ;
2609 if ( anOutPort->IsGate() ) {
2610 aGateOutPort = anOutPort ;
2611 cdebug << " Gate " ;
2613 OutParametersList[i].Value <<= l;
2614 anOutPort->Value( OutParametersList[i].Value );
2616 else if ( anOutPort->IsLoop() ) {
2617 cdebug << " Loop " ;
2618 anOutPort->Value( OutParametersList[i].Value );
2619 // InLoop Port of EndLoopNode is ready :
2620 anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
2622 else if ( anOutPort->IsSwitch() ) {
2623 cdebug << " Switch " ;
2624 anOutPort->Value( OutParametersList[i].Value );
2625 if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
2626 if ( OrSwitch && anOutPort->BoolValue() ) {
2627 cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true WARNING"
2631 OrSwitch = OrSwitch | anOutPort->BoolValue() ;
2634 cdebug << "OrSwitch " << OrSwitch ;
2637 cdebug << " Param " ;
2638 anOutPort->Value( OutParametersList[i].Value );
2640 anOutPort->State( NewState ) ;
2641 anOutPort->Done( true ) ;
2643 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
2644 bool fromGOTO = false ;
2645 GraphBase::OutPort * aGOTOPort = _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetChangeNodeInGate()->GetOutPort() ;
2647 fromGOTO = aGOTOPort->IsGOTO() ;
2649 if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
2650 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
2651 << anOutPort->ChangeInPorts( j )->PortName() << ","
2652 << anOutPort->ChangeInPorts( j )->Kind() << ") WILL BE changed from "
2653 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
2655 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
2656 << ") to " << anOutPort->NodeName() << "("
2657 << anOutPort->PortName() << ")" << endl ;
2658 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2661 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
2662 << anOutPort->ChangeInPorts( j )->PortName() << ","
2663 << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
2664 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
2666 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
2667 << ") to " << anOutPort->NodeName() << "("
2668 << anOutPort->PortName() << ")" << endl ;
2672 switch (anOutPort->Value()->type()->kind()) {
2673 case CORBA::tk_string:
2675 (*anOutPort->Value()) >>= t;
2676 cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
2678 case CORBA::tk_boolean:
2680 (*anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
2681 cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
2683 case CORBA::tk_char:
2685 (*anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
2686 cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
2688 case CORBA::tk_short:
2690 (*anOutPort->Value()) >>= s;
2691 cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
2693 case CORBA::tk_long:
2695 (*anOutPort->Value()) >>= l;
2696 cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
2698 case CORBA::tk_float:
2700 (*anOutPort->Value()) >>= f;
2701 cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
2703 case CORBA::tk_double:
2705 (*anOutPort->Value()) >>= d;
2706 cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
2708 case CORBA::tk_objref:
2709 CORBA::Object_ptr obj ;
2712 (*anOutPort->Value()) >>= obj ;
2713 retstr = ObjectToString( obj );
2714 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
2718 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
2719 << "Catched ERROR" << endl ;
2723 cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
2729 if ( aGateOutPort && IsSwitchNode() ) {
2731 // cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
2732 // << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
2734 OutParametersList[0].Value <<= l ;
2735 aGateOutPort->Value( OutParametersList[0].Value ) ;
2738 // cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
2739 // << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
2741 OutParametersList[0].Value <<= l ;
2742 aGateOutPort->Value( OutParametersList[0].Value ) ;
2744 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
2745 GraphBase::InPort * anInPort ;
2746 anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
2748 anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;