1 // SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowBase_InNodeThreads.cxx
25 // Author : Jean Rahuel, CEA
42 #if defined __GNUC_2__
43 // _CS_gbo_040604 include explicite pour l'utilisation de
44 // std::transform dans UpperCase
45 #include <cctype> // for toupper
46 #include <algorithm> // for transform
53 #include <SALOMEconfig.h>
54 #include CORBA_CLIENT_HEADER(SALOME_Component)
55 #include "SALOME_LifeCycleCORBA.hxx"
57 #include "DataFlowExecutor_DataFlow.hxx"
58 #include "DataFlowEditor_DataFlow.hxx" // GraphEditor package must be built BEFORE
61 static void UpperCase(std::string& rstr)
63 #if defined __GNUC_2__
64 // _CS_gbo_040604 towupper n'existe pas. Utilisation de toupper. Par
65 // ailleurs, include explicite de cctype et algorithm pour toupper
66 // et transform respectivement.
67 std::transform(rstr.begin(), rstr.end(), rstr.begin(),toupper);
69 std::transform(rstr.begin(), rstr.end(), rstr.begin(),towupper);
73 #define SendEventTrace 1
74 int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {
76 _CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
78 cdebug_in << pthread_self() << "/" << ThreadNo() << " SendEvent Graph " << _OutNode->Name()
79 << " Node " << Name() << " Event : " << Automaton()->EventName( anEvent )
80 << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack
81 << " ControlState : " << Automaton()->ControlStateName( ControlState() )
86 _NextState = Automaton()->NextState( _OldState , anEvent ) ;
87 if ( _NextState == _OldState ) {
88 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
89 << " GraphExecutor::InNodeThreads::SendEvent SameStates ERROR _OldState/_NextState "
90 << _OldState << " Event " << Automaton()->EventName( anEvent ) << endl ;
91 _NextAction = GraphExecutor::VoidAction ;
95 _NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
98 cdebug << pthread_self() << "/" << ThreadNo() << "NextState( " << _OldState << " , "
99 << Automaton()->EventName( anEvent ) << " ) --> _NextState = " << _NextState
100 << " NextAction( " << _NextState << " , " << Automaton()->EventName( anEvent )
101 << " ) --> _NextAction = "
102 << Automaton()->ActionName( _NextAction ) << endl ;
105 // State( _NextState ) ;
106 // if ( _OldState == GraphExecutor::SuccessedExecutingState ||
107 // _OldState == GraphExecutor::ErroredExecutingState ) {
112 cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
113 << Name() << endl << " ControlState : "
114 << Automaton()->ControlStateName( ControlState() ) << endl
115 << " OldState : " << Automaton()->StateName( _OldState ) << endl
116 << " Event : " << Automaton()->EventName( anEvent ) << endl
117 << " NextState : " << Automaton()->StateName( _NextState ) << endl
118 << " Action : " << Automaton()->ActionName( _NextAction ) << endl
119 << " CreateNewThread " << CreateNewThread() << endl
120 << " _RewindStack " << _RewindStack << endl ;
123 int sts = executeAction() ;
126 cdebug_out << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
127 << " Event : " << Automaton()->EventName( anEvent )
128 << " State : " << Automaton()->StateName( State() )
136 #define ActionsTrace 1
137 // ReadyAction - RunningAction - DoneAction - SuspendedAction :
138 // for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
139 void GraphExecutor::InNode::ReadyAction() {
140 if ( pthread_mutex_lock( &_MutexWait ) ) {
141 perror("Ready pthread_mutex_lock ") ;
145 cdebug << pthread_self() << "/" << ThreadNo()
146 << "ReadyAction pthread_cond_broadcast _ReadyWait "
149 if ( pthread_cond_broadcast( &_ReadyWait ) ) {
150 perror("Ready pthread_cond_broadcast ") ;
152 if ( pthread_mutex_unlock( &_MutexWait ) ) {
153 perror("Ready pthread_mutex_unlock ") ;
158 void GraphExecutor::InNode::RunningAction() {
159 if ( pthread_mutex_lock( &_MutexWait ) ) {
160 perror("Running pthread_mutex_lock ") ;
164 cdebug << pthread_self() << "/" << ThreadNo()
165 << "RunningAction pthread_cond_broadcast _RunningWait "
168 // That activate the pthread_cond_wait for RunninWait
169 if ( pthread_cond_broadcast( &_RunningWait ) ) {
170 perror("Running pthread_cond_broadcast ") ;
172 if ( pthread_mutex_unlock( &_MutexWait ) ) {
173 perror("Running pthread_mutex_unlock ") ;
178 void GraphExecutor::InNode::DoneAction() {
179 if ( pthread_mutex_lock( &_MutexWait ) ) {
180 perror("Done pthread_mutex_lock ") ;
184 cdebug << pthread_self() << "/" << ThreadNo()
185 << "DoneAction pthread_cond_broadcast _DoneWait "
188 if ( pthread_cond_broadcast( &_DoneWait ) ) {
189 perror("Done pthread_cond_broadcast ") ;
191 if ( pthread_mutex_unlock( &_MutexWait ) ) {
192 perror("Done pthread_mutex_unlock ") ;
197 void GraphExecutor::InNode::SuspendedAction() {
198 if ( pthread_mutex_lock( &_MutexWait ) ) {
199 perror("Suspended pthread_mutex_lock ") ;
203 cdebug << pthread_self() << "/" << ThreadNo()
204 << "SuspendedAction pthread_cond_broadcast _SuspendedWait "
207 if ( pthread_cond_broadcast( &_SuspendedWait ) ) {
208 perror("Suspended pthread_cond_broadcast ") ;
210 if ( pthread_mutex_unlock( &_MutexWait ) ) {
211 perror("Suspended pthread_mutex_unlock ") ;
216 // SuspendAction <--> { ResumeAction - ReStartAction }
217 GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() {
219 if ( pthread_mutex_lock( &_MutexWait ) ) {
220 perror("Suspend pthread_mutex_lock ") ;
223 if ( !_SuspendSync ) {
224 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
225 << " SuspendAction pthread_cond_wait _SuspendWait "
226 << Automaton()->StateName( State() ) << endl ;
227 _SuspendSync = true ;
228 _OutNode->SuspendThread() ;
229 if ( pthread_cond_wait( &_SuspendWait , &_MutexWait ) ) {
230 perror("SuspendAction pthread_cond_wait ") ;
232 _OutNode->ResumeThread() ;
234 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
235 << " SuspendAction pthread_cond_waited"
236 << Automaton()->StateName( State() ) << endl ;
241 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
242 << " NO SuspendAction pthread_cond_wait"
243 << Automaton()->StateName( State() ) << endl ;
246 // SendEvent( _aResumeEvent ) ; ===> Mutex with myself !
247 _SuspendSync = false ;
248 if ( ControlState() == SUPERV::ToSuspendStartState ||
249 ControlState() == SUPERV::ToSuspendState ) {
250 ControlState( SUPERV::VoidState ) ;
252 if ( pthread_mutex_unlock( &_MutexWait ) ) {
253 perror("SuspendAction pthread_mutex_unlock ") ;
257 SendEvent( _aResumeEvent ) ;
258 // if ( ControlState() == SUPERV::ToSuspendStartState ) {
259 // ControlState( SUPERV::VoidState ) ;
262 if ( pthread_mutex_lock( &_MutexWait ) ) {
263 perror("SuspendAction pthread_mutex_lock ") ;
268 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
269 << " SuspendAction pthread_cond_signal _ResumeWait" << endl ;
271 if ( pthread_cond_signal( &_ResumeWait ) ) {
272 perror("SuspendAction pthread_cond_signal _ResumeWait ") ;
275 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
276 << " SuspendAction pthread_cond_signaled _ResumeWait " << endl ;
281 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
282 << " NO SuspendAction pthread_cond_signal _ResumeWait" << endl ;
286 if ( pthread_mutex_unlock( &_MutexWait ) ) {
287 perror("SuspendAction pthread_mutex_unlock ") ;
290 if ( _aReStartNode ) {
291 cdebug << Name() << " " << Automaton()->StateName( State() )
292 << "aReStartNode : " << _aReStartNode->Name() << " "
293 << Automaton()->StateName( _aReStartNode->State() ) << endl ;
294 _aReStartNode->SendEvent( _aResumeEvent ) ;
297 cdebug << "NO aReStartNode"
298 << Automaton()->StateName( State() ) << endl ;
300 return _aReStartNode ;
303 bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent ) {
305 if ( pthread_mutex_lock( &_MutexWait ) ) {
306 perror("ResumeAction pthread_mutex_lock ") ;
309 _aResumeEvent = aResumeEvent ;
310 if ( _SuspendSync ) {
312 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
313 << " ResumeAction pthread_cond_signal" << endl ;
315 if ( pthread_cond_signal( &_SuspendWait ) ) {
316 perror("ResumeAction pthread_cond_signal ") ;
319 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
320 << " ResumeAction pthread_cond_signaled _SuspendWait " << endl ;
326 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
327 << " NO ResumeAction pthread_cond_signal" << endl ;
329 if ( pthread_self() == ThreadNo() ) {
330 RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
333 _SuspendSync = true ;
334 RetVal = true ; // Il faut tout de meme attendre ci-apres ...
337 if ( pthread_mutex_unlock( &_MutexWait ) ) {
338 perror("ResumeAction pthread_mutex_unlock ") ;
343 if ( pthread_mutex_lock( &_MutexWait ) ) {
344 perror("ResumeAction pthread_mutex_lock ") ;
347 if ( !_ResumeSync ) {
349 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
350 << Name() << " ResumeAction pthread_cond_wait _ResumeWait "
351 << Automaton()->StateName( State() ) << endl ;
354 if ( pthread_cond_wait( &_ResumeWait , &_MutexWait ) ) {
355 perror("ResumeAction pthread_cond_wait ") ;
358 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
359 << Name() << " ResumeAction pthread_cond_waited _ResumeWait"
360 << Automaton()->StateName( State() ) << endl ;
366 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
367 << Name() << " NO ResumeAction pthread_cond_wait _ResumeWait"
368 << Automaton()->StateName( State() ) << endl ;
372 _ResumeSync = false ;
373 if ( pthread_mutex_unlock( &_MutexWait ) ) {
374 perror("ResumeAction pthread_mutex_unlock ") ;
379 cdebug << pthread_self() << "/" << ThreadNo()
380 << "GraphExecutor::InNodeThreads::ResumeAction RetVal " << RetVal << endl ;
385 bool GraphExecutor::InNode::ReStartAction( GraphExecutor::InNode * aReStartNode ,
386 GraphExecutor::NodeEvent anEvent ) {
387 GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
388 _aReStartNode = aReStartNode ;
389 _aReStartEvent = anEvent ;
390 cdebug << pthread_self() << "/" << ThreadNo()
391 << " GraphExecutor::InNodeThreads::ReStartAction from "
392 << Name() << " " << Automaton()->StateName( State() ) << " to "
393 << aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
394 << Automaton()->StateName( aReStartNode->State() ) ;
395 if ( oldReStartNode ) {
396 cdebug << " oldReStartNode " << oldReStartNode->Name() << endl ;
401 return ResumeAction( GraphExecutor::ToReStartEvent ) ;
404 void GraphExecutor::InNode::KilledAction() {
405 if ( pthread_mutex_lock( &_MutexWait ) ) {
406 perror("Killed pthread_mutex_lock ") ;
410 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_wait"
413 if ( pthread_cond_wait( &_KillWait , &_MutexWait ) ) {
414 perror("Killed pthread_cond_wait ") ;
416 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_waited"
420 cdebug << "pthread_cond " << Name() << " NO Killed pthread_cond_wait"
424 if ( pthread_mutex_unlock( &_MutexWait ) ) {
425 perror("Killed pthread_mutex_unlock ") ;
430 void GraphExecutor::InNode::KillAction() {
431 if ( pthread_mutex_lock( &_MutexWait ) ) {
432 perror("Kill pthread_mutex_lock ") ;
436 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signal"
438 // if ( pthread_cond_broadcast( &_KillWait ) ) {
439 if ( pthread_cond_signal( &_KillWait ) ) {
440 perror("Kill pthread_cond_broadcast ") ;
442 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signaled"
446 cdebug << "pthread_cond " << Name() << " NO Kill pthread_cond_signal"
450 if ( pthread_mutex_unlock( &_MutexWait ) ) {
451 perror("Kill pthread_mutex_unlock ") ;
456 void GraphExecutor::InNode::StoppedAction() {
457 if ( pthread_mutex_lock( &_MutexWait ) ) {
458 perror("Stopped pthread_mutex_lock ") ;
461 if ( pthread_cond_wait( &_StopWait , &_MutexWait ) ) {
462 perror("Stopped pthread_cond_wait ") ;
464 if ( pthread_mutex_unlock( &_MutexWait ) ) {
465 perror("Stopped pthread_mutex_unlock ") ;
470 void GraphExecutor::InNode::StopAction() {
471 if ( pthread_mutex_lock( &_MutexWait ) ) {
472 perror("Stop pthread_mutex_lock ") ;
475 if ( pthread_cond_broadcast( &_StopWait ) ) {
476 perror("Stop pthread_cond_broadcast ") ;
478 if ( pthread_mutex_unlock( &_MutexWait ) ) {
479 perror("Stop pthread_mutex_unlock ") ;
484 void GraphExecutor::InNode::ThreadStartedAction() {
485 if ( pthread_mutex_lock( &_MutexWait ) ) {
486 perror("ThreadStarted pthread_mutex_lock ") ;
489 if ( !_ThreadStartedSync ) {
491 cdebug << pthread_self() << "/" << ThreadNo()
492 << "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait"
495 _ThreadStartedSync = true ;
496 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
497 perror("ThreadStarted pthread_cond_wait ") ;
500 cdebug << pthread_self() << "/" << ThreadNo()
501 << "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited"
507 cdebug << pthread_self() << "/" << ThreadNo()
508 << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait"
512 _ThreadStartedSync = false ;
513 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
514 perror("ThreadStart pthread_cond_signal ") ;
518 cdebug << pthread_self() << "/" << ThreadNo()
519 << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled"
523 if ( pthread_mutex_unlock( &_MutexWait ) ) {
524 perror("ThreadStarted pthread_mutex_unlock ") ;
529 void GraphExecutor::InNode::ThreadStartAction() {
530 if ( pthread_mutex_lock( &_MutexWait ) ) {
531 perror("ThreadStart pthread_mutex_lock ") ;
534 if ( _ThreadStartedSync ) {
536 cdebug << pthread_self() << "/" << ThreadNo()
537 << "pthread_cond " << Name() << " ThreadStart pthread_cond_signal"
540 _ThreadStartedSync = false ;
541 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
542 perror("ThreadStart pthread_cond_broadcast ") ;
545 cdebug << pthread_self() << "/" << ThreadNo()
546 << "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled"
552 cdebug << pthread_self() << "/" << ThreadNo()
553 << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal"
556 _ThreadStartedSync = true ;
558 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
559 perror("ThreadStarted pthread_cond_wait ") ;
563 cdebug << pthread_self() << "/" << ThreadNo()
564 << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited"
568 if ( pthread_mutex_unlock( &_MutexWait ) ) {
569 perror("ThreadStart pthread_mutex_unlock ") ;
574 int GraphExecutor::InNode::executeAction() {
575 int oldRewindStack = ( _RewindStack > MAXSTACKTHREADSIZE ) ;
576 if ( !CreateNewThread() && oldRewindStack ) {
578 cdebug << pthread_self() << "/" << ThreadNo()
579 << " executeAction start Thread _RewindStack " << _RewindStack << " > "
580 << MAXSTACKTHREADSIZE << " CreateNewThread "
581 << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "("
582 << Name() << ")" << endl;
584 CreateNewThread( true ) ;
585 _OutNode->IncrCreatedThreads() ;
588 if ( CreateNewThread() ) {
589 CreateNewThread( false ) ;
590 //JR 15.04.2005 Debug PAL8624 RetroConception :
591 // if ( ThreadNo() == 0 ) {
594 cdebug << pthread_self() << "/" << ThreadNo()
595 << " executeAction start Thread _RewindStack " << _RewindStack << " "
596 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
600 int pthread_sts = 1 ;
601 // _OutNode->PushEvent( NULL , GraphExecutor::NewThreadEvent ,
602 // GraphExecutor::ExecutingState ) ;
603 while ( (pthread_sts = pthread_create(&T, NULL, run_function, this )) ) {
604 char * msg = "Cannot pthread_create " ;
606 cdebug << ThreadNo() << " " << msg << " --> sleep(5)" << endl ;
607 cdebug << ThreadNo() << " PTHREAD_THREADS_MAX : "
608 << PTHREAD_THREADS_MAX << " pthread_create status : " ;
609 if ( pthread_sts == EAGAIN ) {
610 cdebug << "EAGAIN(" << pthread_sts << ")" << endl ;
611 cdebug << _OutNode->CreatedThreads() << " was created (and exited)" << endl ;
612 cdebug << "It seems to me that with gdb we are limited to 256 threads" << endl ;
615 cdebug << pthread_sts << endl ;
619 pthread_exit( msg ) ;
622 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
623 << " executeAction has created thread " << T << endl ;
625 ThreadStartedAction() ;
627 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
628 << "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
632 //JR 15.04.2005 Debug PAL8624 RetroConception :
636 cdebug << pthread_self() << "/" << ThreadNo()
637 << " executeAction restart Thread _RewindStack " << _RewindStack << " "
638 << Automaton()->StateName( State() ) << " "
639 << Automaton()->ActionName( _NextAction ) << "(" << Name()
640 << ") ReStartAction ==>" << endl;
642 State( GraphExecutor::SuspendedSuccessedState ) ;
643 if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
644 cdebug << pthread_self() << "/" << ThreadNo()
645 << " executeAction STATE & CALLED "
646 << Automaton()->ActionName( _NextAction ) << "(" << Name()
647 << ") ERROR-DEBUG " << endl;
651 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
652 << Automaton()->ActionName( _NextAction ) << "(" << Name()
660 if ( _CurrentEvent == ExecuteEvent ) {
664 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
665 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
668 return ExecuteAction() ;
673 void GraphExecutor::InNode::coutbegin() {
675 cdebug << pthread_self() << "/" << ThreadNo() << " run_function begin"
676 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
679 void GraphExecutor::InNode::coutexit() {
681 cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit _RewindStack " << _RewindStack
682 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
685 void * run_function(void *p) {
686 GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
688 aNode->NewThread( pthread_self() ) ;
689 if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) {
690 perror("pthread_setcanceltype ") ;
693 if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) {
694 perror("pthread_setcancelstate ") ;
697 aNode->ThreadStartAction() ;
698 // cout << "run_function " << aNode->Name() << "->ExecuteAction() Coupled : " << aNode->CoupledNode()
700 aNode->ExecuteAction() ;
701 char * msg = new char[40] ;
702 sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
703 strcat( msg , " thread exit" ) ;
705 aNode->ExitThread() ;
708 pthread_exit( (void * ) smsg.c_str() ) ;
712 int GraphExecutor::InNode::ExecuteAction() {
716 const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
717 const char * statename = Automaton()->StateName( State() ) ;
718 const char * nextstatename = Automaton()->StateName( _NextState ) ;
719 cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name() << " --> ExecuteAction "
720 << nextactionname << " " << statename << " NextState "
721 << nextstatename << endl ;
724 State( _NextState ) ;
725 switch ( _NextAction ) {
726 case GraphExecutor::ErrorAction : {
727 sts = ErrorAction() ;
730 case GraphExecutor::VoidAction : {
734 case GraphExecutor::DataWaiting_SomeDataReadyAction : {
735 sts = DataWaiting_SomeDataReadyAction() ;
738 case GraphExecutor::DataUndef_NotAllDataReadyAction : {
739 sts = DataUndef_NotAllDataReadyAction() ;
742 case GraphExecutor::DataUndef_AllDataReadyAction : {
743 sts = DataUndef_AllDataReadyAction() ;
746 case GraphExecutor::DataReady_SuspendAction : {
747 sts = DataReady_SuspendAction() ;
750 case GraphExecutor::SuspendedReady_ResumeAction : {
751 sts = SuspendedReady_ResumeAction() ;
754 case GraphExecutor::DataReady_KillAction : {
755 sts = DataReady_KillAction() ;
758 case GraphExecutor::DataReady_StopAction : {
759 sts = DataReady_StopAction() ;
762 case GraphExecutor::DataReady_ExecuteAction : {
763 sts = DataReady_ExecuteAction() ;
766 case GraphExecutor::Executing_SuspendAction : {
767 sts = Executing_SuspendAction() ;
770 case GraphExecutor::SuspendedExecuting_ResumeAction : {
771 sts = SuspendedExecuting_ResumeAction() ;
774 case GraphExecutor::Executing_KillAction : {
775 sts = Executing_KillAction() ;
778 case GraphExecutor::Executing_StopAction : {
779 sts = Executing_StopAction() ;
782 case GraphExecutor::Executing_SuccessAction : {
783 sts = Executing_SuccessAction() ;
786 case GraphExecutor::Executing_ErrorAction : {
787 sts = Executing_ErrorAction() ;
790 case GraphExecutor::Successed_SuccessAction : {
791 sts = Successed_SuccessAction() ;
794 case GraphExecutor::Errored_ErrorAction : {
795 sts = Errored_ErrorAction() ;
798 case GraphExecutor::Successed_SuspendAction : {
799 sts = Successed_SuspendAction() ;
802 case GraphExecutor::Errored_SuspendAction : {
803 sts = Errored_SuspendAction() ;
806 case GraphExecutor::SuspendedSuccessed_ResumeAction : {
807 sts = SuspendedSuccessed_ResumeAction() ;
810 case GraphExecutor::SuspendedErrored_ResumeAction : {
811 sts = SuspendedErrored_ResumeAction() ;
814 case GraphExecutor::Successed_KillAction : {
815 sts = Successed_KillAction() ;
818 case GraphExecutor::Errored_KillAction : {
819 sts = Errored_KillAction() ;
822 case GraphExecutor::Successed_StopAction : {
823 sts = Successed_StopAction() ;
826 case GraphExecutor::Errored_StopAction : {
827 sts = Errored_StopAction() ;
830 case GraphExecutor::SuspendedSuccessed_ReStartAction : {
831 sts = SuspendedSuccessed_ReStartAction() ;
834 case GraphExecutor::SuspendedErrored_ReStartAction : {
835 sts = SuspendedErrored_ReStartAction() ;
838 case GraphExecutor::SuspendedSuccessed_ReStartAndSuspendAction : {
839 sts = SuspendedSuccessed_ReStartAndSuspendAction() ;
842 case GraphExecutor::SuspendedErrored_ReStartAndSuspendAction : {
843 sts = SuspendedErrored_ReStartAndSuspendAction() ;
847 cdebug << pthread_self() << "/" << ThreadNo()
848 << " GraphExecutor::InNodeThreads::SendEvent Error Undefined Action : "
849 << _NextAction << endl ;
854 cdebug_out << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
855 << nextactionname << endl ;
860 int GraphExecutor::InNode::ErrorAction() {
861 cdebug << pthread_self() << "/" << ThreadNo() << " Automaton ErrorAction Node "
866 int GraphExecutor::InNode::VoidAction() {
867 cdebug << pthread_self() << "/" << ThreadNo() << " VoidAction " << Name() << endl;
871 #define SomeDataReadyActionTrace 1
872 int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
873 #if SomeDataReadyActionTrace
874 cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name()
875 << " DataWaiting_SomeDataReadyAction from " << DataFromNode() << endl;
880 bool LoopBeginning = false ;
881 bool LoopFinished = false ;
882 bool SwitchFinished = false ;
883 bool SwitchDefault = false ;
884 bool DoAllDataReadyIf = true ;
886 if ( IsLoopNode() ) {
887 GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
888 if ( anOutLoopPort && anOutLoopPort->BoolValue() ) {
889 LoopBeginning = true ; // Beginning of Loop
892 else if ( IsEndLoopNode() ) {
893 GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
894 if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) {
895 LoopFinished = true ; // End of Loop
898 else if ( IsEndSwitchNode() ) {
899 if ( strcmp( GOTONode()->CoupledNode()->Name() , DataFromNode() ) ) {
900 GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default Port
901 //JR 09.02.2005 : SomeDataReady is NOT from the SwitchNode
902 if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
903 //JR 09.02.2005 : the OutPort of the SwitchNode connected to the default port is closed ===>
904 // Here after we consider that that DefaultPort is Ready (even if it's value is false)
905 SwitchFinished = true ; // End of Switch
909 //JR 20.04.2005 : SomeDataReady is FROM the SwitchNode
911 //JR 16.02.2005 Debug : Change InPorts of EndSwitchNode that have the same name as an OutPort of
912 // the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
913 GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default P
914 //JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is activated :
915 if ( anOutGateSwitchPort ) {
916 if ( anOutGateSwitchPort->BoolValue() ) {
917 SwitchDefault = true ;
919 //JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is NOT activated :
920 // a SwitchBranch should be activated
922 DoAllDataReadyIf = false ;
924 #if SomeDataReadyActionTrace
925 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
926 << " activated from CoupledNode " << GOTONode()->CoupledNode()->Name() << " "
927 << anOutGateSwitchPort->NodeName() << "( " << anOutGateSwitchPort->PortName()
928 << " ) to InDefault " ;
930 if ( GraphBase::Base::_prof_debug ) {
931 anOutGateSwitchPort->StringValue( *GraphBase::Base::_fdebug ) ;
940 #if SomeDataReadyActionTrace
941 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
942 << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished
943 << " SwitchDefault " << SwitchDefault << " DoAllDataReadyIf " << DoAllDataReadyIf << endl ;
945 for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
946 GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
947 GraphBase::OutPort * anOutPort ;
948 if ( SwitchDefault && !anInPort->IsDataStream() ) {
949 //Set the field OutPort of that InPort of the EndSwitchNode to the corresponding OutPort
951 anOutPort = CoupledNode()->GetChangeOutPort( anInPort->PortName() ) ;
952 #if SomeDataReadyActionTrace
953 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
954 << anInPort->PortName() << " change of OutPort from "
955 << anInPort->GetOutPort()->NodeName() << "( " << anInPort->GetOutPort()->PortName()
956 << " ) to " << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )"
959 anInPort->ChangeOutPort( anOutPort ) ;
962 anOutPort = anInPort->GetOutPort() ;
964 #if SomeDataReadyActionTrace
965 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
966 << anInPort->PortName() << " " << anInPort->PortState() << " "
967 << anInPort->PortStatus() << " " << anInPort->Kind() ;
969 cdebug << " from OutPort " << anOutPort->NodeName() << "( " << anOutPort->PortName()
973 cdebug << " without OutPort " ;
977 if ( anInPort->IsGate() && anOutPort == NULL ) {
979 anInPort->PortState( SUPERV::ReadyState ) ;
980 #if SomeDataReadyActionTrace
981 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
982 << anInPort->PortName() << " ControlPort inactive." << endl ;
986 // That InPort get its value from an other node : the node of anOutPort linked to that anInPort is
987 // different from the sender of SomeDataReady (DataFromNode)
988 else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
989 if ( anInPort->PortState() == SUPERV::ReadyState ) {
991 #if SomeDataReadyActionTrace
992 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
993 << anInPort->PortName() << " " << anInPort->PortState() << " Was Done from Node "
994 << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
995 << anOutPort->PortState() << " ) PortDone " << anOutPort->PortDone() << " " ;
997 if ( GraphBase::Base::_prof_debug ) {
998 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1004 else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
1005 anInPort->PortState( SUPERV::ReadyState ) ;
1007 #if SomeDataReadyActionTrace
1008 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1009 << anInPort->PortName() << " Was Done from Node "
1010 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1011 << ") LoopBeginning " << LoopBeginning << " " ;
1013 if ( GraphBase::Base::_prof_debug ) {
1014 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1020 else if ( LoopFinished ) {
1021 anInPort->PortState( SUPERV::ReadyState ) ;
1023 #if SomeDataReadyActionTrace
1024 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1025 << anInPort->PortName() << " Was Done from Node "
1026 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1027 << ") LoopFinished " << LoopFinished << " " ;
1029 if ( GraphBase::Base::_prof_debug ) {
1030 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1036 else if ( anInPort->IsGate() && SwitchFinished ) {
1037 anInPort->PortState( SUPERV::ReadyState ) ;
1039 #if SomeDataReadyActionTrace
1040 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1041 << anInPort->PortName() << " Was Done from Node "
1042 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1043 << ") SwitchFinished " << SwitchFinished << " " ;
1045 if ( GraphBase::Base::_prof_debug ) {
1046 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1052 else if ( anInPort->IsGate() &&
1053 _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->IsGOTONode() ) {
1054 // GateOutPort of GOTONodes are always opened
1055 anInPort->PortState( SUPERV::ReadyState ) ;
1057 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
1058 CORBA::Any anAny = CORBA::Any() ;
1059 //JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
1060 anAny <<= (long ) 1 ;
1061 _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->GetChangeNodeOutGate()->SetValue( anAny ) ;
1062 #if SomeDataReadyActionTrace
1063 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1064 << anInPort->PortName() << " Was Done from Node "
1065 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1068 if ( GraphBase::Base::_prof_debug ) {
1069 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1076 #if SomeDataReadyActionTrace
1077 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1078 << " " << Automaton()->StateName( State() ) << " LoopBeginning "
1079 << LoopBeginning << " " << anInPort->PortName() << " DataConnected "
1080 << anInPort->IsDataConnected() << " Was NOT Done from Node "
1081 << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
1082 << anOutPort->PortState() << " , PortDone " << anOutPort->PortDone() << ") "
1088 // That InPort get its value from the sending node (DataFromNode)
1089 else if ( anInPort->IsGate() ) {
1090 //JR 30.03.2005 const CORBA::Any * theValue = anOutPort->Value() ;
1091 const CORBA::Any theValue = anOutPort->Value() ;
1093 //JR 30.03.2005 (*theValue) >>= GateOpened ;
1094 theValue >>= GateOpened ;
1095 if ( GateOpened != 0 ) {
1097 anInPort->PortState( SUPERV::ReadyState ) ;
1098 #if SomeDataReadyActionTrace
1099 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1100 << anInPort->PortName() << " Gate is Opened from Node "
1101 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1104 if ( GraphBase::Base::_prof_debug ) {
1105 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1111 else if ( LoopFinished ) {
1112 anInPort->PortState( SUPERV::ReadyState ) ;
1113 #if SomeDataReadyActionTrace
1114 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1115 << anInPort->PortName() << " GATE IS CLOSED from Node "
1116 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1117 << ") LoopFinished" ;
1119 if ( GraphBase::Base::_prof_debug ) {
1120 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1127 #if SomeDataReadyActionTrace
1128 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
1129 << anInPort->PortName() << " GATE IS CLOSED from Node "
1130 << anOutPort->NodeName() << "( " << anOutPort->PortName()
1133 if ( GraphBase::Base::_prof_debug ) {
1134 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1141 else if ( anOutPort->PortDone() ) {
1142 #if SomeDataReadyActionTrace
1143 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
1144 << anInPort->PortName() << " " << anInPort->PortStatus() << " "
1145 << Automaton()->StateName( anInPort->PortState() ) << " is Done from Node "
1146 << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
1147 << anOutPort->PortStatus() << " --> ReadyState " ;
1149 if ( GraphBase::Base::_prof_debug ) {
1150 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
1156 anInPort->PortState( SUPERV::ReadyState ) ;
1157 // MacroNode : give immediately the value to the corresponding graph
1158 if ( IsMacroNode() ) {
1159 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1160 cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name() << " --> InputOfAny "
1161 << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready ( "
1162 << anInPort->PortName() << " ) ===> InputOfAny" << endl ;
1163 // GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1164 //JR 30.03.2005 aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
1165 aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
1169 #if SomeDataReadyActionTrace
1170 cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( "
1171 << anInPort->PortName() << ") " << anInPort->PortStatus()
1172 << " is NOT Done from Node "
1173 << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
1174 << anOutPort->PortStatus() << " " << anOutPort->PortDone() << endl ;
1179 if ( InReady == GetNodeInPortsSize() && DoAllDataReadyIf ) { // All Flags != 0 :
1180 //JR 15.04.2005 Debug PAL8624 RetroConception :
1181 // res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
1182 #if SomeDataReadyActionTrace
1183 cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << " HasAllDataReady"
1186 HasAllDataReady( true ) ; // ==> Ready to execute
1189 else { // At least one Flag == 0 :
1190 HasAllDataReady( false ) ;
1191 res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
1194 #if SomeDataReadyActionTrace
1195 cdebug_out << pthread_self() << "/" << ThreadNo() << Name()
1196 << " DataWaiting_SomeDataReadyAction " << endl;
1202 #define TraceDataReadyAction 1
1203 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
1204 //JR 15.04.2005 Debug PAL8624 RetroConception :
1205 // CreateNewThreadIf( false ) ;
1206 #if TraceDataReadyAction
1207 cdebug << pthread_self() << " for " << ThreadNo()
1208 << " DataUndef_NotAllDataReadyAction " << Name() << endl;
1213 int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
1214 #if TraceDataReadyAction
1215 cdebug << pthread_self() << "/" << ThreadNo()
1216 << " --> DataUndef_AllDataReadyAction " << Name() << endl ;
1217 // << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
1218 // << IsLockedDataWait() ;
1220 //JR 15.04.2005 Debug PAL8624 RetroConception :
1221 if ( !CreateNewThread() ) {
1222 #if TraceDataReadyAction
1223 cdebug << "Thread " << ThreadNo() << " --> " << pthread_self() << endl ;
1225 ThreadNo( pthread_self() ) ;
1228 _OutNode->IncrCreatedThreads() ;
1230 _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
1231 GraphExecutor::DataReadyState ) ;
1233 SUPERV::ControlState aControl = ControlState() ;
1234 switch ( aControl ) {
1235 case SUPERV::VoidState : {
1236 SendEvent( GraphExecutor::ExecuteEvent ) ;
1239 case SUPERV::ToSuspendState : {
1240 SendEvent( GraphExecutor::SuspendEvent ) ;
1243 case SUPERV::ToSuspendStartState : {
1244 SendEvent( GraphExecutor::SuspendEvent ) ;
1247 case SUPERV::ToSuspendDoneState : {
1248 SendEvent( GraphExecutor::ExecuteEvent ) ;
1251 case SUPERV::ToKillState : {
1252 SendEvent( GraphExecutor::KillEvent ) ;
1255 case SUPERV::ToKillDoneState : {
1256 SendEvent( GraphExecutor::ExecuteEvent ) ;
1259 case SUPERV::ToStopState : {
1260 SendEvent( GraphExecutor::StopEvent ) ;
1264 cdebug << ThreadNo()
1265 << " GraphExecutor::InNodeThreads::DataUndef_AllDataReadyAction Error Undefined Control : "
1266 << aControl << endl ;
1270 #if TraceDataReadyAction
1271 cdebug << pthread_self() << "/" << ThreadNo()
1272 << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
1277 int GraphExecutor::InNode::DataReady_SuspendAction() {
1278 cdebug << pthread_self() << "/" << ThreadNo()
1279 << "DataReady_SuspendAction --> Suspend " << Name()
1280 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
1281 << _OutNode->SuspendedThreads() << endl;
1282 _OutNode->PushEvent( this , GraphExecutor::SuspendedReadyEvent ,
1283 GraphExecutor::SuspendedReadyState ) ;
1284 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1285 cdebug << pthread_self() << "/" << ThreadNo()
1286 << "DataReady_SuspendAction Resumed " << Name() << endl;
1287 if ( aReStartNode ) {
1288 _aReStartNode = NULL ;
1289 aReStartNode->SendEvent( _aReStartEvent ) ;
1292 SendEvent( GraphExecutor::ExecuteEvent ) ;
1297 int GraphExecutor::InNode::SuspendedReady_ResumeAction() {
1298 cdebug << pthread_self() << "/" << ThreadNo() << "SuspendedReady_ResumeAction "
1301 _OutNode->PushEvent( this , GraphExecutor::ResumedReadyEvent ,
1302 GraphExecutor::ResumedReadyState ) ;
1306 int GraphExecutor::InNode::DataReady_KillAction() {
1307 _OutNode->PushEvent( this , GraphExecutor::KilledReadyEvent ,
1308 GraphExecutor::KilledReadyState ) ;
1310 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_KillAction " << Name()
1311 << " will pthread_exit()" << endl;
1315 int GraphExecutor::InNode::DataReady_StopAction() {
1316 _OutNode->PushEvent( this , GraphExecutor::StoppedReadyEvent ,
1317 GraphExecutor::StoppedReadyState ) ;
1319 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_StopAction " << Name()
1320 << " will pthread_exit()" << endl;
1326 #define TraceDataReady_ExecuteAction 1
1327 int GraphExecutor::InNode::DataReady_ExecuteAction() {
1329 #if TraceDataReady_ExecuteAction
1330 cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
1333 _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
1334 GraphExecutor::ExecutingState ) ;
1340 SUPERV::GraphState PortState = SUPERV::ReadyState ;
1341 GraphExecutor::AutomatonState NewState = GraphExecutor::DataUndefState ;
1342 GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
1345 ServicesAnyData * InParametersList ;
1347 ServicesAnyData * OutParametersList ;
1349 nInParams = GetNodeInPortsSize() ;
1350 InParametersList = new ServicesAnyData[nInParams];
1351 InParametersSet( Err , nInParams , InParametersList ) ;
1353 nOutParams = GetNodeOutPortsSize() ;
1354 OutParametersList = new ServicesAnyData[nOutParams];
1355 InOutParametersSet( nOutParams , OutParametersList ) ;
1357 if ( !IsMacroNode() ) {
1359 Engines::Container_var myContainer ;
1360 Engines::Component_var myObjComponent ;
1361 if ( !IsFactoryNode() ) {
1362 #if TraceDataReady_ExecuteAction
1363 cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
1365 if ( IsComputingNode() ) {
1366 ObjInterface( true ) ;
1367 CORBA::Object_ptr obj ;
1368 InParametersList[0].Value >>= obj ;
1369 CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
1370 myObjComponent = Engines::Component::_narrow( objvar ) ;
1375 else if ( CORBA::is_nil( Component() ) ) {
1376 // ostringstream astr ;
1377 // astr << "Graph " << _OutNode->Name() << " Node " << Name()
1378 // << " : load of component " << ComponentName() << " in container "
1380 // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1381 Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() ,
1382 //JR 17.02.2005 Memory Leak my_strdup( ComponentName() ) ,
1384 myContainer , myObjComponent ) ;
1385 ObjInterface( false ) ;
1386 SetContainer( myContainer ) ;
1387 SetComponent( myObjComponent ) ;
1390 myContainer = Container() ;
1391 myObjComponent = Component() ;
1392 #if TraceDataReady_ExecuteAction
1393 cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
1397 myObjComponent->ping() ;
1400 cdebug << "ping() catched" << endl ;
1405 if ( Err || ControlState() == SUPERV::ToKillState ||
1406 ControlState() == SUPERV::ToKillDoneState ||
1407 ControlState() == SUPERV::ToStopState ) {
1408 #if TraceDataReady_ExecuteAction
1409 cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
1410 // MESSAGE(pthread_self() << "Executor::InNode::DataReady_ExecuteAction of " << Name()
1411 // << " ControlState " << Automaton()->ControlStateName( ControlState() )
1412 // << " BEFORE execution ThreadNo " << ThreadNo() ) ;
1417 if ( ControlState() == SUPERV::ToSuspendState ) {
1418 #if TraceDataReady_ExecuteAction
1419 cdebug << ThreadNo() << "ToSuspendState before running." << endl ;
1420 MESSAGE(ThreadNo() << "ToSuspendState before running.") ;
1424 // ostringstream astr ;
1425 // astr << "Graph " << _OutNode->Name() << " Run of Node " << Name() ;
1426 // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1427 #if TraceDataReady_ExecuteAction
1429 cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
1430 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1431 cdebug << " , " << InParametersList[ i ].Name << "[kind"
1432 << InParametersList[ i ].Value.type()->kind() << "]" ;
1434 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1435 cdebug << " , " << OutParametersList[ i ].Name << "[kind"
1436 << OutParametersList[ i ].Value.type()->kind() << "]" ;
1438 if ( IsOneOfInLineNodes() ) {
1439 cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
1440 << InLineNode()->PyRunMethod() << " length "
1441 << (*InLineNode()->PythonFunction()).length() ;
1443 cdebug << ")" << endl ;
1446 if ( IsOneOfInLineNodes() ) {
1447 bool StsPyDynInvoke = true;
1448 _OutNode->PyThreadLock() ;
1451 // if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
1452 bool ItIsaLoop = false ;
1453 bool CopyInOut = false ;
1454 if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
1455 strlen( InLineNode()->PyFuncName() ) ) {
1456 #if TraceDataReady_ExecuteAction
1457 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1458 << InLineNode()->PyFuncName()
1459 << "' IsInLineNode PyDynInvoke" << endl ;
1461 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1462 InLineNode()->PyFuncName() ,
1463 &InParametersList[0] , ServiceInParameter().length() ,
1464 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1465 if ( !StsPyDynInvoke ) {
1466 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1468 else if ( IsLoopNode() ) {
1470 bool CopyOutIn = false ;
1471 // Switch between Init() and Next()
1472 // if InLoop port is true and does not come from EndLoop ==> execute Init
1473 // if InLoop port is false or come from EndLoop ==> execute Next
1474 // GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
1475 // if ( GetNodeInLoop()->GetOutPort()->BoolValue() &&
1477 if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init()
1478 #if TraceDataReady_ExecuteAction
1479 cdebug << ThreadNo() << " !ObjInterface " << Name()
1480 << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
1481 << "' InitLoop " << LoopNode()->PyRunMethod() << endl ;
1483 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1484 InLineNode()->PyFuncName() ,
1485 &InParametersList[1] , ServiceInParameter().length() ,
1486 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1487 if ( !StsPyDynInvoke ) {
1488 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1493 #if TraceDataReady_ExecuteAction
1494 cdebug << ThreadNo() << " !ObjInterface " << Name()
1495 << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ;
1498 #if TraceDataReady_ExecuteAction
1499 cdebug << ThreadNo() << " !ObjInterface " << Name()
1500 << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ;
1504 else if ( LoopNode()->PyNextMethod() &&
1505 strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next()
1506 #if TraceDataReady_ExecuteAction
1507 cdebug << ThreadNo() << " !ObjInterface " << Name()
1508 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
1509 << "' " << LoopNode()->PyNextMethod() << endl ;
1511 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
1512 LoopNode()->PyNextName() ,
1513 &InParametersList[1] , ServiceInParameter().length() ,
1514 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1515 if ( !StsPyDynInvoke ) {
1516 RemovePyDynInvoke( LoopNode()->PyNextName() ) ;
1521 #if TraceDataReady_ExecuteAction
1522 cdebug << ThreadNo() << " !ObjInterface " << Name()
1523 << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ;
1526 if ( StsPyDynInvoke ) {
1528 #if TraceDataReady_ExecuteAction
1529 cdebug << ThreadNo() << " !ObjInterface " << Name()
1530 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
1531 << "' Copy of " << ServiceInParameter().length()
1532 << " OutParameters" << endl ;
1535 // Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next )
1536 for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
1537 InParametersList[i].Value = OutParametersList[i].Value ;
1538 InParametersList[i].Name = OutParametersList[i].Name ;
1539 #if TraceDataReady_ExecuteAction
1540 switch ( InParametersList[i].Value.type()->kind() ) {
1541 case CORBA::tk_string :
1543 InParametersList[i].Value >>= t ;
1544 cdebug << "ArgOut->In" << i << " : "
1545 << InParametersList[i].Name.c_str()
1546 << " Value(string) " << t << endl ;
1548 case CORBA::tk_boolean:
1550 InParametersList[i].Value >>= (CORBA::Any::to_boolean ) b;
1551 cdebug << "ArgOut->In" << i << " : "
1552 << InParametersList[i].Name.c_str()
1553 << " Value(boolean) " << b << endl ;
1555 case CORBA::tk_char:
1557 InParametersList[i].Value >>= (CORBA::Any::to_char ) c;
1558 cdebug << "ArgOut->In" << i << " : "
1559 << InParametersList[i].Name.c_str()
1560 << " Value(char) " << c << endl ;
1562 case CORBA::tk_short:
1564 InParametersList[i].Value >>= s;
1565 cdebug << "ArgOut->In" << i << " : "
1566 << InParametersList[i].Name.c_str()
1567 << " Value(short) " << s << endl ;
1569 case CORBA::tk_long :
1571 InParametersList[i].Value >>= l;
1572 cdebug << "ArgOut->In" << i << " : "
1573 << InParametersList[i].Name.c_str()
1574 << " Value(long) " << l << endl ;
1576 case CORBA::tk_float :
1578 InParametersList[i].Value >>= f;
1579 cdebug << "ArgOut->In" << i << " : "
1580 << InParametersList[i].Name.c_str()
1581 << " Value(float) " << f << endl ;
1583 case CORBA::tk_double :
1585 InParametersList[i].Value >>= d;
1586 cdebug << "ArgOut->In" << i << " : "
1587 << InParametersList[i].Name.c_str()
1588 << " Value(double) " << d << endl ;
1590 case CORBA::tk_objref :
1591 CORBA::Object_ptr obj ;
1594 InParametersList[i].Value >>= obj ;
1595 retstr = ObjectToString( obj );
1596 cdebug << "ArgOut->In" << i << " : "
1597 << InParametersList[i].Name.c_str()
1598 << " Value(object reference) " << retstr << endl ;
1601 cdebug << "ArgOut->In" << i << " : "
1602 << InParametersList[i].Name.c_str()
1603 << " Value(object reference) Catched ERROR" << endl ;
1607 cdebug << "ArgOut->In" << i << " : "
1608 << InParametersList[i].Name.c_str()
1609 << " Value(other) ERROR" << endl ;
1614 if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
1615 #if TraceDataReady_ExecuteAction
1616 cdebug << ThreadNo() << " !ObjInterface " << Name()
1617 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
1618 << "' " << LoopNode()->PyMoreMethod() << endl ;
1620 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
1621 LoopNode()->PyMoreName() ,
1622 &InParametersList[1] , ServiceInParameter().length() ,
1623 &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
1624 if ( !StsPyDynInvoke ) {
1625 RemovePyDynInvoke( LoopNode()->PyMoreName() ) ;
1629 #if TraceDataReady_ExecuteAction
1630 cdebug << ThreadNo() << " !ObjInterface " << Name()
1631 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
1632 << "' No MoreMethod" << endl ;
1639 cdebug << ThreadNo() << " InLineNode " << Name() << " "
1640 << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
1641 << " Python Dynamic Call Error"
1645 else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
1646 strlen( InLineNode()->PyFuncName() ) ) {
1647 #if TraceDataReady_ExecuteAction
1648 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1649 << InLineNode()->PyFuncName()
1650 << "' IsSwitchNode PyDynInvoke" << endl ;
1652 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1653 InLineNode()->PyFuncName() ,
1654 &InParametersList[0] , ServiceInParameter().length() ,
1655 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1656 if ( !StsPyDynInvoke ) {
1657 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1660 // else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
1661 else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
1662 strlen( InLineNode()->PyFuncName() ) ) {
1663 #if TraceDataReady_ExecuteAction
1664 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1665 << InLineNode()->PyFuncName()
1666 << "' IsGOTONode PyDynInvoke" << endl ;
1668 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1669 InLineNode()->PyFuncName() ,
1670 &InParametersList[0] , ServiceInParameter().length() ,
1671 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1672 if ( !StsPyDynInvoke ) {
1673 RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
1676 // else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
1677 else if ( ( IsEndSwitchNode() ) &&
1678 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1679 #if TraceDataReady_ExecuteAction
1680 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1681 << InLineNode()->PyFuncName()
1682 << "' IsSwitchNode PyDynInvoke" << endl ;
1684 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1685 InLineNode()->PyFuncName() ,
1686 &InParametersList[0] , ServiceInParameter().length() ,
1687 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1688 if ( !StsPyDynInvoke ) {
1689 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1692 else if ( ( IsEndLoopNode() ) &&
1693 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1694 #if TraceDataReady_ExecuteAction
1695 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1696 << InLineNode()->PyFuncName()
1697 << "' IsSwitchNode PyDynInvoke" << endl ;
1699 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1700 InLineNode()->PyFuncName() ,
1701 &InParametersList[0] , ServiceInParameter().length() + 1 ,
1702 &OutParametersList[0] , ServiceOutParameter().length() + 1 ) ;
1703 if ( !StsPyDynInvoke ) {
1704 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1708 // else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
1709 if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL ||
1710 strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) {
1711 // This is a void Python Function : without code (No PyFuncName)
1712 #if TraceDataReady_ExecuteAction
1713 cdebug << ThreadNo() << " !ObjInterface " << Name()
1714 << " Copy of " << ServiceInParameter().length()
1715 << " OutParameters" << endl ;
1720 if ( IsLoopNode() || IsEndLoopNode() ) {
1722 argin0 = 1 ; // after DoLoop
1723 if ( IsLoopNode() ) { // More() is void
1724 // OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
1725 #if TraceDataReady_ExecuteAction
1726 cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)"
1729 GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
1730 //JR 30.03.2005 OutParametersList[0].Value = *anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
1731 OutParametersList[0].Value = anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
1734 //PAL8072 ==> PAL8512
1735 //JR 24.03.2005 : Debug : void InLine Python function : check of the number of Input Ports
1736 // equals the number of Output Ports was missing
1737 if ( ServiceInParameter().length() != ServiceOutParameter().length() ) {
1738 StsPyDynInvoke = false ;
1741 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1742 OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
1743 #if TraceDataReady_ExecuteAction
1744 switch ( InParametersList[argin0 + i].Value.type()->kind() ) {
1745 case CORBA::tk_string :
1746 cdebug << "ArgOut->In" << argin0 + i << " : "
1747 << InParametersList[argin0 + i].Name.c_str()
1748 << " Value(string) "
1749 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1751 case CORBA::tk_boolean:
1752 cdebug << "ArgOut->In" << argin0 + i << " : "
1753 << InParametersList[argin0 + i].Name.c_str()
1754 << " Value(boolean) "
1755 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1757 case CORBA::tk_char:
1758 cdebug << "ArgOut->In" << argin0 + i << " : "
1759 << InParametersList[argin0 + i].Name.c_str()
1761 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1763 case CORBA::tk_short:
1764 cdebug << "ArgOut->In" << argin0 + i << " : "
1765 << InParametersList[argin0 + i].Name.c_str()
1767 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1769 case CORBA::tk_long :
1770 cdebug << "ArgOut->In" << argin0 + i << " : "
1771 << InParametersList[argin0 + i].Name.c_str()
1773 << OutParametersList[argout0 + i ].Name.c_str() << endl ;
1775 case CORBA::tk_double :
1776 cdebug << "ArgOut->In" << argin0 + i << " : "
1777 << InParametersList[argin0 + i].Name.c_str()
1778 << " Value(double) "
1779 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1781 case CORBA::tk_objref :
1782 cdebug << "ArgOut->In" << argin0 + i << " : "
1783 << InParametersList[argin0 + i].Name.c_str()
1784 << " Value(object reference) "
1785 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1788 cdebug << "ArgOut->In" << argin0 + i << " : "
1789 << InParametersList[argin0 + i].Name.c_str()
1790 << " Value(other) ERROR "
1791 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1797 if ( !StsPyDynInvoke ) {
1799 cdebug << ThreadNo() << " InLineNode " << Name()
1800 << " Python Dynamic Call Error"
1806 cdebug << ThreadNo() << " InLineNode " << Name()
1807 << " Python Dynamic Call Exception catched ERROR"
1811 _OutNode->PyThreadUnLock() ;
1816 #if TraceDataReady_ExecuteAction
1817 cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ;
1819 DynInvoke( myObjComponent, "Names" ,
1820 _OutNode->Name() , Name() ) ;
1823 cdebug << "DynInvoke Names catched ERROR" << endl ;
1825 // for DataStreamNodes : call of SetProperties ===> environment variables in the component/container
1826 if ( ComputingNode()->HasDataStream() ) {
1828 #if TraceDataReady_ExecuteAction
1829 cdebug << "DynInvoke -> SetProperties " << _OutNode->Name() << " " << Name() << endl ;
1831 Engines::FieldsDict_var dict = new Engines::FieldsDict;
1833 dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
1834 // myContainer->getHostName() ne renvoit pas le nom complet (avec domaine).
1835 // dict[ 0 ].value <<= myContainer->getHostName() ;
1836 char FullyQualifiedDomainName[256]="";
1837 gethostname(FullyQualifiedDomainName,255);
1838 dict[ 0 ].value <<= FullyQualifiedDomainName ;
1839 dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
1840 dict[ 1 ].value <<= "/tmp" ;
1841 dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
1842 stringstream ofst1 ;
1843 ofst1 << ComputingNode()->SubStreamGraph() ;
1844 string cpl = string( "/tmp/" ) + string( _OutNode->Name() ) + string( "_" ) +
1845 ofst1.str() + string( ".cpl" );
1846 dict[ 2 ].value <<= cpl.c_str() ;
1847 dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
1848 string uname = Name();
1850 dict[ 3 ].value <<= uname.c_str() ;
1852 myObjComponent->setProperties( dict ) ;
1855 cdebug << "DynInvoke setProperties catched ERROR" << endl ;
1859 if ( !Err && IsComputingNode() ) {
1860 #if TraceDataReady_ExecuteAction
1861 cdebug << ThreadNo() << " !ObjInterface " << Name()
1862 << " IsComputingNode DynInvoke" << endl ;
1863 cdebug << ServiceInParameter().length()-1 << " input parameters and "
1864 << ServiceOutParameter().length() << " output parameters" << endl ;
1866 IsLoading( false ) ;
1867 DynInvoke( myObjComponent,
1869 &InParametersList[1] , ServiceInParameter().length()-1 ,
1870 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1872 else if ( !Err && IsFactoryNode() ) {
1873 #if TraceDataReady_ExecuteAction
1874 cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
1875 << " IsFactoryNode DynInvoke" << endl ;
1876 cdebug << ServiceInParameter().length() << " input parameters and "
1877 << ServiceOutParameter().length() << " output parameters" << endl ;
1879 IsLoading( false ) ;
1880 DynInvoke( myObjComponent,
1882 &InParametersList[0] , ServiceInParameter().length() ,
1883 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1885 // cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
1886 // << myObjComponent->CpuUsed_impl() << endl ;
1890 cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
1891 << " Node(Component) Dynamic Call Exception catched ERROR"
1893 //Reset of _ThreadId in the Container ...
1895 myObjComponent->Kill_impl() ;
1905 // ostringstream astr ;
1906 // astr << "Graph " << _OutNode->Name() << " Node " << Name() << " is done : "
1907 // << Automaton()->StateName( State() ) ;
1908 // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1912 // if exception or something else - IsLoading( false ) may not NOT has been called
1916 if ( ControlState() == SUPERV::ToKillState ||
1917 ControlState() == SUPERV::ToKillDoneState ||
1918 ControlState() == SUPERV::ToStopState ) {
1919 PortState = SUPERV::ErrorState ;
1920 NewState = GraphExecutor::KilledState ;
1921 NewEvent = GraphExecutor::KillEvent ;
1924 PortState = SUPERV::ErrorState ;
1925 NewState = GraphExecutor::ErroredState ;
1926 NewEvent = GraphExecutor::ErrorEvent ;
1930 PortState = SUPERV::ReadyState ;
1931 NewState = GraphExecutor::DataReadyState ;
1932 NewEvent = GraphExecutor::SuccessEvent ;
1935 if ( !IsMacroNode() ) {
1937 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1939 NewEvent = GraphExecutor::ErrorEvent ;
1941 delete [] InParametersList ;
1942 delete [] OutParametersList ;
1945 if ( !IsMacroNode() ) {
1947 SendEvent( NewEvent ) ;
1950 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1951 #if TraceDataReady_ExecuteAction
1952 cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " "
1953 << aMacroGraph->Name() << " ->DoneWait()"
1954 << " State " << aMacroGraph->State() << endl;
1956 aMacroGraph->DoneWait() ;
1957 #if TraceDataReady_ExecuteAction
1958 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State " << aMacroGraph->State() << endl;
1960 if ( aMacroGraph->State() == SUPERV::DoneState ) {
1961 PortState = SUPERV::ReadyState ;
1962 NewState = GraphExecutor::DataReadyState ;
1963 NewEvent = GraphExecutor::SuccessEvent ;
1967 if ( ControlState() == SUPERV::ToKillState ||
1968 ControlState() == SUPERV::ToKillDoneState ||
1969 ControlState() == SUPERV::ToStopState ) {
1970 PortState = SUPERV::ErrorState ;
1971 NewState = GraphExecutor::KilledState ;
1972 NewEvent = GraphExecutor::KillEvent ;
1975 PortState = SUPERV::ErrorState ;
1976 NewState = GraphExecutor::ErroredState ;
1977 NewEvent = GraphExecutor::ErrorEvent ;
1980 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1982 NewEvent = GraphExecutor::ErrorEvent ;
1984 delete [] InParametersList ;
1985 delete [] OutParametersList ;
1986 SendEvent( NewEvent ) ;
1989 #if TraceDataReady_ExecuteAction
1990 cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
1995 int GraphExecutor::InNode::Executing_SuspendAction() {
1996 _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
1997 GraphExecutor::SuspendedExecutingState ) ;
1998 cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
2002 int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
2003 cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
2004 GraphExecutor::AutomatonState next_state ;
2005 next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
2006 _OutNode->NewThread() ; // Only for Threads count
2007 _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
2009 State( next_state ) ;
2013 int GraphExecutor::InNode::Executing_KillAction() {
2014 cdebug << ThreadNo() << " Executing_KillAction " << Name() << " Thread " << ThreadNo()<< endl;
2016 if ( pthread_self() == ThreadNo() ) {
2017 cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
2019 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
2020 GraphExecutor::KilledExecutingState ) ;
2023 else if ( pthread_cancel( ThreadNo() ) ) {
2024 perror("Executing_KillAction pthread_cancel error") ;
2027 cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
2028 << " pthread_canceled" << endl ;
2030 _OutNode->ExitThread( ThreadNo() ) ;
2031 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
2032 GraphExecutor::KilledExecutingState ) ;
2037 int GraphExecutor::InNode::Executing_StopAction() {
2038 cdebug << ThreadNo() << " Executing_StopAction " << Name() << " Thread " << ThreadNo() << endl;
2040 if ( pthread_cancel( ThreadNo() ) ) {
2041 perror("Executing_KillAction pthread_cancel error") ;
2044 cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
2045 << " pthread_canceled" << endl ;
2047 _OutNode->ExitThread( ThreadNo() ) ;
2048 _OutNode->PushEvent( this , GraphExecutor::StoppedExecutingEvent ,
2049 GraphExecutor::StoppedExecutingState ) ;
2054 int GraphExecutor::InNode::Executing_SuccessAction() {
2055 // cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
2056 _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
2057 GraphExecutor::SuccessedState ) ;
2058 // MESSAGE(pthread_self() << "Executor::InNode::Executing_SuccessAction of " << Name()
2059 // << " ControlState " << Automaton()->ControlStateName( ControlState() )
2060 // << " AFTER execution ThreadNo " << ThreadNo() ) ;
2061 SUPERV::ControlState aControl = ControlState() ;
2062 switch ( aControl ) {
2063 case SUPERV::VoidState : {
2064 SendEvent( SuccessEvent ) ;
2067 case SUPERV::ToSuspendState : {
2068 SendEvent( SuccessEvent ) ;
2071 case SUPERV::ToSuspendDoneState : {
2072 SendEvent( GraphExecutor::SuspendEvent ) ;
2075 case SUPERV::ToKillState : {
2076 SendEvent( GraphExecutor::KillEvent ) ;
2079 case SUPERV::ToKillDoneState : {
2080 SendEvent( GraphExecutor::KillEvent ) ;
2083 case SUPERV::ToStopState : {
2084 SendEvent( GraphExecutor::StopEvent ) ;
2088 cdebug << ThreadNo()
2089 << " GraphExecutor::InNodeThreads::Executing_SuccessAction Error Undefined Control : "
2090 << aControl << endl ;
2094 // cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
2098 int GraphExecutor::InNode::Executing_ErrorAction() {
2099 cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
2100 _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
2101 GraphExecutor::ErroredState ) ;
2103 SUPERV::ControlState aControl = ControlState() ;
2104 switch ( aControl ) {
2105 case SUPERV::VoidState : {
2106 SendEvent( ErrorEvent ) ;
2109 case SUPERV::ToSuspendState : {
2110 SendEvent( ErrorEvent ) ;
2113 case SUPERV::ToSuspendDoneState : {
2114 SendEvent( GraphExecutor::SuspendEvent ) ;
2117 case SUPERV::ToKillState : {
2118 SendEvent( GraphExecutor::KillEvent ) ;
2121 case SUPERV::ToKillDoneState : {
2122 SendEvent( GraphExecutor::KillEvent ) ;
2125 case SUPERV::ToStopState : {
2126 SendEvent( GraphExecutor::StopEvent ) ;
2130 cdebug << ThreadNo()
2131 << " GraphExecutor::InNodeThreads::Executing_ErrorAction Error Undefined Control : "
2132 << aControl << endl ;
2136 cdebug << ThreadNo() << " <-- Executing_ErrorAction " << Name() << endl;
2140 #define SetWaitingStatesTrace 0
2141 // Set SUPERV::WaitingState to all InPorts
2142 void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
2145 bool docdebug = false ;
2146 State( GraphExecutor::DataWaitingState ) ;
2147 #if SetWaitingStatesTrace
2148 cdebug << "SetWaitingStates " << Name() << " " << Automaton()->StateName( State() ) << endl ;
2150 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2151 GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
2152 #if SetWaitingStatesTrace
2153 cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
2154 << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
2157 // JR Debug 07.01.2005 : Close the Gates instead of open !!!
2158 if ( anInPort->IsGate() ) { // Loop : Close the doors
2159 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
2161 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
2162 CORBA::Any anAny = CORBA::Any() ;
2163 // *anAny <<= (long ) 1 ;
2164 //JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 0 ;
2165 anAny <<= (long ) 0 ;
2166 anOutPort->SetValue( anAny ) ;
2167 anInPort->PortState( SUPERV::WaitingState ) ;
2171 else if ( anInPort->PortState() != SUPERV::WaitingState &&
2172 !anInPort->IsDataConnected() ) {
2174 #if SetWaitingStatesTrace
2175 cdebug << ThreadNo()
2176 << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
2180 if ( !anInPort->IsDataStream() ) {
2181 anInPort->PortState( SUPERV::WaitingState ) ;
2184 #if SetWaitingStatesTrace
2185 cdebug << " --> InPort " << Name() << "( " << anInPort->PortName() << " ) "
2186 << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
2189 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
2190 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
2192 //JR 07.03.2005 Debug : Reset of Done flag in OutPorts !... :
2193 if ( !anOutPort->IsDataStream() ) {
2194 anOutPort->PortDone( false ) ;
2195 anOutPort->PortState( SUPERV::WaitingState ) ;
2197 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
2198 if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
2199 !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) &&
2200 !anOutPort->IsDataStream() &&
2201 !anOutPort->ChangeInPorts( j )->IsDataStream() &&
2202 !anOutPort->ChangeInPorts( j )->IsExternConnected() ) {
2203 #if SetWaitingStatesTrace
2204 cdebug << ThreadNo()
2205 << " InNodeThreads::SetWaitingStates OutPort "
2206 << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
2207 << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
2208 << anOutPort->ChangeInPorts( j )->NodeName() << "( "
2209 << anOutPort->ChangeInPorts( j )->PortName() << " "
2210 << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
2212 GraphBase::ComputingNode * aToNode ;
2213 aToNode = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() ) ;
2214 // JR 12.01.2005 Debug : the OutPort linked to the InPort of a EndSwitchNode was changed so final
2215 // values of InPorts of EndSwitchNode may be wrong
2216 // (depending of order of linkednodes)
2217 if ( !aToNode->IsEndSwitchNode() &&
2218 strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
2219 // After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from
2220 // EndLoopNode or GOTONode. But if there is several nested loops we should re-establish.
2221 #if SetWaitingStatesTrace
2222 cdebug << ThreadNo()
2223 << " InNodeThreads::SetWaitingStates Node " << Name() << " "
2224 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
2225 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
2226 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
2227 << anOutPort->PortName() << " )" << endl ;
2229 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2232 //JR 21.04.2005 Debug : the OutPort field of InPorts of EndSwitchNodes must be an OutPort
2233 // of a SwitchBranch or of a NOTSwitchBranch if a link exist
2234 // (if not there is no change)
2235 else if ( !IsSwitchNode() && aToNode->IsEndSwitchNode() &&
2236 strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
2237 #if SetWaitingStatesTrace
2238 cdebug << ThreadNo()
2239 << " InNodeThreads::SetWaitingStates Node " << Name() << " "
2240 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
2241 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
2242 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
2243 << anOutPort->PortName() << " )" << endl ;
2245 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2247 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ;
2248 if ( aNode != EndNode ) {
2249 aNode->SetWaitingStates( EndNode ) ;
2253 #if SetWaitingStatesTrace
2254 cdebug << " --> OutPort " << Name() << "( " << anOutPort->PortName() << " ) "
2255 << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
2260 #define SuccessActionTrace 1
2262 int GraphExecutor::InNode::Successed_SuccessAction() {
2263 #if SuccessActionTrace
2264 cdebug_in << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2269 //JR 15.04.2005 Debug RetroConception :
2270 //The behavior of firstzeroNode and firsttoNode is not reliable and must be removed
2271 //The real problem is :
2272 // 1. send "SomeDataReady" event to linked nodes of the current node
2273 // 2. DO NOT send "AllDataReady" event even if all data are ready in SomeDataReady Action
2274 // but register only that all data are ready :
2275 // MAJOR ENHANCEMENT OF GRAPHEXECUTOR
2276 // 3. activate AllDataReady Action for each node (except the first one ) which have all
2277 // its data ready with a creation of a new thread
2278 // 3. activate AllDataReady Action for the first node which have all its data
2279 // ready in the current thread
2280 //The difficult problem (that I had in the past) was to clearly identify the above behavior ==>
2281 // firstzeroNode, firsttoNode, createnewthreadif, loackdatawait, "would dead lock" etc...
2282 // because if SomeDataReady Action see that all data were ready, it called immediately
2283 // AllDataReady Action ==> bugs difficult to understand and to reproduce
2284 //And the MAJOR DEBUG is (since the first "maquette") : we may have concurrent executions
2285 // of "SomeDataReady" in several threads and there WAS NO MUTEX to protect that
2286 // concurrent actions on the same node
2287 // int linkednodesnumber = LinkedNodesSize() ;
2288 // GraphExecutor::InNode *firstzeroNode = NULL ;
2289 GraphExecutor::InNode *firsttoNode = NULL ;
2290 GraphExecutor::InNode *toNode ;
2293 list<GraphExecutor::InNode *> SomeDataNodes ;
2297 if ( IsMacroNode() ) {
2298 #if SuccessActionTrace
2299 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done"
2305 //JR 09.02.2005 : That complicated part of the code manages LOOPS and GOTO
2306 if ( IsGOTONode() ||
2307 ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
2308 #if SuccessActionTrace
2309 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2310 << " SetWaitingStates " << endl ;
2312 const GraphBase::OutPort * aGateOutPort ;
2313 if ( IsGOTONode() ) {
2314 aGateOutPort = GetNodeOutGate() ;
2317 aGateOutPort = GetNodeOutLoop() ;
2319 if ( aGateOutPort->InPortsSize() != 1 ) {
2320 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction aGateOutPort->InPortsSize "
2321 << aGateOutPort->InPortsSize() << " != 1 ERROR " << Name() << endl ;
2323 GraphExecutor::InNode * aLabelNode = NULL ;
2324 for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
2325 const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
2326 aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
2327 #if SuccessActionTrace
2328 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
2329 << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
2331 aLabelNode->SetWaitingStates( this ) ;
2332 // JR 07.01.2005 Debug : Open the Gate of the coupledNode closed by SetWaitingStates
2333 GraphBase::OutPort * anOutPort = aLabelNode->GetChangeNodeInGate()->GetOutPort() ;
2335 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
2336 CORBA::Any anAny = CORBA::Any() ;
2337 //JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
2338 anAny <<= (long ) 1 ;
2339 anOutPort->SetValue( anAny ) ;
2340 aLabelNode->GetChangeNodeInGate()->PortState( SUPERV::ReadyState ) ;
2343 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
2344 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
2345 if ( anInPort->GetOutPort() ) {
2346 #if SuccessActionTrace
2347 cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
2348 << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
2353 //PAL8176 ==> PAL8516
2354 //JR 24.03.2005 Debug : the number of OutPorts of a GOTONode and of InPorts of its linked
2355 // InLine node must be the same
2356 if ( GetNodeOutPortsSize() != aLabelNode-> GetNodeInPortsSize() ) {
2357 cdebug << pthread_self() << "/" << ThreadNo()
2358 << " Successed_SuccessAction # number of ports " << GetNodeOutPortsSize()
2359 << " != " << aLabelNode-> GetNodeInPortsSize() << endl ;
2360 SendEvent( GraphExecutor::ErrorEvent ) ;
2364 for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
2365 GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
2366 if ( !aBusParamOutPort->IsGate() ) {
2367 GraphBase::InPort * aBusParamChangeInPort = NULL ;
2368 if ( aBusParamOutPort->IsLoop() ) {
2369 // For EndLoop do not copy EndLoop(DoLoop) in Loop(InLoop)
2370 // aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
2373 aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
2375 if ( aBusParamChangeInPort ) {
2376 aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
2377 #if SuccessActionTrace
2378 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
2379 << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
2380 << aBusParamOutPort->PortName() << endl ;
2383 else if ( IsGOTONode() ) {
2384 //PAL8176 ==> PAL8516
2385 //JR 24.03.2005 Debug : the names of OutPorts of a GOTONode and of InPorts of its linked
2386 // InLine node must be the same
2387 cdebug << pthread_self() << "/" << ThreadNo()
2388 << " Successed_SuccessAction # names of ports "
2389 << aBusParamOutPort->PortName() << endl ;
2390 SendEvent( GraphExecutor::ErrorEvent ) ;
2398 //JR 15.04.2005 Debug PAL8624 RetroConception :
2399 // THERE IS ONLY ONE NODE COUPLED TO A GOTONODE OR AN ENDLOOPNODE BUT Mutex/Lock for consistency
2401 const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
2402 if ( aGateInPort ) {
2403 if ( aGateInPort->GetOutPort() ) {
2404 //JR 21.02.2005 Debug Memory leak : aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
2405 //JR 30.03.2005 aGateInPort->GetOutPort()->Value( *aGateOutPort->Value() ) ;
2406 aGateInPort->GetOutPort()->SetValue( aGateOutPort->Value() ) ;
2408 //JR 15.04.2005 Debug PAL8624 RetroConception :
2409 if ( !aLabelNode->SendSomeDataReady( Name() ) ) {
2410 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2411 << Name() << " SendSomeDataReady to " << aLabelNode->Name() << " ERROR"
2415 if ( aLabelNode->HasAllDataReady() ) {
2416 aLabelNode->ThreadNo( pthread_self() ) ;
2417 aLabelNode->CreateNewThread( false ) ;
2418 aLabelNode->RewindStack( RewindStack() ) ;
2419 aLabelNode->HasAllDataReady( false ) ;
2420 res = aLabelNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
2424 cdebug << pthread_self() << "/" << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
2425 << " NO port " << aGateOutPort->PortName() << " in "
2426 << aLabelNode->Name() << endl;
2432 //==================================================
2433 // JR 09.02.2005 : this is not a EndLoop or a GOTO :
2434 //==================================================
2435 else { // Not a EndLoop or a GOTO
2436 #if SuccessActionTrace
2437 cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
2438 << " with " << LinkedNodesSize() << " linked nodes :" ;
2439 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2440 cdebug << " " << LinkedNodes( i )->Name() ;
2444 //JR 15.04.2005 Debug PAL8624 RetroConception :
2445 // If this is a LoopNode and if DoLoopPort == false, we go directly to the EndOfLoopNode and
2446 // we do not activate Nodes within the loop
2447 bool IgnoreForEndLoop = false ;
2448 // If this is a SwitchNode and if DefaultOutPort == true, we do not activate Nodes within Switch
2449 // We activate directly the EnSwitch
2450 // BUT the NotSwitchBranch(es) are NOT activated :
2451 bool IgnoreForDefaultSwitch = false ;
2452 if ( IsLoopNode() ) {
2453 GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
2454 if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
2455 IgnoreForEndLoop = true ;
2458 else if ( IsSwitchNode() ) {
2459 const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
2460 if ( anOutGatePort->BoolValue() && anOutGatePort->InPortsSize() ) { // DefaultPort is activated
2461 // The DefaultOutPort of that SwitchNode is true and is connected
2462 IgnoreForDefaultSwitch = true ;
2466 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2467 //JR 15.04.2005 Debug PAL8624 RetroConception :
2468 // If this is a LoopNode and if DoLoopPort == false, we go directly to the EndOfLoopNode and
2469 // we do not activate Nodes within the loop
2470 // bool IgnoreForEndLoop = false ;
2471 // If this is a SwitchNode and if DefaultOutPort == true, we do not activate Nodes within Switch
2472 // We activate directly the EnSwitch
2473 // BUT the NotSwitchBranch(es) are NOT activated :
2474 // bool IgnoreForDefaultSwitch = false ;
2475 GraphBase::ComputingNode * aComputingNode ;
2476 aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
2477 toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
2478 #if SuccessActionTrace
2479 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction of " << Name()
2480 << " [" << i << "] " << LinkedNodes( i )->Name() << " toNode " << toNode
2481 << " IgnoreForEndLoop " << IgnoreForEndLoop ;
2483 cdebug << " " << toNode->Kind() << endl ;
2486 //JR 15.04.2005 Debug PAL8624 RetroConception :
2488 //JR 18.05.2005 : we must lock because of concurrent SendEvent if NotAllDataReady :
2489 toNode->LockDataReady() ;
2490 if ( IsComputingNode() && toNode->IsInLineNode() ) {
2491 GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
2492 toGateInPort->PortState( SUPERV::ReadyState ) ;
2493 GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
2494 if ( GateOutPort ) {
2495 GateOutPort->PortStatus( DataConnected );
2496 GateOutPort->PortState( SUPERV::ReadyState ) ;
2497 GateOutPort->PortDone( true ) ;
2500 //JR 15.04.2005 Debug PAL8624 RetroConception :
2501 if ( IsLoopNode() ) {
2502 // GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
2503 // if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
2504 // if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
2505 if ( IgnoreForEndLoop && !strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
2506 // IgnoreForEndLoop = true ;
2508 // else { // toNode is the EndLoopNode
2509 GraphBase::InPort * toLoopInPort ;
2510 toLoopInPort = toNode->GetChangeNodeInLoop() ;
2511 if ( toLoopInPort->PortState() != SUPERV::ReadyState ) {
2512 toLoopInPort->PortState( SUPERV::ReadyState ) ;
2516 //JR 15.04.2005 Debug PAL8624 RetroConception :
2517 // else if ( IsSwitchNode() ) {
2518 // const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
2519 // if ( anOutGatePort->BoolValue() && anOutGatePort->InPortsSize() ) { // DefaultPort is activated
2520 // The DefaultOutPort of that SwitchNode is true and is connected
2521 // IgnoreForDefaultSwitch = true ;
2524 else if ( toNode->IsInLineNode() ) {
2526 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
2527 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
2531 bool activatetoNode = true ;
2532 //We have to execute the loop :
2533 if ( !IgnoreForEndLoop ) {
2534 //The loop is not finished :
2535 if ( toNode->IsLoopNode() ) {
2536 //We enter in a new loop :
2537 GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
2538 toLoopInPort->PortState( SUPERV::ReadyState ) ;
2539 GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
2540 LoopOutPort->PortStatus( DataConnected );
2541 LoopOutPort->PortState( SUPERV::ReadyState ) ;
2542 LoopOutPort->PortDone( true ) ;
2543 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
2544 CORBA::Any anAny = CORBA::Any() ; // InitLoop
2545 //JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
2546 anAny <<= (long ) 1 ;
2547 LoopOutPort->SetValue( anAny ) ;
2549 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
2550 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
2554 //The loop is finished :
2555 else if ( IsLoopNode() ) {
2556 if ( toNode->IsEndLoopNode() ) {
2557 //Not the corresponding EndLoopNode :
2558 if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
2559 cdebug << pthread_self() << "/" << ThreadNo()
2560 << " Successed_SuccessAction NO activate EndLoopNode " << toNode->Name()
2562 activatetoNode = false ;
2565 //Not a EndLoopNode :
2567 cdebug << pthread_self() << "/" << ThreadNo()
2568 << " Successed_SuccessAction NO activate node " << toNode->Name() << endl ;
2569 activatetoNode = false ;
2572 // If the DefaultPort of that SwitchNode is connected to the DefaultPort of the EndSwitchNode
2573 // the NotSwitchBranch(es) are NOT activated :
2574 // If the DefaultPort of that SwitchNode is connected to SwitchBranch(es)
2575 // the NotSwitchBranch(es) are NOT activated :
2576 if ( IgnoreForDefaultSwitch ) {
2577 //We have to activate Default to EndSwitchNode
2578 #if SuccessActionTrace
2579 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction search "
2580 << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
2581 << "IgnoreForDefaultSwitch" << IgnoreForDefaultSwitch << endl ;
2583 activatetoNode = false ;
2584 const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
2585 const GraphBase::InPort * anInPort = NULL ;
2587 for ( j = 0 ; j < anOutGatePort->InPortsSize() ; j++ ) {
2588 anInPort = anOutGatePort->InPorts( j ) ;
2589 const GraphBase::ComputingNode * aNode ;
2590 aNode = _OutNode->Graph()->GetGraphNode( anInPort->NodeName() ) ;
2592 #if SuccessActionTrace
2593 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction try "
2594 << aNode << " " << aNode->Name() << " == " << toNode << " " << toNode->Name()
2598 if ( aNode && (const GraphBase::ComputingNode * ) toNode->ComputingNode() == aNode ) {
2599 // toNode is connected to the DefaultPort of that SwitchNode :
2600 cdebug << pthread_self() << "/" << ThreadNo()
2601 << " Successed_SuccessAction activate node " << aNode->Name() << endl ;
2602 activatetoNode = true ;
2606 cdebug << pthread_self() << "/" << ThreadNo()
2607 << " Successed_SuccessAction NO activate node " << aNode->Name() << endl ;
2611 //JR 19.04.2005 Debug : Do not activate the EndSwitchNode if DefaultGate is close.
2612 //JR 20.04.2005 : it is false : an outport of the SwitchNode may be connected to an
2613 // input port of the EndSwitchNode
2614 if ( activatetoNode ) {
2615 #if SuccessActionTrace
2616 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2617 << toNode->Name() << "->SendSomeDataReady( " << Name() << " )" << endl ;
2619 if ( !toNode->SendSomeDataReady( Name() ) ) {
2620 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2621 << Name() << " SendSomeDataReady to " << toNode->Name() << " ERROR"
2626 toNode->UnLockDataReady() ;
2631 //JR 10.02.2005 : Debug at the end of execution of a SwitchNode :
2632 // Here after we may start execution of only one SwitchBranch or of the Default
2633 // But with activation of only one SwitchBranch we may activate several nodes of that SwitchBranch and
2634 // we may activate several nodes of NotSwitchBranch ( a NotSwitchBranch is a Branch of the Switch
2635 // where GatePorts of Nodes are not connected ; that Branches are always executed for each of SwitchBranch
2636 // BUT are not executed when Default is activated).
2637 // So the bug is that all input ports of the corresponding EndSwitchNode must have the status NOTDONE !
2638 // (Only if Default OutPort is closed and Default InPort is closed)
2639 if ( IsSwitchNode() ) {
2640 GraphBase::InLineNode * anEndSwitchNode = GOTONode()->CoupledNode() ;
2641 if ( !GetNodeOutGate()->BoolValue() && anEndSwitchNode->GetNodeInGate()->GetOutPort() &&
2642 !anEndSwitchNode->GetNodeInGate()->GetOutPort()->BoolValue() ) {
2643 #if SuccessActionTrace
2644 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << anEndSwitchNode->Name()
2645 << " reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
2648 for ( i = 0 ; i < anEndSwitchNode->GetNodeInPortsSize() ; i++ ) {
2649 GraphBase::OutPort * anOutPort = anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort() ;
2651 //JR 08.03.2005 Debug : update of state only if not a StreamPort
2652 if ( anOutPort && strcmp( anOutPort->NodeName() , Name() ) &&
2653 !anOutPort->IsDataStream() ) {
2654 #if SuccessActionTrace
2655 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2656 << anEndSwitchNode->Name() << " InPort "
2657 << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOTDONE from "
2658 << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
2660 anEndSwitchNode->GetChangeNodeInPort( i )->PortState( SUPERV::WaitingState ) ;
2661 anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort()->PortDone( false ) ;
2664 #if SuccessActionTrace
2665 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2666 << anEndSwitchNode->Name() << " InPort "
2667 << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOT Changed : directly from "
2668 << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
2674 #if SuccessActionTrace
2675 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2676 << " " << Kind() << " OutGate->Value " << GetNodeOutGate()->BoolValue()
2677 << " NO reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
2682 //JR 15.04.2005 Debug PAL8624 RetroConception :
2683 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2684 GraphBase::ComputingNode * aComputingNode ;
2685 aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
2686 toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
2687 if ( toNode ) { // Only Not DataFlowNode :
2688 toNode->LockDataReady() ;
2689 if ( toNode->HasAllDataReady() ) {
2690 SomeDataNodes.push_back( toNode ) ;
2691 toNode->HasAllDataReady( false ) ;
2692 #if SuccessActionTrace
2693 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
2694 << Name() << " push "
2695 << toNode->Name() << " " << SomeDataNodes.size() << endl ;
2698 toNode->UnLockDataReady() ;
2702 // firsttoNode : node that has the same ThreadNo() as the current node and that have to be activated
2703 // firstzeroNode : node that has a null ThreadNo() and that have to be activated
2704 //JR 15.04.2005 Debug PAL8624 RetroConception :
2705 while ( SomeDataNodes.size() > 1 ) {
2706 GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
2707 SomeDataNodes.pop_front() ;
2708 #if SuccessActionTrace
2709 cdebug << pthread_self() << "/" << ThreadNo()
2710 << " Successed_SuccessAction pop size "
2711 << SomeDataNodes.size() << " " << aNode->Name() << endl ;
2712 cdebug << pthread_self() << "/" << ThreadNo() << " " << aNode->Name()
2713 << " Successed_SuccessAction poped and will start in a new thread" << endl ;
2715 aNode->CreateNewThread( true ) ;
2716 _OutNode->IncrCreatedThreads() ;
2717 //JR 15.04.2005 Debug PAL8624 RetroConception :
2718 res = aNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
2721 if ( SomeDataNodes.size() ) {
2722 firsttoNode = SomeDataNodes.front() ;
2723 SomeDataNodes.pop_front() ;
2726 if ( firsttoNode ) {
2727 #if SuccessActionTrace
2728 cdebug << pthread_self() << "/" << ThreadNo()
2729 << " Successed_SuccessAction start firsttoNode "
2730 << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
2732 // firsttoNode->CreateNewThreadIf( false ) ;
2733 firsttoNode->CreateNewThread( false ) ;
2734 firsttoNode->RewindStack( RewindStack() ) ;
2735 if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
2736 #if SuccessActionTrace
2737 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
2738 << " : " << firsttoNode->Name() << " "
2739 << Automaton()->StateName( firsttoNode->State() )
2740 << " --> DataWaitingState for Thread "
2741 << firsttoNode->ThreadNo() << endl ;
2743 firsttoNode->State( GraphExecutor::DataWaitingState ) ;
2745 firsttoNode->ThreadNo( pthread_self() ) ;
2746 // On continue avec le meme thread
2748 #if SuccessActionTrace
2749 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
2750 << " for firsttoNode " << firsttoNode->Name()
2751 << " " << Automaton()->StateName( firsttoNode->State() ) << endl ;
2753 //JR 15.04.2005 Debug PAL8624 RetroConception :
2754 //No creation of thread and with LockDataReady an other node in an other thread cannot be
2755 // waiting for that lock ( if it was the case we could not find AllDataReady for firsttoNode
2756 res = firsttoNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
2759 #if SuccessActionTrace
2760 cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
2761 << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL" << endl ;
2766 #if SuccessActionTrace
2767 cdebug_out << pthread_self() << "/" << ThreadNo()
2768 << " Successed_SuccessAction " << Name() << endl;
2773 #define SendSomeDataReadyTrace 1
2774 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
2775 bool RetVal = false ;
2776 if ( IsDataFlowNode() ) {
2777 #if SendSomeDataReadyTrace
2778 cdebug_in << ThreadNo() << "InNode::SendSomeDataReady " << FromNodeName
2779 << " send Result to graph " << Name() << endl;
2783 #if SendSomeDataReadyTrace
2784 cdebug_in << pthread_self() << "/" << ThreadNo() << FromNodeName
2785 << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
2786 << Automaton()->StateName( State() ) << endl;
2788 if ( State() == GraphExecutor::SuccessedState ||
2789 State() == GraphExecutor::SuspendedSuccessedState ||
2790 State() == GraphExecutor::SuspendedSuccessedToReStartState ) {
2791 #if SendSomeDataReadyTrace
2792 cdebug << ThreadNo() << " " << FromNodeName
2793 << " : " << Name() << " " << Automaton()->StateName( State() )
2794 << " --> DataWaitingState for Thread "
2795 << ThreadNo() << " " << endl ;
2797 State( GraphExecutor::DataWaitingState ) ;
2799 // We begin that LoopNode if SendSomeDataReady does not come from the corresponding EndLoopNode
2800 if ( IsLoopNode() && strcmp( LoopNode()->CoupledNodeName() , FromNodeName ) ) {
2801 #if SendSomeDataReadyTrace
2802 cdebug << ThreadNo() << "InNode::SendSomeDataReady " << Name() << " Set _InitLoop from "
2803 << FromNodeName << endl ;
2807 #if SendSomeDataReadyTrace
2808 cdebug << "SendEvent( SomeDataReadyEvent )" << endl ;
2810 //JR 15.04.2005 Debug PAL8624 RetroConception :
2811 DataFromNode( FromNodeName ) ;
2812 // RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
2813 RetVal = SendEvent( GraphExecutor::SomeDataReadyEvent );
2814 //JR 15.04.2005 Debug PAL8624 RetroConception :
2816 #if SendSomeDataReadyTrace
2817 cdebug_out << pthread_self() << "/" << ThreadNo() << FromNodeName
2818 << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
2819 << Automaton()->StateName( State() ) << " " << RetVal << endl;
2824 int GraphExecutor::InNode::Errored_ErrorAction() {
2825 cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
2826 << " will pthread_exit" << endl;
2831 int GraphExecutor::InNode::Successed_SuspendAction() {
2832 cdebug << ThreadNo() << " Successed_SuspendAction -->Suspend " << Name()
2833 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
2834 << _OutNode->SuspendedThreads() << endl;
2835 _OutNode->PushEvent( this , GraphExecutor::SuspendedSuccessedEvent ,
2836 GraphExecutor::SuspendedSuccessedState ) ;
2838 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
2839 cdebug << ThreadNo() << " Successed_SuspendAction Resumed " << Name() ;
2840 if ( aReStartNode ) {
2841 _aReStartNode = NULL ;
2842 cdebug << " for " << aReStartNode->Name() << endl;
2843 aReStartNode->SendEvent( _aReStartEvent ) ;
2847 SendEvent( GraphExecutor::ResumeEvent ) ;
2852 int GraphExecutor::InNode::Errored_SuspendAction() {
2853 cdebug << ThreadNo() << " Errored_SuspendAction -->Suspend " << Name()
2854 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
2855 << _OutNode->SuspendedThreads() << endl;
2856 _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
2857 GraphExecutor::SuspendedErroredState ) ;
2859 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
2860 cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
2862 if ( aReStartNode ) {
2863 _aReStartNode = NULL ;
2864 aReStartNode->SendEvent( _aReStartEvent ) ;
2867 SendEvent( GraphExecutor::ResumeEvent ) ;
2872 int GraphExecutor::InNode::SuspendedSuccessed_ResumeAction() {
2873 cdebug << ThreadNo() << " SuspendedSuccessed_ResumeAction " << Name() << endl;
2875 _OutNode->PushEvent( this , GraphExecutor::ResumedSuccessedEvent ,
2876 GraphExecutor::ResumedSuccessedState ) ;
2877 SendEvent( ResumedSuccessedEvent ) ;
2881 int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
2882 cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
2884 _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
2885 GraphExecutor::ResumedErroredState ) ;
2886 SendEvent( ResumedErroredEvent ) ;
2890 int GraphExecutor::InNode::Successed_KillAction() {
2892 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2893 GraphExecutor::KilledSuccessedState ) ;
2894 cdebug << ThreadNo() << " Successed_KillAction " << Name() << endl;
2898 int GraphExecutor::InNode::Errored_KillAction() {
2900 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2901 GraphExecutor::KilledErroredState ) ;
2902 cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
2906 int GraphExecutor::InNode::Successed_StopAction() {
2908 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2909 GraphExecutor::StoppedSuccessedState ) ;
2910 cdebug << ThreadNo() << " Successed_StopAction " << Name() << endl;
2914 int GraphExecutor::InNode::Errored_StopAction() {
2916 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2917 GraphExecutor::StoppedErroredState ) ;
2918 cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
2922 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
2923 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2924 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2925 GraphExecutor::ReStartedState ) ;
2927 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2928 GetChangeNodeInPort( i )->PortState( SUPERV::ReadyState ) ;
2930 SendEvent( ExecuteEvent ) ;
2931 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2935 int GraphExecutor::InNode::SuspendedErrored_ReStartAction() {
2936 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2937 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2938 GraphExecutor::ReStartedState ) ;
2940 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2941 GetChangeNodeInPort( i )->PortState( SUPERV::ReadyState ) ;
2943 SendEvent( ExecuteEvent ) ;
2944 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2948 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAndSuspendAction() {
2949 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2951 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2952 GraphExecutor::ReStartedState ) ;
2953 State( GraphExecutor::DataWaitingState ) ;
2955 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2958 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2959 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2963 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2968 int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
2969 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2971 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2972 GraphExecutor::ReStartedState ) ;
2973 State( GraphExecutor::DataWaitingState ) ;
2975 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2978 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2979 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2983 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2988 #define InParametersSetTrace 1
2989 void GraphExecutor::InNode::InParametersSet( bool & Err ,
2991 ServicesAnyData * InParametersList ) {
2993 #if InParametersSetTrace
2994 cdebug << pthread_self() << "/" << ThreadNo() << " InParametersSet " << Name() << endl ;
2996 for ( i = 0 ; i < nInParams ; i++ ) {
2997 ServicesAnyData D = InParametersList[i];
2998 GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
2999 GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
3000 if ( anInPort->IsGate() && theOutPort == NULL ) {
3001 #if InParametersSetTrace
3002 cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
3003 << anInPort->GetServicesParameter().Parametertype
3004 << " is inactive. " << anInPort->Kind() << endl ;
3007 else if ( anInPort->PortState() == SUPERV::ReadyState ) {
3008 if ( anInPort->IsGate() ) {
3009 //JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
3010 CORBA::Any anAny = CORBA::Any() ;
3011 //JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 0 ;
3012 anAny <<= (long ) 0 ;
3013 theOutPort->SetValue( anAny ) ;
3016 if ( !anInPort->IsDataStream() &&
3017 !anInPort->IsDataConnected() ) {
3018 anInPort->PortState( SUPERV::WaitingState ) ;
3020 //JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
3021 // D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
3022 D.Name = anInPort->PortName() ;
3023 //JR 30.03.2005 const CORBA::Any * AnyPtr = theOutPort->Value() ;
3024 const CORBA::Any AnyRef = theOutPort->Value() ;
3025 #if InParametersSetTrace
3026 cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() << " "
3027 << anInPort->PortState() << " " << D.Name << " "
3028 << anInPort->GetServicesParameter().Parametertype << endl ;
3030 //JR 30.03.2005 D.Value = * AnyPtr ; // CORBA::Any
3031 D.Value = AnyRef ; // CORBA::Any
3032 //JR 18.02.2005 Debug Memory leak : string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
3033 // const char * Type = _Type.c_str() ;
3034 const char * Type = anInPort->GetServicesParameter().Parametertype ;
3035 switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
3036 case CORBA::tk_string:
3039 #if InParametersSetTrace
3040 cdebug << t << " (string)" ;
3042 if ( !strcmp( Type , "string" ) ) {
3044 else if ( !strcmp( Type , "boolean" ) ) {
3047 sscanf( t , "%ld" , &d ) ;
3049 D.Value <<= (CORBA::Any::from_boolean ) b ;
3050 // theOutPort->Value( D.Value ) ;
3052 else if ( !strcmp( Type , "char" ) ) {
3055 sscanf( t , "%ld" , &d ) ;
3057 D.Value <<= (CORBA::Any::from_char ) c ;
3058 #if InParametersSetTrace
3059 cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
3061 // theOutPort->Value( D.Value ) ;
3063 else if ( !strcmp( Type , "short" ) ) {
3066 sscanf( t , "%ld" , &d ) ;
3069 #if InParametersSetTrace
3070 cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
3072 // theOutPort->Value( D.Value ) ;
3074 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3076 sscanf( t , "%ld" , &l ) ;
3078 #if InParametersSetTrace
3079 cdebug << "string '" << t << " --> long " << l ;
3081 // theOutPort->Value( D.Value ) ;
3083 else if ( !strcmp( Type , "float" ) ) {
3085 sscanf( t , "%lf" , &d ) ;
3088 #if InParametersSetTrace
3089 cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
3090 << setw(25) << setprecision(18) << f ;
3092 // theOutPort->Value( D.Value ) ;
3094 else if ( !strcmp( Type , "double" ) ) {
3096 sscanf( t , "%lf" , &d ) ;
3098 #if InParametersSetTrace
3099 cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
3101 // theOutPort->Value( D.Value ) ;
3103 // else if ( !strcmp( Type , "objref" ) ) {
3105 CORBA::Object_ptr ObjRef ;
3107 ObjRef = StringToObject( t ) ;
3108 D.Value <<= ObjRef ;
3111 D.Value <<= CORBA::Object::_nil() ;
3113 // theOutPort->Value( D.Value ) ;
3116 // cdebug << " (other ERROR)" << endl ;
3118 #if InParametersSetTrace
3119 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3122 case CORBA::tk_long:
3123 #if InParametersSetTrace
3124 cdebug << ThreadNo() << " " << Name() << " ArgIn" << i << " " << D.Name << " "
3125 << anInPort->GetServicesParameter().Parametertype << " " << anInPort->Kind()
3127 theOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
3132 #if InParametersSetTrace
3133 cdebug << l << " (long)" << endl ;
3135 if ( !strcmp( Type , "string" ) ) {
3137 sprintf( t , "%ld" , l ) ;
3139 // theOutPort->Value( D.Value ) ;
3141 else if ( !strcmp( Type , "boolean" ) ) {
3144 D.Value <<= (CORBA::Any::from_boolean ) b ;
3145 // theOutPort->Value( D.Value ) ;
3147 else if ( !strcmp( Type , "char" ) ) {
3149 c = (unsigned char ) l ;
3150 D.Value <<= (CORBA::Any::from_char ) c ;
3151 // theOutPort->Value( D.Value ) ;
3153 else if ( !strcmp( Type , "short" ) ) {
3157 // theOutPort->Value( D.Value ) ;
3159 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3161 else if ( !strcmp( Type , "float" ) ) {
3165 // theOutPort->Value( D.Value ) ;
3167 else if ( !strcmp( Type , "double" ) ) {
3171 // theOutPort->Value( D.Value ) ;
3173 // else if ( !strcmp( Type , "objref" ) ) {
3175 D.Value <<= CORBA::Object::_nil() ;
3176 // theOutPort->Value( D.Value ) ;
3179 // cdebug << " (other ERROR)" << endl ;
3181 #if InParametersSetTrace
3182 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3185 case CORBA::tk_double:
3188 #if InParametersSetTrace
3189 cdebug << d << " (double)" << endl ;
3191 if ( !strcmp( Type , "string" ) ) {
3193 sprintf( t , "%lf" , d ) ;
3195 // theOutPort->Value( D.Value ) ;
3197 else if ( !strcmp( Type , "boolean" ) ) {
3200 D.Value <<= (CORBA::Any::from_boolean ) b ;
3201 // theOutPort->Value( D.Value ) ;
3203 else if ( !strcmp( Type , "char" ) ) {
3205 c = (unsigned char ) d ;
3206 D.Value <<= (CORBA::Any::from_char ) c ;
3207 // theOutPort->Value( D.Value ) ;
3209 else if ( !strcmp( Type , "short" ) ) {
3213 // theOutPort->Value( D.Value ) ;
3215 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3219 // theOutPort->Value( D.Value ) ;
3221 else if ( !strcmp( Type , "float" ) ) {
3225 // theOutPort->Value( D.Value ) ;
3227 else if ( !strcmp( Type , "double" ) ) {
3229 // else if ( !strcmp( Type , "objref" ) ) {
3231 D.Value <<= CORBA::Object::_nil() ;
3232 // theOutPort->Value( D.Value ) ;
3235 // cdebug << " (other ERROR)" << endl ;
3237 #if InParametersSetTrace
3238 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3241 case CORBA::tk_objref:
3242 if ( !strcmp( Type , "string" ) ) {
3243 CORBA::Object_ptr ObjRef ;
3246 D.Value >>= ObjRef ;
3247 retstr = ObjectToString( ObjRef ) ;
3248 D.Value <<= retstr ;
3249 // theOutPort->Value( D.Value ) ;
3255 cdebug << "ToString( object ) Catched ERROR" << endl ;
3258 else if ( !strcmp( Type , "boolean" ) ) {
3260 D.Value <<= (CORBA::Any::from_boolean ) b ;
3261 // theOutPort->Value( D.Value ) ;
3263 else if ( !strcmp( Type , "char" ) ) {
3264 unsigned char c = 0 ;
3265 D.Value <<= (CORBA::Any::from_char ) c ;
3266 // theOutPort->Value( D.Value ) ;
3268 else if ( !strcmp( Type , "short" ) ) {
3271 // theOutPort->Value( D.Value ) ;
3273 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3276 // theOutPort->Value( D.Value ) ;
3278 else if ( !strcmp( Type , "float" ) ) {
3281 // theOutPort->Value( D.Value ) ;
3283 else if ( !strcmp( Type , "double" ) ) {
3286 // theOutPort->Value( D.Value ) ;
3288 // else if ( !strcmp( Type , "objref" ) ) {
3290 CORBA::Object_ptr obj ;
3294 retstr = ObjectToString( obj ) ;
3295 #if InParametersSetTrace
3296 cdebug << retstr << endl ;
3303 cdebug << "ToString( object ) Catched ERROR" << endl ;
3307 // cdebug << " (other ERROR)" << endl ;
3309 #if InParametersSetTrace
3310 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
3314 cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
3318 cdebug << ThreadNo() << " In" << i << " : wrong state ERROR State "
3319 << anInPort->PortState() << " NameState "
3320 << Automaton()->StateName( anInPort->PortState() ) << " PortName "
3321 << anInPort->PortName() << " Parametername "
3322 << anInPort->GetServicesParameter().Parametername << endl ;
3325 InParametersList[i] = D ;
3329 void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
3330 ServicesAnyData * OutParametersList ) {
3331 #if InParametersSetTrace
3332 cdebug << pthread_self() << "/" << ThreadNo() << " InOutParametersSet " << Name() << endl ;
3335 for ( i = 0 ; i < nOutParams ; i++ ) {
3336 ServicesAnyData D = OutParametersList[i] ;
3338 //JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
3339 // D.Name = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametername);
3340 D.Name = GetChangeNodeOutPort(i)->PortName() ;
3341 //JR 18.02.2005 Debug Memory leak : string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
3342 const char * Type = GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype ;
3343 #if InParametersSetTrace
3344 bool OutDone = GetChangeNodeOutPort(i)->PortDone() ;
3345 cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " PortDone( " << OutDone << " ) Type : "
3348 if ( !strcmp( Type , "string" ) ) {
3349 D.Value <<= (char *) NULL ;
3351 else if ( !strcmp( Type , "boolean" ) ) {
3353 D.Value <<= (CORBA::Any::from_boolean ) b ;
3355 else if ( !strcmp( Type , "char" ) ) {
3356 unsigned char c = 0 ;
3357 D.Value <<= (CORBA::Any::from_char ) c ;
3359 else if ( !strcmp( Type , "short" ) ) {
3363 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
3364 D.Value <<= (long ) 0 ;
3366 else if ( !strcmp( Type , "float" ) ) {
3370 else if ( !strcmp( Type , "double" ) ) {
3375 D.Value <<= CORBA::Object::_nil() ;
3377 #if InParametersSetTrace
3378 switch (D.Value.type()->kind()) { // { string , long , double , objref }
3379 case CORBA::tk_string:
3382 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
3384 case CORBA::tk_boolean:
3386 D.Value >>= (CORBA::Any::to_boolean ) b;
3387 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
3389 case CORBA::tk_char:
3391 D.Value >>= (CORBA::Any::to_char ) c;
3392 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
3394 case CORBA::tk_short:
3397 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
3399 case CORBA::tk_long:
3402 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
3404 case CORBA::tk_float:
3407 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
3409 case CORBA::tk_double:
3412 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
3414 case CORBA::tk_objref:
3416 CORBA::Object_ptr obj ;
3419 retstr = ObjectToString( obj ) ;
3420 cdebug << ThreadNo() << retstr << endl ;
3423 cdebug << "ToString( object ) Catched ERROR" << endl ;
3427 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
3430 OutParametersList[i] = D ;
3434 #define OutParametersSetTrace 1
3435 bool GraphExecutor::InNode::OutParametersSet( bool Err ,
3436 SUPERV::GraphState PortState ,
3438 ServicesAnyData * OutParametersList ) {
3439 bool RetVal = true ;
3441 GraphBase::OutPort * aGateOutPort = NULL ;
3442 bool OrSwitch = false ;
3443 bool DefaultSwitch = false ;
3444 #if OutParametersSetTrace
3445 cdebug_in << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState "
3446 << PortState << endl ;
3448 // cout << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState " << PortState << endl ;
3449 if ( nOutParams && !IsMacroNode() ) {
3450 GraphBase::OutPort * anOutPort ;
3451 for ( i = 0 ; i < nOutParams ; i++ ) {
3452 anOutPort = GetChangeNodeOutPort(i) ;
3454 anOutPort->PortState( PortState ) ;
3455 anOutPort->PortDone( true ) ;
3458 #if OutParametersSetTrace
3459 cdebug << ThreadNo() << "OutParametersSet " << "Out" << i << " " << Name() << " "
3460 << anOutPort->PortName() << " " << anOutPort->Kind() ;
3462 ServicesAnyData D = OutParametersList[i] ;
3463 switch (D.Value.type()->kind()) { // { string , long , double , objref }
3464 case CORBA::tk_string: {
3467 #if OutParametersSetTrace
3468 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
3472 case CORBA::tk_boolean: {
3474 D.Value >>= (CORBA::Any::to_boolean ) b;
3475 long l = (long ) b ;
3477 #if OutParametersSetTrace
3478 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
3482 case CORBA::tk_char: {
3484 D.Value >>= (CORBA::Any::to_char ) c;
3485 long l = (long ) c ;
3487 #if OutParametersSetTrace
3488 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
3492 case CORBA::tk_short: {
3495 long l = (long ) s ;
3497 #if OutParametersSetTrace
3498 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
3502 case CORBA::tk_long: {
3505 #if OutParametersSetTrace
3506 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
3510 case CORBA::tk_float: {
3513 double d = (double ) f ;
3515 #if OutParametersSetTrace
3516 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
3520 case CORBA::tk_double: {
3523 #if OutParametersSetTrace
3524 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
3528 case CORBA::tk_objref: {
3530 CORBA::Object_ptr obj ;
3532 #if OutParametersSetTrace
3534 retstr = ObjectToString( obj ) ;
3535 cdebug << ThreadNo() << retstr << endl ;
3539 cdebug << "ToString( object ) Catched ERROR" << endl ;
3545 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
3549 OutParametersList[i] = D ;
3550 if ( !anOutPort->IsDataStream() ) {
3551 if ( anOutPort->IsGate() ) {
3552 aGateOutPort = anOutPort ;
3553 #if OutParametersSetTrace
3554 cdebug << " Gate " ;
3557 OutParametersList[i].Value <<= l;
3558 anOutPort->SetValue( OutParametersList[i].Value );
3560 else if ( anOutPort->IsLoop() ) {
3561 #if OutParametersSetTrace
3562 cdebug << " Loop " ;
3564 anOutPort->SetValue( OutParametersList[i].Value );
3565 // InLoop Port of EndLoopNode is ready :
3566 anOutPort->ChangeInPorts(0)->PortState( SUPERV::ReadyState ) ;
3568 else if ( anOutPort->IsSwitch() ) {
3569 #if OutParametersSetTrace
3570 cdebug << " Switch " ;
3572 anOutPort->SetValue( OutParametersList[i].Value );
3573 if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
3574 //JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches :
3575 //It controls that there is only one SwitchBranch activated
3576 //If it's final value is false ==> activation of the Default to GOTO to EndSwitchNode
3577 //DefaultSwitch is true if a SwitchPort is linked to the DefaultPort of the EndSwitchNode
3578 if ( OrSwitch && anOutPort->BoolValue() ) {
3579 cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true ERROR"
3583 else if ( anOutPort->BoolValue() ) {
3584 //JR 09.02.2005 Debug : case of a SwitchPort linked to the DefaultPort of the EndSwitchNode :
3585 if ( !strcmp( anOutPort->ChangeInPorts( 0 )->NodeName() , GOTONode()->CoupledNodeName() ) ) {
3586 DefaultSwitch = anOutPort->BoolValue() ;
3589 OrSwitch = OrSwitch | anOutPort->BoolValue() ;
3591 #if OutParametersSetTrace
3592 cdebug << "InNodeThreads::OutParameters OrSwitch " << OrSwitch << "DefaultSwitch "
3593 << DefaultSwitch << endl ;
3599 #if OutParametersSetTrace
3600 cdebug << " Param " ;
3602 anOutPort->SetValue( OutParametersList[i].Value );
3604 anOutPort->PortState( PortState ) ;
3605 anOutPort->PortDone( true ) ;
3607 #if OutParametersSetTrace
3608 cdebug << "OutParametersSet OrSwitch " << OrSwitch << "DefaultSwitch "
3609 << DefaultSwitch << endl ;
3612 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
3613 #if OutParametersSetTrace
3614 cdebug << ThreadNo() << "OutParametersSet " << "Out" << i << " " << Name() << " "
3615 << anOutPort->PortName() << " " << anOutPort->Kind() << " --> "
3616 << anOutPort->ChangeInPorts( j )->NodeName() << "( "
3617 << anOutPort->ChangeInPorts( j )->PortName() << anOutPort->ChangeInPorts( j )->Kind()
3620 bool fromGOTO = false ;
3621 const char * ToNodeName = anOutPort->ChangeInPorts( j )->NodeName() ;
3622 if ( !strcmp( ToNodeName , _OutNode->Name() ) &&
3623 _OutNode->Graph()->GraphMacroLevel() != 0 ) {
3624 #if OutParametersSetTrace
3625 cdebug << "OutParametersSet ToNodeName " << _OutNode->Name() << " CoupledNode "
3626 << _OutNode->Graph()->CoupledNodeName() << _OutNode->Graph()->CoupledNode()
3628 cdebug << " GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
3630 _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor()->OutputOfAny( _OutNode->Graph()->CoupledNodeName() ,
3631 anOutPort->ChangeInPorts( j )->PortName() ,
3632 //JR 30.03.2005 *anOutPort->Value() ) ;
3633 anOutPort->Value() ) ;
3636 GraphBase::ComputingNode * ToNode = _OutNode->Graph()->GetChangeGraphNode( ToNodeName ) ;
3638 // cout << "OutParametersSet ToNodeName " << ToNodeName << endl ;
3639 // cdebug << "OutParametersSet ToNodeName " << ToNodeName << " " << ToNode->Name() << endl ;
3640 GraphBase::OutPort * aGOTOPort = ToNode->GetChangeNodeInGate()->GetOutPort() ;
3642 fromGOTO = aGOTOPort->IsGOTO() ;
3644 if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
3645 #if OutParametersSetTrace
3646 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
3647 << anOutPort->ChangeInPorts( j )->PortName() << ","
3648 << anOutPort->ChangeInPorts( j )->Kind() << ") CHANGED from "
3649 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
3651 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
3652 << " to " << anOutPort->ChangeInPorts( j )->GetOutPort()->Kind()
3653 << ") : Done " << anOutPort->PortDone() << " State "
3654 << Automaton()->StateName( anOutPort->ChangeInPorts( j )->PortState() ) << endl ;
3656 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
3659 #if OutParametersSetTrace
3660 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
3661 << anOutPort->ChangeInPorts( j )->PortName() << ","
3662 << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
3663 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
3665 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
3666 << " " << anOutPort->ChangeInPorts( j )->GetOutPort()->Kind()
3673 #if OutParametersSetTrace
3674 switch ( anOutPort->Value().type()->kind() ) {
3675 case CORBA::tk_string:
3677 anOutPort->Value() >>= t;
3678 cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
3680 case CORBA::tk_boolean:
3682 anOutPort->Value() >>= (CORBA::Any::to_boolean ) b;
3683 cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
3685 case CORBA::tk_char:
3687 anOutPort->Value() >>= (CORBA::Any::to_char ) c;
3688 cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
3690 case CORBA::tk_short:
3692 anOutPort->Value() >>= s;
3693 cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
3695 case CORBA::tk_long:
3697 anOutPort->Value() >>= l;
3698 cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
3700 case CORBA::tk_float:
3702 anOutPort->Value() >>= f;
3703 cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
3705 case CORBA::tk_double:
3707 anOutPort->Value() >>= d;
3708 cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
3710 case CORBA::tk_objref:
3711 CORBA::Object_ptr obj ;
3714 anOutPort->Value() >>= obj ;
3715 retstr = ObjectToString( obj );
3716 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
3720 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
3721 << "Catched ERROR" << endl ;
3726 cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
3732 if ( aGateOutPort && IsSwitchNode() ) {
3733 //JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches :
3734 //It controls that there is only one SwitchBranch activated
3735 //If it's final value is false ==> activation of the Default to GOTO to EndSwitchNode
3736 //DefaultSwitch is true if a SwitchPort (SwitchBranch) is linked to the DefaultPort of the EndSwitchNode
3737 if ( !OrSwitch && !DefaultSwitch ) {
3738 if ( aGateOutPort->InPortsSize() && aGateOutPort->ChangeInPorts( 0 ) ) {
3739 #if OutParametersSetTrace
3740 cdebug << ThreadNo() << " " << "OutGate " << Name() << " Open of "
3741 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " WITH DefaultPort"
3745 OutParametersList[0].Value <<= l ;
3746 aGateOutPort->SetValue( OutParametersList[0].Value ) ;
3749 #if OutParametersSetTrace
3750 cdebug << ThreadNo() << " " << "OutGate " << Name() << " "
3751 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NOT CONNECTED ERROR"
3757 //JR 07.04.2005 Debug : reset only if it is not a default switch (SwitchBranch or
3758 // SwitchParameter of SwitchNode connected to the InDefaultPort of
3761 else if ( !DefaultSwitch ) {
3762 #if OutParametersSetTrace
3763 cdebug << ThreadNo() << " " << "OutGate " << Name() << " Close of "
3764 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NO DefaultPort"
3765 << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch << endl ;
3768 OutParametersList[0].Value <<= l ;
3769 aGateOutPort->SetValue( OutParametersList[0].Value ) ;
3771 // The OutPort field of InPorts of EndSwitchNode may be updated only in branches :
3772 // for the Default case they should not be changed (if they are changed ==> bug if we activate
3773 // a branch after a use of the Default)
3774 if ( !OrSwitch || DefaultSwitch ) { // DefaultPort or DefaultSwitch
3776 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
3777 GraphBase::InPort * anInPort ;
3778 anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
3780 //JR 16.02.2005 Debug : Change InPorts of EndSwitchNode that have the same name as an OutPort of
3781 // the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
3782 // if ( anInPort && !anInPort->IsGate() ) {
3783 if ( anInPort && anInPort->GetOutPort() ) {
3784 #if OutParametersSetTrace
3785 cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName() << "( "
3786 << anInPort->PortName() << " , " << anInPort->Kind() << " ) linked from "
3787 << anInPort->GetOutPort()->NodeName()
3788 << "( " << anInPort->GetOutPort()->PortName() << " ) CHANGED TO linked from "
3789 << GetChangeNodeOutPort( i )->NodeName() << "( "
3790 << GetChangeNodeOutPort( i )->PortName() << " )" << endl ;
3792 anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
3798 #if OutParametersSetTrace
3799 cdebug_out << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState "
3800 << PortState << " RetVal " << RetVal << endl ;