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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : DataFlowBase_InNodeThreads.cxx
25 // Author : Jean Rahuel, CEA
42 #if defined __GNUC_2__
43 // _CS_gbo_040604 include explicite pour l'utilisation de
44 // std::transform dans UpperCase
45 #include <cctype> // for toupper
46 #include <algorithm> // for transform
53 #include <SALOMEconfig.h>
54 #include CORBA_CLIENT_HEADER(SALOME_Component)
55 #include "SALOME_LifeCycleCORBA.hxx"
57 #include "DataFlowExecutor_DataFlow.hxx"
58 #include "DataFlowEditor_DataFlow.hxx" // GraphEditor package must be built BEFORE
61 static void UpperCase(std::string& rstr)
63 #if defined __GNUC_2__
64 // _CS_gbo_040604 towupper n'existe pas. Utilisation de toupper. Par
65 // ailleurs, include explicite de cctype et algorithm pour toupper
66 // et transform respectivement.
67 std::transform(rstr.begin(), rstr.end(), rstr.begin(),toupper);
69 std::transform(rstr.begin(), rstr.end(), rstr.begin(),towupper);
73 #define SendEventTrace 1
74 int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {
76 _CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
78 cdebug_in << pthread_self() << "/" << ThreadNo() << " SendEvent Graph " << _OutNode->Name()
79 << " Node " << Name() << " Event : " << Automaton()->EventName( anEvent )
80 << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack
81 << " ControlState : " << Automaton()->ControlStateName( ControlState() )
86 _NextState = Automaton()->NextState( _OldState , anEvent ) ;
87 if ( _NextState == _OldState ) {
88 string anErrorMessage = string( "Automaton error for node " ) +
89 string( Name() ) + " (SuperVision executor error)." ;
90 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
91 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
92 << " GraphExecutor::InNodeThreads::SendEvent SameStates ERROR _OldState/_NextState "
93 << _OldState << " Event " << Automaton()->EventName( anEvent ) << endl ;
94 _NextAction = GraphExecutor::VoidAction ;
98 _NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
101 cdebug << pthread_self() << "/" << ThreadNo() << "NextState( " << _OldState << " , "
102 << Automaton()->EventName( anEvent ) << " ) --> _NextState = " << _NextState
103 << " NextAction( " << _NextState << " , " << Automaton()->EventName( anEvent )
104 << " ) --> _NextAction = "
105 << Automaton()->ActionName( _NextAction ) << endl ;
108 // State( _NextState ) ;
109 // if ( _OldState == GraphExecutor::SuccessedExecutingState ||
110 // _OldState == GraphExecutor::ErroredExecutingState ) {
115 cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
116 << Name() << endl << " ControlState : "
117 << Automaton()->ControlStateName( ControlState() ) << endl
118 << " OldState : " << Automaton()->StateName( _OldState ) << endl
119 << " Event : " << Automaton()->EventName( anEvent ) << endl
120 << " NextState : " << Automaton()->StateName( _NextState ) << endl
121 << " Action : " << Automaton()->ActionName( _NextAction ) << endl
122 << " CreateNewThread " << CreateNewThread() << endl
123 << " _RewindStack " << _RewindStack << endl ;
127 #if ExitWhenNodeAborted
128 if ( _OutNode->IsNodeAborted() ) {
130 cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
131 << " will exit : a node was aborted ..." << endl ;
133 State( _NextState ) ;
137 sts = executeAction() ;
140 sts = executeAction() ;
144 cdebug_out << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
145 << " Event : " << Automaton()->EventName( anEvent )
146 << " State : " << Automaton()->StateName( State() )
154 #define ActionsTrace 1
155 // ReadyAction - RunningAction - DoneAction - SuspendedAction :
156 // for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
157 void GraphExecutor::InNode::ReadyAction() {
158 if ( pthread_mutex_lock( &_MutexWait ) ) {
159 perror("Ready pthread_mutex_lock ") ;
163 cdebug << pthread_self() << "/" << ThreadNo()
164 << "ReadyAction pthread_cond_broadcast _ReadyWait "
167 if ( pthread_cond_broadcast( &_ReadyWait ) ) {
168 perror("Ready pthread_cond_broadcast ") ;
170 if ( pthread_mutex_unlock( &_MutexWait ) ) {
171 perror("Ready pthread_mutex_unlock ") ;
176 void GraphExecutor::InNode::RunningAction() {
177 if ( pthread_mutex_lock( &_MutexWait ) ) {
178 perror("Running pthread_mutex_lock ") ;
182 cdebug << pthread_self() << "/" << ThreadNo()
183 << "RunningAction pthread_cond_broadcast _RunningWait "
186 // That activate the pthread_cond_wait for RunninWait
187 if ( pthread_cond_broadcast( &_RunningWait ) ) {
188 perror("Running pthread_cond_broadcast ") ;
190 if ( pthread_mutex_unlock( &_MutexWait ) ) {
191 perror("Running pthread_mutex_unlock ") ;
196 void GraphExecutor::InNode::DoneAction() {
197 if ( pthread_mutex_lock( &_MutexWait ) ) {
198 perror("Done pthread_mutex_lock ") ;
202 cdebug << pthread_self() << "/" << ThreadNo()
203 << "DoneAction pthread_cond_broadcast _DoneWait "
206 if ( pthread_cond_broadcast( &_DoneWait ) ) {
207 perror("Done pthread_cond_broadcast ") ;
209 if ( pthread_mutex_unlock( &_MutexWait ) ) {
210 perror("Done pthread_mutex_unlock ") ;
215 void GraphExecutor::InNode::SuspendedAction() {
216 if ( pthread_mutex_lock( &_MutexWait ) ) {
217 perror("Suspended pthread_mutex_lock ") ;
221 cdebug << pthread_self() << "/" << ThreadNo()
222 << "SuspendedAction pthread_cond_broadcast _SuspendedWait "
225 if ( pthread_cond_broadcast( &_SuspendedWait ) ) {
226 perror("Suspended pthread_cond_broadcast ") ;
228 if ( pthread_mutex_unlock( &_MutexWait ) ) {
229 perror("Suspended pthread_mutex_unlock ") ;
234 // SuspendAction <--> { ResumeAction - ReStartAction }
235 GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() {
237 if ( pthread_mutex_lock( &_MutexWait ) ) {
238 perror("Suspend pthread_mutex_lock ") ;
241 if ( !_SuspendSync ) {
242 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
243 << " SuspendAction pthread_cond_wait _SuspendWait "
244 << Automaton()->StateName( State() ) << endl ;
245 _SuspendSync = true ;
246 _OutNode->SuspendThread() ;
247 if ( pthread_cond_wait( &_SuspendWait , &_MutexWait ) ) {
248 perror("SuspendAction pthread_cond_wait ") ;
250 _OutNode->ResumeThread() ;
252 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
253 << " SuspendAction pthread_cond_waited"
254 << Automaton()->StateName( State() ) << endl ;
259 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
260 << " NO SuspendAction pthread_cond_wait"
261 << Automaton()->StateName( State() ) << endl ;
264 // SendEvent( _aResumeEvent ) ; ===> Mutex with myself !
265 _SuspendSync = false ;
266 if ( ControlState() == SUPERV::ToSuspendStartState ||
267 ControlState() == SUPERV::ToSuspendState ) {
268 ControlState( SUPERV::VoidState ) ;
270 if ( pthread_mutex_unlock( &_MutexWait ) ) {
271 perror("SuspendAction pthread_mutex_unlock ") ;
275 SendEvent( _aResumeEvent ) ;
276 // if ( ControlState() == SUPERV::ToSuspendStartState ) {
277 // ControlState( SUPERV::VoidState ) ;
280 if ( pthread_mutex_lock( &_MutexWait ) ) {
281 perror("SuspendAction pthread_mutex_lock ") ;
286 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
287 << " SuspendAction pthread_cond_signal _ResumeWait" << endl ;
289 if ( pthread_cond_signal( &_ResumeWait ) ) {
290 perror("SuspendAction pthread_cond_signal _ResumeWait ") ;
293 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
294 << " SuspendAction pthread_cond_signaled _ResumeWait " << endl ;
299 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
300 << " NO SuspendAction pthread_cond_signal _ResumeWait" << endl ;
304 if ( pthread_mutex_unlock( &_MutexWait ) ) {
305 perror("SuspendAction pthread_mutex_unlock ") ;
308 if ( _aReStartNode ) {
309 cdebug << Name() << " " << Automaton()->StateName( State() )
310 << "aReStartNode : " << _aReStartNode->Name() << " "
311 << Automaton()->StateName( _aReStartNode->State() ) << endl ;
312 _aReStartNode->SendEvent( _aResumeEvent ) ;
315 cdebug << "NO aReStartNode"
316 << Automaton()->StateName( State() ) << endl ;
318 return _aReStartNode ;
321 bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent ) {
323 if ( pthread_mutex_lock( &_MutexWait ) ) {
324 perror("ResumeAction pthread_mutex_lock ") ;
327 _aResumeEvent = aResumeEvent ;
328 if ( _SuspendSync ) {
330 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
331 << " ResumeAction pthread_cond_signal" << endl ;
333 if ( pthread_cond_signal( &_SuspendWait ) ) {
334 perror("ResumeAction pthread_cond_signal ") ;
337 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
338 << " ResumeAction pthread_cond_signaled _SuspendWait " << endl ;
344 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
345 << " NO ResumeAction pthread_cond_signal" << endl ;
347 if ( pthread_self() == ThreadNo() ) {
348 RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
351 _SuspendSync = true ;
352 RetVal = true ; // Il faut tout de meme attendre ci-apres ...
355 if ( pthread_mutex_unlock( &_MutexWait ) ) {
356 perror("ResumeAction pthread_mutex_unlock ") ;
361 if ( pthread_mutex_lock( &_MutexWait ) ) {
362 perror("ResumeAction pthread_mutex_lock ") ;
365 if ( !_ResumeSync ) {
367 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
368 << Name() << " ResumeAction pthread_cond_wait _ResumeWait "
369 << Automaton()->StateName( State() ) << endl ;
372 if ( pthread_cond_wait( &_ResumeWait , &_MutexWait ) ) {
373 perror("ResumeAction pthread_cond_wait ") ;
376 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
377 << Name() << " ResumeAction pthread_cond_waited _ResumeWait"
378 << Automaton()->StateName( State() ) << endl ;
384 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
385 << Name() << " NO ResumeAction pthread_cond_wait _ResumeWait"
386 << Automaton()->StateName( State() ) << endl ;
390 _ResumeSync = false ;
391 if ( pthread_mutex_unlock( &_MutexWait ) ) {
392 perror("ResumeAction pthread_mutex_unlock ") ;
397 cdebug << pthread_self() << "/" << ThreadNo()
398 << "GraphExecutor::InNodeThreads::ResumeAction RetVal " << RetVal << endl ;
403 bool GraphExecutor::InNode::ReStartAction( GraphExecutor::InNode * aReStartNode ,
404 GraphExecutor::NodeEvent anEvent ) {
405 GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
406 _aReStartNode = aReStartNode ;
407 _aReStartEvent = anEvent ;
408 cdebug << pthread_self() << "/" << ThreadNo()
409 << " GraphExecutor::InNodeThreads::ReStartAction from "
410 << Name() << " " << Automaton()->StateName( State() ) << " to "
411 << aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
412 << Automaton()->StateName( aReStartNode->State() ) ;
413 if ( oldReStartNode ) {
414 cdebug << " oldReStartNode " << oldReStartNode->Name() << endl ;
419 return ResumeAction( GraphExecutor::ToReStartEvent ) ;
422 void GraphExecutor::InNode::KilledAction() {
423 if ( pthread_mutex_lock( &_MutexWait ) ) {
424 perror("Killed pthread_mutex_lock ") ;
428 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_wait"
431 if ( pthread_cond_wait( &_KillWait , &_MutexWait ) ) {
432 perror("Killed pthread_cond_wait ") ;
434 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_waited"
438 cdebug << "pthread_cond " << Name() << " NO Killed pthread_cond_wait"
442 if ( pthread_mutex_unlock( &_MutexWait ) ) {
443 perror("Killed pthread_mutex_unlock ") ;
448 void GraphExecutor::InNode::KillAction() {
449 if ( pthread_mutex_lock( &_MutexWait ) ) {
450 perror("Kill pthread_mutex_lock ") ;
454 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signal"
456 // if ( pthread_cond_broadcast( &_KillWait ) ) {
457 if ( pthread_cond_signal( &_KillWait ) ) {
458 perror("Kill pthread_cond_broadcast ") ;
460 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signaled"
464 cdebug << "pthread_cond " << Name() << " NO Kill pthread_cond_signal"
468 if ( pthread_mutex_unlock( &_MutexWait ) ) {
469 perror("Kill pthread_mutex_unlock ") ;
474 void GraphExecutor::InNode::StoppedAction() {
475 if ( pthread_mutex_lock( &_MutexWait ) ) {
476 perror("Stopped pthread_mutex_lock ") ;
479 if ( pthread_cond_wait( &_StopWait , &_MutexWait ) ) {
480 perror("Stopped pthread_cond_wait ") ;
482 if ( pthread_mutex_unlock( &_MutexWait ) ) {
483 perror("Stopped pthread_mutex_unlock ") ;
488 void GraphExecutor::InNode::StopAction() {
489 if ( pthread_mutex_lock( &_MutexWait ) ) {
490 perror("Stop pthread_mutex_lock ") ;
493 if ( pthread_cond_broadcast( &_StopWait ) ) {
494 perror("Stop pthread_cond_broadcast ") ;
496 if ( pthread_mutex_unlock( &_MutexWait ) ) {
497 perror("Stop pthread_mutex_unlock ") ;
502 void GraphExecutor::InNode::ThreadStartedAction() {
503 if ( pthread_mutex_lock( &_MutexWait ) ) {
504 perror("ThreadStarted pthread_mutex_lock ") ;
507 if ( !_ThreadStartedSync ) {
509 cdebug << pthread_self() << "/" << ThreadNo()
510 << "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait"
513 _ThreadStartedSync = true ;
514 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
515 perror("ThreadStarted pthread_cond_wait ") ;
518 cdebug << pthread_self() << "/" << ThreadNo()
519 << "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited"
525 cdebug << pthread_self() << "/" << ThreadNo()
526 << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait"
530 _ThreadStartedSync = false ;
531 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
532 perror("ThreadStart pthread_cond_signal ") ;
536 cdebug << pthread_self() << "/" << ThreadNo()
537 << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled"
541 if ( pthread_mutex_unlock( &_MutexWait ) ) {
542 perror("ThreadStarted pthread_mutex_unlock ") ;
547 void GraphExecutor::InNode::ThreadStartAction() {
548 if ( pthread_mutex_lock( &_MutexWait ) ) {
549 perror("ThreadStart pthread_mutex_lock ") ;
552 if ( _ThreadStartedSync ) {
554 cdebug << pthread_self() << "/" << ThreadNo()
555 << "pthread_cond " << Name() << " ThreadStart pthread_cond_signal"
558 _ThreadStartedSync = false ;
559 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
560 perror("ThreadStart pthread_cond_broadcast ") ;
563 cdebug << pthread_self() << "/" << ThreadNo()
564 << "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled"
570 cdebug << pthread_self() << "/" << ThreadNo()
571 << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal"
574 _ThreadStartedSync = true ;
576 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
577 perror("ThreadStarted pthread_cond_wait ") ;
581 cdebug << pthread_self() << "/" << ThreadNo()
582 << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited"
586 if ( pthread_mutex_unlock( &_MutexWait ) ) {
587 perror("ThreadStart pthread_mutex_unlock ") ;
592 int GraphExecutor::InNode::executeAction() {
594 int oldRewindStack = ( _RewindStack > MAXSTACKTHREADSIZE ) ;
595 if ( !CreateNewThread() && oldRewindStack ) {
597 cdebug << pthread_self() << "/" << ThreadNo()
598 << " executeAction start Thread _RewindStack " << _RewindStack << " > "
599 << MAXSTACKTHREADSIZE << " CreateNewThread "
600 << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "("
601 << Name() << ")" << endl;
603 CreateNewThread( true ) ;
604 _OutNode->IncrCreatedThreads() ;
607 if ( CreateNewThread() ) {
608 CreateNewThread( false ) ;
609 //JR 15.04.2005 Debug PAL8624 RetroConception :
610 // if ( ThreadNo() == 0 ) {
613 cdebug << pthread_self() << "/" << ThreadNo()
614 << " executeAction start Thread _RewindStack " << _RewindStack << " "
615 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
619 int pthread_sts = 1 ;
620 // _OutNode->PushEvent( NULL , GraphExecutor::NewThreadEvent ,
621 // GraphExecutor::ExecutingState ) ;
622 while ( (pthread_sts = pthread_create(&T, NULL, run_function, this )) ) {
623 char * msg = "Cannot pthread_create " ;
625 cdebug << ThreadNo() << " " << msg << " --> sleep(5)" << endl ;
626 // cdebug << ThreadNo() << " PTHREAD_THREADS_MAX : "
627 // << PTHREAD_THREADS_MAX << " pthread_create status : " ;
628 if ( pthread_sts == EAGAIN ) {
629 cdebug << "EAGAIN(" << pthread_sts << ")" << endl ;
630 cdebug << _OutNode->CreatedThreads() << " was created (and exited)" << endl ;
631 cdebug << "It seems to me that with gdb we are limited to 256 threads" << endl ;
634 cdebug << pthread_sts << endl ;
638 pthread_exit( msg ) ;
640 _OutNode->setRunFuncThread( T ) ; // mkr : IPAL14711
642 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
643 << " executeAction has created thread " << T << endl ;
645 ThreadStartedAction() ;
647 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
648 << "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
652 //JR 15.04.2005 Debug PAL8624 RetroConception :
656 cdebug << pthread_self() << "/" << ThreadNo()
657 << " executeAction restart Thread _RewindStack " << _RewindStack << " "
658 << Automaton()->StateName( State() ) << " "
659 << Automaton()->ActionName( _NextAction ) << "(" << Name()
660 << ") ReStartAction ==>" << endl;
662 State( GraphExecutor::SuspendedSuccessedState ) ;
663 if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
664 cdebug << pthread_self() << "/" << ThreadNo()
665 << " executeAction STATE & CALLED "
666 << Automaton()->ActionName( _NextAction ) << "(" << Name()
667 << ") ERROR-DEBUG " << endl;
671 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
672 << Automaton()->ActionName( _NextAction ) << "(" << Name()
680 if ( _CurrentEvent == ExecuteEvent ) {
684 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
685 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
688 return ExecuteAction() ;
693 void GraphExecutor::InNode::coutbegin() {
695 cdebug << pthread_self() << "/" << ThreadNo() << " run_function begin"
696 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
699 void GraphExecutor::InNode::coutexit() {
701 cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit _RewindStack " << _RewindStack
702 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
705 void * run_function(void *p) {
706 GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
708 aNode->NewThread( pthread_self() ) ;
709 if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) {
710 perror("pthread_setcanceltype ") ;
713 if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) {
714 perror("pthread_setcancelstate ") ;
717 aNode->ThreadStartAction() ;
718 // cout << "run_function " << aNode->Name() << "->ExecuteAction() Coupled : " << aNode->CoupledNode()
720 aNode->ExecuteAction() ;
721 char * msg = new char[40] ;
722 sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
723 strcat( msg , " thread exit" ) ;
725 aNode->ExitThread() ;
728 pthread_exit( (void * ) smsg.c_str() ) ;
732 int GraphExecutor::InNode::ExecuteAction() {
736 const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
737 const char * statename = Automaton()->StateName( State() ) ;
738 const char * nextstatename = Automaton()->StateName( _NextState ) ;
739 cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name() << " --> ExecuteAction "
740 << nextactionname << " " << statename << " NextState "
741 << nextstatename << endl ;
744 State( _NextState ) ;
745 switch ( _NextAction ) {
746 case GraphExecutor::ErrorAction : {
747 sts = ErrorAction() ;
750 case GraphExecutor::VoidAction : {
754 case GraphExecutor::DataWaiting_SomeDataReadyAction : {
755 sts = DataWaiting_SomeDataReadyAction() ;
758 case GraphExecutor::DataUndef_NotAllDataReadyAction : {
759 sts = DataUndef_NotAllDataReadyAction() ;
762 case GraphExecutor::DataUndef_AllDataReadyAction : {
763 sts = DataUndef_AllDataReadyAction() ;
766 case GraphExecutor::DataReady_SuspendAction : {
767 sts = DataReady_SuspendAction() ;
770 case GraphExecutor::SuspendedReady_ResumeAction : {
771 sts = SuspendedReady_ResumeAction() ;
774 case GraphExecutor::DataReady_KillAction : {
775 sts = DataReady_KillAction() ;
778 case GraphExecutor::DataReady_StopAction : {
779 sts = DataReady_StopAction() ;
782 case GraphExecutor::DataReady_ExecuteAction : {
783 sts = DataReady_ExecuteAction() ;
786 case GraphExecutor::Executing_SuspendAction : {
787 sts = Executing_SuspendAction() ;
790 case GraphExecutor::SuspendedExecuting_ResumeAction : {
791 sts = SuspendedExecuting_ResumeAction() ;
794 case GraphExecutor::Executing_KillAction : {
795 sts = Executing_KillAction() ;
798 case GraphExecutor::Executing_StopAction : {
799 sts = Executing_StopAction() ;
802 case GraphExecutor::Executing_SuccessAction : {
803 sts = Executing_SuccessAction() ;
806 case GraphExecutor::Errored_ExecutingAction : {
807 sts = Errored_ExecutingAction() ;
810 case GraphExecutor::Successed_SuccessAction : {
811 sts = Successed_SuccessAction() ;
814 case GraphExecutor::Errored_ErrorAction : {
815 sts = Errored_ErrorAction() ;
818 case GraphExecutor::Successed_SuspendAction : {
819 sts = Successed_SuspendAction() ;
822 case GraphExecutor::Errored_SuspendAction : {
823 sts = Errored_SuspendAction() ;
826 case GraphExecutor::SuspendedSuccessed_ResumeAction : {
827 sts = SuspendedSuccessed_ResumeAction() ;
830 case GraphExecutor::SuspendedErrored_ResumeAction : {
831 sts = SuspendedErrored_ResumeAction() ;
834 case GraphExecutor::Successed_KillAction : {
835 sts = Successed_KillAction() ;
838 case GraphExecutor::Errored_KillAction : {
839 sts = Errored_KillAction() ;
842 case GraphExecutor::Successed_StopAction : {
843 sts = Successed_StopAction() ;
846 case GraphExecutor::Errored_StopAction : {
847 sts = Errored_StopAction() ;
850 case GraphExecutor::SuspendedSuccessed_ReStartAction : {
851 sts = SuspendedSuccessed_ReStartAction() ;
854 case GraphExecutor::SuspendedErrored_ReStartAction : {
855 sts = SuspendedErrored_ReStartAction() ;
858 case GraphExecutor::SuspendedSuccessed_ReStartAndSuspendAction : {
859 sts = SuspendedSuccessed_ReStartAndSuspendAction() ;
862 case GraphExecutor::SuspendedErrored_ReStartAndSuspendAction : {
863 sts = SuspendedErrored_ReStartAndSuspendAction() ;
867 cdebug << pthread_self() << "/" << ThreadNo()
868 << " GraphExecutor::InNodeThreads::SendEvent Error Undefined Action : "
869 << _NextAction << endl ;
874 cdebug_out << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
875 << nextactionname << endl ;
880 int GraphExecutor::InNode::ErrorAction() {
881 cdebug << pthread_self() << "/" << ThreadNo() << " Automaton ErrorAction Node "
886 int GraphExecutor::InNode::VoidAction() {
887 cdebug << pthread_self() << "/" << ThreadNo() << " VoidAction " << Name() << endl;
891 #define SomeDataReadyActionTrace 1
892 int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
893 #if SomeDataReadyActionTrace
894 cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name()
895 << " DataWaiting_SomeDataReadyAction from " << DataFromNode()
896 << " " << GetNodeInPortsSize() << " Inport(s)" << endl;
901 bool LoopBeginning = false ;
902 bool LoopFinished = false ;
903 bool SwitchFinished = false ;
904 bool SwitchDefault = false ;
905 bool DoAllDataReadyIf = true ;
907 if ( IsLoopNode() ) {
908 GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
909 if ( anOutLoopPort && anOutLoopPort->BoolValue() ) {
910 LoopBeginning = true ; // Beginning of Loop
913 else if ( IsEndLoopNode() ) {
914 GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
915 if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) {
916 LoopFinished = true ; // End of Loop
919 else if ( IsEndSwitchNode() ) {
920 if ( strcmp( GOTONode()->CoupledNode()->Name() , DataFromNode() ) ) {
921 GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default Port
922 //JR 09.02.2005 : SomeDataReady is NOT from the SwitchNode
923 if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
924 //JR 09.02.2005 : the OutPort of the SwitchNode connected to the default port is closed ===>
925 // Here after we consider that that DefaultPort is Ready (even if it's value is false) in
926 // order to have the good count of InPorts Ready in the EndSwitchNode
927 // SwitchFinished = true ; // End of Switch
929 // But we do that only if the InDefaultPort of the EndSwitchNode is not connected or
930 // is connected from the OutDefaultPort of the corresponding SwitchNode
931 if ( !strcmp( GOTONode()->CoupledNode()->Name() , anOutGateSwitchPort->NodeName() ) ) {
932 SwitchFinished = true ; // End of Switch
937 //JR 20.04.2005 : SomeDataReady is FROM the SwitchNode to that EndSwitchNode
939 //JR 16.02.2005 Debug : Change InPorts of EndSwitchNode that have the same name as an OutPort of
940 // the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
941 GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default P
942 //JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is activated :
943 if ( anOutGateSwitchPort ) {
944 if ( anOutGateSwitchPort->BoolValue() ) {
945 SwitchDefault = true ;
947 //JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is NOT activated :
948 // a SwitchBranch should be activated
950 DoAllDataReadyIf = false ;
952 #if SomeDataReadyActionTrace
953 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
954 << " activated from CoupledNode " << GOTONode()->CoupledNode()->Name() << " "
955 << anOutGateSwitchPort->NodeName() << "( " << anOutGateSwitchPort->PortName()
956 << " ) to InDefault " ;
958 if ( GraphBase::Base::_prof_debug ) {
959 anOutGateSwitchPort->StringValue( *GraphBase::Base::_fdebug ) ;
965 //JR 28.06.2005 : SomeDataReady is from the SwitchNode and the InDefault is not connected :
966 // a SwitchBranch should be activated
968 DoAllDataReadyIf = false ;
973 #if SomeDataReadyActionTrace
974 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
975 << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished
976 << " SwitchDefault " << SwitchDefault << " DoAllDataReadyIf " << DoAllDataReadyIf << endl ;
978 for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
979 GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
980 GraphBase::OutPort * anOutPort ;
981 if ( SwitchDefault && !anInPort->IsDataStream() ) {
982 //Get or Set the field OutPort of that InPort of the EndSwitchNode to the corresponding OutPort
984 anOutPort = anInPort->GetOutPort() ;
986 #if SomeDataReadyActionTrace
987 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort"
989 << anInPort->PortName() << " already setted to OutPort " << anOutPort->NodeName()
990 << "( " << anOutPort->PortName() << " )" << endl ;
994 anOutPort = CoupledNode()->GetChangeOutPort( anInPort->PortName() ) ;
996 #if SomeDataReadyActionTrace
997 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort"
999 << anInPort->PortName() << " change of OutPort from "
1000 << anInPort->GetOutPort()->NodeName() << "( " << anInPort->GetOutPort()->PortName()
1001 << " ) to " << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )"
1006 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort"
1008 << anInPort->PortName() << " have NO OutPort ERROR " << endl ;
1011 anInPort->ChangeOutPort( anOutPort ) ;
1015 anOutPort = anInPort->GetOutPort() ;
1017 #if SomeDataReadyActionTrace
1018 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort"
1020 << anInPort->PortName() << " " << anInPort->PortState() << " "
1021 << anInPort->PortStatus() << " " << anInPort->Kind() ;
1023 cdebug << " from OutPort " << anOutPort->NodeName() << "( " << anOutPort->PortName()
1027 cdebug << " without OutPort " ;
1031 if ( anInPort->IsGate() && anOutPort == NULL ) {
1033 anInPort->PortState( SUPERV::ReadyState ) ;
1034 #if SomeDataReadyActionTrace
1035 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1036 << anInPort->PortName() << " ControlPort inactive." << endl ;
1040 // That InPort get its value from an other node : the node of anOutPort linked to that anInPort is
1041 // different from the sender of SomeDataReady (DataFromNode) :
1042 else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
1043 if ( anInPort->PortState() == SUPERV::ReadyState ) {
1045 #if SomeDataReadyActionTrace
1046 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1047 << anInPort->PortName() << " " << anInPort->PortState() << " Was Done from Node "
1048 << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
1049 << anOutPort->PortState() << " ) PortDone " << anOutPort->PortDone() << " " ;
1051 if ( GraphBase::Base::_prof_debug ) {
1052 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1057 //JR 30.01.2007 : wrong debug for PAL12455
1059 // mkr : PAL12455 -->
1060 // MacroNode : give immediately the value to the corresponding graph
1061 if ( IsMacroNode() ) {
1062 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1063 cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name() << " --> InputOfAny "
1064 << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready ( "
1065 << anInPort->PortName() << " ) ===> InputOfAny" << endl ;
1066 // GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1067 //JR 30.03.2005 aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1068 aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
1070 // mkr : PAL12455 <--
1073 else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
1074 anInPort->PortState( SUPERV::ReadyState ) ;
1076 #if SomeDataReadyActionTrace
1077 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1078 << anInPort->PortName() << " Was Done from Node "
1079 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1080 << ") LoopBeginning " << LoopBeginning << " " ;
1082 if ( GraphBase::Base::_prof_debug ) {
1083 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1089 else if ( LoopFinished ) {
1090 anInPort->PortState( SUPERV::ReadyState ) ;
1092 #if SomeDataReadyActionTrace
1093 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1094 << anInPort->PortName() << " Was Done from Node "
1095 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1096 << ") LoopFinished " << LoopFinished << " " ;
1098 if ( GraphBase::Base::_prof_debug ) {
1099 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1105 else if ( anInPort->IsGate() && SwitchFinished ) {
1106 anInPort->PortState( SUPERV::ReadyState ) ;
1108 #if SomeDataReadyActionTrace
1109 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1110 << anInPort->PortName() << " Was Done from Node "
1111 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1112 << ") SwitchFinished " << SwitchFinished << " " ;
1114 if ( GraphBase::Base::_prof_debug ) {
1115 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1121 else if ( anInPort->IsGate() &&
1122 _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->IsGOTONode() ) {
1123 // GateOutPort of GOTONodes are always opened
1124 anInPort->PortState( SUPERV::ReadyState ) ;
1126 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
1127 CORBA::Any anAny = CORBA::Any() ;
1128 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 1 ;
1129 anAny <<= (CORBA::Long ) 1 ;
1130 _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->GetChangeNodeOutGate()->SetValue( anAny ) ;
1131 #if SomeDataReadyActionTrace
1132 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1133 << anInPort->PortName() << " Was Done from Node "
1134 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1137 if ( GraphBase::Base::_prof_debug ) {
1138 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1145 #if SomeDataReadyActionTrace
1146 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1147 << " " << Automaton()->StateName( State() ) << " LoopBeginning "
1148 << LoopBeginning << " " << anInPort->PortName() << " DataConnected "
1149 << anInPort->IsDataConnected() << " Was NOT Done from Node "
1150 << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
1151 << anOutPort->PortState() << " , PortDone " << anOutPort->PortDone() << ") "
1157 // That InPort get its value from the sending node (DataFromNode)
1158 else if ( anInPort->IsGate() ) {
1159 //JR 30.03.2005 const CORBA::Any * theValue = anOutPort->Value() ;
1160 const CORBA::Any theValue = anOutPort->Value() ;
1161 CORBA::Long GateOpened ;
1162 //JR 30.03.2005 (*theValue) >>= GateOpened ;
1163 theValue >>= GateOpened ;
1164 if ( GateOpened != 0 ) {
1166 anInPort->PortState( SUPERV::ReadyState ) ;
1167 #if SomeDataReadyActionTrace
1168 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1169 << anInPort->PortName() << " Gate is Opened from Node "
1170 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1173 if ( GraphBase::Base::_prof_debug ) {
1174 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1180 else if ( LoopFinished ) {
1181 anInPort->PortState( SUPERV::ReadyState ) ;
1182 #if SomeDataReadyActionTrace
1183 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1184 << anInPort->PortName() << " GATE IS CLOSED from Node "
1185 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1186 << ") LoopFinished" ;
1188 if ( GraphBase::Base::_prof_debug ) {
1189 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1196 #if SomeDataReadyActionTrace
1197 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1198 << anInPort->PortName() << " GATE IS CLOSED from Node "
1199 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1202 if ( GraphBase::Base::_prof_debug ) {
1203 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1210 else if ( anOutPort->PortDone() ) {
1211 #if SomeDataReadyActionTrace
1212 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
1213 << anInPort->PortName() << " " << anInPort->PortStatus() << " "
1214 << Automaton()->StateName( anInPort->PortState() ) << " is Done from Node "
1215 << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
1216 << anOutPort->PortStatus() << " --> ReadyState " ;
1218 if ( GraphBase::Base::_prof_debug ) {
1219 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1225 anInPort->PortState( SUPERV::ReadyState ) ;
1226 // MacroNode : give immediately the value to the corresponding graph
1227 if ( IsMacroNode() ) {
1228 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1229 cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name() << " --> InputOfAny "
1230 << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready ( "
1231 << anInPort->PortName() << " ) ===> InputOfAny" << endl ;
1232 // GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1233 //JR 30.03.2005 aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1234 aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
1238 #if SomeDataReadyActionTrace
1239 cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( "
1240 << anInPort->PortName() << ") " << anInPort->PortStatus()
1241 << " is NOT Done from Node "
1242 << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
1243 << anOutPort->PortStatus() << " " << anOutPort->PortDone() << endl ;
1248 if ( InReady == GetNodeInPortsSize() && DoAllDataReadyIf ) { // All Flags != 0 :
1249 //JR 15.04.2005 Debug PAL8624 RetroConception :
1250 // res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
1251 #if SomeDataReadyActionTrace
1252 cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << " HasAllDataReady"
1255 //JR 30.01.2007 Right Debug PAL12455 --->
1256 //That must be done only for DataConnected ports and only once
1257 if ( IsMacroNode() ) {
1258 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1259 for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
1260 GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
1261 GraphBase::OutPort * anOutPort ;
1262 anOutPort = anInPort->GetOutPort() ;
1263 if ( anInPort->IsDataConnected() ) {
1264 cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name()
1265 << " --> InputOfAny " << InReady << "/" << GetNodeInPortsSize()
1266 << " InPorts are Ready ( " << anInPort->PortName()
1267 << " ) ===> InputOfAny" << endl ;
1268 aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
1272 // <--- JR 30.01.2007 Right Debug PAL12455
1273 HasAllDataReady( true ) ; // ==> Ready to execute
1276 else { // At least one Flag == 0 :
1277 #if SomeDataReadyActionTrace
1278 cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << " HasNOTAllDataReady "
1279 << InReady << "/" << GetNodeInPortsSize() << " DoAllDataReadyIf " << DoAllDataReadyIf << endl ;
1281 HasAllDataReady( false ) ;
1282 res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
1285 #if SomeDataReadyActionTrace
1286 cdebug_out << pthread_self() << "/" << ThreadNo() << Name()
1287 << " DataWaiting_SomeDataReadyAction " << endl;
1293 #define NotAllDataReadyActionTrace 1
1294 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
1295 //JR 15.04.2005 Debug PAL8624 RetroConception :
1296 // CreateNewThreadIf( false ) ;
1297 #if NotAllDataReadyActionTrace
1298 cdebug << pthread_self() << " for " << ThreadNo()
1299 << " DataUndef_NotAllDataReadyAction " << Name() << endl;
1304 #define AllDataReadyActionTrace 1
1305 int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
1306 #if AllDataReadyActionTrace
1307 cdebug << pthread_self() << "/" << ThreadNo()
1308 << " --> DataUndef_AllDataReadyAction " << Name() << endl ;
1309 // << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
1310 // << IsLockedDataWait() ;
1312 //JR 15.04.2005 Debug PAL8624 RetroConception :
1313 if ( !CreateNewThread() ) {
1314 #if AllDataReadyActionTrace
1315 cdebug << "Thread " << ThreadNo() << " --> " << pthread_self() << endl ;
1317 ThreadNo( pthread_self() ) ;
1320 _OutNode->IncrCreatedThreads() ;
1322 _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
1323 GraphExecutor::DataReadyState ) ;
1325 SUPERV::ControlState aControl = ControlState() ;
1326 switch ( aControl ) {
1327 case SUPERV::VoidState : {
1328 SendEvent( GraphExecutor::ExecuteEvent ) ;
1331 case SUPERV::ToSuspendState : {
1332 SendEvent( GraphExecutor::SuspendEvent ) ;
1335 case SUPERV::ToSuspendStartState : {
1336 SendEvent( GraphExecutor::SuspendEvent ) ;
1339 case SUPERV::ToSuspendDoneState : {
1340 SendEvent( GraphExecutor::ExecuteEvent ) ;
1343 case SUPERV::ToKillState : {
1344 SendEvent( GraphExecutor::KillEvent ) ;
1347 case SUPERV::ToKillDoneState : {
1348 SendEvent( GraphExecutor::ExecuteEvent ) ;
1351 case SUPERV::ToStopState : {
1352 SendEvent( GraphExecutor::StopEvent ) ;
1356 cdebug << ThreadNo()
1357 << " GraphExecutor::InNodeThreads::DataUndef_AllDataReadyAction Error Undefined Control : "
1358 << aControl << endl ;
1362 #if AllDataReadyActionTrace
1363 cdebug << pthread_self() << "/" << ThreadNo()
1364 << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
1369 int GraphExecutor::InNode::DataReady_SuspendAction() {
1370 cdebug << pthread_self() << "/" << ThreadNo()
1371 << "DataReady_SuspendAction --> Suspend " << Name()
1372 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
1373 << _OutNode->SuspendedThreads() << endl;
1374 _OutNode->PushEvent( this , GraphExecutor::SuspendedReadyEvent ,
1375 GraphExecutor::SuspendedReadyState ) ;
1376 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1377 cdebug << pthread_self() << "/" << ThreadNo()
1378 << "DataReady_SuspendAction Resumed " << Name() << endl;
1379 if ( aReStartNode ) {
1380 _aReStartNode = NULL ;
1381 aReStartNode->SendEvent( _aReStartEvent ) ;
1384 SendEvent( GraphExecutor::ExecuteEvent ) ;
1389 int GraphExecutor::InNode::SuspendedReady_ResumeAction() {
1390 cdebug << pthread_self() << "/" << ThreadNo() << "SuspendedReady_ResumeAction "
1393 _OutNode->PushEvent( this , GraphExecutor::ResumedReadyEvent ,
1394 GraphExecutor::ResumedReadyState ) ;
1398 int GraphExecutor::InNode::DataReady_KillAction() {
1399 _OutNode->PushEvent( this , GraphExecutor::KilledReadyEvent ,
1400 GraphExecutor::KilledReadyState ) ;
1402 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_KillAction " << Name()
1403 << " will pthread_exit()" << endl;
1407 int GraphExecutor::InNode::DataReady_StopAction() {
1408 _OutNode->PushEvent( this , GraphExecutor::StoppedReadyEvent ,
1409 GraphExecutor::StoppedReadyState ) ;
1411 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_StopAction " << Name()
1412 << " will pthread_exit()" << endl;
1418 #define TraceDataReady_ExecuteAction 1
1419 int GraphExecutor::InNode::DataReady_ExecuteAction() {
1421 #if TraceDataReady_ExecuteAction
1422 cdebug_in << pthread_self() << "/" << ThreadNo() << " DataReady_ExecuteAction "
1425 _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
1426 GraphExecutor::ExecutingState ) ;
1432 Engines::Container_var myContainer ;
1433 Engines::Component_var myObjComponent ;
1435 SUPERV::GraphState PortState = SUPERV::ReadyState ;
1436 GraphExecutor::AutomatonState NewState = GraphExecutor::DataUndefState ;
1437 GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
1440 ServicesAnyData * InParametersList = NULL ;
1442 ServicesAnyData * OutParametersList = NULL ;
1444 nInParams = GetNodeInPortsSize() ;
1445 #if TraceDataReady_ExecuteAction
1446 char * aName = Name() ;
1447 cdebug << pthread_self() << "/" << ThreadNo() << " " << aName
1448 << " nInParams " << nInParams << " InParametersList "
1449 << (void * ) InParametersList << endl ;
1451 InParametersList = new ServicesAnyData[nInParams];
1452 InParametersSet( Err , nInParams , InParametersList ) ;
1454 nOutParams = GetNodeOutPortsSize() ;
1455 OutParametersList = new ServicesAnyData[nOutParams];
1456 InOutParametersSet( nOutParams , OutParametersList ) ;
1459 if ( !Err && IsComputingNode() ) {
1460 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1461 << " after creation of InParametersList : nInParams " << nInParams
1464 for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
1465 cdebug << "InParametersList[" << i << "] : "
1466 << InParametersList[i].Name << " "
1467 << AnyValue( InParametersList[i].Value ) << endl ;
1469 CORBA::Object * obj ;
1470 InParametersList[0].Value >>= obj ;
1471 Engines::Component_var theObjComponent ;
1472 theObjComponent = Engines::Component::_narrow( obj ) ;
1473 DynInvoke( theObjComponent , "ping" ,
1474 NULL , 0 , NULL , 0 ) ;
1475 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " ping done "
1477 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1478 << " after creation of OutParametersList :" << endl;
1479 for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
1480 cdebug << "OutParametersList[" << i << "] : "
1481 << OutParametersList[i].Name << " "
1482 << AnyValue( OutParametersList[i].Value ) << endl ;
1487 if ( !IsMacroNode() ) {
1489 if ( !IsFactoryNode() ) {
1490 #if TraceDataReady_ExecuteAction
1491 cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
1493 if ( IsComputingNode() ) {
1494 ObjInterface( true ) ;
1495 //JR 05.08.2005 DEBUG : that code runs with SALOME_3 (OMNIOrb4) ...
1496 #if OMNIORB_VERSION >= 4
1497 CORBA::Object * obj ;
1498 InParametersList[0].Value >>= obj ;
1499 myObjComponent = Engines::Component::_narrow( obj ) ;
1500 //JR 05.08.2005 DEBUG : the folowing code runs with OMNIOrb3 but gives
1501 // unpredictable results with SALOME_3 (OMNIOrb4) ...
1503 CORBA::Object_ptr obj ;
1504 InParametersList[0].Value >>= obj ;
1505 CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
1506 myObjComponent = Engines::Component::_duplicate( Engines::Component::_narrow( objvar ) ) ;
1512 else if ( CORBA::is_nil( Component() ) ) {
1513 Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() ,
1514 //JR 17.02.2005 Memory Leak my_strdup( ComponentName() ) ,
1516 myContainer , myObjComponent ) ;
1517 ObjInterface( false ) ;
1518 SetContainer( myContainer ) ;
1519 SetComponent( myObjComponent ) ;
1522 myContainer = Container() ;
1523 myObjComponent = Component() ;
1524 #if TraceDataReady_ExecuteAction
1525 cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
1528 myObjComponent->ping() ;
1531 cdebug << "ping() ERROR catched" << endl ;
1537 if ( Err || ControlState() == SUPERV::ToKillState ||
1538 ControlState() == SUPERV::ToKillDoneState ||
1539 ControlState() == SUPERV::ToStopState ) {
1540 #if TraceDataReady_ExecuteAction
1541 cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
1546 if ( ControlState() == SUPERV::ToSuspendState ) {
1547 #if TraceDataReady_ExecuteAction
1548 cdebug << ThreadNo() << "ToSuspendState before running." << endl ;
1549 MESSAGE(ThreadNo() << "ToSuspendState before running.") ;
1552 #if TraceDataReady_ExecuteAction
1554 cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
1555 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1556 cdebug << " , " << InParametersList[ i ].Name << "[kind"
1557 << InParametersList[ i ].Value.type()->kind() << "]" ;
1559 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1560 cdebug << " , " << OutParametersList[ i ].Name << "[kind"
1561 << OutParametersList[ i ].Value.type()->kind() << "]" ;
1563 if ( IsOneOfInLineNodes() ) {
1564 cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
1565 << InLineNode()->PyRunMethod() << " length "
1566 << (*InLineNode()->PythonFunction()).length()
1567 << " InParametersList " << InParametersList
1568 << " OutParametersList " << OutParametersList ;
1570 cdebug << ")" << endl ;
1573 if ( IsOneOfInLineNodes() ) {
1574 Err = DataReady_ExecuteActionInLineNodes( InParametersList ,
1575 OutParametersList ) ;
1580 if ( IsComputingNode() ) {
1581 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1582 << " myObjComponent " << myObjComponent << " "
1583 << ObjectToString( myObjComponent ) << endl ;
1584 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1585 << " before DynInvoke nInParams " << nInParams
1588 CORBA::Object * obj ;
1589 InParametersList[0].Value >>= obj ;
1590 Engines::Component_var theObjComponent ;
1591 theObjComponent = Engines::Component::_narrow( obj ) ;
1592 DynInvoke( theObjComponent , "ping" ,
1593 NULL , 0 , NULL , 0 ) ;
1594 for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
1595 cdebug << "InParametersList[" << i << "] : "
1596 << InParametersList[i].Name << " "
1597 << AnyValue( InParametersList[i].Value ) << endl ;
1602 #if TraceDataReady_ExecuteAction
1603 cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ;
1605 DynInvoke( myObjComponent, "Names" ,
1606 _OutNode->Name() , Name() ) ;
1609 string anErrorMessage = string( "Dynamic CORBA call to Names for node " ) +
1610 string( Name() ) + " catched." ;
1611 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1612 cdebug << "DynInvoke Names catched ERROR" << endl ;
1614 // for DataStreamNodes : call of SetProperties ===> environment variables in the component/container
1615 if ( ComputingNode()->HasDataStream() ) {
1617 #if TraceDataReady_ExecuteAction
1618 cdebug << "DynInvoke -> SetProperties " << _OutNode->Name() << " " << Name() << endl ;
1620 Engines::FieldsDict_var dict = new Engines::FieldsDict;
1622 dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
1623 // myContainer->getHostName() ne renvoit pas le nom complet (avec domaine).
1624 // dict[ 0 ].value <<= myContainer->getHostName() ;
1625 char FullyQualifiedDomainName[256]="";
1626 gethostname(FullyQualifiedDomainName,255);
1627 dict[ 0 ].value <<= FullyQualifiedDomainName ;
1628 dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
1629 dict[ 1 ].value <<= "/tmp" ;
1630 dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
1631 stringstream ofst1 ;
1632 ofst1 << ComputingNode()->SubStreamGraph() ;
1633 string cpl = string( "/tmp/" ) + string( _OutNode->Name() ) + string( "_" ) +
1634 ofst1.str() + string( ".cpl" );
1635 dict[ 2 ].value <<= cpl.c_str() ;
1636 dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
1637 string uname = Name();
1639 dict[ 3 ].value <<= uname.c_str() ;
1641 myObjComponent->setProperties( dict ) ;
1644 string anErrorMessage = string( "Dynamic CORBA call to setProperties for node " ) +
1645 string( Name() ) + " catched." ;
1646 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1647 cdebug << "DynInvoke setProperties catched ERROR" << endl ;
1653 if ( !Err && IsComputingNode() ) {
1654 #if TraceDataReady_ExecuteAction
1655 cdebug << ThreadNo() << " !ObjInterface " << Name()
1656 << " IsComputingNode DynInvoke" << endl ;
1657 cdebug << ServiceInParameter().length()-1 << " input parameters and "
1658 << ServiceOutParameter().length() << " output parameters" << endl ;
1660 IsLoading( false ) ;
1661 DynInvoke( myObjComponent,
1663 &InParametersList[1] , ServiceInParameter().length()-1 ,
1664 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1666 { cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1667 << " myObjComponent " << myObjComponent << " "
1668 << ObjectToString( myObjComponent ) << endl ;
1669 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1670 << " after DynInvoke nInParams " << nInParams
1672 CORBA::Object * obj ;
1673 InParametersList[0].Value >>= obj ;
1674 Engines::Component_var theObjComponent ;
1675 theObjComponent = Engines::Component::_narrow( obj ) ;
1676 DynInvoke( theObjComponent , "ping" ,
1677 NULL , 0 , NULL , 0 ) ;
1678 for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
1679 cdebug << "InParametersList[" << i << "] : "
1680 << InParametersList[i].Name << " "
1681 << AnyValue( InParametersList[i].Value ) << endl ;
1686 else if ( !Err && IsFactoryNode() ) {
1687 #if TraceDataReady_ExecuteAction
1688 cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
1689 << " IsFactoryNode DynInvoke" << endl ;
1690 cdebug << ServiceInParameter().length() << " input parameters and "
1691 << ServiceOutParameter().length() << " output parameters" << endl ;
1693 IsLoading( false ) ;
1694 DynInvoke( myObjComponent,
1696 &InParametersList[0] , ServiceInParameter().length() ,
1697 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1699 // cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
1700 // << myObjComponent->CpuUsed_impl() << endl ;
1704 string anErrorMessage = string( "Dynamic CORBA call for node " ) +
1705 string( Name() ) + " catched." ;
1706 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1707 cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
1708 << " Node(Component) Dynamic Call Exception catched ERROR"
1710 //Reset of _ThreadId in the Container ...
1712 // myObjComponent->Kill_impl() ;
1723 // if exception or something else - IsLoading( false ) may not NOT has been called
1727 if ( ControlState() == SUPERV::ToKillState ||
1728 ControlState() == SUPERV::ToKillDoneState ||
1729 ControlState() == SUPERV::ToStopState ) {
1730 PortState = SUPERV::ErrorState ;
1731 NewState = GraphExecutor::KilledState ;
1732 NewEvent = GraphExecutor::KillEvent ;
1735 PortState = SUPERV::ErrorState ;
1736 NewState = GraphExecutor::ErroredState ;
1737 NewEvent = GraphExecutor::ErrorEvent ;
1741 PortState = SUPERV::ReadyState ;
1742 NewState = GraphExecutor::DataReadyState ;
1743 NewEvent = GraphExecutor::SuccessEvent ;
1746 if ( !IsMacroNode() ) {
1748 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1750 NewEvent = GraphExecutor::ErrorEvent ;
1753 if ( !Err && IsComputingNode() ) {
1754 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1755 << " myObjComponent " << myObjComponent << " "
1756 << ObjectToString( myObjComponent ) << endl ;
1757 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1758 << " delete [] InParametersList nInParams " << nInParams
1761 CORBA::Object * obj ;
1762 InParametersList[0].Value >>= obj ;
1763 Engines::Component_var theObjComponent ;
1764 theObjComponent = Engines::Component::_narrow( obj ) ;
1765 DynInvoke( theObjComponent , "ping" ,
1766 NULL , 0 , NULL , 0 ) ;
1767 for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
1768 cdebug << "InParametersList[" << i << "] : "
1769 << InParametersList[i].Name << " "
1770 << AnyValue( InParametersList[i].Value ) << endl ;
1775 delete [] InParametersList ;
1778 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1779 << " catch ERROR of delete [] InParametersList" << endl ;
1781 #if TraceDataReady_ExecuteAction
1782 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1783 << " delete [] OutParametersList :" << endl;
1785 for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
1786 cdebug << "OutParametersList[" << i << "] : "
1787 << OutParametersList[i].Name << " "
1788 << AnyValue( OutParametersList[i].Value ) << endl ;
1792 delete [] OutParametersList ;
1795 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1796 << " catch ERROR of delete [] OutParametersList" << endl ;
1798 SendEvent( NewEvent ) ;
1801 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1802 #if TraceDataReady_ExecuteAction
1804 for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
1805 cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
1806 << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
1807 << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
1808 if ( GraphBase::Base::_prof_debug ) {
1809 GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
1811 if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
1812 cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
1816 cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " "
1817 << aMacroGraph->Name() << " ->DoneWait()"
1818 << " State " << aMacroGraph->State() << endl;
1820 aMacroGraph->DoneWait() ;
1821 #if TraceDataReady_ExecuteAction
1822 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State "
1823 << aMacroGraph->State() << endl;
1826 //JR 29.09.2005 Debug for CEA (examples/GraphMacroNodes1) :
1827 // Set of value of the OutGate of the corresponding MacroNode was missing
1828 CORBA::Any anAny = CORBA::Any() ;
1829 anAny <<= (CORBA::Long ) 1 ;
1830 GraphMacroNode()->GraphEditor()->Executor()->OutputOfAny( Name() , "Gate" , anAny ) ;
1831 #if TraceDataReady_ExecuteAction
1832 cdebug << "DataReady_ExecuteAction OutputOfAny( " << Name() << " , Gate , 1 )" << endl ;
1834 for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
1835 cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
1836 << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
1837 << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
1838 if ( GraphBase::Base::_prof_debug ) {
1839 GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
1841 if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
1842 cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
1846 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State " << aMacroGraph->State() << endl;
1848 if ( aMacroGraph->State() == SUPERV::DoneState ) {
1849 PortState = SUPERV::ReadyState ;
1850 NewState = GraphExecutor::DataReadyState ;
1851 NewEvent = GraphExecutor::SuccessEvent ;
1855 if ( ControlState() == SUPERV::ToKillState ||
1856 ControlState() == SUPERV::ToKillDoneState ||
1857 ControlState() == SUPERV::ToStopState ) {
1858 PortState = SUPERV::ErrorState ;
1859 NewState = GraphExecutor::KilledState ;
1860 NewEvent = GraphExecutor::KillEvent ;
1863 PortState = SUPERV::ErrorState ;
1864 NewState = GraphExecutor::ErroredState ;
1865 NewEvent = GraphExecutor::ErrorEvent ;
1868 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1870 NewEvent = GraphExecutor::ErrorEvent ;
1872 delete [] InParametersList ;
1873 delete [] OutParametersList ;
1874 SendEvent( NewEvent ) ;
1877 #if TraceDataReady_ExecuteAction
1878 cdebug_out << ThreadNo() << " DataReady_ExecuteAction " << Name() << endl;
1883 int GraphExecutor::InNode::DataReady_ExecuteActionInLineNodes( ServicesAnyData * InParametersList ,
1884 ServicesAnyData * OutParametersList ) {
1886 #if TraceDataReady_ExecuteAction
1887 cdebug_in << pthread_self() << "/" << ThreadNo()
1888 << " DataReady_ExecuteActionInLineNodes " << Name()
1889 << " InParametersList " << InParametersList
1890 << " OutParametersList " << OutParametersList << endl;
1893 bool StsPyDynInvoke = true ;
1894 _OutNode->PyThreadLock() ;
1897 bool ItIsaLoop = false ;
1898 bool CopyInOut = false ;
1899 if ( IsInLineNode() &&
1900 strlen( InLineNode()->PyFuncName() ) ) {
1901 #if TraceDataReady_ExecuteAction
1902 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1903 << InLineNode()->PyFuncName()
1904 << "' IsInLineNode PyDynInvoke" << endl ;
1906 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1907 InLineNode()->PyFuncName() ,
1908 InParametersList , ServiceInParameter().length() ,
1909 OutParametersList , ServiceOutParameter().length() ) ;
1910 if ( !StsPyDynInvoke ) {
1911 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1914 else if ( IsLoopNode() ) {
1916 Err = DataReady_ExecuteActionLoopNodes( InParametersList ,
1920 else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
1921 strlen( InLineNode()->PyFuncName() ) ) {
1922 #if TraceDataReady_ExecuteAction
1923 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1924 << InLineNode()->PyFuncName()
1925 << "' IsSwitchNode PyDynInvoke" << endl ;
1927 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1928 InLineNode()->PyFuncName() ,
1929 InParametersList , ServiceInParameter().length() ,
1930 OutParametersList , ServiceOutParameter().length() ) ;
1932 if ( !StsPyDynInvoke ) {
1933 string anErrorMessage = string( "Dynamic Python call for node " ) +
1934 string( Name() ) + " function " +
1935 InLineNode()->PyFuncName() + " error." ;
1936 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1937 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1940 else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
1941 strlen( InLineNode()->PyFuncName() ) ) {
1942 #if TraceDataReady_ExecuteAction
1943 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1944 << InLineNode()->PyFuncName()
1945 << "' IsGOTONode PyDynInvoke" << endl ;
1948 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1949 InLineNode()->PyFuncName() ,
1950 InParametersList , ServiceInParameter().length() ,
1951 OutParametersList , ServiceOutParameter().length() ) ;
1953 if ( !StsPyDynInvoke ) {
1954 string anErrorMessage = string( "Dynamic Python call for node " ) +
1955 string( Name() ) + " function " +
1956 InLineNode()->PyFuncName() + " error." ;
1957 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1958 RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
1961 else if ( ( IsEndSwitchNode() ) &&
1962 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1963 #if TraceDataReady_ExecuteAction
1964 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1965 << InLineNode()->PyFuncName()
1966 << "' IsSwitchNode PyDynInvoke" << endl ;
1969 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1970 InLineNode()->PyFuncName() ,
1971 InParametersList , ServiceInParameter().length() ,
1972 OutParametersList , ServiceOutParameter().length() ) ;
1974 if ( !StsPyDynInvoke ) {
1975 string anErrorMessage = string( "Dynamic Python call for node " ) +
1976 string( Name() ) + " function " +
1977 InLineNode()->PyFuncName() + " error." ;
1978 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1979 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1982 else if ( IsEndLoopNode() &&
1983 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1984 #if TraceDataReady_ExecuteAction
1985 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1986 << InLineNode()->PyFuncName()
1987 << "' IsSwitchNode PyDynInvoke" << endl ;
1990 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1991 InLineNode()->PyFuncName() ,
1992 InParametersList , ServiceInParameter().length() + 1 ,
1993 OutParametersList , ServiceOutParameter().length() + 1 ) ;
1995 if ( !StsPyDynInvoke ) {
1996 string anErrorMessage = string( "Dynamic Python call for node " ) +
1997 string( Name() ) + " function " +
1998 InLineNode()->PyFuncName() + " error." ;
1999 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2000 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
2004 if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL ||
2005 strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) {
2006 // This is a void Python Function : without code (No PyFuncName)
2007 #if TraceDataReady_ExecuteAction
2008 cdebug << ThreadNo() << " !ObjInterface " << Name()
2009 << " Copy of " << ServiceInParameter().length()
2010 << " OutParameters" << endl ;
2015 if ( IsLoopNode() || IsEndLoopNode() ) {
2017 argin0 = 1 ; // after DoLoop
2018 if ( IsLoopNode() ) { // More() is void
2019 #if TraceDataReady_ExecuteAction
2020 cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)"
2023 GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
2024 OutParametersList[0].Value = anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
2027 //PAL8072 ==> PAL8512
2028 //JR 24.03.2005 : Debug : void InLine Python function : check of the number of Input Ports
2029 // equals the number of Output Ports was missing
2030 if ( ServiceInParameter().length() != ServiceOutParameter().length() ) {
2031 string anErrorMessage = string( "Inconsistent number of In<->Out parameters for the vois Python function of the node " ) +
2033 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2034 StsPyDynInvoke = false ;
2037 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
2038 OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
2040 #if TraceDataReady_ExecuteAction
2041 cdebug << "ArgOut->In" << InParametersList[argin0 + i].Name.c_str()
2042 << " " << AnyValue( InParametersList[argin0 + i].Value )
2048 if ( !StsPyDynInvoke ) {
2050 string anErrorMessage = string( "Dynamic Python call for node " ) +
2051 string( Name() ) + " error." ;
2052 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2053 cdebug << ThreadNo() << " InLineNode " << Name()
2054 << " Python Dynamic Call Error"
2060 string anErrorMessage = string( "Dynamic Python call for node " ) +
2061 string( Name() ) + " catched." ;
2062 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2063 cdebug << ThreadNo() << " InLineNode " << Name()
2064 << " Python Dynamic Call Exception catched ERROR"
2068 _OutNode->PyThreadUnLock() ;
2069 #if TraceDataReady_ExecuteAction
2070 cdebug_out << pthread_self() << "/" << ThreadNo()
2071 << " DataReady_ExecuteActionInLineNodes " << Name() << endl;
2076 int GraphExecutor::InNode::DataReady_ExecuteActionLoopNodes( ServicesAnyData * InParametersList ,
2077 ServicesAnyData * OutParametersList ,
2078 bool & CopyInOut ) {
2080 #if TraceDataReady_ExecuteAction
2081 cdebug_in << pthread_self() << "/" << ThreadNo()
2082 << " DataReady_ExecuteActionLoopNodes " << Name()
2083 << " InParametersList " << InParametersList
2084 << " OutParametersList " << OutParametersList << endl;
2087 bool StsPyDynInvoke = true ;
2088 bool CopyOutIn = false ;
2089 // Switch between Init() and Next()
2090 // if InLoop port is true and does not come from EndLoop ==> execute Init
2091 // if InLoop port is false or come from EndLoop ==> execute Next
2093 if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init()
2094 #if TraceDataReady_ExecuteAction
2095 cdebug << ThreadNo() << " !ObjInterface " << Name()
2096 << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
2097 << "' InitLoop " << LoopNode()->PyRunMethod() << endl ;
2099 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
2100 InLineNode()->PyFuncName() ,
2101 &InParametersList[1] , ServiceInParameter().length() ,
2102 &OutParametersList[1] , ServiceOutParameter().length() ) ;
2103 if ( !StsPyDynInvoke ) {
2104 string anErrorMessage = string( "Dynamic Python call for node " ) +
2105 string( Name() ) + " function " +
2106 InLineNode()->PyFuncName() + " error." ;
2107 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2108 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
2113 #if TraceDataReady_ExecuteAction
2114 cdebug << ThreadNo() << " !ObjInterface " << Name()
2115 << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ;
2118 #if TraceDataReady_ExecuteAction
2119 cdebug << ThreadNo() << " !ObjInterface " << Name()
2120 << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ;
2124 else if ( LoopNode()->PyNextMethod() &&
2125 strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next()
2126 #if TraceDataReady_ExecuteAction
2127 cdebug << ThreadNo() << " !ObjInterface " << Name()
2128 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
2129 << "' " << LoopNode()->PyNextMethod() << endl ;
2131 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
2132 LoopNode()->PyNextName() ,
2133 &InParametersList[1] , ServiceInParameter().length() ,
2134 &OutParametersList[1] , ServiceOutParameter().length() ) ;
2135 if ( !StsPyDynInvoke ) {
2136 string anErrorMessage = string( "Dynamic Python call for node " ) +
2137 string( Name() ) + " function " +
2138 LoopNode()->PyNextName() + " error." ;
2139 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2140 RemovePyDynInvoke( LoopNode()->PyNextName() ) ;
2145 #if TraceDataReady_ExecuteAction
2146 cdebug << ThreadNo() << " !ObjInterface " << Name()
2147 << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ;
2150 if ( StsPyDynInvoke ) {
2152 #if TraceDataReady_ExecuteAction
2153 cdebug << ThreadNo() << " !ObjInterface " << Name()
2154 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
2155 << "' Copy of " << ServiceInParameter().length()
2156 << " OutParameters" << endl ;
2159 // Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next )
2160 for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
2161 InParametersList[i].Value = OutParametersList[i].Value ;
2162 InParametersList[i].Name = OutParametersList[i].Name ;
2163 #if TraceDataReady_ExecuteAction
2164 cdebug << "ArgOut->In" << InParametersList[ i].Name.c_str()
2165 << " " << AnyValue( InParametersList[ i].Value )
2170 if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
2171 #if TraceDataReady_ExecuteAction
2172 cdebug << ThreadNo() << " !ObjInterface " << Name()
2173 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
2174 << "' " << LoopNode()->PyMoreMethod() << endl ;
2176 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
2177 LoopNode()->PyMoreName() ,
2178 &InParametersList[1] , ServiceInParameter().length() ,
2179 &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
2180 if ( !StsPyDynInvoke ) {
2181 string anErrorMessage = string( "Dynamic Python call for node " ) +
2182 string( Name() ) + " function " +
2183 LoopNode()->PyMoreName() + " error." ;
2184 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2185 RemovePyDynInvoke( LoopNode()->PyMoreName() ) ;
2189 #if TraceDataReady_ExecuteAction
2190 cdebug << ThreadNo() << " !ObjInterface " << Name()
2191 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
2192 << "' No MoreMethod" << endl ;
2199 cdebug << ThreadNo() << " InLineNode " << Name() << " "
2200 << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
2201 << " Python Dynamic Call Error"
2204 #if TraceDataReady_ExecuteAction
2205 cdebug_out << pthread_self() << "/" << ThreadNo()
2206 << " DataReady_ExecuteActionLoopNodes " << Name() << endl;
2211 int GraphExecutor::InNode::Executing_SuspendAction() {
2212 _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
2213 GraphExecutor::SuspendedExecutingState ) ;
2214 cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
2218 int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
2219 cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
2220 GraphExecutor::AutomatonState next_state ;
2221 next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
2222 _OutNode->NewThread() ; // Only for Threads count
2223 _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
2225 State( next_state ) ;
2229 int GraphExecutor::InNode::Executing_KillAction() {
2230 cdebug << ThreadNo() << " Executing_KillAction " << Name() << " Thread " << ThreadNo()<< endl;
2232 if ( pthread_self() == ThreadNo() ) {
2233 cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
2235 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
2236 GraphExecutor::KilledExecutingState ) ;
2239 else if ( pthread_cancel( ThreadNo() ) ) {
2240 perror("Executing_KillAction pthread_cancel error") ;
2243 cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
2244 << " pthread_canceled" << endl ;
2246 _OutNode->ExitThread( ThreadNo() ) ;
2247 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
2248 GraphExecutor::KilledExecutingState ) ;
2253 int GraphExecutor::InNode::Executing_StopAction() {
2254 cdebug << ThreadNo() << " Executing_StopAction " << Name() << " Thread " << ThreadNo() << endl;
2256 if ( pthread_cancel( ThreadNo() ) ) {
2257 perror("Executing_KillAction pthread_cancel error") ;
2260 cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
2261 << " pthread_canceled" << endl ;
2263 _OutNode->ExitThread( ThreadNo() ) ;
2264 _OutNode->PushEvent( this , GraphExecutor::StoppedExecutingEvent ,
2265 GraphExecutor::StoppedExecutingState ) ;
2270 int GraphExecutor::InNode::Executing_SuccessAction() {
2271 // cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
2272 _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
2273 GraphExecutor::SuccessedState ) ;
2274 // MESSAGE(pthread_self() << "Executor::InNode::Executing_SuccessAction of " << Name()
2275 // << " ControlState " << Automaton()->ControlStateName( ControlState() )
2276 // << " AFTER execution ThreadNo " << ThreadNo() ) ;
2277 SUPERV::ControlState aControl = ControlState() ;
2278 switch ( aControl ) {
2279 case SUPERV::VoidState : {
2280 SendEvent( SuccessEvent ) ;
2283 case SUPERV::ToSuspendState : {
2284 SendEvent( SuccessEvent ) ;
2287 case SUPERV::ToSuspendDoneState : {
2288 SendEvent( GraphExecutor::SuspendEvent ) ;
2291 case SUPERV::ToKillState : {
2292 SendEvent( GraphExecutor::KillEvent ) ;
2295 case SUPERV::ToKillDoneState : {
2296 SendEvent( GraphExecutor::KillEvent ) ;
2299 case SUPERV::ToStopState : {
2300 SendEvent( GraphExecutor::StopEvent ) ;
2304 cdebug << ThreadNo()
2305 << " GraphExecutor::InNodeThreads::Executing_SuccessAction Error Undefined Control : "
2306 << aControl << endl ;
2310 // cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
2314 int GraphExecutor::InNode::Errored_ExecutingAction() {
2315 cdebug << ThreadNo() << " --> Errored_ExecutingAction " << Name() << endl;
2316 _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
2317 GraphExecutor::ErroredState ) ;
2319 _OutNode->NodeAborted( Name() ) ;
2321 SUPERV::ControlState aControl = ControlState() ;
2322 switch ( aControl ) {
2323 case SUPERV::VoidState : {
2324 SendEvent( ErrorEvent ) ;
2327 case SUPERV::ToSuspendState : {
2328 SendEvent( ErrorEvent ) ;
2331 case SUPERV::ToSuspendDoneState : {
2332 SendEvent( GraphExecutor::SuspendEvent ) ;
2335 case SUPERV::ToKillState : {
2336 SendEvent( GraphExecutor::KillEvent ) ;
2339 case SUPERV::ToKillDoneState : {
2340 SendEvent( GraphExecutor::KillEvent ) ;
2343 case SUPERV::ToStopState : {
2344 SendEvent( GraphExecutor::StopEvent ) ;
2348 cdebug << ThreadNo()
2349 << " GraphExecutor::InNodeThreads::Errored_ExecutingAction Error Undefined Control : "
2350 << aControl << endl ;
2354 cdebug << ThreadNo() << " <-- Errored_ExecutingAction " << Name() << endl;
2358 #define SetWaitingStatesTrace 0
2359 // Set SUPERV::WaitingState to all InPorts and Nodes
2360 void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
2363 bool docdebug = false ;
2364 State( GraphExecutor::DataWaitingState ) ;
2365 #if SetWaitingStatesTrace
2366 cdebug << "SetWaitingStates " << Name() << " " << Automaton()->StateName( State() ) << endl ;
2368 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2369 GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
2370 #if SetWaitingStatesTrace
2371 cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
2372 << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
2375 // JR Debug 07.01.2005 : Close the Gates instead of open !!!
2376 if ( anInPort->IsGate() ) { // Loop : Close the doors
2377 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
2379 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
2380 CORBA::Any anAny = CORBA::Any() ;
2381 // *anAny <<= (CORBA::Long ) 1 ;
2382 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 0 ;
2383 anAny <<= (CORBA::Long ) 0 ;
2384 anOutPort->SetValue( anAny ) ;
2385 anInPort->PortState( SUPERV::WaitingState ) ;
2389 else if ( anInPort->PortState() != SUPERV::WaitingState &&
2390 !anInPort->IsDataConnected() ) {
2392 #if SetWaitingStatesTrace
2393 cdebug << ThreadNo()
2394 << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
2398 if ( !anInPort->IsDataStream() ) {
2399 anInPort->PortState( SUPERV::WaitingState ) ;
2402 #if SetWaitingStatesTrace
2403 cdebug << " --> InPort " << Name() << "( " << anInPort->PortName() << " ) "
2404 << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
2406 //JR NPAL14110 09.02.2007 : SetWaitingStates was missing in the corresponding SubGraph !...
2407 if ( IsMacroNode() ) {
2408 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
2409 #if SetWaitingStatesTrace
2410 cdebug << ThreadNo()
2411 << " --> GraphExecutor::InNodeThreads::SetWaitingStates MacroNode " << Name()
2412 << " ---> MacroGraph " << aMacroGraph->Name() << " Inport "
2413 << anInPort->PortName() << endl;
2415 aMacroGraph->SetWaitingStates( anInPort->PortName() ) ;
2418 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
2419 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
2421 //JR 07.03.2005 Debug : Reset of Done flag in OutPorts !... :
2422 if ( !anOutPort->IsDataStream() ) {
2423 anOutPort->PortDone( false ) ;
2424 anOutPort->PortState( SUPERV::WaitingState ) ;
2426 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
2427 if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
2428 !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) &&
2429 !anOutPort->IsDataStream() &&
2430 !anOutPort->ChangeInPorts( j )->IsDataStream() &&
2431 !anOutPort->ChangeInPorts( j )->IsExternConnected() ) {
2432 #if SetWaitingStatesTrace
2433 cdebug << ThreadNo()
2434 << " InNodeThreads::SetWaitingStates OutPort "
2435 << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
2436 << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
2437 << anOutPort->ChangeInPorts( j )->NodeName() << "( "
2438 << anOutPort->ChangeInPorts( j )->PortName() << " "
2439 << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
2441 GraphBase::ComputingNode * aToNode ;
2442 aToNode = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() ) ;
2443 // JR 12.01.2005 Debug : the OutPort linked to the InPort of a EndSwitchNode was changed so final
2444 // values of InPorts of EndSwitchNode may be wrong
2445 // (depending of order of linkednodes)
2446 if ( !aToNode->IsEndSwitchNode() &&
2447 strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
2448 // After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from
2449 // EndLoopNode or GOTONode. But if there is several nested loops we should re-establish.
2450 #if SetWaitingStatesTrace
2451 cdebug << ThreadNo()
2452 << " InNodeThreads::SetWaitingStates Node " << Name() << " "
2453 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
2454 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
2455 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
2456 << anOutPort->PortName() << " )" << endl ;
2458 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2461 //JR 21.04.2005 Debug : the OutPort field of InPorts of EndSwitchNodes must be an OutPort
2462 // of a SwitchBranch or of a NOTSwitchBranch if a link exist
2463 // (if not there is no change)
2464 else if ( !IsSwitchNode() && aToNode->IsEndSwitchNode() &&
2465 strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
2466 #if SetWaitingStatesTrace
2467 cdebug << ThreadNo()
2468 << " InNodeThreads::SetWaitingStates Node " << Name() << " "
2469 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
2470 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
2471 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
2472 << anOutPort->PortName() << " )" << endl ;
2474 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2476 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ;
2477 if ( aNode != EndNode ) {
2478 aNode->SetWaitingStates( EndNode ) ;
2482 #if SetWaitingStatesTrace
2483 cdebug << " --> OutPort " << Name() << "( " << anOutPort->PortName() << " ) "
2484 << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
2489 #define SuccessActionTrace 1
2491 int GraphExecutor::InNode::Successed_SuccessAction() {
2492 #if SuccessActionTrace
2493 cdebug_in << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2498 //JR 15.04.2005 Debug RetroConception :
2499 //The behavior of firstzeroNode and firsttoNode is not reliable and must be removed
2500 //The real problem is :
2501 // 1. send "SomeDataReady" event to linked nodes of the current node
2502 // 2. DO NOT send "AllDataReady" event even if all data are ready in SomeDataReady Action
2503 // but register only that all data are ready :
2504 // MAJOR ENHANCEMENT OF GRAPHEXECUTOR
2505 // 3. activate AllDataReady Action for each node (except the first one ) which have all
2506 // its data ready with a creation of a new thread
2507 // 3. activate AllDataReady Action for the first node which have all its data
2508 // ready in the current thread
2509 //The difficult problem (that I had in the past) was to clearly identify the above behavior ==>
2510 // firstzeroNode, firsttoNode, createnewthreadif, loackdatawait, "would dead lock" etc...
2511 // because if SomeDataReady Action see that all data were ready, it called immediately
2512 // AllDataReady Action ==> bugs difficult to understand and to reproduce
2513 //And the MAJOR DEBUG is (since the first "maquette") : we may have concurrent executions
2514 // of "SomeDataReady" in several threads and there WAS NO MUTEX to protect that
2515 // concurrent actions on the same node
2516 // int linkednodesnumber = LinkedNodesSize() ;
2517 // GraphExecutor::InNode *firstzeroNode = NULL ;
2518 GraphExecutor::InNode *firsttoNode = NULL ;
2519 GraphExecutor::InNode *toNode ;
2522 list<GraphExecutor::InNode *> SomeDataNodes ;
2526 if ( IsMacroNode() ) {
2527 #if SuccessActionTrace
2528 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done for that MacroNode"
2534 //JR 09.02.2005 : That complicated part of the code manages LOOPS and GOTO
2535 if ( IsGOTONode() ||
2536 ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
2537 #if SuccessActionTrace
2538 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2539 << " SetWaitingStates " << endl ;
2541 const GraphBase::OutPort * aGateOutPort ;
2542 if ( IsGOTONode() ) {
2543 aGateOutPort = GetNodeOutGate() ;
2546 aGateOutPort = GetNodeOutLoop() ;
2548 if ( aGateOutPort->InPortsSize() != 1 ) {
2549 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction aGateOutPort->InPortsSize "
2550 << aGateOutPort->InPortsSize() << " != 1 ERROR " << Name() << endl ;
2552 GraphExecutor::InNode * aLabelNode = NULL ;
2553 for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
2554 const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
2555 aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
2556 #if SuccessActionTrace
2557 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
2558 << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
2560 State( GraphExecutor::DataWaitingState ) ;
2561 aLabelNode->SetWaitingStates( this ) ;
2562 // JR 07.01.2005 Debug : Open the Gate of the coupledNode closed by SetWaitingStates
2563 GraphBase::OutPort * anOutPort = aLabelNode->GetChangeNodeInGate()->GetOutPort() ;
2565 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
2566 CORBA::Any anAny = CORBA::Any() ;
2567 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 1 ;
2568 anAny <<= (CORBA::Long ) 1 ;
2569 anOutPort->SetValue( anAny ) ;
2570 aLabelNode->GetChangeNodeInGate()->PortState( SUPERV::ReadyState ) ;
2573 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
2574 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
2575 if ( anInPort->GetOutPort() ) {
2576 #if SuccessActionTrace
2577 cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
2578 << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
2583 //PAL8176 ==> PAL8516
2584 //JR 24.03.2005 Debug : the number of OutPorts of a GOTONode and of InPorts of its linked
2585 // InLine node must be the same
2586 if ( GetNodeOutPortsSize() != aLabelNode-> GetNodeInPortsSize() ) {
2587 cdebug << pthread_self() << "/" << ThreadNo()
2588 << " Successed_SuccessAction # number of ports " << GetNodeOutPortsSize()
2589 << " != " << aLabelNode-> GetNodeInPortsSize() << endl ;
2590 SendEvent( GraphExecutor::ErrorEvent ) ;
2594 for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
2595 GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
2596 if ( !aBusParamOutPort->IsGate() ) {
2597 GraphBase::InPort * aBusParamChangeInPort = NULL ;
2598 if ( aBusParamOutPort->IsLoop() ) {
2599 // For EndLoop do not copy EndLoop(DoLoop) in Loop(InLoop)
2600 // aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
2603 aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
2605 if ( aBusParamChangeInPort ) {
2606 aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
2607 #if SuccessActionTrace
2608 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
2609 << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
2610 << aBusParamOutPort->PortName() << endl ;
2613 else if ( IsGOTONode() ) {
2614 //PAL8176 ==> PAL8516
2615 //JR 24.03.2005 Debug : the names of OutPorts of a GOTONode and of InPorts of its linked
2616 // InLine node must be the same
2617 cdebug << pthread_self() << "/" << ThreadNo()
2618 << " Successed_SuccessAction # names of ports "
2619 << aBusParamOutPort->PortName() << endl ;
2620 SendEvent( GraphExecutor::ErrorEvent ) ;
2628 //JR 15.04.2005 Debug PAL8624 RetroConception :
2629 // THERE IS ONLY ONE NODE COUPLED TO A GOTONODE OR AN ENDLOOPNODE BUT Mutex/Lock for consistency
2631 const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
2632 if ( aGateInPort ) {
2633 if ( aGateInPort->GetOutPort() ) {
2634 //JR 21.02.2005 Debug Memory leak : aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
2635 //JR 30.03.2005 aGateInPort->GetOutPort()->Value( *aGateOutPort->Value() ) ;
2636 aGateInPort->GetOutPort()->SetValue( aGateOutPort->Value() ) ;
2638 //JR 15.04.2005 Debug PAL8624 RetroConception :
2639 if ( !aLabelNode->SendSomeDataReady( Name() ) ) {
2640 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2641 << Name() << " SendSomeDataReady to " << aLabelNode->Name() << " ERROR"
2644 SendEvent( GraphExecutor::ErrorEvent ) ;
2647 if ( aLabelNode->HasAllDataReady() ) {
2648 aLabelNode->ThreadNo( pthread_self() ) ;
2649 aLabelNode->CreateNewThread( false ) ;
2650 aLabelNode->RewindStack( RewindStack() ) ;
2651 aLabelNode->HasAllDataReady( false ) ;
2652 res = aLabelNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
2656 cdebug << pthread_self() << "/" << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
2657 << " NO port " << aGateOutPort->PortName() << " in "
2658 << aLabelNode->Name() << endl;
2664 //==================================================
2665 // JR 09.02.2005 : this is not a EndLoop or a GOTO :
2666 //==================================================
2667 else { // Not a EndLoop or a GOTO
2668 #if SuccessActionTrace
2669 cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
2670 << " with " << LinkedNodesSize() << " linked nodes :" ;
2671 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2672 cdebug << " " << LinkedNodes( i )->Name() ;
2676 //JR 15.04.2005 Debug PAL8624 RetroConception :
2677 // If this is a LoopNode and if DoLoopPort == false, we go directly to the EndOfLoopNode and
2678 // we do not activate Nodes within the loop
2679 bool IgnoreForEndLoop = false ;
2680 // If this is a SwitchNode and if DefaultOutPort == true, we do not activate Nodes within Switch
2681 // We activate directly the EnSwitch
2682 // BUT the NotSwitchBranch(es) are NOT activated :
2683 bool IgnoreForDefaultSwitch = false ;
2684 if ( IsLoopNode() ) {
2685 GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
2686 if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
2687 IgnoreForEndLoop = true ;
2690 else if ( IsSwitchNode() ) {
2691 const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
2692 if ( anOutGatePort->BoolValue() && anOutGatePort->InPortsSize() ) { // DefaultPort is activated
2693 // The DefaultOutPort of that SwitchNode is true and is connected
2694 IgnoreForDefaultSwitch = true ;
2698 //Loop of LinkedNodes for SendSomeDataReady :
2699 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2700 GraphBase::ComputingNode * aComputingNode ;
2701 aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
2702 toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
2703 #if SuccessActionTrace
2704 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction of " << Name()
2705 << " [" << i << "] " << LinkedNodes( i )->Name() << " toNode " << toNode
2706 << " IgnoreForEndLoop " << IgnoreForEndLoop ;
2708 cdebug << " " << toNode->Kind() << endl ;
2711 //JR 15.04.2005 Debug PAL8624 RetroConception :
2713 //JR 18.05.2005 : we must lock because of concurrent SendEvent if NotAllDataReady :
2714 toNode->LockDataReady() ;
2715 if ( IsComputingNode() && toNode->IsInLineNode() ) {
2716 GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
2717 toGateInPort->PortState( SUPERV::ReadyState ) ;
2718 GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
2719 if ( GateOutPort ) {
2720 GateOutPort->PortStatus( DataConnected );
2721 GateOutPort->PortState( SUPERV::ReadyState ) ;
2722 GateOutPort->PortDone( true ) ;
2726 //JR 15.04.2005 Debug PAL8624 RetroConception :
2727 if ( IsLoopNode() ) {
2728 if ( IgnoreForEndLoop && !strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
2729 GraphBase::InPort * toLoopInPort ;
2730 toLoopInPort = toNode->GetChangeNodeInLoop() ;
2731 if ( toLoopInPort->PortState() != SUPERV::ReadyState ) {
2732 toLoopInPort->PortState( SUPERV::ReadyState ) ;
2736 //JR 15.04.2005 Debug PAL8624 RetroConception :
2737 else if ( toNode->IsInLineNode() ) {
2739 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
2740 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
2744 bool activatetoNode = true ;
2745 //We have to execute the loop :
2746 if ( !IgnoreForEndLoop ) {
2747 //The loop is not finished :
2748 if ( toNode->IsLoopNode() ) {
2749 //We enter in a new loop :
2750 GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
2751 toLoopInPort->PortState( SUPERV::ReadyState ) ;
2752 GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
2753 LoopOutPort->PortStatus( DataConnected );
2754 LoopOutPort->PortState( SUPERV::ReadyState ) ;
2755 LoopOutPort->PortDone( true ) ;
2756 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
2757 CORBA::Any anAny = CORBA::Any() ; // InitLoop
2758 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 1 ;
2759 anAny <<= (CORBA::Long ) 1 ;
2760 LoopOutPort->SetValue( anAny ) ;
2762 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
2763 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
2767 //The loop is finished :
2768 else if ( IsLoopNode() ) {
2769 if ( toNode->IsEndLoopNode() ) {
2770 //Not the corresponding EndLoopNode :
2771 if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
2772 #if SuccessActionTrace
2773 cdebug << pthread_self() << "/" << ThreadNo()
2774 << " Successed_SuccessAction NO activate EndLoopNode " << toNode->Name()
2777 activatetoNode = false ;
2780 //Not a EndLoopNode :
2782 #if SuccessActionTrace
2783 cdebug << pthread_self() << "/" << ThreadNo()
2784 << " Successed_SuccessAction NO activate node " << toNode->Name() << endl ;
2786 activatetoNode = false ;
2790 // If the DefaultPort of that SwitchNode is connected to the DefaultPort of the EndSwitchNode
2791 // the NotSwitchBranch(es) are NOT activated :
2792 if ( IgnoreForDefaultSwitch ) {
2793 //We have to activate Default to EndSwitchNode
2794 #if SuccessActionTrace
2795 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction search "
2796 << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
2797 << "IgnoreForDefaultSwitch" << IgnoreForDefaultSwitch << endl ;
2799 activatetoNode = false ;
2800 const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
2801 const GraphBase::InPort * anInPort = NULL ;
2803 for ( j = 0 ; j < anOutGatePort->InPortsSize() ; j++ ) {
2804 anInPort = anOutGatePort->InPorts( j ) ;
2805 const GraphBase::ComputingNode * aNode ;
2806 aNode = _OutNode->Graph()->GetGraphNode( anInPort->NodeName() ) ;
2808 #if SuccessActionTrace
2809 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction try "
2810 << aNode << " " << aNode->Name() << " == " << toNode << " " << toNode->Name()
2814 if ( aNode && (const GraphBase::ComputingNode * ) toNode->ComputingNode() == aNode ) {
2815 // toNode is connected to the DefaultPort of that SwitchNode :
2816 #if SuccessActionTrace
2817 cdebug << pthread_self() << "/" << ThreadNo()
2818 << " Successed_SuccessAction activate node " << aNode->Name() << endl ;
2820 activatetoNode = true ;
2824 #if SuccessActionTrace
2825 cdebug << pthread_self() << "/" << ThreadNo()
2826 << " Successed_SuccessAction NO activate node " << aNode->Name() << endl ;
2831 //JR 19.04.2005 Debug : Do not activate the EndSwitchNode if DefaultGate is close.
2832 //JR 20.04.2005 : it is false : an outport of the SwitchNode may be connected to an
2833 // input port of the EndSwitchNode
2834 if ( activatetoNode ) {
2835 #if SuccessActionTrace
2836 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2837 << toNode->Name() << "->SendSomeDataReady( " << Name() << " )" << endl ;
2839 if ( !toNode->SendSomeDataReady( Name() ) ) {
2840 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2841 << Name() << " SendSomeDataReady to " << toNode->Name() << " ERROR"
2844 toNode->UnLockDataReady() ;
2845 SendEvent( GraphExecutor::ErrorEvent ) ;
2849 toNode->UnLockDataReady() ;
2851 } //End of Loop of LinkedNodes for SendSomeDataReady
2853 //JR 10.02.2005 : Debug at the end of execution of a SwitchNode :
2854 // Here after we may start execution of only one SwitchBranch or of the Default
2855 // But with activation of only one SwitchBranch we may activate several nodes of that SwitchBranch and
2856 // we may activate several nodes of NotSwitchBranch ( a NotSwitchBranch is a Branch of the Switch
2857 // where GatePorts of Nodes are not connected ; that Branches are always executed for each of SwitchBranch
2858 // BUT are not executed when Default is activated).
2859 if ( IsSwitchNode() ) {
2860 GraphBase::InLineNode * anEndSwitchNode = GOTONode()->CoupledNode() ;
2861 //The InPorts of the EndSwitchNode may be connected from that SwitchNode
2862 //So at first, if we activate a SwitchBranch, we have to establish the correct OutPort in the InPorts
2863 // of the EndSwitchNode (for the SwitchBranch and the NOTSwitchBranch[es] :
2865 // So the bug is that all input ports of the corresponding EndSwitchNode must have the status NOTDONE !
2866 // (Only if Default OutPort is closed and Default InPort is closed) :
2867 if ( !GetNodeOutGate()->BoolValue() && anEndSwitchNode->GetNodeInGate()->GetOutPort() &&
2868 !anEndSwitchNode->GetNodeInGate()->GetOutPort()->BoolValue() ) {
2869 #if SuccessActionTrace
2870 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << anEndSwitchNode->Name()
2871 << " reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
2874 for ( i = 0 ; i < anEndSwitchNode->GetNodeInPortsSize() ; i++ ) {
2875 GraphBase::OutPort * anOutPort = anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort() ;
2877 //JR 08.03.2005 Debug : update of state only if not a StreamPort
2878 if ( anOutPort && strcmp( anOutPort->NodeName() , Name() ) &&
2879 !anOutPort->IsDataStream() ) {
2880 #if SuccessActionTrace
2881 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2882 << anEndSwitchNode->Name() << " InPort "
2883 << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOTDONE from "
2884 << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
2886 anEndSwitchNode->GetChangeNodeInPort( i )->PortState( SUPERV::WaitingState ) ;
2887 anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort()->PortDone( false ) ;
2890 #if SuccessActionTrace
2891 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2892 << anEndSwitchNode->Name() << " InPort "
2893 << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOT Changed : directly from "
2894 << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
2900 #if SuccessActionTrace
2901 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2902 << " " << Kind() << " OutGate->Value " << GetNodeOutGate()->BoolValue()
2903 << " NO reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
2908 //JR 15.04.2005 Debug PAL8624 RetroConception :
2909 //Make the list of nodes to activate :
2910 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2911 GraphBase::ComputingNode * aComputingNode ;
2912 aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
2913 toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
2914 if ( toNode ) { // Only Not DataFlowNode :
2915 toNode->LockDataReady() ; // Only ONE Node may send AllDataReadyEvent to an other node
2916 if ( toNode->HasAllDataReady() ) {
2917 SomeDataNodes.push_back( toNode ) ;
2918 toNode->HasAllDataReady( false ) ;
2919 #if SuccessActionTrace
2920 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2921 << Name() << " push "
2922 << toNode->Name() << " " << SomeDataNodes.size() << endl ;
2925 toNode->UnLockDataReady() ;
2929 // firsttoNode : node that has the same ThreadNo() as the current node and that have to be activated
2930 //JR 15.04.2005 Debug PAL8624 RetroConception :
2931 //Activation of nodes that have AllDataReady in a new thread except one :
2932 while ( SomeDataNodes.size() > 1 ) {
2933 GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
2934 SomeDataNodes.pop_front() ;
2935 #if SuccessActionTrace
2936 cdebug << pthread_self() << "/" << ThreadNo()
2937 << " Successed_SuccessAction pop size "
2938 << SomeDataNodes.size() << " " << aNode->Name() << endl ;
2939 cdebug << pthread_self() << "/" << ThreadNo() << " " << aNode->Name()
2940 << " Successed_SuccessAction poped and will start in a new thread" << endl ;
2942 aNode->CreateNewThread( true ) ;
2943 _OutNode->IncrCreatedThreads() ;
2944 //JR 15.04.2005 Debug PAL8624 RetroConception :
2945 res = aNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
2948 //Activation of the last node that have AllDataReady in the same thread :
2949 if ( SomeDataNodes.size() ) {
2950 firsttoNode = SomeDataNodes.front() ;
2951 SomeDataNodes.pop_front() ;
2953 if ( firsttoNode ) {
2954 #if SuccessActionTrace
2955 cdebug << pthread_self() << "/" << ThreadNo()
2956 << " Successed_SuccessAction start firsttoNode "
2957 << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
2959 // firsttoNode->CreateNewThreadIf( false ) ;
2960 firsttoNode->CreateNewThread( false ) ;
2961 firsttoNode->RewindStack( RewindStack() ) ;
2962 if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
2963 #if SuccessActionTrace
2964 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
2965 << " : " << firsttoNode->Name() << " "
2966 << Automaton()->StateName( firsttoNode->State() )
2967 << " --> DataWaitingState for Thread "
2968 << firsttoNode->ThreadNo() << endl ;
2970 firsttoNode->State( GraphExecutor::DataWaitingState ) ;
2972 firsttoNode->ThreadNo( pthread_self() ) ;
2973 // On continue avec le meme thread
2975 #if SuccessActionTrace
2976 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2977 << " for firsttoNode " << firsttoNode->Name()
2978 << " " << Automaton()->StateName( firsttoNode->State() ) << endl ;
2980 //JR 15.04.2005 Debug PAL8624 RetroConception :
2981 //No creation of thread and with LockDataReady, an other node in an other thread cannot be
2982 // waiting for that lock ( if it was the case we could not find AllDataReady for firsttoNode
2983 res = firsttoNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
2986 #if SuccessActionTrace
2987 cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
2988 << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL" << endl ;
2993 #if SuccessActionTrace
2994 cdebug_out << pthread_self() << "/" << ThreadNo()
2995 << " Successed_SuccessAction " << Name() << endl;
3000 #define SendSomeDataReadyTrace 1
3001 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
3002 bool RetVal = false ;
3003 if ( IsDataFlowNode() ) {
3004 #if SendSomeDataReadyTrace
3005 cdebug_in << ThreadNo() << "InNode::SendSomeDataReady " << FromNodeName
3006 << " send Result to graph " << Name() << endl;
3010 #if SendSomeDataReadyTrace
3011 cdebug_in << pthread_self() << "/" << ThreadNo() << FromNodeName
3012 << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
3013 << Automaton()->StateName( State() ) << endl;
3015 if ( State() == GraphExecutor::SuccessedState ||
3016 State() == GraphExecutor::SuspendedSuccessedState ||
3017 State() == GraphExecutor::SuspendedSuccessedToReStartState ) {
3018 #if SendSomeDataReadyTrace
3019 cdebug << ThreadNo() << " " << FromNodeName
3020 << " : " << Name() << " " << Automaton()->StateName( State() )
3021 << " --> DataWaitingState for Thread "
3022 << ThreadNo() << " " << endl ;
3024 State( GraphExecutor::DataWaitingState ) ;
3026 // We begin that LoopNode if SendSomeDataReady does not come from the corresponding EndLoopNode
3027 if ( IsLoopNode() && strcmp( LoopNode()->CoupledNodeName() , FromNodeName ) ) {
3028 #if SendSomeDataReadyTrace
3029 cdebug << ThreadNo() << "InNode::SendSomeDataReady " << Name() << " Set _InitLoop from "
3030 << FromNodeName << endl ;
3034 #if SendSomeDataReadyTrace
3035 cdebug << "SendEvent( SomeDataReadyEvent )" << endl ;
3037 //JR 15.04.2005 Debug PAL8624 RetroConception :
3038 DataFromNode( FromNodeName ) ;
3039 // RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
3040 RetVal = SendEvent( GraphExecutor::SomeDataReadyEvent );
3041 //JR 15.04.2005 Debug PAL8624 RetroConception :
3043 #if SendSomeDataReadyTrace
3044 cdebug_out << pthread_self() << "/" << ThreadNo() << FromNodeName
3045 << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
3046 << Automaton()->StateName( State() ) << " " << RetVal << endl;
3051 int GraphExecutor::InNode::Errored_ErrorAction() {
3052 cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
3053 << " will pthread_exit" << endl;
3055 _OutNode->NodeAborted( Name() ) ;
3061 int GraphExecutor::InNode::Successed_SuspendAction() {
3062 cdebug << ThreadNo() << " Successed_SuspendAction -->Suspend " << Name()
3063 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
3064 << _OutNode->SuspendedThreads() << endl;
3065 _OutNode->PushEvent( this , GraphExecutor::SuspendedSuccessedEvent ,
3066 GraphExecutor::SuspendedSuccessedState ) ;
3068 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
3069 cdebug << ThreadNo() << " Successed_SuspendAction Resumed " << Name() ;
3070 if ( aReStartNode ) {
3071 _aReStartNode = NULL ;
3072 cdebug << " for " << aReStartNode->Name() << endl;
3073 aReStartNode->SendEvent( _aReStartEvent ) ;
3077 SendEvent( GraphExecutor::ResumeEvent ) ;
3082 int GraphExecutor::InNode::Errored_SuspendAction() {
3083 cdebug << ThreadNo() << " Errored_SuspendAction -->Suspend " << Name()
3084 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
3085 << _OutNode->SuspendedThreads() << endl;
3086 _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
3087 GraphExecutor::SuspendedErroredState ) ;
3089 _OutNode->NodeAborted( Name() ) ;
3092 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
3093 cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
3095 if ( aReStartNode ) {
3096 _aReStartNode = NULL ;
3097 aReStartNode->SendEvent( _aReStartEvent ) ;
3100 SendEvent( GraphExecutor::ResumeEvent ) ;
3105 int GraphExecutor::InNode::SuspendedSuccessed_ResumeAction() {
3106 cdebug << ThreadNo() << " SuspendedSuccessed_ResumeAction " << Name() << endl;
3108 _OutNode->PushEvent( this , GraphExecutor::ResumedSuccessedEvent ,
3109 GraphExecutor::ResumedSuccessedState ) ;
3110 SendEvent( ResumedSuccessedEvent ) ;
3114 int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
3115 cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
3117 _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
3118 GraphExecutor::ResumedErroredState ) ;
3120 _OutNode->NodeAborted( Name() ) ;
3122 SendEvent( ResumedErroredEvent ) ;
3126 int GraphExecutor::InNode::Successed_KillAction() {
3128 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
3129 GraphExecutor::KilledSuccessedState ) ;
3130 cdebug << ThreadNo() << " Successed_KillAction " << Name() << endl;
3134 int GraphExecutor::InNode::Errored_KillAction() {
3136 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
3137 GraphExecutor::KilledErroredState ) ;
3139 _OutNode->NodeAborted( Name() ) ;
3141 cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
3145 int GraphExecutor::InNode::Successed_StopAction() {
3147 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
3148 GraphExecutor::StoppedSuccessedState ) ;
3149 cdebug << ThreadNo() << " Successed_StopAction " << Name() << endl;
3153 int GraphExecutor::InNode::Errored_StopAction() {
3155 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
3156 GraphExecutor::StoppedErroredState ) ;
3158 _OutNode->NodeAborted( Name() ) ;
3160 cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
3164 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
3165 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
3166 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
3167 GraphExecutor::ReStartedState ) ;
3169 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
3170 GetChangeNodeInPort( i )->PortState( SUPERV::ReadyState ) ;
3172 SendEvent( ExecuteEvent ) ;
3173 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
3177 int GraphExecutor::InNode::SuspendedErrored_ReStartAction() {
3178 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
3179 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
3180 GraphExecutor::ReStartedState ) ;
3182 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
3183 GetChangeNodeInPort( i )->PortState( SUPERV::ReadyState ) ;
3185 SendEvent( ExecuteEvent ) ;
3186 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
3190 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAndSuspendAction() {
3191 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
3193 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
3194 GraphExecutor::ReStartedState ) ;
3195 State( GraphExecutor::DataWaitingState ) ;
3197 cdebug << "InNode::Suspend() Node " << Name() << endl ;
3200 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
3201 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
3205 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
3210 int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
3211 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
3213 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
3214 GraphExecutor::ReStartedState ) ;
3215 State( GraphExecutor::DataWaitingState ) ;
3217 cdebug << "InNode::Suspend() Node " << Name() << endl ;
3220 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
3221 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
3225 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
3230 #define InParametersSetTrace 1
3231 void GraphExecutor::InNode::InParametersSet( bool & Err ,
3233 ServicesAnyData * InParametersList ) {
3235 #if InParametersSetTrace
3236 cdebug << pthread_self() << "/" << ThreadNo() << " InParametersSet " << Name() << endl ;
3238 for ( i = 0 ; i < nInParams ; i++ ) {
3239 ServicesAnyData D = InParametersList[i];
3240 GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
3241 GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
3242 if ( anInPort->IsGate() && theOutPort == NULL ) {
3243 #if InParametersSetTrace
3244 cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
3245 << anInPort->GetServicesParameter().Parametertype
3246 << " is inactive. " << anInPort->Kind() << endl ;
3249 else if ( anInPort->PortState() == SUPERV::ReadyState ) {
3250 if ( anInPort->IsGate() ) {
3251 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
3252 CORBA::Any anAny = CORBA::Any() ;
3253 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 0 ;
3254 anAny <<= (CORBA::Long ) 0 ;
3255 theOutPort->SetValue( anAny ) ;
3258 if ( !anInPort->IsDataStream()
3260 !anInPort->IsDataConnected() ) {
3261 anInPort->PortState( SUPERV::WaitingState ) ;
3263 //JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
3264 // D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
3265 D.Name = anInPort->PortName() ;
3266 //JR 30.03.2005 const CORBA::Any * AnyPtr = theOutPort->Value() ;
3267 const CORBA::Any AnyRef = theOutPort->Value() ;
3268 #if InParametersSetTrace
3269 cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() << " "
3270 << anInPort->PortState() << " " << D.Name << " "
3271 << anInPort->GetServicesParameter().Parametertype << endl ;
3273 //JR 30.03.2005 D.Value = * AnyPtr ; // CORBA::Any
3274 D.Value = AnyRef ; // CORBA::Any
3275 //JR 18.02.2005 Debug Memory leak : string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
3276 // const char * Type = _Type.c_str() ;
3277 const char * Type = anInPort->GetServicesParameter().Parametertype ;
3278 switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
3279 case CORBA::tk_string:
3282 #if InParametersSetTrace
3283 cdebug << t << " (string)" ;
3285 if ( !strcmp( Type , "string" ) ) {
3287 else if ( !strcmp( Type , "boolean" ) ) {
3290 sscanf( t , "%ld" , &d ) ;
3292 D.Value <<= (CORBA::Any::from_boolean ) b ;
3293 // theOutPort->Value( D.Value ) ;
3295 else if ( !strcmp( Type , "char" ) ) {
3298 sscanf( t , "%ld" , &d ) ;
3300 D.Value <<= (CORBA::Any::from_char ) c ;
3301 #if InParametersSetTrace
3302 cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
3304 // theOutPort->Value( D.Value ) ;
3306 else if ( !strcmp( Type , "short" ) ) {
3309 sscanf( t , "%ld" , &d ) ;
3312 #if InParametersSetTrace
3313 cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
3315 // theOutPort->Value( D.Value ) ;
3317 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3319 sscanf( t , "%ld" , &ll ) ;
3320 CORBA::Long l = ll ;
3322 #if InParametersSetTrace
3323 cdebug << "string '" << t << " --> CORBA::Long " << l ;
3325 // theOutPort->Value( D.Value ) ;
3327 else if ( !strcmp( Type , "float" ) ) {
3329 sscanf( t , "%lf" , &d ) ;
3331 #ifdef REDHAT // mkr : debug for PAL12255
3334 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3335 D.Value <<= (CORBA::Float) f ;
3337 #if InParametersSetTrace
3338 cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
3339 << setw(25) << setprecision(18) << f ;
3341 // theOutPort->Value( D.Value ) ;
3343 else if ( !strcmp( Type , "double" ) ) {
3345 sscanf( t , "%lf" , &d ) ;
3346 #ifdef REDHAT // mkr : debug for PAL12255
3349 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3350 D.Value <<= (CORBA::Double) d ;
3352 #if InParametersSetTrace
3353 cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
3355 // theOutPort->Value( D.Value ) ;
3357 // else if ( !strcmp( Type , "objref" ) ) {
3359 CORBA::Object_ptr ObjRef ;
3361 ObjRef = StringToObject( t ) ;
3362 D.Value <<= ObjRef ;
3365 D.Value <<= CORBA::Object::_nil() ;
3367 // theOutPort->Value( D.Value ) ;
3370 // cdebug << " (other ERROR)" << endl ;
3372 #if InParametersSetTrace
3373 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3376 case CORBA::tk_long:
3377 #if InParametersSetTrace
3378 cdebug << ThreadNo() << " " << Name() << " ArgIn" << i << " " << D.Name << " "
3379 << anInPort->GetServicesParameter().Parametertype << " " << anInPort->Kind()
3381 theOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
3386 #if InParametersSetTrace
3387 cdebug << l << " (CORBA::Long)" << endl ;
3389 if ( !strcmp( Type , "string" ) ) {
3391 sprintf( t , "%ld" , (long)l ) ;
3393 // theOutPort->Value( D.Value ) ;
3395 else if ( !strcmp( Type , "boolean" ) ) {
3398 D.Value <<= (CORBA::Any::from_boolean ) b ;
3399 // theOutPort->Value( D.Value ) ;
3401 else if ( !strcmp( Type , "char" ) ) {
3403 c = (unsigned char ) l ;
3404 D.Value <<= (CORBA::Any::from_char ) c ;
3405 // theOutPort->Value( D.Value ) ;
3407 else if ( !strcmp( Type , "short" ) ) {
3411 // theOutPort->Value( D.Value ) ;
3413 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3415 else if ( !strcmp( Type , "float" ) ) {
3418 #ifdef REDHAT // mkr : debug for PAL12255
3421 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3422 D.Value <<= (CORBA::Float) f ;
3424 // theOutPort->Value( D.Value ) ;
3426 else if ( !strcmp( Type , "double" ) ) {
3429 #ifdef REDHAT // mkr : debug for PAL12255
3432 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3433 D.Value <<= (CORBA::Double) d ;
3435 // theOutPort->Value( D.Value ) ;
3437 // else if ( !strcmp( Type , "objref" ) ) {
3439 D.Value <<= CORBA::Object::_nil() ;
3440 // theOutPort->Value( D.Value ) ;
3443 // cdebug << " (other ERROR)" << endl ;
3445 #if InParametersSetTrace
3446 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3449 case CORBA::tk_double:
3452 #if InParametersSetTrace
3453 cdebug << d << " (double)" << endl ;
3455 if ( !strcmp( Type , "string" ) ) {
3457 sprintf( t , "%lf" , d ) ;
3459 // theOutPort->Value( D.Value ) ;
3461 else if ( !strcmp( Type , "boolean" ) ) {
3464 D.Value <<= (CORBA::Any::from_boolean ) b ;
3465 // theOutPort->Value( D.Value ) ;
3467 else if ( !strcmp( Type , "char" ) ) {
3469 c = (unsigned char ) d ;
3470 D.Value <<= (CORBA::Any::from_char ) c ;
3471 // theOutPort->Value( D.Value ) ;
3473 else if ( !strcmp( Type , "short" ) ) {
3477 // theOutPort->Value( D.Value ) ;
3479 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3481 l = (CORBA::Long ) d ;
3483 // theOutPort->Value( D.Value ) ;
3485 else if ( !strcmp( Type , "float" ) ) {
3488 #ifdef REDHAT // mkr : debug for PAL12255
3491 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3492 D.Value <<= (CORBA::Float) f ;
3494 // theOutPort->Value( D.Value ) ;
3496 else if ( !strcmp( Type , "double" ) ) {
3498 // else if ( !strcmp( Type , "objref" ) ) {
3500 D.Value <<= CORBA::Object::_nil() ;
3501 // theOutPort->Value( D.Value ) ;
3504 // cdebug << " (other ERROR)" << endl ;
3506 #if InParametersSetTrace
3507 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3510 case CORBA::tk_objref:
3511 if ( !strcmp( Type , "string" ) ) {
3512 CORBA::Object_ptr ObjRef ;
3515 #if OMNIORB_VERSION >= 4
3516 D.Value >>= (CORBA::Any::to_object ) ObjRef ;
3518 D.Value >>= ObjRef ;
3520 retstr = ObjectToString( ObjRef ) ;
3521 D.Value <<= retstr ;
3522 // theOutPort->Value( D.Value ) ;
3528 cdebug << "ToString( object ) Catched ERROR" << endl ;
3531 else if ( !strcmp( Type , "boolean" ) ) {
3533 D.Value <<= (CORBA::Any::from_boolean ) b ;
3534 // theOutPort->Value( D.Value ) ;
3536 else if ( !strcmp( Type , "char" ) ) {
3537 unsigned char c = 0 ;
3538 D.Value <<= (CORBA::Any::from_char ) c ;
3539 // theOutPort->Value( D.Value ) ;
3541 else if ( !strcmp( Type , "short" ) ) {
3544 // theOutPort->Value( D.Value ) ;
3546 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3549 // theOutPort->Value( D.Value ) ;
3551 else if ( !strcmp( Type , "float" ) ) {
3553 #ifdef REDHAT // mkr : debug for PAL12255
3556 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3557 D.Value <<= (CORBA::Float) f ;
3559 // theOutPort->Value( D.Value ) ;
3561 else if ( !strcmp( Type , "double" ) ) {
3563 #ifdef REDHAT // mkr : debug for PAL12255
3566 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3567 D.Value <<= (CORBA::Double) d ;
3569 // theOutPort->Value( D.Value ) ;
3571 // else if ( !strcmp( Type , "objref" ) ) {
3573 CORBA::Object_ptr obj ;
3576 #if OMNIORB_VERSION >= 4
3577 D.Value >>= (CORBA::Any::to_object ) obj ;
3581 retstr = ObjectToString( obj ) ;
3582 #if InParametersSetTrace
3583 cdebug << retstr << endl ;
3590 cdebug << "ToString( object ) Catched ERROR" << endl ;
3594 // cdebug << " (other ERROR)" << endl ;
3596 #if InParametersSetTrace
3597 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3601 cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
3605 cdebug << ThreadNo() << " In" << i << " : wrong state ERROR State "
3606 << anInPort->PortState() << " NameState "
3607 << Automaton()->StateName( anInPort->PortState() ) << " PortName "
3608 << anInPort->PortName() << " Parametername "
3609 << anInPort->GetServicesParameter().Parametername << endl ;
3612 InParametersList[i] = D ;
3616 void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
3617 ServicesAnyData * OutParametersList ) {
3618 #if InParametersSetTrace
3619 cdebug << pthread_self() << "/" << ThreadNo() << " InOutParametersSet " << Name() << endl ;
3622 for ( i = 0 ; i < nOutParams ; i++ ) {
3623 ServicesAnyData D = OutParametersList[i] ;
3625 //JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
3626 // D.Name = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametername);
3627 D.Name = GetChangeNodeOutPort(i)->PortName() ;
3628 //JR 18.02.2005 Debug Memory leak : string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
3629 const char * Type = GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype ;
3630 #if InParametersSetTrace
3631 bool OutDone = GetChangeNodeOutPort(i)->PortDone() ;
3632 cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " PortDone( " << OutDone << " ) Type : "
3635 if ( !strcmp( Type , "string" ) ) {
3636 // D.Value <<= (char *) NULL ;
3639 else if ( !strcmp( Type , "boolean" ) ) {
3641 D.Value <<= (CORBA::Any::from_boolean ) b ;
3643 else if ( !strcmp( Type , "char" ) ) {
3644 unsigned char c = 0 ;
3645 D.Value <<= (CORBA::Any::from_char ) c ;
3647 else if ( !strcmp( Type , "short" ) ) {
3651 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3652 D.Value <<= (CORBA::Long ) 0 ;
3654 else if ( !strcmp( Type , "float" ) ) {
3656 #ifdef REDHAT // mkr : debug for PAL12255
3659 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3660 D.Value <<= (CORBA::Float) f ;
3663 else if ( !strcmp( Type , "double" ) ) {
3665 #ifdef REDHAT // mkr : debug for PAL12255
3668 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3669 D.Value <<= (CORBA::Double) d ;
3673 D.Value <<= CORBA::Object::_nil() ;
3675 #if InParametersSetTrace
3676 switch (D.Value.type()->kind()) { // { string , long , double , objref }
3677 case CORBA::tk_string:
3680 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
3682 case CORBA::tk_boolean:
3684 D.Value >>= (CORBA::Any::to_boolean ) b;
3685 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
3687 case CORBA::tk_char:
3689 D.Value >>= (CORBA::Any::to_char ) c;
3690 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
3692 case CORBA::tk_short:
3695 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
3697 case CORBA::tk_long:
3700 cdebug << ThreadNo() << " " << l << "(CORBA::Long)" << endl ;
3702 case CORBA::tk_float:
3705 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
3707 case CORBA::tk_double:
3710 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
3712 case CORBA::tk_objref:
3714 CORBA::Object_ptr obj ;
3716 #if OMNIORB_VERSION >= 4
3717 D.Value >>= (CORBA::Any::to_object ) obj ;
3721 retstr = ObjectToString( obj ) ;
3722 cdebug << ThreadNo() << retstr << endl ;
3725 cdebug << "ToString( object ) Catched ERROR" << endl ;
3729 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
3732 OutParametersList[i] = D ;
3736 #define OutParametersSetTrace 1
3737 bool GraphExecutor::InNode::OutParametersSet( bool Err ,
3738 SUPERV::GraphState PortState ,
3740 ServicesAnyData * OutParametersList ) {
3741 bool RetVal = true ;
3743 GraphBase::OutPort * aGateOutPort = NULL ;
3744 bool OrSwitch = false ;
3745 bool DefaultSwitch = false ;
3746 #if OutParametersSetTrace
3747 cdebug_in << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState "
3748 << PortState << endl ;
3750 // cout << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState " << PortState << endl ;
3751 if ( nOutParams && !IsMacroNode() ) {
3752 GraphBase::OutPort * anOutPort ;
3753 for ( i = 0 ; i < nOutParams ; i++ ) {
3754 anOutPort = GetChangeNodeOutPort(i) ;
3756 anOutPort->PortState( PortState ) ;
3757 anOutPort->PortDone( true ) ;
3760 #if OutParametersSetTrace
3761 cdebug << ThreadNo() << "OutParametersSet " << "Out" << i << " " << Name() << " "
3762 << anOutPort->PortName() << " " << anOutPort->Kind() ;
3764 ServicesAnyData D = OutParametersList[i] ;
3765 switch (D.Value.type()->kind()) { // { string , long , double , objref }
3766 case CORBA::tk_string: {
3769 #if OutParametersSetTrace
3770 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
3774 case CORBA::tk_boolean: {
3776 D.Value >>= (CORBA::Any::to_boolean ) b;
3777 CORBA::Long l = (CORBA::Long ) b ;
3779 #if OutParametersSetTrace
3780 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
3784 case CORBA::tk_char: {
3786 D.Value >>= (CORBA::Any::to_char ) c;
3787 CORBA::Long l = (CORBA::Long ) c ;
3789 #if OutParametersSetTrace
3790 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
3794 case CORBA::tk_short: {
3797 CORBA::Long l = (CORBA::Long ) s ;
3799 #if OutParametersSetTrace
3800 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
3804 case CORBA::tk_long: {
3807 #if OutParametersSetTrace
3808 cdebug << ThreadNo() << " " << l << "(CORBA::Long)" << endl ;
3812 case CORBA::tk_float: {
3815 double d = (double ) f ;
3816 #ifdef REDHAT // mkr : debug for PAL12255
3819 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3820 D.Value <<= (CORBA::Double) d ;
3822 #if OutParametersSetTrace
3823 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
3827 case CORBA::tk_double: {
3830 #if OutParametersSetTrace
3831 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
3835 case CORBA::tk_objref: {
3837 CORBA::Object_ptr obj ;
3838 #if OMNIORB_VERSION >= 4
3839 D.Value >>= (CORBA::Any::to_object ) obj ;
3843 #if OutParametersSetTrace
3845 retstr = ObjectToString( obj ) ;
3846 cdebug << ThreadNo() << retstr << endl ;
3850 cdebug << "ToString( object ) Catched ERROR" << endl ;
3856 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
3860 OutParametersList[i] = D ;
3861 if ( !anOutPort->IsDataStream() ) {
3862 if ( anOutPort->IsGate() ) {
3863 aGateOutPort = anOutPort ;
3864 #if OutParametersSetTrace
3865 cdebug << " Gate " ;
3868 OutParametersList[i].Value <<= l;
3869 anOutPort->SetValue( OutParametersList[i].Value );
3871 else if ( anOutPort->IsLoop() ) {
3872 #if OutParametersSetTrace
3873 cdebug << " Loop " ;
3875 anOutPort->SetValue( OutParametersList[i].Value );
3876 // InLoop Port of EndLoopNode is ready :
3877 anOutPort->ChangeInPorts(0)->PortState( SUPERV::ReadyState ) ;
3879 else if ( anOutPort->IsSwitch() ) {
3880 #if OutParametersSetTrace
3881 cdebug << " Switch " ;
3883 anOutPort->SetValue( OutParametersList[i].Value );
3884 if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
3885 //We have a SwitchBranch or the DefaultBranch .
3886 //JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches (SwitchParameters) :
3887 //It controls that there is only one SwitchBranch activated
3888 //If it's final value is false ==> activation of the Default to GOTO to EndSwitchNode
3889 //DefaultSwitch is true if a SwitchPort is linked to the DefaultPort of the EndSwitchNode
3890 if ( OrSwitch && anOutPort->BoolValue() ) {
3891 string anErrorMessage = string( "More than one SwitchBranch should be activated in SwitchNode " ) +
3892 string( Name() ) + string( "( " ) +
3893 string( anOutPort->PortName() ) + string( " )" ) ;
3894 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
3895 cdebug << "Executor::InNodeThreads::OutParameters more than one SwitchBranch is true ERROR"
3899 else if ( anOutPort->BoolValue() ) {
3900 //JR 09.02.2005 Debug : case of a SwitchPort linked to the DefaultPort of the EndSwitchNode :
3901 if ( !strcmp( anOutPort->ChangeInPorts( 0 )->NodeName() , GOTONode()->CoupledNodeName() ) ) {
3902 DefaultSwitch = anOutPort->BoolValue() ;
3905 OrSwitch = OrSwitch | anOutPort->BoolValue() ;
3907 #if OutParametersSetTrace
3908 cdebug << "InNodeThreads::OutParameters OrSwitch " << OrSwitch << "DefaultSwitch "
3909 << DefaultSwitch << endl ;
3915 #if OutParametersSetTrace
3916 cdebug << " Param " ;
3918 anOutPort->SetValue( OutParametersList[i].Value );
3920 anOutPort->PortState( PortState ) ;
3921 anOutPort->PortDone( true ) ;
3923 #if OutParametersSetTrace
3924 cdebug << "OutParametersSet OrSwitch " << OrSwitch << "DefaultSwitch "
3925 << DefaultSwitch << endl ;
3928 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
3929 #if OutParametersSetTrace
3930 cdebug << ThreadNo() << "OutParametersSet " << "Out" << i << " " << Name() << " "
3931 << anOutPort->PortName() << " " << anOutPort->Kind() << " --> "
3932 << anOutPort->ChangeInPorts( j )->NodeName() << "( "
3933 << anOutPort->ChangeInPorts( j )->PortName() << anOutPort->ChangeInPorts( j )->Kind()
3936 bool fromGOTO = false ;
3937 const char * ToNodeName = anOutPort->ChangeInPorts( j )->NodeName() ;
3938 if ( !strcmp( ToNodeName , _OutNode->Name() ) &&
3939 _OutNode->Graph()->GraphMacroLevel() != 0 ) {
3940 //JR NPAL14110 09.02.2007 : That must be done only at the end of SubGraph because we may
3941 // have an output of the SubGraph in a Loop !...
3942 // So that code must be done in CheckAllDone
3944 #if OutParametersSetTrace
3945 cdebug << "OutParametersSet ToNodeName " << _OutNode->Name() << " CoupledNode "
3946 << _OutNode->Graph()->CoupledNodeName() << _OutNode->Graph()->CoupledNode()
3948 cdebug << "OutParametersSet GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
3950 _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor()->OutputOfAny( _OutNode->Graph()->CoupledNodeName() ,
3951 anOutPort->ChangeInPorts( j )->PortName() ,
3952 //JR 30.03.2005 *anOutPort->Value() ) ;
3953 anOutPort->Value() ) ;
3954 #if OutParametersSetTrace
3955 cdebug << "OutParametersSet OutputOfAny( "
3956 << _OutNode->Graph()->CoupledNodeName() << " , "
3957 << anOutPort->ChangeInPorts( j )->PortName() << " , value )" << endl ;
3962 GraphBase::ComputingNode * ToNode = _OutNode->Graph()->GetChangeGraphNode( ToNodeName ) ;
3964 // cout << "OutParametersSet ToNodeName " << ToNodeName << endl ;
3965 // cdebug << "OutParametersSet ToNodeName " << ToNodeName << " " << ToNode->Name() << endl ;
3966 GraphBase::OutPort * aGOTOPort = ToNode->GetChangeNodeInGate()->GetOutPort() ;
3968 fromGOTO = aGOTOPort->IsGOTO() ;
3970 if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
3971 #if OutParametersSetTrace
3972 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
3973 << anOutPort->ChangeInPorts( j )->PortName() << ","
3974 << anOutPort->ChangeInPorts( j )->Kind() << ") CHANGED from "
3975 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
3977 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
3978 << " to " << anOutPort->ChangeInPorts( j )->GetOutPort()->Kind()
3979 << ") : Done " << anOutPort->PortDone() << " State "
3980 << Automaton()->StateName( anOutPort->ChangeInPorts( j )->PortState() ) << endl ;
3982 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
3985 #if OutParametersSetTrace
3986 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
3987 << anOutPort->ChangeInPorts( j )->PortName() << ","
3988 << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
3989 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
3991 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
3992 << " " << anOutPort->ChangeInPorts( j )->GetOutPort()->Kind()
3999 #if OutParametersSetTrace
4000 switch ( anOutPort->Value().type()->kind() ) {
4001 case CORBA::tk_string:
4003 (anOutPort->Value()) >>= t;
4004 cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
4006 case CORBA::tk_boolean:
4008 (anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
4009 cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
4011 case CORBA::tk_char:
4013 (anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
4014 cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
4016 case CORBA::tk_short:
4018 (anOutPort->Value()) >>= s;
4019 cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
4021 case CORBA::tk_long:
4023 (anOutPort->Value()) >>= l;
4024 cdebug << ThreadNo() << " Out" << i << " : " << l << "(CORBA::Long)" << endl ;
4026 case CORBA::tk_float:
4028 (anOutPort->Value()) >>= f;
4029 cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
4031 case CORBA::tk_double:
4033 (anOutPort->Value()) >>= d;
4034 cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
4036 case CORBA::tk_objref:
4037 CORBA::Object_ptr obj ;
4040 //JR 02.08.2005 Debug SEGV anOutPort->Value() >>= obj ;
4042 anAny = anOutPort->Value() ;
4043 #if OMNIORB_VERSION >= 4
4044 anAny >>= (CORBA::Any::to_object ) obj ;
4048 retstr = ObjectToString( obj );
4049 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
4053 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
4054 << "Catched ERROR" << endl ;
4059 cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
4064 } // End of : for ( i = 0 ; i < nOutParams ; i++ ) {
4065 #if OutParametersSetTrace
4066 cdebug << ThreadNo() << "OutParametersSet End of loop with " << nOutParams
4067 << " OutParams. aGateOutPort " << (void *) aGateOutPort << " IsSwitchNode "
4068 << IsSwitchNode() << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch
4073 if ( IsSwitchNode() && aGateOutPort ) {
4074 //JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches :
4075 //It controls that there is only one SwitchBranch activated
4076 //If it's final value is false ==> activation of the Default in order to GOTO to EndSwitchNode
4077 //DefaultSwitch is true if a SwitchPort (SwitchBranch) is linked to the DefaultPort of the EndSwitchNode
4078 if ( !OrSwitch && !DefaultSwitch ) {
4079 if ( aGateOutPort->InPortsSize() && aGateOutPort->ChangeInPorts( 0 ) ) {
4080 //Dynamic activation of the Default OutPort :
4081 #if OutParametersSetTrace
4082 cdebug << ThreadNo() << " " << "OutGate " << Name() << " Open of "
4083 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " WITH DefaultPort"
4087 OutParametersList[0].Value <<= l ;
4088 aGateOutPort->SetValue( OutParametersList[0].Value ) ;
4091 //The Default OutPort is not linked ==> error
4092 string anErrorMessage = string( "DefaultPort of SwitchNode " ) +
4093 string( Name() ) + " is not connected." ;
4094 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
4095 #if OutParametersSetTrace
4096 cdebug << ThreadNo() << " " << "OutGate " << Name() << " "
4097 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NOT CONNECTED ERROR"
4103 //JR 07.04.2005 Debug : reset only if it is not a default switch (SwitchBranch or
4104 // SwitchParameter of SwitchNode connected to the DefaultInPort of
4107 else if ( !DefaultSwitch ) {
4108 #if OutParametersSetTrace
4109 cdebug << ThreadNo() << " " << "OutGate " << Name() << " Close of "
4110 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NO DefaultPort"
4111 << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch << endl ;
4114 OutParametersList[0].Value <<= l ;
4115 aGateOutPort->SetValue( OutParametersList[0].Value ) ;
4118 // The OutPort field of InPorts of EndSwitchNode may be updated from each OutPort of that SwitchNode :
4119 GraphBase::EndOfSwitchNode * anEndSwitchNode = (GraphBase::EndOfSwitchNode * ) CoupledNode() ;
4122 //JR 16.02.2005 Debug : At first Change InPorts of EndSwitchNode that have the same name as an OutPort of
4123 // the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
4124 //STEP A : InPorts of EndSwitchNode that have the same name as an OutPort of the SwitchNode
4125 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
4126 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
4127 GraphBase::InPort * anInPort = NULL ;
4128 anInPort = anEndSwitchNode->GetChangeInPort( anOutPort->PortName() ) ;
4130 #if OutParametersSetTrace
4131 cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
4132 << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) with same name " ;
4133 if ( anInPort->GetOutPort() ) {
4134 cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
4135 << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
4138 cdebug << "NOT linked " ;
4140 cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
4141 << anOutPort->PortName() << " )" << endl ;
4143 anInPort->ChangeOutPort( anOutPort ) ;
4146 //STEP B : InPorts of EndSwitchNode directly connected from an OutPort of the SwitchNode
4147 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
4148 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
4149 GraphBase::InPort * anInPort ;
4151 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
4152 anInPort = anOutPort->ChangeInPorts( j ) ;
4153 //Update the OutPort field in the Inports directly connected of the EndSwitchNode :
4154 if ( !strcmp( anInPort->NodeName() , anEndSwitchNode->Name() ) ) {
4155 #if OutParametersSetTrace
4156 cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
4157 << "( " << anInPort->PortName() << " , " << anInPort->Kind()
4158 << " ) directly connected " ;
4159 if ( anInPort->GetOutPort() ) {
4160 cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
4161 << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
4164 cdebug << "NOT linked " ;
4166 cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
4167 << anOutPort->PortName() << " )" << endl ;
4169 anInPort->ChangeOutPort( anOutPort ) ;
4173 //STEP C : If it is not the DefaultBranch, explore the SwitchBranch and all NOTSwitchBranch[es]
4174 //Change recursively InPorts of EndSwitchNode linked to that Branch (or that SwitchNode)
4176 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
4177 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
4178 if ( aNode != anEndSwitchNode && !aNode->IsGOTONode() &&
4179 !aNode->IsDataFlowNode() && !aNode->IsDataStreamNode() ) {
4180 const GraphBase::InPort * anInGate = aNode->GetNodeInGate() ;
4181 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aNode->GetInNode() ;
4182 //STEP C1 : SwitchBranch :
4183 if ( anInGate->GetOutPort() ) {
4184 if ( anInGate->GetOutPort()->BoolValue() ) {
4185 #if OutParametersSetTrace
4186 cdebug << "OutParametersSet " << Name() << " SWITCHBranch " << aNode->Name() << endl ;
4189 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
4190 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
4191 anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
4195 //STEP C2 : NOTSwitchBranch :
4197 #if OutParametersSetTrace
4198 cdebug << "OutParametersSet " << Name() << " NOTSWITCHBranch " << aNode->Name() << endl ;
4201 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
4202 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
4203 anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
4212 #if OutParametersSetTrace
4213 cdebug_out << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState "
4214 << PortState << " RetVal " << RetVal << endl ;
4220 void GraphExecutor::InNode::SetOutPortsOfInportsOfEndSwitch( GraphBase::OutPort * anOutPort ,
4221 const char * anEndSwitchNodeName ) {
4222 #if OutParametersSetTrace
4223 cdebug_in << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anOutPort->NodeName() << "( "
4224 << anOutPort->PortName() << " ) with " << anOutPort->InPortsSize() << " links." << endl ;
4226 GraphBase::InPort * anInPort ;
4228 for ( i = 0 ; i < anOutPort->InPortsSize() ; i++ ) {
4229 anInPort = anOutPort->ChangeInPorts( i ) ;
4230 if ( !anInPort->IsDataStream() ) {
4231 //Update the OutPort field in the Inports of the EndSwitchNode :
4232 if ( !strcmp( anInPort->NodeName() , anEndSwitchNodeName ) ) {
4233 #if OutParametersSetTrace
4234 cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
4235 << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " ;
4236 if ( anInPort->GetOutPort() ) {
4237 cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
4238 << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
4241 cdebug << "NOT linked ERROR " ;
4243 cdebug << "CHANGED TO linked from "
4244 << anOutPort->NodeName() << "( "
4245 << anOutPort->PortName() << " )" << endl ;
4247 anInPort->ChangeOutPort( anOutPort ) ;
4250 #if OutParametersSetTrace
4251 cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
4252 << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " << endl ;
4254 GraphBase::ComputingNode * aComputingNode ;
4255 aComputingNode = _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
4256 if ( aComputingNode && !aComputingNode->IsGOTONode() &&
4257 !( IsEndLoopNode() && GOTONode()->CoupledNode() == aComputingNode ) ) {
4258 GraphExecutor::InNode * aNode ;
4259 aNode = (GraphExecutor::InNode * ) aComputingNode->GetInNode() ;
4262 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
4263 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
4264 aNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNodeName ) ;
4271 #if OutParametersSetTrace
4272 cdebug_out << "SetOutPortsOfInportsOfEndSwitch " << Name() << " OutPort " << anOutPort->PortName()