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 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " << anInPort->PortName() << endl ;
784 if ( anInPort->IsGate() && anOutPort == NULL ) {
786 anInPort->State( SUPERV::ReadyState ) ;
787 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
788 << anInPort->PortName() << " ControlPort inactive." << endl ;
790 else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
791 if ( anInPort->State() == SUPERV::ReadyState ) {
793 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
794 << anInPort->PortName() << " Was Done from "
795 << anOutPort->NodeName() << " " << anOutPort->PortName()
798 if ( GraphBase::Base::_prof_debug ) {
799 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
804 else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
805 anInPort->State( SUPERV::ReadyState ) ;
807 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
808 << anInPort->PortName() << " Was Done from "
809 << anOutPort->NodeName() << " " << anOutPort->PortName()
810 << " LoopBeginning " << LoopBeginning ;
812 if ( GraphBase::Base::_prof_debug ) {
813 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
818 else if ( LoopFinished ) {
819 anInPort->State( SUPERV::ReadyState ) ;
821 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
822 << anInPort->PortName() << " Was Done from "
823 << anOutPort->NodeName() << " " << anOutPort->PortName()
826 if ( GraphBase::Base::_prof_debug ) {
827 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
832 else if ( anInPort->IsGate() && SwitchFinished ) {
833 anInPort->State( SUPERV::ReadyState ) ;
835 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
836 << anInPort->PortName() << " Was Done from "
837 << anOutPort->NodeName() << " " << anOutPort->PortName()
838 << " SwitchFinished" ;
840 if ( GraphBase::Base::_prof_debug ) {
841 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
847 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
848 << anInPort->PortName() << " Was NOT Done from "
849 << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
850 << " " << Automaton()->StateName( State() ) << " DataConnected "
851 << anInPort->IsDataConnected() << " LoopBeginning "
852 << LoopBeginning << endl ;
855 else if ( anInPort->IsGate() ) {
856 const CORBA::Any * theValue = anOutPort->Value() ;
858 (*theValue) >>= GateOpened ;
859 if ( GateOpened != 0 ) {
861 anInPort->State( SUPERV::ReadyState ) ;
862 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
863 << anInPort->PortName() << " Gate is Opened from "
864 << anOutPort->NodeName() << " " << anOutPort->PortName()
867 if ( GraphBase::Base::_prof_debug ) {
868 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
873 else if ( LoopFinished ) {
874 anInPort->State( SUPERV::ReadyState ) ;
875 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
876 << anInPort->PortName() << " GATE IS CLOSED from "
877 << anOutPort->NodeName() << " " << anOutPort->PortName()
880 if ( GraphBase::Base::_prof_debug ) {
881 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
887 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
888 << anInPort->PortName() << " GATE IS CLOSED from "
889 << anOutPort->NodeName() << " " << anOutPort->PortName()
892 if ( GraphBase::Base::_prof_debug ) {
893 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
901 anInPort->State( SUPERV::ReadyState ) ;
902 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
903 << anInPort->PortName() << " is Done from "
904 << anOutPort->NodeName() << " " << anOutPort->PortName() << " " ;
906 if ( GraphBase::Base::_prof_debug ) {
907 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
914 if ( InReady == GetNodeInPortsSize() ) { // All Flags != 0 :
915 res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
917 else { // At least one Flag == 0 :
918 res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
921 cdebug << pthread_self() << "/" << ThreadNo()
922 << " <-- DataWaiting_SomeDataReadyAction " << Name() << endl;
927 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
928 CreateNewThreadIf( false ) ;
929 // cdebug << pthread_self() << " for " << ThreadNo()
930 // << " DataUndef_NotAllDataReadyAction " << Name() << endl;
934 int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
935 // cdebug << pthread_self() << "/" << ThreadNo()
936 // << " --> DataUndef_AllDataReadyAction " << Name()
937 // << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
938 // << IsLockedDataWait() ;
939 if ( IsLockedDataWait() ) {
940 // cdebug << " WOULD DEAD-LOCK" << endl ;
941 return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
944 CreateNewThread( CreateNewThreadIf() ) ;
945 if ( !CreateNewThread() ) {
946 // cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
947 ThreadNo( pthread_self() ) ;
949 _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
950 SUPERV::DataReadyState ) ;
952 SUPERV::ControlState aControl = ControlState() ;
953 switch ( aControl ) {
954 case SUPERV::VoidState : {
955 SendEvent( GraphExecutor::ExecuteEvent ) ;
958 case SUPERV::ToSuspendState : {
959 SendEvent( GraphExecutor::SuspendEvent ) ;
962 case SUPERV::ToSuspendStartState : {
963 SendEvent( GraphExecutor::SuspendEvent ) ;
966 case SUPERV::ToSuspendDoneState : {
967 SendEvent( GraphExecutor::ExecuteEvent ) ;
970 case SUPERV::ToKillState : {
971 SendEvent( GraphExecutor::KillEvent ) ;
974 case SUPERV::ToKillDoneState : {
975 SendEvent( GraphExecutor::ExecuteEvent ) ;
978 case SUPERV::ToStopState : {
979 SendEvent( GraphExecutor::StopEvent ) ;
984 << " GraphExecutor::InNodeThreads::DataUndef_AllDataReadyAction Error Undefined Control : "
985 << aControl << endl ;
989 // cdebug << pthread_self() << "/" << ThreadNo()
990 // << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
994 int GraphExecutor::InNode::DataReady_SuspendAction() {
995 cdebug << pthread_self() << "/" << ThreadNo()
996 << "DataReady_SuspendAction --> Suspend " << Name()
997 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
998 << _OutNode->SuspendedThreads() << endl;
999 _OutNode->PushEvent( this , GraphExecutor::SuspendedReadyEvent ,
1000 SUPERV::SuspendedReadyState ) ;
1001 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1002 cdebug << pthread_self() << "/" << ThreadNo()
1003 << "DataReady_SuspendAction Resumed " << Name() << endl;
1004 if ( aReStartNode ) {
1005 _aReStartNode = NULL ;
1006 aReStartNode->SendEvent( _aReStartEvent ) ;
1009 SendEvent( GraphExecutor::ExecuteEvent ) ;
1014 int GraphExecutor::InNode::SuspendedReady_ResumeAction() {
1015 cdebug << pthread_self() << "/" << ThreadNo() << "SuspendedReady_ResumeAction "
1018 _OutNode->PushEvent( this , GraphExecutor::ResumedReadyEvent ,
1019 SUPERV::ResumedReadyState ) ;
1023 int GraphExecutor::InNode::DataReady_KillAction() {
1024 _OutNode->PushEvent( this , GraphExecutor::KilledReadyEvent ,
1025 SUPERV::KilledReadyState ) ;
1027 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_KillAction " << Name()
1028 << " will pthread_exit()" << endl;
1032 int GraphExecutor::InNode::DataReady_StopAction() {
1033 _OutNode->PushEvent( this , GraphExecutor::StoppedReadyEvent ,
1034 SUPERV::StoppedReadyState ) ;
1036 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_StopAction " << Name()
1037 << " will pthread_exit()" << endl;
1043 int GraphExecutor::InNode::DataReady_ExecuteAction() {
1046 // cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
1047 // << Name() << endl;
1048 _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
1049 SUPERV::ExecutingState ) ;
1052 SUPERV::GraphState PortState = SUPERV::ReadyState ;
1053 SUPERV::AutomatonState NewState = SUPERV::DataUndefState ;
1054 GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
1058 int nInParams = GetNodeInPortsSize() ;
1059 ServicesAnyData * InParametersList = new ServicesAnyData[nInParams];
1060 InParametersSet( Err , nInParams , InParametersList ) ;
1062 Engines::Container_var myContainer ;
1063 Engines::Component_var myObjComponent ;
1064 if ( !IsFactoryNode() ) {
1065 // cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
1066 if ( IsComputingNode() ) {
1067 ObjInterface( true ) ;
1068 CORBA::Object_ptr obj ;
1069 InParametersList[0].Value >>= obj ;
1070 CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
1071 myObjComponent = Engines::Component::_narrow( objvar ) ;
1076 else if ( CORBA::is_nil( Component() ) ) {
1077 ostringstream astr ;
1078 astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name()
1079 << " : load of component " << ComponentName() << " in container "
1081 _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1082 Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() ,
1083 my_strdup( ComponentName() ) ,
1084 myContainer , myObjComponent ) ;
1085 ObjInterface( false ) ;
1086 SetContainer( myContainer ) ;
1087 SetComponent( myObjComponent ) ;
1090 myContainer = Container() ;
1091 myObjComponent = Component() ;
1092 // cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
1094 myObjComponent->ping() ;
1097 int nOutParams = GetNodeOutPortsSize() ;
1098 ServicesAnyData * OutParametersList = new ServicesAnyData[nOutParams];
1099 InOutParametersSet( nOutParams , OutParametersList ) ;
1101 if ( Err || ControlState() == SUPERV::ToKillState ||
1102 ControlState() == SUPERV::ToKillDoneState ||
1103 ControlState() == SUPERV::ToStopState ) {
1104 cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
1109 ostringstream astr ;
1110 astr << "Graph " << _OutNode->Graph()->Name() << " Run of Node " << Name() ;
1111 _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1112 cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
1113 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1114 cdebug << " , " << InParametersList[ i ].Name << "[kind"
1115 << InParametersList[ i ].Value.type()->kind() << "]" ;
1117 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1118 cdebug << " , " << OutParametersList[ i ].Name << "[kind"
1119 << OutParametersList[ i ].Value.type()->kind() << "]" ;
1121 if ( IsOneOfInLineNodes() ) {
1122 cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
1123 << InLineNode()->PyRunMethod() << " length " << (*InLineNode()->PythonFunction()).length() ;
1125 cdebug << ")" << endl ;
1127 if ( IsOneOfInLineNodes() ) {
1128 bool StsPyDynInvoke = true;
1129 _OutNode->PyThreadLock() ;
1132 // if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
1133 bool CopyInOut = false ;
1134 if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
1135 strlen( InLineNode()->PyFuncName() ) ) {
1136 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1137 // << InLineNode()->PyFuncName()
1138 // << "' IsInLineNode PyDynInvoke" << endl ;
1139 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1140 InLineNode()->PyFuncName() ,
1141 &InParametersList[0] , ServiceInParameter().length() ,
1142 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1144 else if ( IsLoopNode() ) {
1145 bool CopyOutIn = false ;
1146 if ( GetNodeInLoop()->GetOutPort()->BoolValue() && /*InLineNode()->PyRunMethod() &&*/
1147 strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port
1148 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1149 // << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
1151 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1152 InLineNode()->PyFuncName() ,
1153 &InParametersList[1] , ServiceInParameter().length() ,
1154 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1157 else if ( LoopNode()->PyNextMethod() &&
1158 strlen( LoopNode()->PyNextName() ) ){
1159 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1160 // << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
1162 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
1163 LoopNode()->PyNextName() ,
1164 &InParametersList[1] , ServiceInParameter().length() ,
1165 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1168 if ( StsPyDynInvoke && CopyOutIn ) {
1169 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1170 // << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
1171 // << "' Copy of " << ServiceInParameter().length()
1172 // << " OutParameters" << endl ;
1174 for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
1175 InParametersList[i].Value = OutParametersList[i].Value ;
1176 InParametersList[i].Name = OutParametersList[i].Name ;
1178 switch ( InParametersList[i].Value.type()->kind() ) {
1179 case CORBA::tk_string :
1181 InParametersList[i].Value >>= t ;
1182 cdebug << "ArgOut->In" << i << " : "
1183 << InParametersList[i].Name.c_str()
1184 << " Value(string) " << t << endl ;
1186 case CORBA::tk_double :
1188 InParametersList[i].Value >>= d;
1189 cdebug << "ArgOut->In" << i << " : "
1190 << InParametersList[i].Name.c_str()
1191 << " Value(double) " << d << endl ;
1193 case CORBA::tk_long :
1195 InParametersList[i].Value >>= l;
1196 cdebug << "ArgOut->In" << i << " : "
1197 << InParametersList[i].Name.c_str()
1198 << " Value(long) " << l << endl ;
1200 case CORBA::tk_objref :
1201 CORBA::Object_ptr obj ;
1204 InParametersList[i].Value >>= obj ;
1205 retstr = ObjectToString( obj );
1206 cdebug << "ArgOut->In" << i << " : "
1207 << InParametersList[i].Name.c_str()
1208 << " Value(object reference) " << retstr << endl ;
1211 cdebug << "ArgOut->In" << i << " : "
1212 << InParametersList[i].Name.c_str()
1213 << " Value(object reference) Catched ERROR" << endl ;
1217 cdebug << "ArgOut->In" << i << " : "
1218 << InParametersList[i].Name.c_str()
1219 << " Value(other) ERROR" << endl ;
1223 if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
1224 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
1225 LoopNode()->PyMoreName() ,
1226 &InParametersList[1] , ServiceInParameter().length() ,
1227 &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
1233 else if ( !StsPyDynInvoke ) {
1235 cdebug << ThreadNo() << " InLineNode " << Name() << " "
1236 << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
1237 << " Python Dynamic Call Error"
1241 else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
1242 strlen( InLineNode()->PyFuncName() ) ) {
1243 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1244 // << InLineNode()->PyFuncName()
1245 // << "' IsSwitchNode PyDynInvoke" << endl ;
1246 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1247 InLineNode()->PyFuncName() ,
1248 &InParametersList[0] , ServiceInParameter().length() ,
1249 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1251 // else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
1252 else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
1253 strlen( InLineNode()->PyFuncName() ) ) {
1254 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1255 // << InLineNode()->PyFuncName()
1256 // << "' IsGOTONode PyDynInvoke" << endl ;
1257 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1258 InLineNode()->PyFuncName() ,
1259 &InParametersList[0] , ServiceInParameter().length() ,
1260 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1262 // else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
1263 else if ( ( IsEndSwitchNode() ) &&
1264 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1265 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1266 // << InLineNode()->PyFuncName()
1267 // << "' IsSwitchNode PyDynInvoke" << endl ;
1268 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1269 InLineNode()->PyFuncName() ,
1270 &InParametersList[0] , ServiceInParameter().length() ,
1271 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1273 else if ( ( IsEndLoopNode() ) &&
1274 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1275 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1276 // << InLineNode()->PyFuncName()
1277 // << "' IsSwitchNode PyDynInvoke" << endl ;
1278 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1279 InLineNode()->PyFuncName() ,
1280 &InParametersList[0] , ServiceInParameter().length() + 1 ,
1281 &OutParametersList[0] , ServiceOutParameter().length() + 1 ) ;
1283 // else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
1284 if ( InLineNode()->PyRunMethod() == NULL ||
1285 strlen( InLineNode()->PyFuncName() ) == 0 || CopyInOut ) {
1286 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1287 // << " Copy of " << ServiceInParameter().length()
1288 // << " OutParameters" << endl ;
1292 if ( IsLoopNode() || IsEndLoopNode() ) {
1294 argin0 = 1 ; // after DoLoop
1295 if ( IsLoopNode() ) {
1296 OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
1299 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1300 OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
1302 switch ( InParametersList[argin0 + i].Value.type()->kind() ) {
1303 case CORBA::tk_string :
1304 cdebug << "ArgOut->In" << argin0 + i << " : "
1305 << InParametersList[argin0 + i].Name.c_str()
1306 << " Value(string) "
1307 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1309 case CORBA::tk_double :
1310 cdebug << "ArgOut->In" << argin0 + i << " : "
1311 << InParametersList[argin0 + i].Name.c_str()
1312 << " Value(double) "
1313 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1315 case CORBA::tk_long :
1316 cdebug << "ArgOut->In" << argin0 + i << " : "
1317 << InParametersList[argin0 + i].Name.c_str()
1319 << OutParametersList[argout0 + i ].Name.c_str() << endl ;
1321 case CORBA::tk_objref :
1322 cdebug << "ArgOut->In" << argin0 + i << " : "
1323 << InParametersList[argin0 + i].Name.c_str()
1324 << " Value(object reference) "
1325 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1328 cdebug << "ArgOut->In" << argin0 + i << " : "
1329 << InParametersList[argin0 + i].Name.c_str()
1330 << " Value(other) ERROR "
1331 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1336 if ( !StsPyDynInvoke ) {
1338 cdebug << ThreadNo() << " InLineNode " << Name()
1339 << " Python Dynamic Call Error"
1345 cdebug << ThreadNo() << " InLineNode " << Name()
1346 << " Python Dynamic Call Exception catched ERROR"
1350 _OutNode->PyThreadUnLock() ;
1355 cdebug << "DynInvoke -> Names " << _OutNode->Graph()->Name() << " " << Name() << endl ;
1356 DynInvoke( myObjComponent, "Names" ,
1357 _OutNode->Graph()->Name() , Name() ) ;
1360 cdebug << "DynInvoke Names catched ERROR" << endl ;
1362 if ( IsComputingNode() ) {
1363 cdebug << ThreadNo() << " !ObjInterface " << Name()
1364 << " IsComputingNode DynInvoke" << endl ;
1365 cdebug << ServiceInParameter().length()-1 << " input parameters and "
1366 << ServiceOutParameter().length() << " output parameters" << endl ;
1367 DynInvoke( myObjComponent,
1369 &InParametersList[1] , ServiceInParameter().length()-1 ,
1370 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1372 else if ( IsFactoryNode() ) {
1373 cdebug << ThreadNo() << " !ObjInterface " << Name()
1374 << " IsFactoryNode DynInvoke" << endl ;
1375 cdebug << ServiceInParameter().length() << " input parameters and "
1376 << ServiceOutParameter().length() << " output parameters" << endl ;
1377 DynInvoke( myObjComponent,
1379 &InParametersList[0] , ServiceInParameter().length() ,
1380 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1382 // cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
1383 // << myObjComponent->CpuUsed_impl() << endl ;
1387 cdebug << ThreadNo() << " !ObjInterface " << Name()
1388 << " Node(Component) Dynamic Call Exception catched ERROR"
1399 ostringstream astr ;
1400 astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() << " is done : "
1401 << Automaton()->StateName( State() ) ;
1402 _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1404 if ( ControlState() == SUPERV::ToKillState ||
1405 ControlState() == SUPERV::ToKillDoneState ||
1406 ControlState() == SUPERV::ToStopState ) {
1407 PortState = SUPERV::ErrorState ;
1408 NewState = SUPERV::KilledState ;
1409 NewEvent = GraphExecutor::KillEvent ;
1412 PortState = SUPERV::ErrorState ;
1413 NewState = SUPERV::ErroredState ;
1414 NewEvent = GraphExecutor::ErrorEvent ;
1418 PortState = SUPERV::ReadyState ;
1419 NewState = SUPERV::DataReadyState ;
1420 NewEvent = GraphExecutor::SuccessEvent ;
1423 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1426 NewEvent = GraphExecutor::ErrorEvent ;
1429 delete [] InParametersList ;
1430 delete [] OutParametersList ;
1433 SendEvent( NewEvent );
1435 // cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
1439 int GraphExecutor::InNode::Executing_SuspendAction() {
1440 _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
1441 SUPERV::SuspendedExecutingState ) ;
1442 cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
1446 int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
1447 cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
1448 SUPERV::AutomatonState next_state ;
1449 next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
1450 _OutNode->NewThread() ; // Only for Threads count
1451 _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
1453 State( next_state ) ;
1457 int GraphExecutor::InNode::Executing_KillAction() {
1458 cdebug << ThreadNo() << " Executing_KillAction " << Name() << endl;
1460 if ( pthread_self() == ThreadNo() ) {
1461 cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
1463 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
1464 SUPERV::KilledExecutingState ) ;
1467 else if ( pthread_cancel( ThreadNo() ) ) {
1468 perror("Executing_KillAction pthread_cancel error") ;
1471 cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
1472 << " pthread_canceled" << endl ;
1474 _OutNode->ExitThread() ;
1475 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
1476 SUPERV::KilledExecutingState ) ;
1481 int GraphExecutor::InNode::Executing_StopAction() {
1482 cdebug << ThreadNo() << " Executing_StopAction " << Name() << endl;
1484 if ( pthread_cancel( ThreadNo() ) ) {
1485 perror("Executing_KillAction pthread_cancel error") ;
1488 cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
1489 << " pthread_canceled" << endl ;
1491 _OutNode->ExitThread() ;
1492 _OutNode->PushEvent( this , GraphExecutor::StoppedExecutingEvent ,
1493 SUPERV::StoppedExecutingState ) ;
1498 int GraphExecutor::InNode::Executing_SuccessAction() {
1499 // cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
1500 _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
1501 SUPERV::SuccessedState ) ;
1502 SUPERV::ControlState aControl = ControlState() ;
1503 switch ( aControl ) {
1504 case SUPERV::VoidState : {
1505 SendEvent( SuccessEvent ) ;
1508 case SUPERV::ToSuspendState : {
1509 SendEvent( SuccessEvent ) ;
1512 case SUPERV::ToSuspendDoneState : {
1513 SendEvent( GraphExecutor::SuspendEvent ) ;
1516 case SUPERV::ToKillState : {
1517 SendEvent( GraphExecutor::KillEvent ) ;
1520 case SUPERV::ToKillDoneState : {
1521 SendEvent( GraphExecutor::KillEvent ) ;
1524 case SUPERV::ToStopState : {
1525 SendEvent( GraphExecutor::StopEvent ) ;
1529 cdebug << ThreadNo()
1530 << " GraphExecutor::InNodeThreads::Executing_SuccessAction Error Undefined Control : "
1531 << aControl << endl ;
1535 // cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
1539 int GraphExecutor::InNode::Executing_ErrorAction() {
1540 cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
1541 _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
1542 SUPERV::ErroredState ) ;
1544 SUPERV::ControlState aControl = ControlState() ;
1545 switch ( aControl ) {
1546 case SUPERV::VoidState : {
1547 SendEvent( ErrorEvent ) ;
1550 case SUPERV::ToSuspendState : {
1551 SendEvent( ErrorEvent ) ;
1554 case SUPERV::ToSuspendDoneState : {
1555 SendEvent( GraphExecutor::SuspendEvent ) ;
1558 case SUPERV::ToKillState : {
1559 SendEvent( GraphExecutor::KillEvent ) ;
1562 case SUPERV::ToKillDoneState : {
1563 SendEvent( GraphExecutor::KillEvent ) ;
1566 case SUPERV::ToStopState : {
1567 SendEvent( GraphExecutor::StopEvent ) ;
1571 cdebug << ThreadNo()
1572 << " GraphExecutor::InNodeThreads::Executing_ErrorAction Error Undefined Control : "
1573 << aControl << endl ;
1577 cdebug << ThreadNo() << " <-- Executing_ErrorAction " << Name() << endl;
1581 // Set SUPERV::WaitingState to all InPorts
1582 void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
1585 bool docdebug = false ;
1586 State( SUPERV::DataWaitingState ) ;
1587 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1588 GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
1589 if ( anInPort->IsGate() ) { // Loop : Open the doors
1590 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1592 CORBA::Any * anAny = new CORBA::Any() ;
1593 *anAny <<= (long ) 1 ;
1594 anOutPort->Value( anAny ) ;
1595 anInPort->State( SUPERV::ReadyState ) ;
1598 else if ( anInPort->State() != SUPERV::WaitingState ) {
1600 // cdebug << ThreadNo()
1601 // << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
1604 if ( !anInPort->IsDataStream() ) {
1605 anInPort->State( SUPERV::WaitingState ) ;
1609 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1610 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
1611 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
1612 if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
1613 !( IsEndLoopNode() && ( anOutPort->IsGate() ||
1614 anOutPort->IsLoop() ) ) &&
1615 !anOutPort->IsDataStream() &&
1616 !anOutPort->ChangeInPorts( j )->IsDataStream() ) {
1617 // cdebug << ThreadNo()
1618 // << " GraphExecutor::InNodeThreads::SetWaitingStates "
1619 // << Name() << "( " << anOutPort->PortName() << " ) --> InPort "
1620 // << anOutPort->ChangeInPorts( j )->PortName() << " from Node "
1621 // << anOutPort->ChangeInPorts( j )->NodeName() << endl;
1622 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ;
1623 if ( aNode != EndNode ) {
1624 aNode->SetWaitingStates( EndNode ) ;
1631 int GraphExecutor::InNode::Successed_SuccessAction() {
1632 // cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
1634 int linkednodesnumber = LinkedNodesSize() ;
1635 GraphExecutor::InNode *firstzeroNode = NULL ;
1636 GraphExecutor::InNode *firsttoNode = NULL ;
1637 GraphExecutor::InNode *toNode ;
1640 list<GraphExecutor::InNode *> SomeDataNodes ;
1644 if ( IsGOTONode() ||
1645 ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
1646 cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
1647 << " SetWaitingStates " << endl ;
1648 const GraphBase::OutPort * aGateOutPort ;
1649 if ( IsGOTONode() ) {
1650 aGateOutPort = GetNodeOutGate() ;
1653 aGateOutPort = GetNodeOutLoop() ;
1655 for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
1656 const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
1657 GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
1658 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
1659 // << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
1660 aLabelNode->SetWaitingStates( this ) ;
1661 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
1662 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
1663 if ( anInPort->GetOutPort() ) {
1664 // cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
1665 // << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
1669 for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
1670 GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
1671 if ( !aBusParamOutPort->IsGate() ) {
1672 GraphBase::InPort * aBusParamChangeInPort = NULL ;
1673 if ( aBusParamOutPort->IsLoop() ) {
1674 aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
1677 aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
1679 if ( aBusParamChangeInPort ) {
1680 aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
1681 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
1682 // << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
1683 // << aBusParamOutPort->PortName() << endl ;
1684 if ( !aLabelNode->IsLockedDataWait() ) {
1685 res = aLabelNode->SendSomeDataReady( Name() ) ;
1687 if ( firsttoNode == NULL &&
1688 aLabelNode->ThreadNo() == pthread_self() ) {
1689 firsttoNode = aLabelNode ;
1690 // cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
1691 // << aLabelNode->Name() << endl ;
1693 else if ( firstzeroNode == NULL &&
1694 aLabelNode->ThreadNo() == 0 ) {
1695 firstzeroNode = aLabelNode ;
1698 SomeDataNodes.push_back( aLabelNode ) ;
1699 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1700 // << aLabelNode->Name() << " " << SomeDataNodes.size()
1706 // cdebug << ThreadNo()
1707 // << " Successed_SuccessAction Loop to HeadNode "
1708 // << aLabelNode->Name() << " with datas from " << Name() << "("
1709 // << aBusParamOutPort->PortName() << ") to port "
1710 // << aBusParamChangeInPort->PortName() << endl;
1714 // cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
1715 // << " NO port " << aBusParamOutPort->PortName() << " in "
1716 // << aLabelNode->Name() << endl;
1720 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
1721 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
1722 if ( anInPort->GetOutPort() ) {
1723 // cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
1724 // << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
1728 const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
1729 if ( aGateInPort ) {
1730 if ( aGateInPort->GetOutPort() ) {
1731 aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
1733 if ( !aLabelNode->IsLockedDataWait() ) {
1734 res = aLabelNode->SendSomeDataReady( Name() ) ;
1736 if ( firsttoNode == NULL &&
1737 aLabelNode->ThreadNo() == pthread_self() ) {
1738 firsttoNode = aLabelNode ;
1739 // cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
1740 // << aLabelNode->Name() << endl ;
1742 else if ( firstzeroNode == NULL &&
1743 aLabelNode->ThreadNo() == 0 ) {
1744 firstzeroNode = aLabelNode ;
1747 SomeDataNodes.push_back( aLabelNode ) ;
1748 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1749 // << aLabelNode->Name() << " " << SomeDataNodes.size()
1756 cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
1757 << " NO port " << aGateOutPort->PortName() << " in "
1758 << aLabelNode->Name() << endl;
1764 // cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
1765 // << " with " << LinkedNodesSize() << " linked nodes :" ;
1766 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
1767 if ( LinkedNodes( i )->IsDataFlowNode() ) {
1768 linkednodesnumber -= 1 ;
1770 // cdebug << " " << LinkedNodes( i )->Name() ;
1773 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
1774 bool IgnoreForEndLoop = false ;
1775 GraphBase::ComputingNode * aComputingNode ;
1776 aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
1777 toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
1778 // cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
1779 // << " [" << i << "] " << LinkedNodes( i )->Name() << endl ;
1780 if ( toNode && !toNode->IsDataFlowNode() ) {
1781 if ( IsComputingNode() && toNode->IsInLineNode() ) {
1782 GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
1783 toGateInPort->State( SUPERV::ReadyState ) ;
1784 GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
1785 if ( GateOutPort ) {
1786 GateOutPort->PortStatus( DataConnected );
1787 GateOutPort->State( SUPERV::ReadyState ) ;
1788 GateOutPort->Done( true ) ;
1792 if ( toNode && IsLoopNode() ) {
1793 GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
1794 if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
1795 if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
1796 IgnoreForEndLoop = true ;
1798 else { // toNode is the EndLoopNode
1799 GraphBase::InPort * toLoopInPort ;
1800 toLoopInPort = toNode->GetChangeNodeInLoop() ;
1801 if ( toLoopInPort->State() != SUPERV::ReadyState ) {
1802 toLoopInPort->State( SUPERV::ReadyState ) ;
1807 else if ( toNode && IsSwitchNode() ) {
1809 else if ( toNode && toNode->IsInLineNode() ) {
1811 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
1812 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
1815 if ( toNode && !IgnoreForEndLoop ) {
1816 if ( toNode && toNode->IsLoopNode() ) {
1817 GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
1818 toLoopInPort->State( SUPERV::ReadyState ) ;
1819 GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
1820 LoopOutPort->PortStatus( DataConnected );
1821 LoopOutPort->State( SUPERV::ReadyState ) ;
1822 LoopOutPort->Done( true ) ;
1823 CORBA::Any * anAny = new CORBA::Any() ;
1824 *anAny <<= (long ) 1 ;
1825 LoopOutPort->Value( anAny ) ;
1827 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
1828 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
1831 res = toNode->SendSomeDataReady( Name() ) ;
1833 if ( firsttoNode == NULL &&
1834 toNode->ThreadNo() == pthread_self() ) {
1835 firsttoNode = toNode ;
1836 // cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
1837 // << toNode->Name() << endl ;
1839 else if ( firstzeroNode == NULL &&
1840 toNode->ThreadNo() == 0 ) {
1841 firstzeroNode = toNode ;
1844 SomeDataNodes.push_back( toNode ) ;
1845 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1846 // << toNode->Name() << " " << SomeDataNodes.size() << endl ;
1853 if ( firsttoNode == NULL && firstzeroNode ) {
1854 firsttoNode = firstzeroNode ;
1855 // cdebug << ThreadNo()
1856 // << " Successed_SuccessAction firsttoNode = firstzeroNode "
1859 else if ( firsttoNode && firstzeroNode ) {
1860 SomeDataNodes.push_back( firstzeroNode ) ;
1861 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode "
1862 // << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ;
1865 while ( SomeDataNodes.size() ) {
1866 GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
1867 SomeDataNodes.pop_front() ;
1868 // cdebug << pthread_self() << "/" << ThreadNo()
1869 // << " Successed_SuccessAction pop "
1870 // << SomeDataNodes.size() << " " << aNode->Name() << endl ;
1871 if ( aNode->State() == SUPERV::DataReadyState ) {
1872 aNode->CreateNewThreadIf( true ) ;
1873 aNode->UnLockDataWait() ;
1874 res = aNode->DataUndef_AllDataReadyAction() ;
1877 // cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
1878 // << aNode->Name() << " "
1879 // << Automaton()->StateName( aNode->State() ) << endl ;
1883 if ( firsttoNode ) {
1884 // cdebug << pthread_self() << "/" << ThreadNo()
1885 // << " Successed_SuccessAction start firsttoNode "
1886 // << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
1887 firsttoNode->CreateNewThreadIf( false ) ;
1888 firsttoNode->RewindStack( RewindStack() ) ;
1889 if ( firsttoNode->State() == SUPERV::SuccessedState ) {
1890 // cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
1891 // << " : " << firsttoNode->Name() << " "
1892 // << Automaton()->StateName( firsttoNode->State() )
1893 // << " --> DataWaitingState for Thread "
1894 // << firsttoNode->ThreadNo() << endl ;
1895 firsttoNode->State( SUPERV::DataWaitingState ) ;
1897 // pthread_t OldT = firsttoNode->ThreadNo() ;
1898 firsttoNode->ThreadNo( pthread_self() ) ;
1899 // On continue avec le meme thread
1900 // cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
1901 // << firsttoNode->Name() << "Thread(" << OldT << "-->"
1902 // << firsttoNode->ThreadNo() << ")" << endl ;
1904 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
1905 // << " for " << firsttoNode->Name()
1906 // << " !firsttoNode->CreateNewThreadIf() "
1907 // << !firsttoNode->CreateNewThreadIf()
1908 // << " " << Automaton()->StateName( firsttoNode->State() ) ;
1909 if ( firsttoNode->State() == SUPERV::DataReadyState ) {
1911 firsttoNode->UnLockDataWait() ;
1912 res = firsttoNode->DataUndef_AllDataReadyAction() ;
1915 cdebug << " ERROR " << endl ;
1919 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
1920 // << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
1924 // if ( linkednodesnumber == 0 && firsttoNode == NULL ) {
1925 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodesSize " << LinkedNodesSize()
1926 // << " firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << " CHECK" << endl ;
1927 // _OutNode->CheckAllDone() ;
1930 // cdebug << pthread_self() << "/" << ThreadNo()
1931 // << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
1932 // << linkednodesnumber << endl;
1936 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
1937 bool RetVal = false ;
1938 if ( IsDataFlowNode() ) {
1939 // cdebug << ThreadNo() << " ----> " << Name()
1940 // << " send Result to graph " << Name() << endl;
1943 // cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
1944 // << " send SomeDataReady to " << Name() << " "
1945 // << Automaton()->StateName( State() )
1946 // << " CreateNewThreadIf() " << CreateNewThreadIf()
1947 // << " LockedDataWait " << IsLockedDataWait() << endl;
1949 cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
1950 << " send SomeDataReady to " << Name() << " "
1951 << Automaton()->StateName( State() )
1952 << " CreateNewThreadIf() " << CreateNewThreadIf()
1953 << " LockedDataWait " << IsLockedDataWait() << endl;
1955 if ( State() == SUPERV::SuccessedState ||
1956 State() == SUPERV::SuspendedSuccessedState ||
1957 State() == SUPERV::SuspendedSuccessedToReStartState ) {
1958 // cdebug << ThreadNo() << " " << FromNodeName
1959 // << " : " << Name() << " " << Automaton()->StateName( State() )
1960 // << " --> DataWaitingState for Thread "
1961 // << ThreadNo() << " " << endl ;
1962 State( SUPERV::DataWaitingState ) ;
1965 DataFromNode( FromNodeName ) ;
1966 RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
1974 int GraphExecutor::InNode::Errored_ErrorAction() {
1975 cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
1976 << " will pthread_exit" << endl;
1981 int GraphExecutor::InNode::Successed_SuspendAction() {
1982 cdebug << ThreadNo() << " Successed_SuspendAction -->Suspend " << Name()
1983 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
1984 << _OutNode->SuspendedThreads() << endl;
1985 _OutNode->PushEvent( this , GraphExecutor::SuspendedSuccessedEvent ,
1986 SUPERV::SuspendedSuccessedState ) ;
1988 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1989 cdebug << ThreadNo() << " Successed_SuspendAction Resumed " << Name() ;
1990 if ( aReStartNode ) {
1991 _aReStartNode = NULL ;
1992 cdebug << " for " << aReStartNode->Name() << endl;
1993 aReStartNode->SendEvent( _aReStartEvent ) ;
1997 SendEvent( GraphExecutor::ResumeEvent ) ;
2002 int GraphExecutor::InNode::Errored_SuspendAction() {
2003 cdebug << ThreadNo() << " Errored_SuspendAction -->Suspend " << Name()
2004 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
2005 << _OutNode->SuspendedThreads() << endl;
2006 _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
2007 SUPERV::SuspendedErroredState ) ;
2009 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
2010 cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
2012 if ( aReStartNode ) {
2013 _aReStartNode = NULL ;
2014 aReStartNode->SendEvent( _aReStartEvent ) ;
2017 SendEvent( GraphExecutor::ResumeEvent ) ;
2022 int GraphExecutor::InNode::SuspendedSuccessed_ResumeAction() {
2023 cdebug << ThreadNo() << " SuspendedSuccessed_ResumeAction " << Name() << endl;
2025 _OutNode->PushEvent( this , GraphExecutor::ResumedSuccessedEvent ,
2026 SUPERV::ResumedSuccessedState ) ;
2027 SendEvent( ResumedSuccessedEvent ) ;
2031 int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
2032 cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
2034 _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
2035 SUPERV::ResumedErroredState ) ;
2036 SendEvent( ResumedErroredEvent ) ;
2040 int GraphExecutor::InNode::Successed_KillAction() {
2042 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2043 SUPERV::KilledSuccessedState ) ;
2044 cdebug << ThreadNo() << " Successed_KillAction " << Name() << endl;
2048 int GraphExecutor::InNode::Errored_KillAction() {
2050 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2051 SUPERV::KilledErroredState ) ;
2052 cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
2056 int GraphExecutor::InNode::Successed_StopAction() {
2058 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2059 SUPERV::StoppedSuccessedState ) ;
2060 cdebug << ThreadNo() << " Successed_StopAction " << Name() << endl;
2064 int GraphExecutor::InNode::Errored_StopAction() {
2066 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2067 SUPERV::StoppedErroredState ) ;
2068 cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
2072 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
2073 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2074 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2075 SUPERV::ReStartedState ) ;
2077 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2078 GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
2080 SendEvent( ExecuteEvent ) ;
2081 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2085 int GraphExecutor::InNode::SuspendedErrored_ReStartAction() {
2086 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2087 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2088 SUPERV::ReStartedState ) ;
2090 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2091 GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
2093 SendEvent( ExecuteEvent ) ;
2094 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2098 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAndSuspendAction() {
2099 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2101 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2102 SUPERV::ReStartedState ) ;
2103 State( SUPERV::DataWaitingState ) ;
2105 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2108 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2109 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2113 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2118 int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
2119 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2121 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2122 SUPERV::ReStartedState ) ;
2123 State( SUPERV::DataWaitingState ) ;
2125 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2128 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2129 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2133 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2138 void GraphExecutor::InNode::InParametersSet( bool & Err ,
2140 ServicesAnyData * InParametersList ) {
2142 for ( i = 0 ; i < nInParams ; i++ ) {
2143 ServicesAnyData D = InParametersList[i];
2144 GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
2145 GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
2146 if ( anInPort->IsGate() && theOutPort == NULL ) {
2147 cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
2148 << anInPort->GetServicesParameter().Parametertype
2149 << " is inactive. " << anInPort->Kind() << endl ;
2151 else if ( anInPort->State() == SUPERV::ReadyState ) {
2152 if ( anInPort->IsGate() ) {
2153 CORBA::Any * anAny = new CORBA::Any() ;
2154 *anAny <<= (long ) 0 ;
2155 theOutPort->Value( anAny ) ;
2157 if ( !anInPort->IsDataStream() ) {
2158 anInPort->State( SUPERV::WaitingState ) ;
2160 D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
2161 cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() ;
2162 cdebug << " " << D.Name << " " << anInPort->GetServicesParameter().Parametertype << " : " ;
2163 D.Value = *theOutPort->Value() ; // CORBA::Any
2164 string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
2165 const char * Type = _Type.c_str() ;
2166 switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
2167 case CORBA::tk_string:
2170 cdebug << t << " (string)" ;
2171 if ( !strcmp( Type , "string" ) ) {
2173 else if ( !strcmp( Type , "boolean" ) ) {
2176 sscanf( t , "%ld" , &d ) ;
2178 D.Value <<= (CORBA::Any::from_boolean ) b ;
2179 // theOutPort->Value( D.Value ) ;
2181 else if ( !strcmp( Type , "char" ) ) {
2184 sscanf( t , "%ld" , &d ) ;
2186 D.Value <<= (CORBA::Any::from_char ) c ;
2187 cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
2188 // theOutPort->Value( D.Value ) ;
2190 else if ( !strcmp( Type , "short" ) ) {
2193 sscanf( t , "%ld" , &d ) ;
2196 cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
2197 // theOutPort->Value( D.Value ) ;
2199 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2201 sscanf( t , "%ld" , &l ) ;
2203 cdebug << "string '" << t << " --> long " << l ;
2204 // theOutPort->Value( D.Value ) ;
2206 else if ( !strcmp( Type , "float" ) ) {
2208 sscanf( t , "%lf" , &d ) ;
2211 cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
2212 << setw(25) << setprecision(18) << f ;
2213 // theOutPort->Value( D.Value ) ;
2215 else if ( !strcmp( Type , "double" ) ) {
2217 sscanf( t , "%lf" , &d ) ;
2219 cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
2220 // theOutPort->Value( D.Value ) ;
2222 // else if ( !strcmp( Type , "objref" ) ) {
2224 CORBA::Object_ptr ObjRef ;
2226 ObjRef = StringToObject( t ) ;
2227 D.Value <<= ObjRef ;
2230 D.Value <<= CORBA::Object::_nil() ;
2232 // theOutPort->Value( D.Value ) ;
2235 // cdebug << " (other ERROR)" << endl ;
2237 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2239 case CORBA::tk_long:
2242 cdebug << l << " (long)" << endl ;
2243 if ( !strcmp( Type , "string" ) ) {
2245 sprintf( t , "%ld" , l ) ;
2247 // theOutPort->Value( D.Value ) ;
2249 else if ( !strcmp( Type , "boolean" ) ) {
2252 D.Value <<= (CORBA::Any::from_boolean ) b ;
2253 // theOutPort->Value( D.Value ) ;
2255 else if ( !strcmp( Type , "char" ) ) {
2257 c = (unsigned char ) l ;
2258 D.Value <<= (CORBA::Any::from_char ) c ;
2259 // theOutPort->Value( D.Value ) ;
2261 else if ( !strcmp( Type , "short" ) ) {
2265 // theOutPort->Value( D.Value ) ;
2267 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2269 else if ( !strcmp( Type , "float" ) ) {
2273 // theOutPort->Value( D.Value ) ;
2275 else if ( !strcmp( Type , "double" ) ) {
2279 // theOutPort->Value( D.Value ) ;
2281 // else if ( !strcmp( Type , "objref" ) ) {
2283 D.Value <<= CORBA::Object::_nil() ;
2284 // theOutPort->Value( D.Value ) ;
2287 // cdebug << " (other ERROR)" << endl ;
2289 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2291 case CORBA::tk_double:
2294 cdebug << d << " (double)" << endl ;
2295 if ( !strcmp( Type , "string" ) ) {
2297 sprintf( t , "%lf" , d ) ;
2299 // theOutPort->Value( D.Value ) ;
2301 else if ( !strcmp( Type , "boolean" ) ) {
2304 D.Value <<= (CORBA::Any::from_boolean ) b ;
2305 // theOutPort->Value( D.Value ) ;
2307 else if ( !strcmp( Type , "char" ) ) {
2309 c = (unsigned char ) d ;
2310 D.Value <<= (CORBA::Any::from_char ) c ;
2311 // theOutPort->Value( D.Value ) ;
2313 else if ( !strcmp( Type , "short" ) ) {
2317 // theOutPort->Value( D.Value ) ;
2319 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2323 // theOutPort->Value( D.Value ) ;
2325 else if ( !strcmp( Type , "float" ) ) {
2329 // theOutPort->Value( D.Value ) ;
2331 else if ( !strcmp( Type , "double" ) ) {
2333 // else if ( !strcmp( Type , "objref" ) ) {
2335 D.Value <<= CORBA::Object::_nil() ;
2336 // theOutPort->Value( D.Value ) ;
2339 // cdebug << " (other ERROR)" << endl ;
2341 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2343 case CORBA::tk_objref:
2344 if ( !strcmp( Type , "string" ) ) {
2345 CORBA::Object_ptr ObjRef ;
2348 D.Value >>= ObjRef ;
2349 retstr = ObjectToString( ObjRef ) ;
2350 D.Value <<= retstr ;
2351 // theOutPort->Value( D.Value ) ;
2357 cdebug << "ToString( object ) Catched ERROR" << endl ;
2360 else if ( !strcmp( Type , "boolean" ) ) {
2362 D.Value <<= (CORBA::Any::from_boolean ) b ;
2363 // theOutPort->Value( D.Value ) ;
2365 else if ( !strcmp( Type , "char" ) ) {
2366 unsigned char c = 0 ;
2367 D.Value <<= (CORBA::Any::from_char ) c ;
2368 // theOutPort->Value( D.Value ) ;
2370 else if ( !strcmp( Type , "short" ) ) {
2373 // theOutPort->Value( D.Value ) ;
2375 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2378 // theOutPort->Value( D.Value ) ;
2380 else if ( !strcmp( Type , "float" ) ) {
2383 // theOutPort->Value( D.Value ) ;
2385 else if ( !strcmp( Type , "double" ) ) {
2388 // theOutPort->Value( D.Value ) ;
2390 // else if ( !strcmp( Type , "objref" ) ) {
2392 CORBA::Object_ptr obj ;
2396 retstr = ObjectToString( obj ) ;
2397 cdebug << retstr << endl ;
2403 cdebug << "ToString( object ) Catched ERROR" << endl ;
2407 // cdebug << " (other ERROR)" << endl ;
2409 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2412 cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
2416 cdebug << ThreadNo() << " In" << i << " : wrong state ERROR State "
2417 << anInPort->State() << " NameState "
2418 << Automaton()->StateName( anInPort->State() ) << " PortName "
2419 << anInPort->PortName() << " Parametername "
2420 << anInPort->GetServicesParameter().Parametername << endl ;
2423 InParametersList[i] = D ;
2427 void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
2428 ServicesAnyData * OutParametersList ) {
2430 for ( i = 0 ; i < nOutParams ; i++ ) {
2431 ServicesAnyData D = OutParametersList[i] ;
2433 D.Name = GetChangeNodeOutPort(i)->GetServicesParameter().Parametername;
2434 string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
2435 const char * Type = _Type.c_str() ;
2436 bool OutDone = GetChangeNodeOutPort(i)->Done() ;
2437 cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " Done("
2438 << OutDone << ") " << Type << " : " << endl ;
2439 if ( !strcmp( Type , "string" ) ) {
2440 D.Value <<= (char *) NULL ;
2442 else if ( !strcmp( Type , "boolean" ) ) {
2444 D.Value <<= (CORBA::Any::from_boolean ) b ;
2446 else if ( !strcmp( Type , "char" ) ) {
2447 unsigned char c = 0 ;
2448 D.Value <<= (CORBA::Any::from_char ) c ;
2450 else if ( !strcmp( Type , "short" ) ) {
2454 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2455 D.Value <<= (long ) 0 ;
2457 else if ( !strcmp( Type , "float" ) ) {
2461 else if ( !strcmp( Type , "double" ) ) {
2466 D.Value <<= CORBA::Object::_nil() ;
2469 switch (D.Value.type()->kind()) { // { string , long , double , objref }
2470 case CORBA::tk_string:
2473 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
2475 case CORBA::tk_boolean:
2477 D.Value >>= (CORBA::Any::to_boolean ) b;
2478 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
2480 case CORBA::tk_char:
2482 D.Value >>= (CORBA::Any::to_char ) c;
2483 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
2485 case CORBA::tk_short:
2488 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
2490 case CORBA::tk_long:
2493 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
2495 case CORBA::tk_float:
2498 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
2500 case CORBA::tk_double:
2503 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
2505 case CORBA::tk_objref:
2507 CORBA::Object_ptr obj ;
2510 retstr = ObjectToString( obj ) ;
2511 cdebug << ThreadNo() << retstr << endl ;
2514 cdebug << "ToString( object ) Catched ERROR" << endl ;
2518 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
2521 OutParametersList[i] = D ;
2525 bool GraphExecutor::InNode::OutParametersSet( bool Err ,
2526 SUPERV::GraphState NewState ,
2528 ServicesAnyData * OutParametersList ) {
2529 bool RetVal = true ;
2531 GraphBase::OutPort * aGateOutPort = NULL ;
2532 bool OrSwitch = false ;
2534 GraphBase::OutPort * anOutPort ;
2535 for ( i = 0 ; i < nOutParams ; i++ ) {
2536 anOutPort = GetChangeNodeOutPort(i) ;
2538 anOutPort->State( NewState ) ;
2539 anOutPort->Done( true ) ;
2542 cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
2543 << anOutPort->PortName() << " " << anOutPort->Kind() ;
2544 ServicesAnyData D = OutParametersList[i] ;
2545 switch (D.Value.type()->kind()) { // { string , long , double , objref }
2546 case CORBA::tk_string: {
2549 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
2552 case CORBA::tk_boolean: {
2554 D.Value >>= (CORBA::Any::to_boolean ) b;
2555 long l = (long ) b ;
2557 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
2560 case CORBA::tk_char: {
2562 D.Value >>= (CORBA::Any::to_char ) c;
2563 long l = (long ) c ;
2565 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
2568 case CORBA::tk_short: {
2571 long l = (long ) s ;
2573 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
2576 case CORBA::tk_long: {
2579 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
2582 case CORBA::tk_float: {
2585 double d = (double ) f ;
2587 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
2590 case CORBA::tk_double: {
2593 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
2596 case CORBA::tk_objref: {
2598 CORBA::Object_ptr obj ;
2601 retstr = ObjectToString( obj ) ;
2602 cdebug << ThreadNo() << retstr << endl ;
2605 cdebug << "ToString( object ) Catched ERROR" << endl ;
2610 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
2613 OutParametersList[i] = D ;
2614 if ( !anOutPort->IsDataStream() ) {
2615 if ( anOutPort->IsGate() ) {
2616 aGateOutPort = anOutPort ;
2617 cdebug << " Gate " ;
2619 OutParametersList[i].Value <<= l;
2620 anOutPort->Value( OutParametersList[i].Value );
2622 else if ( anOutPort->IsLoop() ) {
2623 cdebug << " Loop " ;
2624 anOutPort->Value( OutParametersList[i].Value );
2625 // InLoop Port of EndLoopNode is ready :
2626 anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
2628 else if ( anOutPort->IsSwitch() ) {
2629 cdebug << " Switch " ;
2630 anOutPort->Value( OutParametersList[i].Value );
2631 if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
2632 if ( OrSwitch && anOutPort->BoolValue() ) {
2633 cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true WARNING"
2637 OrSwitch = OrSwitch | anOutPort->BoolValue() ;
2640 cdebug << "OrSwitch " << OrSwitch ;
2643 cdebug << " Param " ;
2644 anOutPort->Value( OutParametersList[i].Value );
2646 anOutPort->State( NewState ) ;
2647 anOutPort->Done( true ) ;
2650 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
2651 bool fromGOTO = false ;
2652 GraphBase::OutPort * aGOTOPort = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetChangeNodeInGate()->GetOutPort() ;
2654 fromGOTO = aGOTOPort->IsGOTO() ;
2656 if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
2657 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
2658 << anOutPort->ChangeInPorts( j )->PortName() << ","
2659 << anOutPort->ChangeInPorts( j )->Kind() << ") WILL BE changed from "
2660 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
2662 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
2663 << ") to " << anOutPort->NodeName() << "("
2664 << anOutPort->PortName() << ")" << endl ;
2665 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2668 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
2669 << anOutPort->ChangeInPorts( j )->PortName() << ","
2670 << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
2671 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
2673 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
2674 << ") to " << anOutPort->NodeName() << "("
2675 << anOutPort->PortName() << ")" << endl ;
2679 switch (anOutPort->Value()->type()->kind()) {
2680 case CORBA::tk_string:
2682 (*anOutPort->Value()) >>= t;
2683 cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
2685 case CORBA::tk_boolean:
2687 (*anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
2688 cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
2690 case CORBA::tk_char:
2692 (*anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
2693 cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
2695 case CORBA::tk_short:
2697 (*anOutPort->Value()) >>= s;
2698 cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
2700 case CORBA::tk_long:
2702 (*anOutPort->Value()) >>= l;
2703 cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
2705 case CORBA::tk_float:
2707 (*anOutPort->Value()) >>= f;
2708 cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
2710 case CORBA::tk_double:
2712 (*anOutPort->Value()) >>= d;
2713 cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
2715 case CORBA::tk_objref:
2716 CORBA::Object_ptr obj ;
2719 (*anOutPort->Value()) >>= obj ;
2720 retstr = ObjectToString( obj );
2721 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
2725 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
2726 << "Catched ERROR" << endl ;
2730 cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
2736 if ( aGateOutPort && IsSwitchNode() ) {
2738 // cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
2739 // << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
2741 OutParametersList[0].Value <<= l ;
2742 aGateOutPort->Value( OutParametersList[0].Value ) ;
2745 // cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
2746 // << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
2748 OutParametersList[0].Value <<= l ;
2749 aGateOutPort->Value( OutParametersList[0].Value ) ;
2751 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
2752 GraphBase::InPort * anInPort ;
2753 anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
2755 anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;