1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
23 // File : DataFlowBase_InNodeThreads.cxx
24 // Author : Jean Rahuel, CEA
41 #if defined __GNUC_2__
42 // _CS_gbo_040604 include explicite pour l'utilisation de
43 // std::transform dans UpperCase
44 #include <cctype> // for toupper
45 #include <algorithm> // for transform
52 #include <SALOMEconfig.h>
53 #include CORBA_CLIENT_HEADER(SALOME_Component)
54 #include "SALOME_LifeCycleCORBA.hxx"
56 #include "DataFlowExecutor_DataFlow.hxx"
57 #include "DataFlowEditor_DataFlow.hxx" // GraphEditor package must be built BEFORE
60 static void UpperCase(std::string& rstr)
62 #if defined __GNUC_2__
63 // _CS_gbo_040604 towupper n'existe pas. Utilisation de toupper. Par
64 // ailleurs, include explicite de cctype et algorithm pour toupper
65 // et transform respectivement.
66 std::transform(rstr.begin(), rstr.end(), rstr.begin(),toupper);
68 std::transform(rstr.begin(), rstr.end(), rstr.begin(),towupper);
72 #define SendEventTrace 1
73 int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {
75 _CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
77 cdebug_in << pthread_self() << "/" << ThreadNo() << " SendEvent Graph " << _OutNode->Name()
78 << " Node " << Name() << " Event : " << Automaton()->EventName( anEvent )
79 << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack
80 << " ControlState : " << Automaton()->ControlStateName( ControlState() )
85 _NextState = Automaton()->NextState( _OldState , anEvent ) ;
86 if ( _NextState == _OldState ) {
87 string anErrorMessage = string( "Automaton error for node " ) +
88 string( Name() ) + " (SuperVision executor error)." ;
89 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
90 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
91 << " GraphExecutor::InNodeThreads::SendEvent SameStates ERROR _OldState/_NextState "
92 << _OldState << " Event " << Automaton()->EventName( anEvent ) << endl ;
93 _NextAction = GraphExecutor::VoidAction ;
97 _NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
100 cdebug << pthread_self() << "/" << ThreadNo() << "NextState( " << _OldState << " , "
101 << Automaton()->EventName( anEvent ) << " ) --> _NextState = " << _NextState
102 << " NextAction( " << _NextState << " , " << Automaton()->EventName( anEvent )
103 << " ) --> _NextAction = "
104 << Automaton()->ActionName( _NextAction ) << endl ;
107 // State( _NextState ) ;
108 // if ( _OldState == GraphExecutor::SuccessedExecutingState ||
109 // _OldState == GraphExecutor::ErroredExecutingState ) {
114 cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
115 << Name() << endl << " ControlState : "
116 << Automaton()->ControlStateName( ControlState() ) << endl
117 << " OldState : " << Automaton()->StateName( _OldState ) << endl
118 << " Event : " << Automaton()->EventName( anEvent ) << endl
119 << " NextState : " << Automaton()->StateName( _NextState ) << endl
120 << " Action : " << Automaton()->ActionName( _NextAction ) << endl
121 << " CreateNewThread " << CreateNewThread() << endl
122 << " _RewindStack " << _RewindStack << endl ;
126 #if ExitWhenNodeAborted
127 if ( _OutNode->IsNodeAborted() ) {
129 cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
130 << " will exit : a node was aborted ..." << endl ;
132 State( _NextState ) ;
136 sts = executeAction() ;
139 sts = executeAction() ;
143 cdebug_out << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
144 << " Event : " << Automaton()->EventName( anEvent )
145 << " State : " << Automaton()->StateName( State() )
153 #define ActionsTrace 1
154 // ReadyAction - RunningAction - DoneAction - SuspendedAction :
155 // for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
156 void GraphExecutor::InNode::ReadyAction() {
157 if ( pthread_mutex_lock( &_MutexWait ) ) {
158 perror("Ready pthread_mutex_lock ") ;
162 cdebug << pthread_self() << "/" << ThreadNo()
163 << "ReadyAction pthread_cond_broadcast _ReadyWait "
166 if ( pthread_cond_broadcast( &_ReadyWait ) ) {
167 perror("Ready pthread_cond_broadcast ") ;
169 if ( pthread_mutex_unlock( &_MutexWait ) ) {
170 perror("Ready pthread_mutex_unlock ") ;
175 void GraphExecutor::InNode::RunningAction() {
176 if ( pthread_mutex_lock( &_MutexWait ) ) {
177 perror("Running pthread_mutex_lock ") ;
181 cdebug << pthread_self() << "/" << ThreadNo()
182 << "RunningAction pthread_cond_broadcast _RunningWait "
185 // That activate the pthread_cond_wait for RunninWait
186 if ( pthread_cond_broadcast( &_RunningWait ) ) {
187 perror("Running pthread_cond_broadcast ") ;
189 if ( pthread_mutex_unlock( &_MutexWait ) ) {
190 perror("Running pthread_mutex_unlock ") ;
195 void GraphExecutor::InNode::DoneAction() {
196 if ( pthread_mutex_lock( &_MutexWait ) ) {
197 perror("Done pthread_mutex_lock ") ;
201 cdebug << pthread_self() << "/" << ThreadNo()
202 << "DoneAction pthread_cond_broadcast _DoneWait "
205 if ( pthread_cond_broadcast( &_DoneWait ) ) {
206 perror("Done pthread_cond_broadcast ") ;
208 if ( pthread_mutex_unlock( &_MutexWait ) ) {
209 perror("Done pthread_mutex_unlock ") ;
214 void GraphExecutor::InNode::SuspendedAction() {
215 if ( pthread_mutex_lock( &_MutexWait ) ) {
216 perror("Suspended pthread_mutex_lock ") ;
220 cdebug << pthread_self() << "/" << ThreadNo()
221 << "SuspendedAction pthread_cond_broadcast _SuspendedWait "
224 if ( pthread_cond_broadcast( &_SuspendedWait ) ) {
225 perror("Suspended pthread_cond_broadcast ") ;
227 if ( pthread_mutex_unlock( &_MutexWait ) ) {
228 perror("Suspended pthread_mutex_unlock ") ;
233 // SuspendAction <--> { ResumeAction - ReStartAction }
234 GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() {
236 if ( pthread_mutex_lock( &_MutexWait ) ) {
237 perror("Suspend pthread_mutex_lock ") ;
240 if ( !_SuspendSync ) {
241 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
242 << " SuspendAction pthread_cond_wait _SuspendWait "
243 << Automaton()->StateName( State() ) << endl ;
244 _SuspendSync = true ;
245 _OutNode->SuspendThread() ;
246 if ( pthread_cond_wait( &_SuspendWait , &_MutexWait ) ) {
247 perror("SuspendAction pthread_cond_wait ") ;
249 _OutNode->ResumeThread() ;
251 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
252 << " SuspendAction pthread_cond_waited"
253 << Automaton()->StateName( State() ) << endl ;
258 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
259 << " NO SuspendAction pthread_cond_wait"
260 << Automaton()->StateName( State() ) << endl ;
263 // SendEvent( _aResumeEvent ) ; ===> Mutex with myself !
264 _SuspendSync = false ;
265 if ( ControlState() == SUPERV::ToSuspendStartState ||
266 ControlState() == SUPERV::ToSuspendState ) {
267 ControlState( SUPERV::VoidState ) ;
269 if ( pthread_mutex_unlock( &_MutexWait ) ) {
270 perror("SuspendAction pthread_mutex_unlock ") ;
274 SendEvent( _aResumeEvent ) ;
275 // if ( ControlState() == SUPERV::ToSuspendStartState ) {
276 // ControlState( SUPERV::VoidState ) ;
279 if ( pthread_mutex_lock( &_MutexWait ) ) {
280 perror("SuspendAction pthread_mutex_lock ") ;
285 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
286 << " SuspendAction pthread_cond_signal _ResumeWait" << endl ;
288 if ( pthread_cond_signal( &_ResumeWait ) ) {
289 perror("SuspendAction pthread_cond_signal _ResumeWait ") ;
292 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
293 << " SuspendAction pthread_cond_signaled _ResumeWait " << endl ;
298 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
299 << " NO SuspendAction pthread_cond_signal _ResumeWait" << endl ;
303 if ( pthread_mutex_unlock( &_MutexWait ) ) {
304 perror("SuspendAction pthread_mutex_unlock ") ;
307 if ( _aReStartNode ) {
308 cdebug << Name() << " " << Automaton()->StateName( State() )
309 << "aReStartNode : " << _aReStartNode->Name() << " "
310 << Automaton()->StateName( _aReStartNode->State() ) << endl ;
311 _aReStartNode->SendEvent( _aResumeEvent ) ;
314 cdebug << "NO aReStartNode"
315 << Automaton()->StateName( State() ) << endl ;
317 return _aReStartNode ;
320 bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent ) {
322 if ( pthread_mutex_lock( &_MutexWait ) ) {
323 perror("ResumeAction pthread_mutex_lock ") ;
326 _aResumeEvent = aResumeEvent ;
327 if ( _SuspendSync ) {
329 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
330 << " ResumeAction pthread_cond_signal" << endl ;
332 if ( pthread_cond_signal( &_SuspendWait ) ) {
333 perror("ResumeAction pthread_cond_signal ") ;
336 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
337 << " ResumeAction pthread_cond_signaled _SuspendWait " << endl ;
343 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
344 << " NO ResumeAction pthread_cond_signal" << endl ;
346 if ( pthread_self() == ThreadNo() ) {
347 RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
350 _SuspendSync = true ;
351 RetVal = true ; // Il faut tout de meme attendre ci-apres ...
354 if ( pthread_mutex_unlock( &_MutexWait ) ) {
355 perror("ResumeAction pthread_mutex_unlock ") ;
360 if ( pthread_mutex_lock( &_MutexWait ) ) {
361 perror("ResumeAction pthread_mutex_lock ") ;
364 if ( !_ResumeSync ) {
366 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
367 << Name() << " ResumeAction pthread_cond_wait _ResumeWait "
368 << Automaton()->StateName( State() ) << endl ;
371 if ( pthread_cond_wait( &_ResumeWait , &_MutexWait ) ) {
372 perror("ResumeAction pthread_cond_wait ") ;
375 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
376 << Name() << " ResumeAction pthread_cond_waited _ResumeWait"
377 << Automaton()->StateName( State() ) << endl ;
383 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
384 << Name() << " NO ResumeAction pthread_cond_wait _ResumeWait"
385 << Automaton()->StateName( State() ) << endl ;
389 _ResumeSync = false ;
390 if ( pthread_mutex_unlock( &_MutexWait ) ) {
391 perror("ResumeAction pthread_mutex_unlock ") ;
396 cdebug << pthread_self() << "/" << ThreadNo()
397 << "GraphExecutor::InNodeThreads::ResumeAction RetVal " << RetVal << endl ;
402 bool GraphExecutor::InNode::ReStartAction( GraphExecutor::InNode * aReStartNode ,
403 GraphExecutor::NodeEvent anEvent ) {
404 GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
405 _aReStartNode = aReStartNode ;
406 _aReStartEvent = anEvent ;
407 cdebug << pthread_self() << "/" << ThreadNo()
408 << " GraphExecutor::InNodeThreads::ReStartAction from "
409 << Name() << " " << Automaton()->StateName( State() ) << " to "
410 << aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
411 << Automaton()->StateName( aReStartNode->State() ) ;
412 if ( oldReStartNode ) {
413 cdebug << " oldReStartNode " << oldReStartNode->Name() << endl ;
418 return ResumeAction( GraphExecutor::ToReStartEvent ) ;
421 void GraphExecutor::InNode::KilledAction() {
422 if ( pthread_mutex_lock( &_MutexWait ) ) {
423 perror("Killed pthread_mutex_lock ") ;
427 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_wait"
430 if ( pthread_cond_wait( &_KillWait , &_MutexWait ) ) {
431 perror("Killed pthread_cond_wait ") ;
433 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_waited"
437 cdebug << "pthread_cond " << Name() << " NO Killed pthread_cond_wait"
441 if ( pthread_mutex_unlock( &_MutexWait ) ) {
442 perror("Killed pthread_mutex_unlock ") ;
447 void GraphExecutor::InNode::KillAction() {
448 if ( pthread_mutex_lock( &_MutexWait ) ) {
449 perror("Kill pthread_mutex_lock ") ;
453 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signal"
455 // if ( pthread_cond_broadcast( &_KillWait ) ) {
456 if ( pthread_cond_signal( &_KillWait ) ) {
457 perror("Kill pthread_cond_broadcast ") ;
459 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signaled"
463 cdebug << "pthread_cond " << Name() << " NO Kill pthread_cond_signal"
467 if ( pthread_mutex_unlock( &_MutexWait ) ) {
468 perror("Kill pthread_mutex_unlock ") ;
473 void GraphExecutor::InNode::StoppedAction() {
474 if ( pthread_mutex_lock( &_MutexWait ) ) {
475 perror("Stopped pthread_mutex_lock ") ;
478 if ( pthread_cond_wait( &_StopWait , &_MutexWait ) ) {
479 perror("Stopped pthread_cond_wait ") ;
481 if ( pthread_mutex_unlock( &_MutexWait ) ) {
482 perror("Stopped pthread_mutex_unlock ") ;
487 void GraphExecutor::InNode::StopAction() {
488 if ( pthread_mutex_lock( &_MutexWait ) ) {
489 perror("Stop pthread_mutex_lock ") ;
492 if ( pthread_cond_broadcast( &_StopWait ) ) {
493 perror("Stop pthread_cond_broadcast ") ;
495 if ( pthread_mutex_unlock( &_MutexWait ) ) {
496 perror("Stop pthread_mutex_unlock ") ;
501 void GraphExecutor::InNode::ThreadStartedAction() {
502 if ( pthread_mutex_lock( &_MutexWait ) ) {
503 perror("ThreadStarted pthread_mutex_lock ") ;
506 if ( !_ThreadStartedSync ) {
508 cdebug << pthread_self() << "/" << ThreadNo()
509 << "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait"
512 _ThreadStartedSync = true ;
513 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
514 perror("ThreadStarted pthread_cond_wait ") ;
517 cdebug << pthread_self() << "/" << ThreadNo()
518 << "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited"
524 cdebug << pthread_self() << "/" << ThreadNo()
525 << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait"
529 _ThreadStartedSync = false ;
530 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
531 perror("ThreadStart pthread_cond_signal ") ;
535 cdebug << pthread_self() << "/" << ThreadNo()
536 << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled"
540 if ( pthread_mutex_unlock( &_MutexWait ) ) {
541 perror("ThreadStarted pthread_mutex_unlock ") ;
546 void GraphExecutor::InNode::ThreadStartAction() {
547 if ( pthread_mutex_lock( &_MutexWait ) ) {
548 perror("ThreadStart pthread_mutex_lock ") ;
551 if ( _ThreadStartedSync ) {
553 cdebug << pthread_self() << "/" << ThreadNo()
554 << "pthread_cond " << Name() << " ThreadStart pthread_cond_signal"
557 _ThreadStartedSync = false ;
558 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
559 perror("ThreadStart pthread_cond_broadcast ") ;
562 cdebug << pthread_self() << "/" << ThreadNo()
563 << "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled"
569 cdebug << pthread_self() << "/" << ThreadNo()
570 << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal"
573 _ThreadStartedSync = true ;
575 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
576 perror("ThreadStarted pthread_cond_wait ") ;
580 cdebug << pthread_self() << "/" << ThreadNo()
581 << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited"
585 if ( pthread_mutex_unlock( &_MutexWait ) ) {
586 perror("ThreadStart pthread_mutex_unlock ") ;
591 int GraphExecutor::InNode::executeAction() {
593 int oldRewindStack = ( _RewindStack > MAXSTACKTHREADSIZE ) ;
594 if ( !CreateNewThread() && oldRewindStack ) {
596 cdebug << pthread_self() << "/" << ThreadNo()
597 << " executeAction start Thread _RewindStack " << _RewindStack << " > "
598 << MAXSTACKTHREADSIZE << " CreateNewThread "
599 << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "("
600 << Name() << ")" << endl;
602 CreateNewThread( true ) ;
603 _OutNode->IncrCreatedThreads() ;
606 if ( CreateNewThread() ) {
607 CreateNewThread( false ) ;
608 //JR 15.04.2005 Debug PAL8624 RetroConception :
609 // if ( ThreadNo() == 0 ) {
612 cdebug << pthread_self() << "/" << ThreadNo()
613 << " executeAction start Thread _RewindStack " << _RewindStack << " "
614 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
618 int pthread_sts = 1 ;
619 // _OutNode->PushEvent( NULL , GraphExecutor::NewThreadEvent ,
620 // GraphExecutor::ExecutingState ) ;
621 while ( (pthread_sts = pthread_create(&T, NULL, run_function, this )) ) {
622 char * msg = "Cannot pthread_create " ;
624 cdebug << ThreadNo() << " " << msg << " --> sleep(5)" << endl ;
625 // cdebug << ThreadNo() << " PTHREAD_THREADS_MAX : "
626 // << PTHREAD_THREADS_MAX << " pthread_create status : " ;
627 if ( pthread_sts == EAGAIN ) {
628 cdebug << "EAGAIN(" << pthread_sts << ")" << endl ;
629 cdebug << _OutNode->CreatedThreads() << " was created (and exited)" << endl ;
630 cdebug << "It seems to me that with gdb we are limited to 256 threads" << endl ;
633 cdebug << pthread_sts << endl ;
637 pthread_exit( msg ) ;
639 _OutNode->setRunFuncThread( T ) ; // mkr : IPAL14711
641 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
642 << " executeAction has created thread " << T << endl ;
644 ThreadStartedAction() ;
646 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
647 << "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
651 //JR 15.04.2005 Debug PAL8624 RetroConception :
655 cdebug << pthread_self() << "/" << ThreadNo()
656 << " executeAction restart Thread _RewindStack " << _RewindStack << " "
657 << Automaton()->StateName( State() ) << " "
658 << Automaton()->ActionName( _NextAction ) << "(" << Name()
659 << ") ReStartAction ==>" << endl;
661 State( GraphExecutor::SuspendedSuccessedState ) ;
662 if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
663 cdebug << pthread_self() << "/" << ThreadNo()
664 << " executeAction STATE & CALLED "
665 << Automaton()->ActionName( _NextAction ) << "(" << Name()
666 << ") ERROR-DEBUG " << endl;
670 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
671 << Automaton()->ActionName( _NextAction ) << "(" << Name()
679 if ( _CurrentEvent == ExecuteEvent ) {
683 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
684 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
687 return ExecuteAction() ;
692 void GraphExecutor::InNode::coutbegin() {
694 cdebug << pthread_self() << "/" << ThreadNo() << " run_function begin"
695 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
698 void GraphExecutor::InNode::coutexit() {
700 cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit _RewindStack " << _RewindStack
701 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
704 void * run_function(void *p) {
705 GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
707 aNode->NewThread( pthread_self() ) ;
708 if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) {
709 perror("pthread_setcanceltype ") ;
712 if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) {
713 perror("pthread_setcancelstate ") ;
716 aNode->ThreadStartAction() ;
717 // cout << "run_function " << aNode->Name() << "->ExecuteAction() Coupled : " << aNode->CoupledNode()
719 aNode->ExecuteAction() ;
720 char * msg = new char[40] ;
721 sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
722 strcat( msg , " thread exit" ) ;
724 aNode->ExitThread() ;
727 pthread_exit( (void * ) smsg.c_str() ) ;
731 int GraphExecutor::InNode::ExecuteAction() {
735 const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
736 const char * statename = Automaton()->StateName( State() ) ;
737 const char * nextstatename = Automaton()->StateName( _NextState ) ;
738 cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name() << " --> ExecuteAction "
739 << nextactionname << " " << statename << " NextState "
740 << nextstatename << endl ;
743 State( _NextState ) ;
744 switch ( _NextAction ) {
745 case GraphExecutor::ErrorAction : {
746 sts = ErrorAction() ;
749 case GraphExecutor::VoidAction : {
753 case GraphExecutor::DataWaiting_SomeDataReadyAction : {
754 sts = DataWaiting_SomeDataReadyAction() ;
757 case GraphExecutor::DataUndef_NotAllDataReadyAction : {
758 sts = DataUndef_NotAllDataReadyAction() ;
761 case GraphExecutor::DataUndef_AllDataReadyAction : {
762 sts = DataUndef_AllDataReadyAction() ;
765 case GraphExecutor::DataReady_SuspendAction : {
766 sts = DataReady_SuspendAction() ;
769 case GraphExecutor::SuspendedReady_ResumeAction : {
770 sts = SuspendedReady_ResumeAction() ;
773 case GraphExecutor::DataReady_KillAction : {
774 sts = DataReady_KillAction() ;
777 case GraphExecutor::DataReady_StopAction : {
778 sts = DataReady_StopAction() ;
781 case GraphExecutor::DataReady_ExecuteAction : {
782 sts = DataReady_ExecuteAction() ;
785 case GraphExecutor::Executing_SuspendAction : {
786 sts = Executing_SuspendAction() ;
789 case GraphExecutor::SuspendedExecuting_ResumeAction : {
790 sts = SuspendedExecuting_ResumeAction() ;
793 case GraphExecutor::Executing_KillAction : {
794 sts = Executing_KillAction() ;
797 case GraphExecutor::Executing_StopAction : {
798 sts = Executing_StopAction() ;
801 case GraphExecutor::Executing_SuccessAction : {
802 sts = Executing_SuccessAction() ;
805 case GraphExecutor::Errored_ExecutingAction : {
806 sts = Errored_ExecutingAction() ;
809 case GraphExecutor::Successed_SuccessAction : {
810 sts = Successed_SuccessAction() ;
813 case GraphExecutor::Errored_ErrorAction : {
814 sts = Errored_ErrorAction() ;
817 case GraphExecutor::Successed_SuspendAction : {
818 sts = Successed_SuspendAction() ;
821 case GraphExecutor::Errored_SuspendAction : {
822 sts = Errored_SuspendAction() ;
825 case GraphExecutor::SuspendedSuccessed_ResumeAction : {
826 sts = SuspendedSuccessed_ResumeAction() ;
829 case GraphExecutor::SuspendedErrored_ResumeAction : {
830 sts = SuspendedErrored_ResumeAction() ;
833 case GraphExecutor::Successed_KillAction : {
834 sts = Successed_KillAction() ;
837 case GraphExecutor::Errored_KillAction : {
838 sts = Errored_KillAction() ;
841 case GraphExecutor::Successed_StopAction : {
842 sts = Successed_StopAction() ;
845 case GraphExecutor::Errored_StopAction : {
846 sts = Errored_StopAction() ;
849 case GraphExecutor::SuspendedSuccessed_ReStartAction : {
850 sts = SuspendedSuccessed_ReStartAction() ;
853 case GraphExecutor::SuspendedErrored_ReStartAction : {
854 sts = SuspendedErrored_ReStartAction() ;
857 case GraphExecutor::SuspendedSuccessed_ReStartAndSuspendAction : {
858 sts = SuspendedSuccessed_ReStartAndSuspendAction() ;
861 case GraphExecutor::SuspendedErrored_ReStartAndSuspendAction : {
862 sts = SuspendedErrored_ReStartAndSuspendAction() ;
866 cdebug << pthread_self() << "/" << ThreadNo()
867 << " GraphExecutor::InNodeThreads::SendEvent Error Undefined Action : "
868 << _NextAction << endl ;
873 cdebug_out << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
874 << nextactionname << endl ;
879 int GraphExecutor::InNode::ErrorAction() {
880 cdebug << pthread_self() << "/" << ThreadNo() << " Automaton ErrorAction Node "
885 int GraphExecutor::InNode::VoidAction() {
886 cdebug << pthread_self() << "/" << ThreadNo() << " VoidAction " << Name() << endl;
890 #define SomeDataReadyActionTrace 1
891 int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
892 #if SomeDataReadyActionTrace
893 cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name()
894 << " DataWaiting_SomeDataReadyAction from " << DataFromNode()
895 << " " << GetNodeInPortsSize() << " Inport(s)" << endl;
900 bool LoopBeginning = false ;
901 bool LoopFinished = false ;
902 bool SwitchFinished = false ;
903 bool SwitchDefault = false ;
904 bool DoAllDataReadyIf = true ;
906 if ( IsLoopNode() ) {
907 GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
908 if ( anOutLoopPort && anOutLoopPort->BoolValue() ) {
909 LoopBeginning = true ; // Beginning of Loop
912 else if ( IsEndLoopNode() ) {
913 GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
914 if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) {
915 LoopFinished = true ; // End of Loop
918 else if ( IsEndSwitchNode() ) {
919 if ( strcmp( GOTONode()->CoupledNode()->Name() , DataFromNode() ) ) {
920 GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default Port
921 //JR 09.02.2005 : SomeDataReady is NOT from the SwitchNode
922 if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
923 //JR 09.02.2005 : the OutPort of the SwitchNode connected to the default port is closed ===>
924 // Here after we consider that that DefaultPort is Ready (even if it's value is false) in
925 // order to have the good count of InPorts Ready in the EndSwitchNode
926 // SwitchFinished = true ; // End of Switch
928 // But we do that only if the InDefaultPort of the EndSwitchNode is not connected or
929 // is connected from the OutDefaultPort of the corresponding SwitchNode
930 if ( !strcmp( GOTONode()->CoupledNode()->Name() , anOutGateSwitchPort->NodeName() ) ) {
931 SwitchFinished = true ; // End of Switch
936 //JR 20.04.2005 : SomeDataReady is FROM the SwitchNode to that EndSwitchNode
938 //JR 16.02.2005 Debug : Change InPorts of EndSwitchNode that have the same name as an OutPort of
939 // the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
940 GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default P
941 //JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is activated :
942 if ( anOutGateSwitchPort ) {
943 if ( anOutGateSwitchPort->BoolValue() ) {
944 SwitchDefault = true ;
946 //JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is NOT activated :
947 // a SwitchBranch should be activated
949 DoAllDataReadyIf = false ;
951 #if SomeDataReadyActionTrace
952 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
953 << " activated from CoupledNode " << GOTONode()->CoupledNode()->Name() << " "
954 << anOutGateSwitchPort->NodeName() << "( " << anOutGateSwitchPort->PortName()
955 << " ) to InDefault " ;
957 if ( GraphBase::Base::_prof_debug ) {
958 anOutGateSwitchPort->StringValue( *GraphBase::Base::_fdebug ) ;
964 //JR 28.06.2005 : SomeDataReady is from the SwitchNode and the InDefault is not connected :
965 // a SwitchBranch should be activated
967 DoAllDataReadyIf = false ;
972 #if SomeDataReadyActionTrace
973 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
974 << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished
975 << " SwitchDefault " << SwitchDefault << " DoAllDataReadyIf " << DoAllDataReadyIf << endl ;
977 for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
978 GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
979 GraphBase::OutPort * anOutPort ;
980 if ( SwitchDefault && !anInPort->IsDataStream() ) {
981 //Get or Set the field OutPort of that InPort of the EndSwitchNode to the corresponding OutPort
983 anOutPort = anInPort->GetOutPort() ;
985 #if SomeDataReadyActionTrace
986 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort"
988 << anInPort->PortName() << " already setted to OutPort " << anOutPort->NodeName()
989 << "( " << anOutPort->PortName() << " )" << endl ;
993 anOutPort = CoupledNode()->GetChangeOutPort( anInPort->PortName() ) ;
995 #if SomeDataReadyActionTrace
996 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort"
998 << anInPort->PortName() << " change of OutPort from "
999 << anInPort->GetOutPort()->NodeName() << "( " << anInPort->GetOutPort()->PortName()
1000 << " ) to " << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )"
1005 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort"
1007 << anInPort->PortName() << " have NO OutPort ERROR " << endl ;
1010 anInPort->ChangeOutPort( anOutPort ) ;
1014 anOutPort = anInPort->GetOutPort() ;
1016 #if SomeDataReadyActionTrace
1017 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort"
1019 << anInPort->PortName() << " " << anInPort->PortState() << " "
1020 << anInPort->PortStatus() << " " << anInPort->Kind() ;
1022 cdebug << " from OutPort " << anOutPort->NodeName() << "( " << anOutPort->PortName()
1026 cdebug << " without OutPort " ;
1030 if ( anInPort->IsGate() && anOutPort == NULL ) {
1032 anInPort->PortState( SUPERV::ReadyState ) ;
1033 #if SomeDataReadyActionTrace
1034 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1035 << anInPort->PortName() << " ControlPort inactive." << endl ;
1039 // That InPort get its value from an other node : the node of anOutPort linked to that anInPort is
1040 // different from the sender of SomeDataReady (DataFromNode) :
1041 else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
1042 if ( anInPort->PortState() == SUPERV::ReadyState ) {
1044 #if SomeDataReadyActionTrace
1045 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1046 << anInPort->PortName() << " " << anInPort->PortState() << " Was Done from Node "
1047 << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
1048 << anOutPort->PortState() << " ) PortDone " << anOutPort->PortDone() << " " ;
1050 if ( GraphBase::Base::_prof_debug ) {
1051 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1056 //JR 30.01.2007 : wrong debug for PAL12455
1058 // mkr : PAL12455 -->
1059 // MacroNode : give immediately the value to the corresponding graph
1060 if ( IsMacroNode() ) {
1061 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1062 cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name() << " --> InputOfAny "
1063 << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready ( "
1064 << anInPort->PortName() << " ) ===> InputOfAny" << endl ;
1065 // GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1066 //JR 30.03.2005 aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1067 aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
1069 // mkr : PAL12455 <--
1072 else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
1073 anInPort->PortState( SUPERV::ReadyState ) ;
1075 #if SomeDataReadyActionTrace
1076 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1077 << anInPort->PortName() << " Was Done from Node "
1078 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1079 << ") LoopBeginning " << LoopBeginning << " " ;
1081 if ( GraphBase::Base::_prof_debug ) {
1082 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1088 else if ( LoopFinished ) {
1089 anInPort->PortState( SUPERV::ReadyState ) ;
1091 #if SomeDataReadyActionTrace
1092 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1093 << anInPort->PortName() << " Was Done from Node "
1094 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1095 << ") LoopFinished " << LoopFinished << " " ;
1097 if ( GraphBase::Base::_prof_debug ) {
1098 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1104 else if ( anInPort->IsGate() && SwitchFinished ) {
1105 anInPort->PortState( SUPERV::ReadyState ) ;
1107 #if SomeDataReadyActionTrace
1108 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1109 << anInPort->PortName() << " Was Done from Node "
1110 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1111 << ") SwitchFinished " << SwitchFinished << " " ;
1113 if ( GraphBase::Base::_prof_debug ) {
1114 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1120 else if ( anInPort->IsGate() &&
1121 _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->IsGOTONode() ) {
1122 // GateOutPort of GOTONodes are always opened
1123 anInPort->PortState( SUPERV::ReadyState ) ;
1125 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
1126 CORBA::Any anAny = CORBA::Any() ;
1127 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 1 ;
1128 anAny <<= (CORBA::Long ) 1 ;
1129 _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->GetChangeNodeOutGate()->SetValue( anAny ) ;
1130 #if SomeDataReadyActionTrace
1131 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1132 << anInPort->PortName() << " Was Done from Node "
1133 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1136 if ( GraphBase::Base::_prof_debug ) {
1137 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1144 #if SomeDataReadyActionTrace
1145 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1146 << " " << Automaton()->StateName( State() ) << " LoopBeginning "
1147 << LoopBeginning << " " << anInPort->PortName() << " DataConnected "
1148 << anInPort->IsDataConnected() << " Was NOT Done from Node "
1149 << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
1150 << anOutPort->PortState() << " , PortDone " << anOutPort->PortDone() << ") "
1156 // That InPort get its value from the sending node (DataFromNode)
1157 else if ( anInPort->IsGate() ) {
1158 //JR 30.03.2005 const CORBA::Any * theValue = anOutPort->Value() ;
1159 const CORBA::Any theValue = anOutPort->Value() ;
1160 CORBA::Long GateOpened ;
1161 //JR 30.03.2005 (*theValue) >>= GateOpened ;
1162 theValue >>= GateOpened ;
1163 if ( GateOpened != 0 ) {
1165 anInPort->PortState( SUPERV::ReadyState ) ;
1166 #if SomeDataReadyActionTrace
1167 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1168 << anInPort->PortName() << " Gate is Opened from Node "
1169 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1172 if ( GraphBase::Base::_prof_debug ) {
1173 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1179 else if ( LoopFinished ) {
1180 anInPort->PortState( SUPERV::ReadyState ) ;
1181 #if SomeDataReadyActionTrace
1182 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1183 << anInPort->PortName() << " GATE IS CLOSED from Node "
1184 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1185 << ") LoopFinished" ;
1187 if ( GraphBase::Base::_prof_debug ) {
1188 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1195 #if SomeDataReadyActionTrace
1196 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1197 << anInPort->PortName() << " GATE IS CLOSED from Node "
1198 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1201 if ( GraphBase::Base::_prof_debug ) {
1202 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1209 else if ( anOutPort->PortDone() ) {
1210 #if SomeDataReadyActionTrace
1211 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
1212 << anInPort->PortName() << " " << anInPort->PortStatus() << " "
1213 << Automaton()->StateName( anInPort->PortState() ) << " is Done from Node "
1214 << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
1215 << anOutPort->PortStatus() << " --> ReadyState " ;
1217 if ( GraphBase::Base::_prof_debug ) {
1218 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1224 anInPort->PortState( SUPERV::ReadyState ) ;
1225 // MacroNode : give immediately the value to the corresponding graph
1226 if ( IsMacroNode() ) {
1227 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1228 cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name() << " --> InputOfAny "
1229 << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready ( "
1230 << anInPort->PortName() << " ) ===> InputOfAny" << endl ;
1231 // GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1232 //JR 30.03.2005 aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1233 aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
1237 #if SomeDataReadyActionTrace
1238 cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( "
1239 << anInPort->PortName() << ") " << anInPort->PortStatus()
1240 << " is NOT Done from Node "
1241 << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
1242 << anOutPort->PortStatus() << " " << anOutPort->PortDone() << endl ;
1247 if ( InReady == GetNodeInPortsSize() && DoAllDataReadyIf ) { // All Flags != 0 :
1248 //JR 15.04.2005 Debug PAL8624 RetroConception :
1249 // res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
1250 #if SomeDataReadyActionTrace
1251 cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << " HasAllDataReady"
1254 //JR 30.01.2007 Right Debug PAL12455 --->
1255 //That must be done only for DataConnected ports and only once
1256 if ( IsMacroNode() ) {
1257 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1258 for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
1259 GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
1260 GraphBase::OutPort * anOutPort ;
1261 anOutPort = anInPort->GetOutPort() ;
1262 if ( anInPort->IsDataConnected() ) {
1263 cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name()
1264 << " --> InputOfAny " << InReady << "/" << GetNodeInPortsSize()
1265 << " InPorts are Ready ( " << anInPort->PortName()
1266 << " ) ===> InputOfAny" << endl ;
1267 aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
1271 // <--- JR 30.01.2007 Right Debug PAL12455
1272 HasAllDataReady( true ) ; // ==> Ready to execute
1275 else { // At least one Flag == 0 :
1276 #if SomeDataReadyActionTrace
1277 cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << " HasNOTAllDataReady "
1278 << InReady << "/" << GetNodeInPortsSize() << " DoAllDataReadyIf " << DoAllDataReadyIf << endl ;
1280 HasAllDataReady( false ) ;
1281 res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
1284 #if SomeDataReadyActionTrace
1285 cdebug_out << pthread_self() << "/" << ThreadNo() << Name()
1286 << " DataWaiting_SomeDataReadyAction " << endl;
1292 #define NotAllDataReadyActionTrace 1
1293 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
1294 //JR 15.04.2005 Debug PAL8624 RetroConception :
1295 // CreateNewThreadIf( false ) ;
1296 #if NotAllDataReadyActionTrace
1297 cdebug << pthread_self() << " for " << ThreadNo()
1298 << " DataUndef_NotAllDataReadyAction " << Name() << endl;
1303 #define AllDataReadyActionTrace 1
1304 int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
1305 #if AllDataReadyActionTrace
1306 cdebug << pthread_self() << "/" << ThreadNo()
1307 << " --> DataUndef_AllDataReadyAction " << Name() << endl ;
1308 // << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
1309 // << IsLockedDataWait() ;
1311 //JR 15.04.2005 Debug PAL8624 RetroConception :
1312 if ( !CreateNewThread() ) {
1313 #if AllDataReadyActionTrace
1314 cdebug << "Thread " << ThreadNo() << " --> " << pthread_self() << endl ;
1316 ThreadNo( pthread_self() ) ;
1319 _OutNode->IncrCreatedThreads() ;
1321 _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
1322 GraphExecutor::DataReadyState ) ;
1324 SUPERV::ControlState aControl = ControlState() ;
1325 switch ( aControl ) {
1326 case SUPERV::VoidState : {
1327 SendEvent( GraphExecutor::ExecuteEvent ) ;
1330 case SUPERV::ToSuspendState : {
1331 SendEvent( GraphExecutor::SuspendEvent ) ;
1334 case SUPERV::ToSuspendStartState : {
1335 SendEvent( GraphExecutor::SuspendEvent ) ;
1338 case SUPERV::ToSuspendDoneState : {
1339 SendEvent( GraphExecutor::ExecuteEvent ) ;
1342 case SUPERV::ToKillState : {
1343 SendEvent( GraphExecutor::KillEvent ) ;
1346 case SUPERV::ToKillDoneState : {
1347 SendEvent( GraphExecutor::ExecuteEvent ) ;
1350 case SUPERV::ToStopState : {
1351 SendEvent( GraphExecutor::StopEvent ) ;
1355 cdebug << ThreadNo()
1356 << " GraphExecutor::InNodeThreads::DataUndef_AllDataReadyAction Error Undefined Control : "
1357 << aControl << endl ;
1361 #if AllDataReadyActionTrace
1362 cdebug << pthread_self() << "/" << ThreadNo()
1363 << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
1368 int GraphExecutor::InNode::DataReady_SuspendAction() {
1369 cdebug << pthread_self() << "/" << ThreadNo()
1370 << "DataReady_SuspendAction --> Suspend " << Name()
1371 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
1372 << _OutNode->SuspendedThreads() << endl;
1373 _OutNode->PushEvent( this , GraphExecutor::SuspendedReadyEvent ,
1374 GraphExecutor::SuspendedReadyState ) ;
1375 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1376 cdebug << pthread_self() << "/" << ThreadNo()
1377 << "DataReady_SuspendAction Resumed " << Name() << endl;
1378 if ( aReStartNode ) {
1379 _aReStartNode = NULL ;
1380 aReStartNode->SendEvent( _aReStartEvent ) ;
1383 SendEvent( GraphExecutor::ExecuteEvent ) ;
1388 int GraphExecutor::InNode::SuspendedReady_ResumeAction() {
1389 cdebug << pthread_self() << "/" << ThreadNo() << "SuspendedReady_ResumeAction "
1392 _OutNode->PushEvent( this , GraphExecutor::ResumedReadyEvent ,
1393 GraphExecutor::ResumedReadyState ) ;
1397 int GraphExecutor::InNode::DataReady_KillAction() {
1398 _OutNode->PushEvent( this , GraphExecutor::KilledReadyEvent ,
1399 GraphExecutor::KilledReadyState ) ;
1401 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_KillAction " << Name()
1402 << " will pthread_exit()" << endl;
1406 int GraphExecutor::InNode::DataReady_StopAction() {
1407 _OutNode->PushEvent( this , GraphExecutor::StoppedReadyEvent ,
1408 GraphExecutor::StoppedReadyState ) ;
1410 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_StopAction " << Name()
1411 << " will pthread_exit()" << endl;
1417 #define TraceDataReady_ExecuteAction 1
1418 int GraphExecutor::InNode::DataReady_ExecuteAction() {
1420 #if TraceDataReady_ExecuteAction
1421 cdebug_in << pthread_self() << "/" << ThreadNo() << " DataReady_ExecuteAction "
1424 _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
1425 GraphExecutor::ExecutingState ) ;
1431 Engines::Container_var myContainer ;
1432 Engines::Component_var myObjComponent ;
1434 SUPERV::GraphState PortState = SUPERV::ReadyState ;
1435 GraphExecutor::AutomatonState NewState = GraphExecutor::DataUndefState ;
1436 GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
1439 ServicesAnyData * InParametersList = NULL ;
1441 ServicesAnyData * OutParametersList = NULL ;
1443 nInParams = GetNodeInPortsSize() ;
1444 #if TraceDataReady_ExecuteAction
1445 char * aName = Name() ;
1446 cdebug << pthread_self() << "/" << ThreadNo() << " " << aName
1447 << " nInParams " << nInParams << " InParametersList "
1448 << (void * ) InParametersList << endl ;
1450 InParametersList = new ServicesAnyData[nInParams];
1451 InParametersSet( Err , nInParams , InParametersList ) ;
1453 nOutParams = GetNodeOutPortsSize() ;
1454 OutParametersList = new ServicesAnyData[nOutParams];
1455 InOutParametersSet( nOutParams , OutParametersList ) ;
1458 if ( !Err && IsComputingNode() ) {
1459 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1460 << " after creation of InParametersList : nInParams " << nInParams
1463 for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
1464 cdebug << "InParametersList[" << i << "] : "
1465 << InParametersList[i].Name << " "
1466 << AnyValue( InParametersList[i].Value ) << endl ;
1468 CORBA::Object * obj ;
1469 InParametersList[0].Value >>= obj ;
1470 Engines::Component_var theObjComponent ;
1471 theObjComponent = Engines::Component::_narrow( obj ) ;
1472 DynInvoke( theObjComponent , "ping" ,
1473 NULL , 0 , NULL , 0 ) ;
1474 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " ping done "
1476 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1477 << " after creation of OutParametersList :" << endl;
1478 for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
1479 cdebug << "OutParametersList[" << i << "] : "
1480 << OutParametersList[i].Name << " "
1481 << AnyValue( OutParametersList[i].Value ) << endl ;
1486 if ( !IsMacroNode() ) {
1488 if ( !IsFactoryNode() ) {
1489 #if TraceDataReady_ExecuteAction
1490 cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
1492 if ( IsComputingNode() ) {
1493 ObjInterface( true ) ;
1494 //JR 05.08.2005 DEBUG : that code runs with SALOME_3 (OMNIOrb4) ...
1495 #if OMNIORB_VERSION >= 4
1496 CORBA::Object * obj ;
1497 InParametersList[0].Value >>= obj ;
1498 myObjComponent = Engines::Component::_narrow( obj ) ;
1499 //JR 05.08.2005 DEBUG : the folowing code runs with OMNIOrb3 but gives
1500 // unpredictable results with SALOME_3 (OMNIOrb4) ...
1502 CORBA::Object_ptr obj ;
1503 InParametersList[0].Value >>= obj ;
1504 CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
1505 myObjComponent = Engines::Component::_duplicate( Engines::Component::_narrow( objvar ) ) ;
1511 else if ( CORBA::is_nil( Component() ) ) {
1512 Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() ,
1513 //JR 17.02.2005 Memory Leak my_strdup( ComponentName() ) ,
1515 myContainer , myObjComponent ) ;
1516 ObjInterface( false ) ;
1517 SetContainer( myContainer ) ;
1518 SetComponent( myObjComponent ) ;
1521 myContainer = Container() ;
1522 myObjComponent = Component() ;
1523 #if TraceDataReady_ExecuteAction
1524 cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
1527 myObjComponent->ping() ;
1530 cdebug << "ping() ERROR catched" << endl ;
1536 if ( Err || ControlState() == SUPERV::ToKillState ||
1537 ControlState() == SUPERV::ToKillDoneState ||
1538 ControlState() == SUPERV::ToStopState ) {
1539 #if TraceDataReady_ExecuteAction
1540 cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
1545 if ( ControlState() == SUPERV::ToSuspendState ) {
1546 #if TraceDataReady_ExecuteAction
1547 cdebug << ThreadNo() << "ToSuspendState before running." << endl ;
1548 MESSAGE(ThreadNo() << "ToSuspendState before running.") ;
1551 #if TraceDataReady_ExecuteAction
1553 cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
1554 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1555 cdebug << " , " << InParametersList[ i ].Name << "[kind"
1556 << InParametersList[ i ].Value.type()->kind() << "]" ;
1558 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1559 cdebug << " , " << OutParametersList[ i ].Name << "[kind"
1560 << OutParametersList[ i ].Value.type()->kind() << "]" ;
1562 if ( IsOneOfInLineNodes() ) {
1563 cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
1564 << InLineNode()->PyRunMethod() << " length "
1565 << (*InLineNode()->PythonFunction()).length()
1566 << " InParametersList " << InParametersList
1567 << " OutParametersList " << OutParametersList ;
1569 cdebug << ")" << endl ;
1572 if ( IsOneOfInLineNodes() ) {
1573 Err = DataReady_ExecuteActionInLineNodes( InParametersList ,
1574 OutParametersList ) ;
1579 if ( IsComputingNode() ) {
1580 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1581 << " myObjComponent " << myObjComponent << " "
1582 << ObjectToString( myObjComponent ) << endl ;
1583 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1584 << " before DynInvoke nInParams " << nInParams
1587 CORBA::Object * obj ;
1588 InParametersList[0].Value >>= obj ;
1589 Engines::Component_var theObjComponent ;
1590 theObjComponent = Engines::Component::_narrow( obj ) ;
1591 DynInvoke( theObjComponent , "ping" ,
1592 NULL , 0 , NULL , 0 ) ;
1593 for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
1594 cdebug << "InParametersList[" << i << "] : "
1595 << InParametersList[i].Name << " "
1596 << AnyValue( InParametersList[i].Value ) << endl ;
1601 #if TraceDataReady_ExecuteAction
1602 cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ;
1604 DynInvoke( myObjComponent, "Names" ,
1605 _OutNode->Name() , Name() ) ;
1608 string anErrorMessage = string( "Dynamic CORBA call to Names for node " ) +
1609 string( Name() ) + " catched." ;
1610 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1611 cdebug << "DynInvoke Names catched ERROR" << endl ;
1613 // for DataStreamNodes : call of SetProperties ===> environment variables in the component/container
1614 if ( ComputingNode()->HasDataStream() ) {
1616 #if TraceDataReady_ExecuteAction
1617 cdebug << "DynInvoke -> SetProperties " << _OutNode->Name() << " " << Name() << endl ;
1619 Engines::FieldsDict_var dict = new Engines::FieldsDict;
1621 dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
1622 // myContainer->getHostName() ne renvoit pas le nom complet (avec domaine).
1623 // dict[ 0 ].value <<= myContainer->getHostName() ;
1624 char FullyQualifiedDomainName[256]="";
1625 gethostname(FullyQualifiedDomainName,255);
1626 dict[ 0 ].value <<= FullyQualifiedDomainName ;
1627 dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
1628 dict[ 1 ].value <<= "/tmp" ;
1629 dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
1630 stringstream ofst1 ;
1631 ofst1 << ComputingNode()->SubStreamGraph() ;
1632 string cpl = string( "/tmp/" ) + string( _OutNode->Name() ) + string( "_" ) +
1633 ofst1.str() + string( ".cpl" );
1634 dict[ 2 ].value <<= cpl.c_str() ;
1635 dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
1636 string uname = Name();
1638 dict[ 3 ].value <<= uname.c_str() ;
1640 myObjComponent->setProperties( dict ) ;
1643 string anErrorMessage = string( "Dynamic CORBA call to setProperties for node " ) +
1644 string( Name() ) + " catched." ;
1645 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1646 cdebug << "DynInvoke setProperties catched ERROR" << endl ;
1652 if ( !Err && IsComputingNode() ) {
1653 #if TraceDataReady_ExecuteAction
1654 cdebug << ThreadNo() << " !ObjInterface " << Name()
1655 << " IsComputingNode DynInvoke" << endl ;
1656 cdebug << ServiceInParameter().length()-1 << " input parameters and "
1657 << ServiceOutParameter().length() << " output parameters" << endl ;
1659 IsLoading( false ) ;
1660 DynInvoke( myObjComponent,
1662 &InParametersList[1] , ServiceInParameter().length()-1 ,
1663 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1665 { cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1666 << " myObjComponent " << myObjComponent << " "
1667 << ObjectToString( myObjComponent ) << endl ;
1668 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1669 << " after DynInvoke nInParams " << nInParams
1671 CORBA::Object * obj ;
1672 InParametersList[0].Value >>= obj ;
1673 Engines::Component_var theObjComponent ;
1674 theObjComponent = Engines::Component::_narrow( obj ) ;
1675 DynInvoke( theObjComponent , "ping" ,
1676 NULL , 0 , NULL , 0 ) ;
1677 for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
1678 cdebug << "InParametersList[" << i << "] : "
1679 << InParametersList[i].Name << " "
1680 << AnyValue( InParametersList[i].Value ) << endl ;
1685 else if ( !Err && IsFactoryNode() ) {
1686 #if TraceDataReady_ExecuteAction
1687 cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
1688 << " IsFactoryNode DynInvoke" << endl ;
1689 cdebug << ServiceInParameter().length() << " input parameters and "
1690 << ServiceOutParameter().length() << " output parameters" << endl ;
1692 IsLoading( false ) ;
1693 DynInvoke( myObjComponent,
1695 &InParametersList[0] , ServiceInParameter().length() ,
1696 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1698 // cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
1699 // << myObjComponent->CpuUsed_impl() << endl ;
1703 string anErrorMessage = string( "Dynamic CORBA call for node " ) +
1704 string( Name() ) + " catched." ;
1705 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1706 cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
1707 << " Node(Component) Dynamic Call Exception catched ERROR"
1709 //Reset of _ThreadId in the Container ...
1711 // myObjComponent->Kill_impl() ;
1722 // if exception or something else - IsLoading( false ) may not NOT has been called
1726 if ( ControlState() == SUPERV::ToKillState ||
1727 ControlState() == SUPERV::ToKillDoneState ||
1728 ControlState() == SUPERV::ToStopState ) {
1729 PortState = SUPERV::ErrorState ;
1730 NewState = GraphExecutor::KilledState ;
1731 NewEvent = GraphExecutor::KillEvent ;
1734 PortState = SUPERV::ErrorState ;
1735 NewState = GraphExecutor::ErroredState ;
1736 NewEvent = GraphExecutor::ErrorEvent ;
1740 PortState = SUPERV::ReadyState ;
1741 NewState = GraphExecutor::DataReadyState ;
1742 NewEvent = GraphExecutor::SuccessEvent ;
1745 if ( !IsMacroNode() ) {
1747 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1749 NewEvent = GraphExecutor::ErrorEvent ;
1752 if ( !Err && IsComputingNode() ) {
1753 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1754 << " myObjComponent " << myObjComponent << " "
1755 << ObjectToString( myObjComponent ) << endl ;
1756 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1757 << " delete [] InParametersList nInParams " << nInParams
1760 CORBA::Object * obj ;
1761 InParametersList[0].Value >>= obj ;
1762 Engines::Component_var theObjComponent ;
1763 theObjComponent = Engines::Component::_narrow( obj ) ;
1764 DynInvoke( theObjComponent , "ping" ,
1765 NULL , 0 , NULL , 0 ) ;
1766 for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
1767 cdebug << "InParametersList[" << i << "] : "
1768 << InParametersList[i].Name << " "
1769 << AnyValue( InParametersList[i].Value ) << endl ;
1774 delete [] InParametersList ;
1777 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1778 << " catch ERROR of delete [] InParametersList" << endl ;
1780 #if TraceDataReady_ExecuteAction
1781 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
1782 << " delete [] OutParametersList :" << endl;
1784 for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
1785 cdebug << "OutParametersList[" << i << "] : "
1786 << OutParametersList[i].Name << " "
1787 << AnyValue( OutParametersList[i].Value ) << endl ;
1791 delete [] OutParametersList ;
1794 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
1795 << " catch ERROR of delete [] OutParametersList" << endl ;
1797 SendEvent( NewEvent ) ;
1800 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1801 #if TraceDataReady_ExecuteAction
1803 for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
1804 cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
1805 << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
1806 << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
1807 if ( GraphBase::Base::_prof_debug ) {
1808 GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
1810 if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
1811 cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
1815 cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " "
1816 << aMacroGraph->Name() << " ->DoneWait()"
1817 << " State " << aMacroGraph->State() << endl;
1819 aMacroGraph->DoneWait() ;
1820 #if TraceDataReady_ExecuteAction
1821 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State "
1822 << aMacroGraph->State() << endl;
1825 //JR 29.09.2005 Debug for CEA (examples/GraphMacroNodes1) :
1826 // Set of value of the OutGate of the corresponding MacroNode was missing
1827 CORBA::Any anAny = CORBA::Any() ;
1828 anAny <<= (CORBA::Long ) 1 ;
1829 GraphMacroNode()->GraphEditor()->Executor()->OutputOfAny( Name() , "Gate" , anAny ) ;
1830 #if TraceDataReady_ExecuteAction
1831 cdebug << "DataReady_ExecuteAction OutputOfAny( " << Name() << " , Gate , 1 )" << endl ;
1833 for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
1834 cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
1835 << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
1836 << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
1837 if ( GraphBase::Base::_prof_debug ) {
1838 GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
1840 if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
1841 cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
1845 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State " << aMacroGraph->State() << endl;
1847 if ( aMacroGraph->State() == SUPERV::DoneState ) {
1848 PortState = SUPERV::ReadyState ;
1849 NewState = GraphExecutor::DataReadyState ;
1850 NewEvent = GraphExecutor::SuccessEvent ;
1854 if ( ControlState() == SUPERV::ToKillState ||
1855 ControlState() == SUPERV::ToKillDoneState ||
1856 ControlState() == SUPERV::ToStopState ) {
1857 PortState = SUPERV::ErrorState ;
1858 NewState = GraphExecutor::KilledState ;
1859 NewEvent = GraphExecutor::KillEvent ;
1862 PortState = SUPERV::ErrorState ;
1863 NewState = GraphExecutor::ErroredState ;
1864 NewEvent = GraphExecutor::ErrorEvent ;
1867 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1869 NewEvent = GraphExecutor::ErrorEvent ;
1871 delete [] InParametersList ;
1872 delete [] OutParametersList ;
1873 SendEvent( NewEvent ) ;
1876 #if TraceDataReady_ExecuteAction
1877 cdebug_out << ThreadNo() << " DataReady_ExecuteAction " << Name() << endl;
1882 int GraphExecutor::InNode::DataReady_ExecuteActionInLineNodes( ServicesAnyData * InParametersList ,
1883 ServicesAnyData * OutParametersList ) {
1885 #if TraceDataReady_ExecuteAction
1886 cdebug_in << pthread_self() << "/" << ThreadNo()
1887 << " DataReady_ExecuteActionInLineNodes " << Name()
1888 << " InParametersList " << InParametersList
1889 << " OutParametersList " << OutParametersList << endl;
1892 bool StsPyDynInvoke = true ;
1893 _OutNode->PyThreadLock() ;
1896 bool ItIsaLoop = false ;
1897 bool CopyInOut = false ;
1898 if ( IsInLineNode() &&
1899 strlen( InLineNode()->PyFuncName() ) ) {
1900 #if TraceDataReady_ExecuteAction
1901 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1902 << InLineNode()->PyFuncName()
1903 << "' IsInLineNode PyDynInvoke" << endl ;
1905 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1906 InLineNode()->PyFuncName() ,
1907 InParametersList , ServiceInParameter().length() ,
1908 OutParametersList , ServiceOutParameter().length() ) ;
1909 if ( !StsPyDynInvoke ) {
1910 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1913 else if ( IsLoopNode() ) {
1915 Err = DataReady_ExecuteActionLoopNodes( InParametersList ,
1919 else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
1920 strlen( InLineNode()->PyFuncName() ) ) {
1921 #if TraceDataReady_ExecuteAction
1922 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1923 << InLineNode()->PyFuncName()
1924 << "' IsSwitchNode PyDynInvoke" << endl ;
1926 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1927 InLineNode()->PyFuncName() ,
1928 InParametersList , ServiceInParameter().length() ,
1929 OutParametersList , ServiceOutParameter().length() ) ;
1931 if ( !StsPyDynInvoke ) {
1932 string anErrorMessage = string( "Dynamic Python call for node " ) +
1933 string( Name() ) + " function " +
1934 InLineNode()->PyFuncName() + " error." ;
1935 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1936 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1939 else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
1940 strlen( InLineNode()->PyFuncName() ) ) {
1941 #if TraceDataReady_ExecuteAction
1942 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1943 << InLineNode()->PyFuncName()
1944 << "' IsGOTONode PyDynInvoke" << endl ;
1947 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1948 InLineNode()->PyFuncName() ,
1949 InParametersList , ServiceInParameter().length() ,
1950 OutParametersList , ServiceOutParameter().length() ) ;
1952 if ( !StsPyDynInvoke ) {
1953 string anErrorMessage = string( "Dynamic Python call for node " ) +
1954 string( Name() ) + " function " +
1955 InLineNode()->PyFuncName() + " error." ;
1956 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1957 RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
1960 else if ( ( IsEndSwitchNode() ) &&
1961 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1962 #if TraceDataReady_ExecuteAction
1963 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1964 << InLineNode()->PyFuncName()
1965 << "' IsSwitchNode PyDynInvoke" << endl ;
1968 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1969 InLineNode()->PyFuncName() ,
1970 InParametersList , ServiceInParameter().length() ,
1971 OutParametersList , ServiceOutParameter().length() ) ;
1973 if ( !StsPyDynInvoke ) {
1974 string anErrorMessage = string( "Dynamic Python call for node " ) +
1975 string( Name() ) + " function " +
1976 InLineNode()->PyFuncName() + " error." ;
1977 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1978 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1981 else if ( IsEndLoopNode() &&
1982 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1983 #if TraceDataReady_ExecuteAction
1984 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1985 << InLineNode()->PyFuncName()
1986 << "' IsSwitchNode PyDynInvoke" << endl ;
1989 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1990 InLineNode()->PyFuncName() ,
1991 InParametersList , ServiceInParameter().length() + 1 ,
1992 OutParametersList , ServiceOutParameter().length() + 1 ) ;
1994 if ( !StsPyDynInvoke ) {
1995 string anErrorMessage = string( "Dynamic Python call for node " ) +
1996 string( Name() ) + " function " +
1997 InLineNode()->PyFuncName() + " error." ;
1998 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
1999 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
2003 if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL ||
2004 strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) {
2005 // This is a void Python Function : without code (No PyFuncName)
2006 #if TraceDataReady_ExecuteAction
2007 cdebug << ThreadNo() << " !ObjInterface " << Name()
2008 << " Copy of " << ServiceInParameter().length()
2009 << " OutParameters" << endl ;
2014 if ( IsLoopNode() || IsEndLoopNode() ) {
2016 argin0 = 1 ; // after DoLoop
2017 if ( IsLoopNode() ) { // More() is void
2018 #if TraceDataReady_ExecuteAction
2019 cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)"
2022 GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
2023 OutParametersList[0].Value = anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
2026 //PAL8072 ==> PAL8512
2027 //JR 24.03.2005 : Debug : void InLine Python function : check of the number of Input Ports
2028 // equals the number of Output Ports was missing
2029 if ( ServiceInParameter().length() != ServiceOutParameter().length() ) {
2030 string anErrorMessage = string( "Inconsistent number of In<->Out parameters for the vois Python function of the node " ) +
2032 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2033 StsPyDynInvoke = false ;
2036 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
2037 OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
2039 #if TraceDataReady_ExecuteAction
2040 cdebug << "ArgOut->In" << InParametersList[argin0 + i].Name.c_str()
2041 << " " << AnyValue( InParametersList[argin0 + i].Value )
2047 if ( !StsPyDynInvoke ) {
2049 string anErrorMessage = string( "Dynamic Python call for node " ) +
2050 string( Name() ) + " error." ;
2051 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2052 cdebug << ThreadNo() << " InLineNode " << Name()
2053 << " Python Dynamic Call Error"
2059 string anErrorMessage = string( "Dynamic Python call for node " ) +
2060 string( Name() ) + " catched." ;
2061 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2062 cdebug << ThreadNo() << " InLineNode " << Name()
2063 << " Python Dynamic Call Exception catched ERROR"
2067 _OutNode->PyThreadUnLock() ;
2068 #if TraceDataReady_ExecuteAction
2069 cdebug_out << pthread_self() << "/" << ThreadNo()
2070 << " DataReady_ExecuteActionInLineNodes " << Name() << endl;
2075 int GraphExecutor::InNode::DataReady_ExecuteActionLoopNodes( ServicesAnyData * InParametersList ,
2076 ServicesAnyData * OutParametersList ,
2077 bool & CopyInOut ) {
2079 #if TraceDataReady_ExecuteAction
2080 cdebug_in << pthread_self() << "/" << ThreadNo()
2081 << " DataReady_ExecuteActionLoopNodes " << Name()
2082 << " InParametersList " << InParametersList
2083 << " OutParametersList " << OutParametersList << endl;
2086 bool StsPyDynInvoke = true ;
2087 bool CopyOutIn = false ;
2088 // Switch between Init() and Next()
2089 // if InLoop port is true and does not come from EndLoop ==> execute Init
2090 // if InLoop port is false or come from EndLoop ==> execute Next
2092 if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init()
2093 #if TraceDataReady_ExecuteAction
2094 cdebug << ThreadNo() << " !ObjInterface " << Name()
2095 << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
2096 << "' InitLoop " << LoopNode()->PyRunMethod() << endl ;
2098 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
2099 InLineNode()->PyFuncName() ,
2100 &InParametersList[1] , ServiceInParameter().length() ,
2101 &OutParametersList[1] , ServiceOutParameter().length() ) ;
2102 if ( !StsPyDynInvoke ) {
2103 string anErrorMessage = string( "Dynamic Python call for node " ) +
2104 string( Name() ) + " function " +
2105 InLineNode()->PyFuncName() + " error." ;
2106 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2107 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
2112 #if TraceDataReady_ExecuteAction
2113 cdebug << ThreadNo() << " !ObjInterface " << Name()
2114 << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ;
2117 #if TraceDataReady_ExecuteAction
2118 cdebug << ThreadNo() << " !ObjInterface " << Name()
2119 << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ;
2123 else if ( LoopNode()->PyNextMethod() &&
2124 strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next()
2125 #if TraceDataReady_ExecuteAction
2126 cdebug << ThreadNo() << " !ObjInterface " << Name()
2127 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
2128 << "' " << LoopNode()->PyNextMethod() << endl ;
2130 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
2131 LoopNode()->PyNextName() ,
2132 &InParametersList[1] , ServiceInParameter().length() ,
2133 &OutParametersList[1] , ServiceOutParameter().length() ) ;
2134 if ( !StsPyDynInvoke ) {
2135 string anErrorMessage = string( "Dynamic Python call for node " ) +
2136 string( Name() ) + " function " +
2137 LoopNode()->PyNextName() + " error." ;
2138 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2139 RemovePyDynInvoke( LoopNode()->PyNextName() ) ;
2144 #if TraceDataReady_ExecuteAction
2145 cdebug << ThreadNo() << " !ObjInterface " << Name()
2146 << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ;
2149 if ( StsPyDynInvoke ) {
2151 #if TraceDataReady_ExecuteAction
2152 cdebug << ThreadNo() << " !ObjInterface " << Name()
2153 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
2154 << "' Copy of " << ServiceInParameter().length()
2155 << " OutParameters" << endl ;
2158 // Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next )
2159 for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
2160 InParametersList[i].Value = OutParametersList[i].Value ;
2161 InParametersList[i].Name = OutParametersList[i].Name ;
2162 #if TraceDataReady_ExecuteAction
2163 cdebug << "ArgOut->In" << InParametersList[ i].Name.c_str()
2164 << " " << AnyValue( InParametersList[ i].Value )
2169 if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
2170 #if TraceDataReady_ExecuteAction
2171 cdebug << ThreadNo() << " !ObjInterface " << Name()
2172 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
2173 << "' " << LoopNode()->PyMoreMethod() << endl ;
2175 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
2176 LoopNode()->PyMoreName() ,
2177 &InParametersList[1] , ServiceInParameter().length() ,
2178 &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
2179 if ( !StsPyDynInvoke ) {
2180 string anErrorMessage = string( "Dynamic Python call for node " ) +
2181 string( Name() ) + " function " +
2182 LoopNode()->PyMoreName() + " error." ;
2183 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
2184 RemovePyDynInvoke( LoopNode()->PyMoreName() ) ;
2188 #if TraceDataReady_ExecuteAction
2189 cdebug << ThreadNo() << " !ObjInterface " << Name()
2190 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
2191 << "' No MoreMethod" << endl ;
2198 cdebug << ThreadNo() << " InLineNode " << Name() << " "
2199 << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
2200 << " Python Dynamic Call Error"
2203 #if TraceDataReady_ExecuteAction
2204 cdebug_out << pthread_self() << "/" << ThreadNo()
2205 << " DataReady_ExecuteActionLoopNodes " << Name() << endl;
2210 int GraphExecutor::InNode::Executing_SuspendAction() {
2211 _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
2212 GraphExecutor::SuspendedExecutingState ) ;
2213 cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
2217 int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
2218 cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
2219 GraphExecutor::AutomatonState next_state ;
2220 next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
2221 _OutNode->NewThread() ; // Only for Threads count
2222 _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
2224 State( next_state ) ;
2228 int GraphExecutor::InNode::Executing_KillAction() {
2229 cdebug << ThreadNo() << " Executing_KillAction " << Name() << " Thread " << ThreadNo()<< endl;
2231 if ( pthread_self() == ThreadNo() ) {
2232 cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
2234 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
2235 GraphExecutor::KilledExecutingState ) ;
2238 else if ( pthread_cancel( ThreadNo() ) ) {
2239 perror("Executing_KillAction pthread_cancel error") ;
2242 cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
2243 << " pthread_canceled" << endl ;
2245 _OutNode->ExitThread( ThreadNo() ) ;
2246 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
2247 GraphExecutor::KilledExecutingState ) ;
2252 int GraphExecutor::InNode::Executing_StopAction() {
2253 cdebug << ThreadNo() << " Executing_StopAction " << Name() << " Thread " << ThreadNo() << endl;
2255 if ( pthread_cancel( ThreadNo() ) ) {
2256 perror("Executing_KillAction pthread_cancel error") ;
2259 cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
2260 << " pthread_canceled" << endl ;
2262 _OutNode->ExitThread( ThreadNo() ) ;
2263 _OutNode->PushEvent( this , GraphExecutor::StoppedExecutingEvent ,
2264 GraphExecutor::StoppedExecutingState ) ;
2269 int GraphExecutor::InNode::Executing_SuccessAction() {
2270 // cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
2271 _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
2272 GraphExecutor::SuccessedState ) ;
2273 // MESSAGE(pthread_self() << "Executor::InNode::Executing_SuccessAction of " << Name()
2274 // << " ControlState " << Automaton()->ControlStateName( ControlState() )
2275 // << " AFTER execution ThreadNo " << ThreadNo() ) ;
2276 SUPERV::ControlState aControl = ControlState() ;
2277 switch ( aControl ) {
2278 case SUPERV::VoidState : {
2279 SendEvent( SuccessEvent ) ;
2282 case SUPERV::ToSuspendState : {
2283 SendEvent( SuccessEvent ) ;
2286 case SUPERV::ToSuspendDoneState : {
2287 SendEvent( GraphExecutor::SuspendEvent ) ;
2290 case SUPERV::ToKillState : {
2291 SendEvent( GraphExecutor::KillEvent ) ;
2294 case SUPERV::ToKillDoneState : {
2295 SendEvent( GraphExecutor::KillEvent ) ;
2298 case SUPERV::ToStopState : {
2299 SendEvent( GraphExecutor::StopEvent ) ;
2303 cdebug << ThreadNo()
2304 << " GraphExecutor::InNodeThreads::Executing_SuccessAction Error Undefined Control : "
2305 << aControl << endl ;
2309 // cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
2313 int GraphExecutor::InNode::Errored_ExecutingAction() {
2314 cdebug << ThreadNo() << " --> Errored_ExecutingAction " << Name() << endl;
2315 _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
2316 GraphExecutor::ErroredState ) ;
2318 _OutNode->NodeAborted( Name() ) ;
2320 SUPERV::ControlState aControl = ControlState() ;
2321 switch ( aControl ) {
2322 case SUPERV::VoidState : {
2323 SendEvent( ErrorEvent ) ;
2326 case SUPERV::ToSuspendState : {
2327 SendEvent( ErrorEvent ) ;
2330 case SUPERV::ToSuspendDoneState : {
2331 SendEvent( GraphExecutor::SuspendEvent ) ;
2334 case SUPERV::ToKillState : {
2335 SendEvent( GraphExecutor::KillEvent ) ;
2338 case SUPERV::ToKillDoneState : {
2339 SendEvent( GraphExecutor::KillEvent ) ;
2342 case SUPERV::ToStopState : {
2343 SendEvent( GraphExecutor::StopEvent ) ;
2347 cdebug << ThreadNo()
2348 << " GraphExecutor::InNodeThreads::Errored_ExecutingAction Error Undefined Control : "
2349 << aControl << endl ;
2353 cdebug << ThreadNo() << " <-- Errored_ExecutingAction " << Name() << endl;
2357 #define SetWaitingStatesTrace 0
2358 // Set SUPERV::WaitingState to all InPorts and Nodes
2359 void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
2362 bool docdebug = false ;
2363 State( GraphExecutor::DataWaitingState ) ;
2364 #if SetWaitingStatesTrace
2365 cdebug << "SetWaitingStates " << Name() << " " << Automaton()->StateName( State() ) << endl ;
2367 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2368 GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
2369 #if SetWaitingStatesTrace
2370 cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
2371 << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
2374 // JR Debug 07.01.2005 : Close the Gates instead of open !!!
2375 if ( anInPort->IsGate() ) { // Loop : Close the doors
2376 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
2378 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
2379 CORBA::Any anAny = CORBA::Any() ;
2380 // *anAny <<= (CORBA::Long ) 1 ;
2381 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 0 ;
2382 anAny <<= (CORBA::Long ) 0 ;
2383 anOutPort->SetValue( anAny ) ;
2384 anInPort->PortState( SUPERV::WaitingState ) ;
2388 else if ( anInPort->PortState() != SUPERV::WaitingState &&
2389 !anInPort->IsDataConnected() ) {
2391 #if SetWaitingStatesTrace
2392 cdebug << ThreadNo()
2393 << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
2397 if ( !anInPort->IsDataStream() ) {
2398 anInPort->PortState( SUPERV::WaitingState ) ;
2401 #if SetWaitingStatesTrace
2402 cdebug << " --> InPort " << Name() << "( " << anInPort->PortName() << " ) "
2403 << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
2405 //JR NPAL14110 09.02.2007 : SetWaitingStates was missing in the corresponding SubGraph !...
2406 if ( IsMacroNode() ) {
2407 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
2408 #if SetWaitingStatesTrace
2409 cdebug << ThreadNo()
2410 << " --> GraphExecutor::InNodeThreads::SetWaitingStates MacroNode " << Name()
2411 << " ---> MacroGraph " << aMacroGraph->Name() << " Inport "
2412 << anInPort->PortName() << endl;
2414 aMacroGraph->SetWaitingStates( anInPort->PortName() ) ;
2417 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
2418 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
2420 //JR 07.03.2005 Debug : Reset of Done flag in OutPorts !... :
2421 if ( !anOutPort->IsDataStream() ) {
2422 anOutPort->PortDone( false ) ;
2423 anOutPort->PortState( SUPERV::WaitingState ) ;
2425 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
2426 if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
2427 !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) &&
2428 !anOutPort->IsDataStream() &&
2429 !anOutPort->ChangeInPorts( j )->IsDataStream() &&
2430 !anOutPort->ChangeInPorts( j )->IsExternConnected() ) {
2431 #if SetWaitingStatesTrace
2432 cdebug << ThreadNo()
2433 << " InNodeThreads::SetWaitingStates OutPort "
2434 << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
2435 << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
2436 << anOutPort->ChangeInPorts( j )->NodeName() << "( "
2437 << anOutPort->ChangeInPorts( j )->PortName() << " "
2438 << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
2440 GraphBase::ComputingNode * aToNode ;
2441 aToNode = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() ) ;
2442 // JR 12.01.2005 Debug : the OutPort linked to the InPort of a EndSwitchNode was changed so final
2443 // values of InPorts of EndSwitchNode may be wrong
2444 // (depending of order of linkednodes)
2445 if ( !aToNode->IsEndSwitchNode() &&
2446 strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
2447 // After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from
2448 // EndLoopNode or GOTONode. But if there is several nested loops we should re-establish.
2449 #if SetWaitingStatesTrace
2450 cdebug << ThreadNo()
2451 << " InNodeThreads::SetWaitingStates Node " << Name() << " "
2452 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
2453 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
2454 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
2455 << anOutPort->PortName() << " )" << endl ;
2457 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2460 //JR 21.04.2005 Debug : the OutPort field of InPorts of EndSwitchNodes must be an OutPort
2461 // of a SwitchBranch or of a NOTSwitchBranch if a link exist
2462 // (if not there is no change)
2463 else if ( !IsSwitchNode() && aToNode->IsEndSwitchNode() &&
2464 strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
2465 #if SetWaitingStatesTrace
2466 cdebug << ThreadNo()
2467 << " InNodeThreads::SetWaitingStates Node " << Name() << " "
2468 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
2469 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
2470 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
2471 << anOutPort->PortName() << " )" << endl ;
2473 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2475 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ;
2476 if ( aNode != EndNode ) {
2477 aNode->SetWaitingStates( EndNode ) ;
2481 #if SetWaitingStatesTrace
2482 cdebug << " --> OutPort " << Name() << "( " << anOutPort->PortName() << " ) "
2483 << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
2488 #define SuccessActionTrace 1
2490 int GraphExecutor::InNode::Successed_SuccessAction() {
2491 #if SuccessActionTrace
2492 cdebug_in << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2497 //JR 15.04.2005 Debug RetroConception :
2498 //The behavior of firstzeroNode and firsttoNode is not reliable and must be removed
2499 //The real problem is :
2500 // 1. send "SomeDataReady" event to linked nodes of the current node
2501 // 2. DO NOT send "AllDataReady" event even if all data are ready in SomeDataReady Action
2502 // but register only that all data are ready :
2503 // MAJOR ENHANCEMENT OF GRAPHEXECUTOR
2504 // 3. activate AllDataReady Action for each node (except the first one ) which have all
2505 // its data ready with a creation of a new thread
2506 // 3. activate AllDataReady Action for the first node which have all its data
2507 // ready in the current thread
2508 //The difficult problem (that I had in the past) was to clearly identify the above behavior ==>
2509 // firstzeroNode, firsttoNode, createnewthreadif, loackdatawait, "would dead lock" etc...
2510 // because if SomeDataReady Action see that all data were ready, it called immediately
2511 // AllDataReady Action ==> bugs difficult to understand and to reproduce
2512 //And the MAJOR DEBUG is (since the first "maquette") : we may have concurrent executions
2513 // of "SomeDataReady" in several threads and there WAS NO MUTEX to protect that
2514 // concurrent actions on the same node
2515 // int linkednodesnumber = LinkedNodesSize() ;
2516 // GraphExecutor::InNode *firstzeroNode = NULL ;
2517 GraphExecutor::InNode *firsttoNode = NULL ;
2518 GraphExecutor::InNode *toNode ;
2521 list<GraphExecutor::InNode *> SomeDataNodes ;
2525 if ( IsMacroNode() ) {
2526 #if SuccessActionTrace
2527 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done for that MacroNode"
2533 //JR 09.02.2005 : That complicated part of the code manages LOOPS and GOTO
2534 if ( IsGOTONode() ||
2535 ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
2536 #if SuccessActionTrace
2537 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2538 << " SetWaitingStates " << endl ;
2540 const GraphBase::OutPort * aGateOutPort ;
2541 if ( IsGOTONode() ) {
2542 aGateOutPort = GetNodeOutGate() ;
2545 aGateOutPort = GetNodeOutLoop() ;
2547 if ( aGateOutPort->InPortsSize() != 1 ) {
2548 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction aGateOutPort->InPortsSize "
2549 << aGateOutPort->InPortsSize() << " != 1 ERROR " << Name() << endl ;
2551 GraphExecutor::InNode * aLabelNode = NULL ;
2552 for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
2553 const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
2554 aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
2555 #if SuccessActionTrace
2556 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
2557 << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
2559 State( GraphExecutor::DataWaitingState ) ;
2560 aLabelNode->SetWaitingStates( this ) ;
2561 // JR 07.01.2005 Debug : Open the Gate of the coupledNode closed by SetWaitingStates
2562 GraphBase::OutPort * anOutPort = aLabelNode->GetChangeNodeInGate()->GetOutPort() ;
2564 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
2565 CORBA::Any anAny = CORBA::Any() ;
2566 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 1 ;
2567 anAny <<= (CORBA::Long ) 1 ;
2568 anOutPort->SetValue( anAny ) ;
2569 aLabelNode->GetChangeNodeInGate()->PortState( SUPERV::ReadyState ) ;
2572 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
2573 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
2574 if ( anInPort->GetOutPort() ) {
2575 #if SuccessActionTrace
2576 cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
2577 << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
2582 //PAL8176 ==> PAL8516
2583 //JR 24.03.2005 Debug : the number of OutPorts of a GOTONode and of InPorts of its linked
2584 // InLine node must be the same
2585 if ( GetNodeOutPortsSize() != aLabelNode-> GetNodeInPortsSize() ) {
2586 cdebug << pthread_self() << "/" << ThreadNo()
2587 << " Successed_SuccessAction # number of ports " << GetNodeOutPortsSize()
2588 << " != " << aLabelNode-> GetNodeInPortsSize() << endl ;
2589 SendEvent( GraphExecutor::ErrorEvent ) ;
2593 for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
2594 GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
2595 if ( !aBusParamOutPort->IsGate() ) {
2596 GraphBase::InPort * aBusParamChangeInPort = NULL ;
2597 if ( aBusParamOutPort->IsLoop() ) {
2598 // For EndLoop do not copy EndLoop(DoLoop) in Loop(InLoop)
2599 // aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
2602 aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
2604 if ( aBusParamChangeInPort ) {
2605 aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
2606 #if SuccessActionTrace
2607 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
2608 << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
2609 << aBusParamOutPort->PortName() << endl ;
2612 else if ( IsGOTONode() ) {
2613 //PAL8176 ==> PAL8516
2614 //JR 24.03.2005 Debug : the names of OutPorts of a GOTONode and of InPorts of its linked
2615 // InLine node must be the same
2616 cdebug << pthread_self() << "/" << ThreadNo()
2617 << " Successed_SuccessAction # names of ports "
2618 << aBusParamOutPort->PortName() << endl ;
2619 SendEvent( GraphExecutor::ErrorEvent ) ;
2627 //JR 15.04.2005 Debug PAL8624 RetroConception :
2628 // THERE IS ONLY ONE NODE COUPLED TO A GOTONODE OR AN ENDLOOPNODE BUT Mutex/Lock for consistency
2630 const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
2631 if ( aGateInPort ) {
2632 if ( aGateInPort->GetOutPort() ) {
2633 //JR 21.02.2005 Debug Memory leak : aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
2634 //JR 30.03.2005 aGateInPort->GetOutPort()->Value( *aGateOutPort->Value() ) ;
2635 aGateInPort->GetOutPort()->SetValue( aGateOutPort->Value() ) ;
2637 //JR 15.04.2005 Debug PAL8624 RetroConception :
2638 if ( !aLabelNode->SendSomeDataReady( Name() ) ) {
2639 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2640 << Name() << " SendSomeDataReady to " << aLabelNode->Name() << " ERROR"
2643 SendEvent( GraphExecutor::ErrorEvent ) ;
2646 if ( aLabelNode->HasAllDataReady() ) {
2647 aLabelNode->ThreadNo( pthread_self() ) ;
2648 aLabelNode->CreateNewThread( false ) ;
2649 aLabelNode->RewindStack( RewindStack() ) ;
2650 aLabelNode->HasAllDataReady( false ) ;
2651 res = aLabelNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
2655 cdebug << pthread_self() << "/" << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
2656 << " NO port " << aGateOutPort->PortName() << " in "
2657 << aLabelNode->Name() << endl;
2663 //==================================================
2664 // JR 09.02.2005 : this is not a EndLoop or a GOTO :
2665 //==================================================
2666 else { // Not a EndLoop or a GOTO
2667 #if SuccessActionTrace
2668 cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
2669 << " with " << LinkedNodesSize() << " linked nodes :" ;
2670 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2671 cdebug << " " << LinkedNodes( i )->Name() ;
2675 //JR 15.04.2005 Debug PAL8624 RetroConception :
2676 // If this is a LoopNode and if DoLoopPort == false, we go directly to the EndOfLoopNode and
2677 // we do not activate Nodes within the loop
2678 bool IgnoreForEndLoop = false ;
2679 // If this is a SwitchNode and if DefaultOutPort == true, we do not activate Nodes within Switch
2680 // We activate directly the EnSwitch
2681 // BUT the NotSwitchBranch(es) are NOT activated :
2682 bool IgnoreForDefaultSwitch = false ;
2683 if ( IsLoopNode() ) {
2684 GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
2685 if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
2686 IgnoreForEndLoop = true ;
2689 else if ( IsSwitchNode() ) {
2690 const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
2691 if ( anOutGatePort->BoolValue() && anOutGatePort->InPortsSize() ) { // DefaultPort is activated
2692 // The DefaultOutPort of that SwitchNode is true and is connected
2693 IgnoreForDefaultSwitch = true ;
2697 //Loop of LinkedNodes for SendSomeDataReady :
2698 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2699 GraphBase::ComputingNode * aComputingNode ;
2700 aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
2701 toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
2702 #if SuccessActionTrace
2703 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction of " << Name()
2704 << " [" << i << "] " << LinkedNodes( i )->Name() << " toNode " << toNode
2705 << " IgnoreForEndLoop " << IgnoreForEndLoop ;
2707 cdebug << " " << toNode->Kind() << endl ;
2710 //JR 15.04.2005 Debug PAL8624 RetroConception :
2712 //JR 18.05.2005 : we must lock because of concurrent SendEvent if NotAllDataReady :
2713 toNode->LockDataReady() ;
2714 if ( IsComputingNode() && toNode->IsInLineNode() ) {
2715 GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
2716 toGateInPort->PortState( SUPERV::ReadyState ) ;
2717 GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
2718 if ( GateOutPort ) {
2719 GateOutPort->PortStatus( DataConnected );
2720 GateOutPort->PortState( SUPERV::ReadyState ) ;
2721 GateOutPort->PortDone( true ) ;
2725 //JR 15.04.2005 Debug PAL8624 RetroConception :
2726 if ( IsLoopNode() ) {
2727 if ( IgnoreForEndLoop && !strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
2728 GraphBase::InPort * toLoopInPort ;
2729 toLoopInPort = toNode->GetChangeNodeInLoop() ;
2730 if ( toLoopInPort->PortState() != SUPERV::ReadyState ) {
2731 toLoopInPort->PortState( SUPERV::ReadyState ) ;
2735 //JR 15.04.2005 Debug PAL8624 RetroConception :
2736 else if ( toNode->IsInLineNode() ) {
2738 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
2739 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
2743 bool activatetoNode = true ;
2744 //We have to execute the loop :
2745 if ( !IgnoreForEndLoop ) {
2746 //The loop is not finished :
2747 if ( toNode->IsLoopNode() ) {
2748 //We enter in a new loop :
2749 GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
2750 toLoopInPort->PortState( SUPERV::ReadyState ) ;
2751 GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
2752 LoopOutPort->PortStatus( DataConnected );
2753 LoopOutPort->PortState( SUPERV::ReadyState ) ;
2754 LoopOutPort->PortDone( true ) ;
2755 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
2756 CORBA::Any anAny = CORBA::Any() ; // InitLoop
2757 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 1 ;
2758 anAny <<= (CORBA::Long ) 1 ;
2759 LoopOutPort->SetValue( anAny ) ;
2761 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
2762 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
2766 //The loop is finished :
2767 else if ( IsLoopNode() ) {
2768 if ( toNode->IsEndLoopNode() ) {
2769 //Not the corresponding EndLoopNode :
2770 if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
2771 #if SuccessActionTrace
2772 cdebug << pthread_self() << "/" << ThreadNo()
2773 << " Successed_SuccessAction NO activate EndLoopNode " << toNode->Name()
2776 activatetoNode = false ;
2779 //Not a EndLoopNode :
2781 #if SuccessActionTrace
2782 cdebug << pthread_self() << "/" << ThreadNo()
2783 << " Successed_SuccessAction NO activate node " << toNode->Name() << endl ;
2785 activatetoNode = false ;
2789 // If the DefaultPort of that SwitchNode is connected to the DefaultPort of the EndSwitchNode
2790 // the NotSwitchBranch(es) are NOT activated :
2791 if ( IgnoreForDefaultSwitch ) {
2792 //We have to activate Default to EndSwitchNode
2793 #if SuccessActionTrace
2794 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction search "
2795 << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
2796 << "IgnoreForDefaultSwitch" << IgnoreForDefaultSwitch << endl ;
2798 activatetoNode = false ;
2799 const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
2800 const GraphBase::InPort * anInPort = NULL ;
2802 for ( j = 0 ; j < anOutGatePort->InPortsSize() ; j++ ) {
2803 anInPort = anOutGatePort->InPorts( j ) ;
2804 const GraphBase::ComputingNode * aNode ;
2805 aNode = _OutNode->Graph()->GetGraphNode( anInPort->NodeName() ) ;
2807 #if SuccessActionTrace
2808 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction try "
2809 << aNode << " " << aNode->Name() << " == " << toNode << " " << toNode->Name()
2813 if ( aNode && (const GraphBase::ComputingNode * ) toNode->ComputingNode() == aNode ) {
2814 // toNode is connected to the DefaultPort of that SwitchNode :
2815 #if SuccessActionTrace
2816 cdebug << pthread_self() << "/" << ThreadNo()
2817 << " Successed_SuccessAction activate node " << aNode->Name() << endl ;
2819 activatetoNode = true ;
2823 #if SuccessActionTrace
2824 cdebug << pthread_self() << "/" << ThreadNo()
2825 << " Successed_SuccessAction NO activate node " << aNode->Name() << endl ;
2830 //JR 19.04.2005 Debug : Do not activate the EndSwitchNode if DefaultGate is close.
2831 //JR 20.04.2005 : it is false : an outport of the SwitchNode may be connected to an
2832 // input port of the EndSwitchNode
2833 if ( activatetoNode ) {
2834 #if SuccessActionTrace
2835 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2836 << toNode->Name() << "->SendSomeDataReady( " << Name() << " )" << endl ;
2838 if ( !toNode->SendSomeDataReady( Name() ) ) {
2839 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2840 << Name() << " SendSomeDataReady to " << toNode->Name() << " ERROR"
2843 toNode->UnLockDataReady() ;
2844 SendEvent( GraphExecutor::ErrorEvent ) ;
2848 toNode->UnLockDataReady() ;
2850 } //End of Loop of LinkedNodes for SendSomeDataReady
2852 //JR 10.02.2005 : Debug at the end of execution of a SwitchNode :
2853 // Here after we may start execution of only one SwitchBranch or of the Default
2854 // But with activation of only one SwitchBranch we may activate several nodes of that SwitchBranch and
2855 // we may activate several nodes of NotSwitchBranch ( a NotSwitchBranch is a Branch of the Switch
2856 // where GatePorts of Nodes are not connected ; that Branches are always executed for each of SwitchBranch
2857 // BUT are not executed when Default is activated).
2858 if ( IsSwitchNode() ) {
2859 GraphBase::InLineNode * anEndSwitchNode = GOTONode()->CoupledNode() ;
2860 //The InPorts of the EndSwitchNode may be connected from that SwitchNode
2861 //So at first, if we activate a SwitchBranch, we have to establish the correct OutPort in the InPorts
2862 // of the EndSwitchNode (for the SwitchBranch and the NOTSwitchBranch[es] :
2864 // So the bug is that all input ports of the corresponding EndSwitchNode must have the status NOTDONE !
2865 // (Only if Default OutPort is closed and Default InPort is closed) :
2866 if ( !GetNodeOutGate()->BoolValue() && anEndSwitchNode->GetNodeInGate()->GetOutPort() &&
2867 !anEndSwitchNode->GetNodeInGate()->GetOutPort()->BoolValue() ) {
2868 #if SuccessActionTrace
2869 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << anEndSwitchNode->Name()
2870 << " reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
2873 for ( i = 0 ; i < anEndSwitchNode->GetNodeInPortsSize() ; i++ ) {
2874 GraphBase::OutPort * anOutPort = anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort() ;
2876 //JR 08.03.2005 Debug : update of state only if not a StreamPort
2877 if ( anOutPort && strcmp( anOutPort->NodeName() , Name() ) &&
2878 !anOutPort->IsDataStream() ) {
2879 #if SuccessActionTrace
2880 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2881 << anEndSwitchNode->Name() << " InPort "
2882 << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOTDONE from "
2883 << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
2885 anEndSwitchNode->GetChangeNodeInPort( i )->PortState( SUPERV::WaitingState ) ;
2886 anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort()->PortDone( false ) ;
2889 #if SuccessActionTrace
2890 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2891 << anEndSwitchNode->Name() << " InPort "
2892 << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOT Changed : directly from "
2893 << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
2899 #if SuccessActionTrace
2900 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2901 << " " << Kind() << " OutGate->Value " << GetNodeOutGate()->BoolValue()
2902 << " NO reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
2907 //JR 15.04.2005 Debug PAL8624 RetroConception :
2908 //Make the list of nodes to activate :
2909 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2910 GraphBase::ComputingNode * aComputingNode ;
2911 aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
2912 toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
2913 if ( toNode ) { // Only Not DataFlowNode :
2914 toNode->LockDataReady() ; // Only ONE Node may send AllDataReadyEvent to an other node
2915 if ( toNode->HasAllDataReady() ) {
2916 SomeDataNodes.push_back( toNode ) ;
2917 toNode->HasAllDataReady( false ) ;
2918 #if SuccessActionTrace
2919 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2920 << Name() << " push "
2921 << toNode->Name() << " " << SomeDataNodes.size() << endl ;
2924 toNode->UnLockDataReady() ;
2928 // firsttoNode : node that has the same ThreadNo() as the current node and that have to be activated
2929 //JR 15.04.2005 Debug PAL8624 RetroConception :
2930 //Activation of nodes that have AllDataReady in a new thread except one :
2931 while ( SomeDataNodes.size() > 1 ) {
2932 GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
2933 SomeDataNodes.pop_front() ;
2934 #if SuccessActionTrace
2935 cdebug << pthread_self() << "/" << ThreadNo()
2936 << " Successed_SuccessAction pop size "
2937 << SomeDataNodes.size() << " " << aNode->Name() << endl ;
2938 cdebug << pthread_self() << "/" << ThreadNo() << " " << aNode->Name()
2939 << " Successed_SuccessAction poped and will start in a new thread" << endl ;
2941 aNode->CreateNewThread( true ) ;
2942 _OutNode->IncrCreatedThreads() ;
2943 //JR 15.04.2005 Debug PAL8624 RetroConception :
2944 res = aNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
2947 //Activation of the last node that have AllDataReady in the same thread :
2948 if ( SomeDataNodes.size() ) {
2949 firsttoNode = SomeDataNodes.front() ;
2950 SomeDataNodes.pop_front() ;
2952 if ( firsttoNode ) {
2953 #if SuccessActionTrace
2954 cdebug << pthread_self() << "/" << ThreadNo()
2955 << " Successed_SuccessAction start firsttoNode "
2956 << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
2958 // firsttoNode->CreateNewThreadIf( false ) ;
2959 firsttoNode->CreateNewThread( false ) ;
2960 firsttoNode->RewindStack( RewindStack() ) ;
2961 if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
2962 #if SuccessActionTrace
2963 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
2964 << " : " << firsttoNode->Name() << " "
2965 << Automaton()->StateName( firsttoNode->State() )
2966 << " --> DataWaitingState for Thread "
2967 << firsttoNode->ThreadNo() << endl ;
2969 firsttoNode->State( GraphExecutor::DataWaitingState ) ;
2971 firsttoNode->ThreadNo( pthread_self() ) ;
2972 // On continue avec le meme thread
2974 #if SuccessActionTrace
2975 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2976 << " for firsttoNode " << firsttoNode->Name()
2977 << " " << Automaton()->StateName( firsttoNode->State() ) << endl ;
2979 //JR 15.04.2005 Debug PAL8624 RetroConception :
2980 //No creation of thread and with LockDataReady, an other node in an other thread cannot be
2981 // waiting for that lock ( if it was the case we could not find AllDataReady for firsttoNode
2982 res = firsttoNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
2985 #if SuccessActionTrace
2986 cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
2987 << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL" << endl ;
2992 #if SuccessActionTrace
2993 cdebug_out << pthread_self() << "/" << ThreadNo()
2994 << " Successed_SuccessAction " << Name() << endl;
2999 #define SendSomeDataReadyTrace 1
3000 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
3001 bool RetVal = false ;
3002 if ( IsDataFlowNode() ) {
3003 #if SendSomeDataReadyTrace
3004 cdebug_in << ThreadNo() << "InNode::SendSomeDataReady " << FromNodeName
3005 << " send Result to graph " << Name() << endl;
3009 #if SendSomeDataReadyTrace
3010 cdebug_in << pthread_self() << "/" << ThreadNo() << FromNodeName
3011 << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
3012 << Automaton()->StateName( State() ) << endl;
3014 if ( State() == GraphExecutor::SuccessedState ||
3015 State() == GraphExecutor::SuspendedSuccessedState ||
3016 State() == GraphExecutor::SuspendedSuccessedToReStartState ) {
3017 #if SendSomeDataReadyTrace
3018 cdebug << ThreadNo() << " " << FromNodeName
3019 << " : " << Name() << " " << Automaton()->StateName( State() )
3020 << " --> DataWaitingState for Thread "
3021 << ThreadNo() << " " << endl ;
3023 State( GraphExecutor::DataWaitingState ) ;
3025 // We begin that LoopNode if SendSomeDataReady does not come from the corresponding EndLoopNode
3026 if ( IsLoopNode() && strcmp( LoopNode()->CoupledNodeName() , FromNodeName ) ) {
3027 #if SendSomeDataReadyTrace
3028 cdebug << ThreadNo() << "InNode::SendSomeDataReady " << Name() << " Set _InitLoop from "
3029 << FromNodeName << endl ;
3033 #if SendSomeDataReadyTrace
3034 cdebug << "SendEvent( SomeDataReadyEvent )" << endl ;
3036 //JR 15.04.2005 Debug PAL8624 RetroConception :
3037 DataFromNode( FromNodeName ) ;
3038 // RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
3039 RetVal = SendEvent( GraphExecutor::SomeDataReadyEvent );
3040 //JR 15.04.2005 Debug PAL8624 RetroConception :
3042 #if SendSomeDataReadyTrace
3043 cdebug_out << pthread_self() << "/" << ThreadNo() << FromNodeName
3044 << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
3045 << Automaton()->StateName( State() ) << " " << RetVal << endl;
3050 int GraphExecutor::InNode::Errored_ErrorAction() {
3051 cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
3052 << " will pthread_exit" << endl;
3054 _OutNode->NodeAborted( Name() ) ;
3060 int GraphExecutor::InNode::Successed_SuspendAction() {
3061 cdebug << ThreadNo() << " Successed_SuspendAction -->Suspend " << Name()
3062 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
3063 << _OutNode->SuspendedThreads() << endl;
3064 _OutNode->PushEvent( this , GraphExecutor::SuspendedSuccessedEvent ,
3065 GraphExecutor::SuspendedSuccessedState ) ;
3067 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
3068 cdebug << ThreadNo() << " Successed_SuspendAction Resumed " << Name() ;
3069 if ( aReStartNode ) {
3070 _aReStartNode = NULL ;
3071 cdebug << " for " << aReStartNode->Name() << endl;
3072 aReStartNode->SendEvent( _aReStartEvent ) ;
3076 SendEvent( GraphExecutor::ResumeEvent ) ;
3081 int GraphExecutor::InNode::Errored_SuspendAction() {
3082 cdebug << ThreadNo() << " Errored_SuspendAction -->Suspend " << Name()
3083 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
3084 << _OutNode->SuspendedThreads() << endl;
3085 _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
3086 GraphExecutor::SuspendedErroredState ) ;
3088 _OutNode->NodeAborted( Name() ) ;
3091 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
3092 cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
3094 if ( aReStartNode ) {
3095 _aReStartNode = NULL ;
3096 aReStartNode->SendEvent( _aReStartEvent ) ;
3099 SendEvent( GraphExecutor::ResumeEvent ) ;
3104 int GraphExecutor::InNode::SuspendedSuccessed_ResumeAction() {
3105 cdebug << ThreadNo() << " SuspendedSuccessed_ResumeAction " << Name() << endl;
3107 _OutNode->PushEvent( this , GraphExecutor::ResumedSuccessedEvent ,
3108 GraphExecutor::ResumedSuccessedState ) ;
3109 SendEvent( ResumedSuccessedEvent ) ;
3113 int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
3114 cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
3116 _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
3117 GraphExecutor::ResumedErroredState ) ;
3119 _OutNode->NodeAborted( Name() ) ;
3121 SendEvent( ResumedErroredEvent ) ;
3125 int GraphExecutor::InNode::Successed_KillAction() {
3127 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
3128 GraphExecutor::KilledSuccessedState ) ;
3129 cdebug << ThreadNo() << " Successed_KillAction " << Name() << endl;
3133 int GraphExecutor::InNode::Errored_KillAction() {
3135 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
3136 GraphExecutor::KilledErroredState ) ;
3138 _OutNode->NodeAborted( Name() ) ;
3140 cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
3144 int GraphExecutor::InNode::Successed_StopAction() {
3146 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
3147 GraphExecutor::StoppedSuccessedState ) ;
3148 cdebug << ThreadNo() << " Successed_StopAction " << Name() << endl;
3152 int GraphExecutor::InNode::Errored_StopAction() {
3154 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
3155 GraphExecutor::StoppedErroredState ) ;
3157 _OutNode->NodeAborted( Name() ) ;
3159 cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
3163 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
3164 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
3165 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
3166 GraphExecutor::ReStartedState ) ;
3168 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
3169 GetChangeNodeInPort( i )->PortState( SUPERV::ReadyState ) ;
3171 SendEvent( ExecuteEvent ) ;
3172 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
3176 int GraphExecutor::InNode::SuspendedErrored_ReStartAction() {
3177 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
3178 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
3179 GraphExecutor::ReStartedState ) ;
3181 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
3182 GetChangeNodeInPort( i )->PortState( SUPERV::ReadyState ) ;
3184 SendEvent( ExecuteEvent ) ;
3185 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
3189 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAndSuspendAction() {
3190 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
3192 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
3193 GraphExecutor::ReStartedState ) ;
3194 State( GraphExecutor::DataWaitingState ) ;
3196 cdebug << "InNode::Suspend() Node " << Name() << endl ;
3199 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
3200 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
3204 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
3209 int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
3210 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
3212 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
3213 GraphExecutor::ReStartedState ) ;
3214 State( GraphExecutor::DataWaitingState ) ;
3216 cdebug << "InNode::Suspend() Node " << Name() << endl ;
3219 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
3220 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
3224 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
3229 #define InParametersSetTrace 1
3230 void GraphExecutor::InNode::InParametersSet( bool & Err ,
3232 ServicesAnyData * InParametersList ) {
3234 #if InParametersSetTrace
3235 cdebug << pthread_self() << "/" << ThreadNo() << " InParametersSet " << Name() << endl ;
3237 for ( i = 0 ; i < nInParams ; i++ ) {
3238 ServicesAnyData D = InParametersList[i];
3239 GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
3240 GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
3241 if ( anInPort->IsGate() && theOutPort == NULL ) {
3242 #if InParametersSetTrace
3243 cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
3244 << anInPort->GetServicesParameter().Parametertype
3245 << " is inactive. " << anInPort->Kind() << endl ;
3248 else if ( anInPort->PortState() == SUPERV::ReadyState ) {
3249 if ( anInPort->IsGate() ) {
3250 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
3251 CORBA::Any anAny = CORBA::Any() ;
3252 //JR 21.02.2005 Debug Memory leak : *anAny <<= (CORBA::Long ) 0 ;
3253 anAny <<= (CORBA::Long ) 0 ;
3254 theOutPort->SetValue( anAny ) ;
3257 if ( !anInPort->IsDataStream()
3259 !anInPort->IsDataConnected() ) {
3260 anInPort->PortState( SUPERV::WaitingState ) ;
3262 //JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
3263 // D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
3264 D.Name = anInPort->PortName() ;
3265 //JR 30.03.2005 const CORBA::Any * AnyPtr = theOutPort->Value() ;
3266 const CORBA::Any AnyRef = theOutPort->Value() ;
3267 #if InParametersSetTrace
3268 cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() << " "
3269 << anInPort->PortState() << " " << D.Name << " "
3270 << anInPort->GetServicesParameter().Parametertype << endl ;
3272 //JR 30.03.2005 D.Value = * AnyPtr ; // CORBA::Any
3273 D.Value = AnyRef ; // CORBA::Any
3274 //JR 18.02.2005 Debug Memory leak : string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
3275 // const char * Type = _Type.c_str() ;
3276 const char * Type = anInPort->GetServicesParameter().Parametertype ;
3277 switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
3278 case CORBA::tk_string:
3281 #if InParametersSetTrace
3282 cdebug << t << " (string)" ;
3284 if ( !strcmp( Type , "string" ) ) {
3286 else if ( !strcmp( Type , "boolean" ) ) {
3289 sscanf( t , "%ld" , &d ) ;
3291 D.Value <<= (CORBA::Any::from_boolean ) b ;
3292 // theOutPort->Value( D.Value ) ;
3294 else if ( !strcmp( Type , "char" ) ) {
3297 sscanf( t , "%ld" , &d ) ;
3299 D.Value <<= (CORBA::Any::from_char ) c ;
3300 #if InParametersSetTrace
3301 cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
3303 // theOutPort->Value( D.Value ) ;
3305 else if ( !strcmp( Type , "short" ) ) {
3308 sscanf( t , "%ld" , &d ) ;
3311 #if InParametersSetTrace
3312 cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
3314 // theOutPort->Value( D.Value ) ;
3316 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3318 sscanf( t , "%ld" , &ll ) ;
3319 CORBA::Long l = ll ;
3321 #if InParametersSetTrace
3322 cdebug << "string '" << t << " --> CORBA::Long " << l ;
3324 // theOutPort->Value( D.Value ) ;
3326 else if ( !strcmp( Type , "float" ) ) {
3328 sscanf( t , "%lf" , &d ) ;
3330 #ifdef REDHAT // mkr : debug for PAL12255
3333 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3334 D.Value <<= (CORBA::Float) f ;
3336 #if InParametersSetTrace
3337 cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
3338 << setw(25) << setprecision(18) << f ;
3340 // theOutPort->Value( D.Value ) ;
3342 else if ( !strcmp( Type , "double" ) ) {
3344 sscanf( t , "%lf" , &d ) ;
3345 #ifdef REDHAT // mkr : debug for PAL12255
3348 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3349 D.Value <<= (CORBA::Double) d ;
3351 #if InParametersSetTrace
3352 cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
3354 // theOutPort->Value( D.Value ) ;
3356 // else if ( !strcmp( Type , "objref" ) ) {
3358 CORBA::Object_ptr ObjRef ;
3360 ObjRef = StringToObject( t ) ;
3361 D.Value <<= ObjRef ;
3364 D.Value <<= CORBA::Object::_nil() ;
3366 // theOutPort->Value( D.Value ) ;
3369 // cdebug << " (other ERROR)" << endl ;
3371 #if InParametersSetTrace
3372 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3375 case CORBA::tk_long:
3376 #if InParametersSetTrace
3377 cdebug << ThreadNo() << " " << Name() << " ArgIn" << i << " " << D.Name << " "
3378 << anInPort->GetServicesParameter().Parametertype << " " << anInPort->Kind()
3380 theOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
3385 #if InParametersSetTrace
3386 cdebug << l << " (CORBA::Long)" << endl ;
3388 if ( !strcmp( Type , "string" ) ) {
3390 sprintf( t , "%ld" , (long)l ) ;
3392 // theOutPort->Value( D.Value ) ;
3394 else if ( !strcmp( Type , "boolean" ) ) {
3397 D.Value <<= (CORBA::Any::from_boolean ) b ;
3398 // theOutPort->Value( D.Value ) ;
3400 else if ( !strcmp( Type , "char" ) ) {
3402 c = (unsigned char ) l ;
3403 D.Value <<= (CORBA::Any::from_char ) c ;
3404 // theOutPort->Value( D.Value ) ;
3406 else if ( !strcmp( Type , "short" ) ) {
3410 // theOutPort->Value( D.Value ) ;
3412 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3414 else if ( !strcmp( Type , "float" ) ) {
3417 #ifdef REDHAT // mkr : debug for PAL12255
3420 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3421 D.Value <<= (CORBA::Float) f ;
3423 // theOutPort->Value( D.Value ) ;
3425 else if ( !strcmp( Type , "double" ) ) {
3428 #ifdef REDHAT // mkr : debug for PAL12255
3431 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3432 D.Value <<= (CORBA::Double) d ;
3434 // theOutPort->Value( D.Value ) ;
3436 // else if ( !strcmp( Type , "objref" ) ) {
3438 D.Value <<= CORBA::Object::_nil() ;
3439 // theOutPort->Value( D.Value ) ;
3442 // cdebug << " (other ERROR)" << endl ;
3444 #if InParametersSetTrace
3445 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3448 case CORBA::tk_double:
3451 #if InParametersSetTrace
3452 cdebug << d << " (double)" << endl ;
3454 if ( !strcmp( Type , "string" ) ) {
3456 sprintf( t , "%lf" , d ) ;
3458 // theOutPort->Value( D.Value ) ;
3460 else if ( !strcmp( Type , "boolean" ) ) {
3463 D.Value <<= (CORBA::Any::from_boolean ) b ;
3464 // theOutPort->Value( D.Value ) ;
3466 else if ( !strcmp( Type , "char" ) ) {
3468 c = (unsigned char ) d ;
3469 D.Value <<= (CORBA::Any::from_char ) c ;
3470 // theOutPort->Value( D.Value ) ;
3472 else if ( !strcmp( Type , "short" ) ) {
3476 // theOutPort->Value( D.Value ) ;
3478 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3480 l = (CORBA::Long ) d ;
3482 // theOutPort->Value( D.Value ) ;
3484 else if ( !strcmp( Type , "float" ) ) {
3487 #ifdef REDHAT // mkr : debug for PAL12255
3490 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3491 D.Value <<= (CORBA::Float) f ;
3493 // theOutPort->Value( D.Value ) ;
3495 else if ( !strcmp( Type , "double" ) ) {
3497 // else if ( !strcmp( Type , "objref" ) ) {
3499 D.Value <<= CORBA::Object::_nil() ;
3500 // theOutPort->Value( D.Value ) ;
3503 // cdebug << " (other ERROR)" << endl ;
3505 #if InParametersSetTrace
3506 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3509 case CORBA::tk_objref:
3510 if ( !strcmp( Type , "string" ) ) {
3511 CORBA::Object_ptr ObjRef ;
3514 #if OMNIORB_VERSION >= 4
3515 D.Value >>= (CORBA::Any::to_object ) ObjRef ;
3517 D.Value >>= ObjRef ;
3519 retstr = ObjectToString( ObjRef ) ;
3520 D.Value <<= retstr ;
3521 // theOutPort->Value( D.Value ) ;
3527 cdebug << "ToString( object ) Catched ERROR" << endl ;
3530 else if ( !strcmp( Type , "boolean" ) ) {
3532 D.Value <<= (CORBA::Any::from_boolean ) b ;
3533 // theOutPort->Value( D.Value ) ;
3535 else if ( !strcmp( Type , "char" ) ) {
3536 unsigned char c = 0 ;
3537 D.Value <<= (CORBA::Any::from_char ) c ;
3538 // theOutPort->Value( D.Value ) ;
3540 else if ( !strcmp( Type , "short" ) ) {
3543 // theOutPort->Value( D.Value ) ;
3545 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3548 // theOutPort->Value( D.Value ) ;
3550 else if ( !strcmp( Type , "float" ) ) {
3552 #ifdef REDHAT // mkr : debug for PAL12255
3555 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3556 D.Value <<= (CORBA::Float) f ;
3558 // theOutPort->Value( D.Value ) ;
3560 else if ( !strcmp( Type , "double" ) ) {
3562 #ifdef REDHAT // mkr : debug for PAL12255
3565 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3566 D.Value <<= (CORBA::Double) d ;
3568 // theOutPort->Value( D.Value ) ;
3570 // else if ( !strcmp( Type , "objref" ) ) {
3572 CORBA::Object_ptr obj ;
3575 #if OMNIORB_VERSION >= 4
3576 D.Value >>= (CORBA::Any::to_object ) obj ;
3580 retstr = ObjectToString( obj ) ;
3581 #if InParametersSetTrace
3582 cdebug << retstr << endl ;
3589 cdebug << "ToString( object ) Catched ERROR" << endl ;
3593 // cdebug << " (other ERROR)" << endl ;
3595 #if InParametersSetTrace
3596 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3600 cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
3604 cdebug << ThreadNo() << " In" << i << " : wrong state ERROR State "
3605 << anInPort->PortState() << " NameState "
3606 << Automaton()->StateName( anInPort->PortState() ) << " PortName "
3607 << anInPort->PortName() << " Parametername "
3608 << anInPort->GetServicesParameter().Parametername << endl ;
3611 InParametersList[i] = D ;
3615 void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
3616 ServicesAnyData * OutParametersList ) {
3617 #if InParametersSetTrace
3618 cdebug << pthread_self() << "/" << ThreadNo() << " InOutParametersSet " << Name() << endl ;
3621 for ( i = 0 ; i < nOutParams ; i++ ) {
3622 ServicesAnyData D = OutParametersList[i] ;
3624 //JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
3625 // D.Name = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametername);
3626 D.Name = GetChangeNodeOutPort(i)->PortName() ;
3627 //JR 18.02.2005 Debug Memory leak : string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
3628 const char * Type = GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype ;
3629 #if InParametersSetTrace
3630 bool OutDone = GetChangeNodeOutPort(i)->PortDone() ;
3631 cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " PortDone( " << OutDone << " ) Type : "
3634 if ( !strcmp( Type , "string" ) ) {
3635 // D.Value <<= (char *) NULL ;
3638 else if ( !strcmp( Type , "boolean" ) ) {
3640 D.Value <<= (CORBA::Any::from_boolean ) b ;
3642 else if ( !strcmp( Type , "char" ) ) {
3643 unsigned char c = 0 ;
3644 D.Value <<= (CORBA::Any::from_char ) c ;
3646 else if ( !strcmp( Type , "short" ) ) {
3650 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3651 D.Value <<= (CORBA::Long ) 0 ;
3653 else if ( !strcmp( Type , "float" ) ) {
3655 #ifdef REDHAT // mkr : debug for PAL12255
3658 //JR D.Value.replace(CORBA::TypeCode::PR_float_tc(), (void*)(&f));
3659 D.Value <<= (CORBA::Float) f ;
3662 else if ( !strcmp( Type , "double" ) ) {
3664 #ifdef REDHAT // mkr : debug for PAL12255
3667 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3668 D.Value <<= (CORBA::Double) d ;
3672 D.Value <<= CORBA::Object::_nil() ;
3674 #if InParametersSetTrace
3675 switch (D.Value.type()->kind()) { // { string , long , double , objref }
3676 case CORBA::tk_string:
3679 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
3681 case CORBA::tk_boolean:
3683 D.Value >>= (CORBA::Any::to_boolean ) b;
3684 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
3686 case CORBA::tk_char:
3688 D.Value >>= (CORBA::Any::to_char ) c;
3689 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
3691 case CORBA::tk_short:
3694 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
3696 case CORBA::tk_long:
3699 cdebug << ThreadNo() << " " << l << "(CORBA::Long)" << endl ;
3701 case CORBA::tk_float:
3704 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
3706 case CORBA::tk_double:
3709 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
3711 case CORBA::tk_objref:
3713 CORBA::Object_ptr obj ;
3715 #if OMNIORB_VERSION >= 4
3716 D.Value >>= (CORBA::Any::to_object ) obj ;
3720 retstr = ObjectToString( obj ) ;
3721 cdebug << ThreadNo() << retstr << endl ;
3724 cdebug << "ToString( object ) Catched ERROR" << endl ;
3728 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
3731 OutParametersList[i] = D ;
3735 #define OutParametersSetTrace 1
3736 bool GraphExecutor::InNode::OutParametersSet( bool Err ,
3737 SUPERV::GraphState PortState ,
3739 ServicesAnyData * OutParametersList ) {
3740 bool RetVal = true ;
3742 GraphBase::OutPort * aGateOutPort = NULL ;
3743 bool OrSwitch = false ;
3744 bool DefaultSwitch = false ;
3745 #if OutParametersSetTrace
3746 cdebug_in << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState "
3747 << PortState << endl ;
3749 // cout << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState " << PortState << endl ;
3750 if ( nOutParams && !IsMacroNode() ) {
3751 GraphBase::OutPort * anOutPort ;
3752 for ( i = 0 ; i < nOutParams ; i++ ) {
3753 anOutPort = GetChangeNodeOutPort(i) ;
3755 anOutPort->PortState( PortState ) ;
3756 anOutPort->PortDone( true ) ;
3759 #if OutParametersSetTrace
3760 cdebug << ThreadNo() << "OutParametersSet " << "Out" << i << " " << Name() << " "
3761 << anOutPort->PortName() << " " << anOutPort->Kind() ;
3763 ServicesAnyData D = OutParametersList[i] ;
3764 switch (D.Value.type()->kind()) { // { string , long , double , objref }
3765 case CORBA::tk_string: {
3768 #if OutParametersSetTrace
3769 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
3773 case CORBA::tk_boolean: {
3775 D.Value >>= (CORBA::Any::to_boolean ) b;
3776 CORBA::Long l = (CORBA::Long ) b ;
3778 #if OutParametersSetTrace
3779 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
3783 case CORBA::tk_char: {
3785 D.Value >>= (CORBA::Any::to_char ) c;
3786 CORBA::Long l = (CORBA::Long ) c ;
3788 #if OutParametersSetTrace
3789 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
3793 case CORBA::tk_short: {
3796 CORBA::Long l = (CORBA::Long ) s ;
3798 #if OutParametersSetTrace
3799 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
3803 case CORBA::tk_long: {
3806 #if OutParametersSetTrace
3807 cdebug << ThreadNo() << " " << l << "(CORBA::Long)" << endl ;
3811 case CORBA::tk_float: {
3814 double d = (double ) f ;
3815 #ifdef REDHAT // mkr : debug for PAL12255
3818 //JR D.Value.replace(CORBA::TypeCode::PR_double_tc(), (void*)(&d));
3819 D.Value <<= (CORBA::Double) d ;
3821 #if OutParametersSetTrace
3822 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
3826 case CORBA::tk_double: {
3829 #if OutParametersSetTrace
3830 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
3834 case CORBA::tk_objref: {
3836 CORBA::Object_ptr obj ;
3837 #if OMNIORB_VERSION >= 4
3838 D.Value >>= (CORBA::Any::to_object ) obj ;
3842 #if OutParametersSetTrace
3844 retstr = ObjectToString( obj ) ;
3845 cdebug << ThreadNo() << retstr << endl ;
3849 cdebug << "ToString( object ) Catched ERROR" << endl ;
3855 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
3859 OutParametersList[i] = D ;
3860 if ( !anOutPort->IsDataStream() ) {
3861 if ( anOutPort->IsGate() ) {
3862 aGateOutPort = anOutPort ;
3863 #if OutParametersSetTrace
3864 cdebug << " Gate " ;
3867 OutParametersList[i].Value <<= l;
3868 anOutPort->SetValue( OutParametersList[i].Value );
3870 else if ( anOutPort->IsLoop() ) {
3871 #if OutParametersSetTrace
3872 cdebug << " Loop " ;
3874 anOutPort->SetValue( OutParametersList[i].Value );
3875 // InLoop Port of EndLoopNode is ready :
3876 anOutPort->ChangeInPorts(0)->PortState( SUPERV::ReadyState ) ;
3878 else if ( anOutPort->IsSwitch() ) {
3879 #if OutParametersSetTrace
3880 cdebug << " Switch " ;
3882 anOutPort->SetValue( OutParametersList[i].Value );
3883 if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
3884 //We have a SwitchBranch or the DefaultBranch .
3885 //JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches (SwitchParameters) :
3886 //It controls that there is only one SwitchBranch activated
3887 //If it's final value is false ==> activation of the Default to GOTO to EndSwitchNode
3888 //DefaultSwitch is true if a SwitchPort is linked to the DefaultPort of the EndSwitchNode
3889 if ( OrSwitch && anOutPort->BoolValue() ) {
3890 string anErrorMessage = string( "More than one SwitchBranch should be activated in SwitchNode " ) +
3891 string( Name() ) + string( "( " ) +
3892 string( anOutPort->PortName() ) + string( " )" ) ;
3893 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
3894 cdebug << "Executor::InNodeThreads::OutParameters more than one SwitchBranch is true ERROR"
3898 else if ( anOutPort->BoolValue() ) {
3899 //JR 09.02.2005 Debug : case of a SwitchPort linked to the DefaultPort of the EndSwitchNode :
3900 if ( !strcmp( anOutPort->ChangeInPorts( 0 )->NodeName() , GOTONode()->CoupledNodeName() ) ) {
3901 DefaultSwitch = anOutPort->BoolValue() ;
3904 OrSwitch = OrSwitch | anOutPort->BoolValue() ;
3906 #if OutParametersSetTrace
3907 cdebug << "InNodeThreads::OutParameters OrSwitch " << OrSwitch << "DefaultSwitch "
3908 << DefaultSwitch << endl ;
3914 #if OutParametersSetTrace
3915 cdebug << " Param " ;
3917 anOutPort->SetValue( OutParametersList[i].Value );
3919 anOutPort->PortState( PortState ) ;
3920 anOutPort->PortDone( true ) ;
3922 #if OutParametersSetTrace
3923 cdebug << "OutParametersSet OrSwitch " << OrSwitch << "DefaultSwitch "
3924 << DefaultSwitch << endl ;
3927 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
3928 #if OutParametersSetTrace
3929 cdebug << ThreadNo() << "OutParametersSet " << "Out" << i << " " << Name() << " "
3930 << anOutPort->PortName() << " " << anOutPort->Kind() << " --> "
3931 << anOutPort->ChangeInPorts( j )->NodeName() << "( "
3932 << anOutPort->ChangeInPorts( j )->PortName() << anOutPort->ChangeInPorts( j )->Kind()
3935 bool fromGOTO = false ;
3936 const char * ToNodeName = anOutPort->ChangeInPorts( j )->NodeName() ;
3937 if ( !strcmp( ToNodeName , _OutNode->Name() ) &&
3938 _OutNode->Graph()->GraphMacroLevel() != 0 ) {
3939 //JR NPAL14110 09.02.2007 : That must be done only at the end of SubGraph because we may
3940 // have an output of the SubGraph in a Loop !...
3941 // So that code must be done in CheckAllDone
3943 #if OutParametersSetTrace
3944 cdebug << "OutParametersSet ToNodeName " << _OutNode->Name() << " CoupledNode "
3945 << _OutNode->Graph()->CoupledNodeName() << _OutNode->Graph()->CoupledNode()
3947 cdebug << "OutParametersSet GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
3949 _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor()->OutputOfAny( _OutNode->Graph()->CoupledNodeName() ,
3950 anOutPort->ChangeInPorts( j )->PortName() ,
3951 //JR 30.03.2005 *anOutPort->Value() ) ;
3952 anOutPort->Value() ) ;
3953 #if OutParametersSetTrace
3954 cdebug << "OutParametersSet OutputOfAny( "
3955 << _OutNode->Graph()->CoupledNodeName() << " , "
3956 << anOutPort->ChangeInPorts( j )->PortName() << " , value )" << endl ;
3961 GraphBase::ComputingNode * ToNode = _OutNode->Graph()->GetChangeGraphNode( ToNodeName ) ;
3963 // cout << "OutParametersSet ToNodeName " << ToNodeName << endl ;
3964 // cdebug << "OutParametersSet ToNodeName " << ToNodeName << " " << ToNode->Name() << endl ;
3965 GraphBase::OutPort * aGOTOPort = ToNode->GetChangeNodeInGate()->GetOutPort() ;
3967 fromGOTO = aGOTOPort->IsGOTO() ;
3969 if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
3970 #if OutParametersSetTrace
3971 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
3972 << anOutPort->ChangeInPorts( j )->PortName() << ","
3973 << anOutPort->ChangeInPorts( j )->Kind() << ") CHANGED from "
3974 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
3976 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
3977 << " to " << anOutPort->ChangeInPorts( j )->GetOutPort()->Kind()
3978 << ") : Done " << anOutPort->PortDone() << " State "
3979 << Automaton()->StateName( anOutPort->ChangeInPorts( j )->PortState() ) << endl ;
3981 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
3984 #if OutParametersSetTrace
3985 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
3986 << anOutPort->ChangeInPorts( j )->PortName() << ","
3987 << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
3988 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
3990 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
3991 << " " << anOutPort->ChangeInPorts( j )->GetOutPort()->Kind()
3998 #if OutParametersSetTrace
3999 switch ( anOutPort->Value().type()->kind() ) {
4000 case CORBA::tk_string:
4002 (anOutPort->Value()) >>= t;
4003 cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
4005 case CORBA::tk_boolean:
4007 (anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
4008 cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
4010 case CORBA::tk_char:
4012 (anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
4013 cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
4015 case CORBA::tk_short:
4017 (anOutPort->Value()) >>= s;
4018 cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
4020 case CORBA::tk_long:
4022 (anOutPort->Value()) >>= l;
4023 cdebug << ThreadNo() << " Out" << i << " : " << l << "(CORBA::Long)" << endl ;
4025 case CORBA::tk_float:
4027 (anOutPort->Value()) >>= f;
4028 cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
4030 case CORBA::tk_double:
4032 (anOutPort->Value()) >>= d;
4033 cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
4035 case CORBA::tk_objref:
4036 CORBA::Object_ptr obj ;
4039 //JR 02.08.2005 Debug SEGV anOutPort->Value() >>= obj ;
4041 anAny = anOutPort->Value() ;
4042 #if OMNIORB_VERSION >= 4
4043 anAny >>= (CORBA::Any::to_object ) obj ;
4047 retstr = ObjectToString( obj );
4048 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
4052 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
4053 << "Catched ERROR" << endl ;
4058 cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
4063 } // End of : for ( i = 0 ; i < nOutParams ; i++ ) {
4064 #if OutParametersSetTrace
4065 cdebug << ThreadNo() << "OutParametersSet End of loop with " << nOutParams
4066 << " OutParams. aGateOutPort " << (void *) aGateOutPort << " IsSwitchNode "
4067 << IsSwitchNode() << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch
4072 if ( IsSwitchNode() && aGateOutPort ) {
4073 //JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches :
4074 //It controls that there is only one SwitchBranch activated
4075 //If it's final value is false ==> activation of the Default in order to GOTO to EndSwitchNode
4076 //DefaultSwitch is true if a SwitchPort (SwitchBranch) is linked to the DefaultPort of the EndSwitchNode
4077 if ( !OrSwitch && !DefaultSwitch ) {
4078 if ( aGateOutPort->InPortsSize() && aGateOutPort->ChangeInPorts( 0 ) ) {
4079 //Dynamic activation of the Default OutPort :
4080 #if OutParametersSetTrace
4081 cdebug << ThreadNo() << " " << "OutGate " << Name() << " Open of "
4082 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " WITH DefaultPort"
4086 OutParametersList[0].Value <<= l ;
4087 aGateOutPort->SetValue( OutParametersList[0].Value ) ;
4090 //The Default OutPort is not linked ==> error
4091 string anErrorMessage = string( "DefaultPort of SwitchNode " ) +
4092 string( Name() ) + " is not connected." ;
4093 _OutNode->Graph()->SetMessages( anErrorMessage ) ;
4094 #if OutParametersSetTrace
4095 cdebug << ThreadNo() << " " << "OutGate " << Name() << " "
4096 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NOT CONNECTED ERROR"
4102 //JR 07.04.2005 Debug : reset only if it is not a default switch (SwitchBranch or
4103 // SwitchParameter of SwitchNode connected to the DefaultInPort of
4106 else if ( !DefaultSwitch ) {
4107 #if OutParametersSetTrace
4108 cdebug << ThreadNo() << " " << "OutGate " << Name() << " Close of "
4109 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NO DefaultPort"
4110 << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch << endl ;
4113 OutParametersList[0].Value <<= l ;
4114 aGateOutPort->SetValue( OutParametersList[0].Value ) ;
4117 // The OutPort field of InPorts of EndSwitchNode may be updated from each OutPort of that SwitchNode :
4118 GraphBase::EndOfSwitchNode * anEndSwitchNode = (GraphBase::EndOfSwitchNode * ) CoupledNode() ;
4121 //JR 16.02.2005 Debug : At first Change InPorts of EndSwitchNode that have the same name as an OutPort of
4122 // the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
4123 //STEP A : InPorts of EndSwitchNode that have the same name as an OutPort of the SwitchNode
4124 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
4125 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
4126 GraphBase::InPort * anInPort = NULL ;
4127 anInPort = anEndSwitchNode->GetChangeInPort( anOutPort->PortName() ) ;
4129 #if OutParametersSetTrace
4130 cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
4131 << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) with same name " ;
4132 if ( anInPort->GetOutPort() ) {
4133 cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
4134 << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
4137 cdebug << "NOT linked " ;
4139 cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
4140 << anOutPort->PortName() << " )" << endl ;
4142 anInPort->ChangeOutPort( anOutPort ) ;
4145 //STEP B : InPorts of EndSwitchNode directly connected from an OutPort of the SwitchNode
4146 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
4147 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
4148 GraphBase::InPort * anInPort ;
4150 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
4151 anInPort = anOutPort->ChangeInPorts( j ) ;
4152 //Update the OutPort field in the Inports directly connected of the EndSwitchNode :
4153 if ( !strcmp( anInPort->NodeName() , anEndSwitchNode->Name() ) ) {
4154 #if OutParametersSetTrace
4155 cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
4156 << "( " << anInPort->PortName() << " , " << anInPort->Kind()
4157 << " ) directly connected " ;
4158 if ( anInPort->GetOutPort() ) {
4159 cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
4160 << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
4163 cdebug << "NOT linked " ;
4165 cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
4166 << anOutPort->PortName() << " )" << endl ;
4168 anInPort->ChangeOutPort( anOutPort ) ;
4172 //STEP C : If it is not the DefaultBranch, explore the SwitchBranch and all NOTSwitchBranch[es]
4173 //Change recursively InPorts of EndSwitchNode linked to that Branch (or that SwitchNode)
4175 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
4176 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
4177 if ( aNode != anEndSwitchNode && !aNode->IsGOTONode() &&
4178 !aNode->IsDataFlowNode() && !aNode->IsDataStreamNode() ) {
4179 const GraphBase::InPort * anInGate = aNode->GetNodeInGate() ;
4180 GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aNode->GetInNode() ;
4181 //STEP C1 : SwitchBranch :
4182 if ( anInGate->GetOutPort() ) {
4183 if ( anInGate->GetOutPort()->BoolValue() ) {
4184 #if OutParametersSetTrace
4185 cdebug << "OutParametersSet " << Name() << " SWITCHBranch " << aNode->Name() << endl ;
4188 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
4189 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
4190 anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
4194 //STEP C2 : NOTSwitchBranch :
4196 #if OutParametersSetTrace
4197 cdebug << "OutParametersSet " << Name() << " NOTSWITCHBranch " << aNode->Name() << endl ;
4200 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
4201 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
4202 anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
4211 #if OutParametersSetTrace
4212 cdebug_out << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState "
4213 << PortState << " RetVal " << RetVal << endl ;
4219 void GraphExecutor::InNode::SetOutPortsOfInportsOfEndSwitch( GraphBase::OutPort * anOutPort ,
4220 const char * anEndSwitchNodeName ) {
4221 #if OutParametersSetTrace
4222 cdebug_in << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anOutPort->NodeName() << "( "
4223 << anOutPort->PortName() << " ) with " << anOutPort->InPortsSize() << " links." << endl ;
4225 GraphBase::InPort * anInPort ;
4227 for ( i = 0 ; i < anOutPort->InPortsSize() ; i++ ) {
4228 anInPort = anOutPort->ChangeInPorts( i ) ;
4229 if ( !anInPort->IsDataStream() ) {
4230 //Update the OutPort field in the Inports of the EndSwitchNode :
4231 if ( !strcmp( anInPort->NodeName() , anEndSwitchNodeName ) ) {
4232 #if OutParametersSetTrace
4233 cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
4234 << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " ;
4235 if ( anInPort->GetOutPort() ) {
4236 cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
4237 << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
4240 cdebug << "NOT linked ERROR " ;
4242 cdebug << "CHANGED TO linked from "
4243 << anOutPort->NodeName() << "( "
4244 << anOutPort->PortName() << " )" << endl ;
4246 anInPort->ChangeOutPort( anOutPort ) ;
4249 #if OutParametersSetTrace
4250 cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
4251 << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " << endl ;
4253 GraphBase::ComputingNode * aComputingNode ;
4254 aComputingNode = _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
4255 if ( aComputingNode && !aComputingNode->IsGOTONode() &&
4256 !( IsEndLoopNode() && GOTONode()->CoupledNode() == aComputingNode ) ) {
4257 GraphExecutor::InNode * aNode ;
4258 aNode = (GraphExecutor::InNode * ) aComputingNode->GetInNode() ;
4261 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
4262 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
4263 aNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNodeName ) ;
4270 #if OutParametersSetTrace
4271 cdebug_out << "SetOutPortsOfInportsOfEndSwitch " << Name() << " OutPort " << anOutPort->PortName()