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);
74 int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {
76 _CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
77 cdebug << pthread_self() << "/" << ThreadNo() << " -->SendEvent Node " << Name()
79 << Automaton()->ControlStateName( ControlState() )
80 << " Event : " << Automaton()->EventName( anEvent )
81 << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack << endl;
84 _NextState = Automaton()->NextState( _OldState , anEvent ) ;
85 if ( _NextState == _OldState ) {
86 cdebug << pthread_self() << "/" << ThreadNo()
87 << " GraphExecutor::InNodeThreads::SendEvent SameStates "
88 << _OldState << endl ;
89 _NextAction = GraphExecutor::VoidAction ;
92 _NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
95 // State( _NextState ) ;
96 // if ( _OldState == GraphExecutor::SuccessedExecutingState ||
97 // _OldState == GraphExecutor::ErroredExecutingState ) {
101 cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
102 << Name() << endl << " ControlState : "
103 << Automaton()->ControlStateName( ControlState() ) << endl
104 << " OldState : " << Automaton()->StateName( _OldState ) << endl
105 << " Event : " << Automaton()->EventName( anEvent ) << endl
106 << " NextState : " << Automaton()->StateName( _NextState ) << endl
107 << " Action : " << Automaton()->ActionName( _NextAction ) << endl
108 << " CreateNewThread " << CreateNewThread() << endl
109 << " _RewindStack " << _RewindStack << endl ;
112 //cout << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
113 << 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 ;
122 int sts = executeAction() ;
124 cdebug << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
125 << " Event : " << Automaton()->EventName( anEvent )
126 << " State : " << Automaton()->StateName( State() )
133 // ReadyAction - RunningAction - DoneAction - SuspendedAction :
134 // for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
135 void GraphExecutor::InNode::ReadyAction() {
136 if ( pthread_mutex_lock( &_MutexWait ) ) {
137 perror("Ready pthread_mutex_lock ") ;
140 cdebug << pthread_self() << "/" << ThreadNo()
141 << "ReadyAction pthread_cond_broadcast _ReadyWait "
143 if ( pthread_cond_broadcast( &_ReadyWait ) ) {
144 perror("Ready pthread_cond_broadcast ") ;
146 if ( pthread_mutex_unlock( &_MutexWait ) ) {
147 perror("Ready pthread_mutex_unlock ") ;
152 void GraphExecutor::InNode::RunningAction() {
153 if ( pthread_mutex_lock( &_MutexWait ) ) {
154 perror("Running pthread_mutex_lock ") ;
157 cdebug << pthread_self() << "/" << ThreadNo()
158 << "RunningAction pthread_cond_broadcast _RunningWait "
160 // That activate the pthread_cond_wait for RunninWait
161 if ( pthread_cond_broadcast( &_RunningWait ) ) {
162 perror("Running pthread_cond_broadcast ") ;
164 if ( pthread_mutex_unlock( &_MutexWait ) ) {
165 perror("Running pthread_mutex_unlock ") ;
170 void GraphExecutor::InNode::DoneAction() {
171 if ( pthread_mutex_lock( &_MutexWait ) ) {
172 perror("Done pthread_mutex_lock ") ;
175 cdebug << pthread_self() << "/" << ThreadNo()
176 << "DoneAction pthread_cond_broadcast _DoneWait "
178 if ( pthread_cond_broadcast( &_DoneWait ) ) {
179 perror("Done pthread_cond_broadcast ") ;
181 if ( pthread_mutex_unlock( &_MutexWait ) ) {
182 perror("Done pthread_mutex_unlock ") ;
187 void GraphExecutor::InNode::SuspendedAction() {
188 if ( pthread_mutex_lock( &_MutexWait ) ) {
189 perror("Suspended pthread_mutex_lock ") ;
192 cdebug << pthread_self() << "/" << ThreadNo()
193 << "SuspendedAction pthread_cond_broadcast _SuspendedWait "
195 if ( pthread_cond_broadcast( &_SuspendedWait ) ) {
196 perror("Suspended pthread_cond_broadcast ") ;
198 if ( pthread_mutex_unlock( &_MutexWait ) ) {
199 perror("Suspended pthread_mutex_unlock ") ;
204 // SuspendAction <--> { ResumeAction - ReStartAction }
205 GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() {
207 if ( pthread_mutex_lock( &_MutexWait ) ) {
208 perror("Suspend pthread_mutex_lock ") ;
211 if ( !_SuspendSync ) {
212 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
213 << " SuspendAction pthread_cond_wait _SuspendWait "
214 << Automaton()->StateName( State() ) << endl ;
215 _SuspendSync = true ;
216 _OutNode->SuspendThread() ;
217 if ( pthread_cond_wait( &_SuspendWait , &_MutexWait ) ) {
218 perror("SuspendAction pthread_cond_wait ") ;
220 _OutNode->ResumeThread() ;
221 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
222 << " SuspendAction pthread_cond_waited"
223 << Automaton()->StateName( State() ) << endl ;
226 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
227 << " NO SuspendAction pthread_cond_wait"
228 << Automaton()->StateName( State() ) << endl ;
230 // SendEvent( _aResumeEvent ) ; ===> Mutex with myself !
231 _SuspendSync = false ;
232 if ( ControlState() == SUPERV::ToSuspendStartState ||
233 ControlState() == SUPERV::ToSuspendState ) {
234 ControlState( SUPERV::VoidState ) ;
236 if ( pthread_mutex_unlock( &_MutexWait ) ) {
237 perror("SuspendAction pthread_mutex_unlock ") ;
241 SendEvent( _aResumeEvent ) ;
242 // if ( ControlState() == SUPERV::ToSuspendStartState ) {
243 // ControlState( SUPERV::VoidState ) ;
246 if ( pthread_mutex_lock( &_MutexWait ) ) {
247 perror("SuspendAction pthread_mutex_lock ") ;
251 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
252 << " SuspendAction pthread_cond_signal _ResumeWait" << endl ;
253 if ( pthread_cond_signal( &_ResumeWait ) ) {
254 perror("SuspendAction pthread_cond_signal _ResumeWait ") ;
256 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
257 << " SuspendAction pthread_cond_signaled _ResumeWait " << endl ;
260 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
261 << " NO SuspendAction pthread_cond_signal _ResumeWait" << endl ;
264 if ( pthread_mutex_unlock( &_MutexWait ) ) {
265 perror("SuspendAction pthread_mutex_unlock ") ;
268 if ( _aReStartNode ) {
269 cdebug << Name() << " " << Automaton()->StateName( State() )
270 << "aReStartNode : " << _aReStartNode->Name() << " "
271 << Automaton()->StateName( _aReStartNode->State() ) << endl ;
272 _aReStartNode->SendEvent( _aResumeEvent ) ;
275 cdebug << "NO aReStartNode"
276 << Automaton()->StateName( State() ) << endl ;
278 return _aReStartNode ;
281 bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent ) {
283 if ( pthread_mutex_lock( &_MutexWait ) ) {
284 perror("ResumeAction pthread_mutex_lock ") ;
287 _aResumeEvent = aResumeEvent ;
288 if ( _SuspendSync ) {
289 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
290 << " ResumeAction pthread_cond_signal" << endl ;
291 if ( pthread_cond_signal( &_SuspendWait ) ) {
292 perror("ResumeAction pthread_cond_signal ") ;
294 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
295 << " ResumeAction pthread_cond_signaled _SuspendWait " << endl ;
299 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
300 << " NO ResumeAction pthread_cond_signal" << endl ;
301 if ( pthread_self() == ThreadNo() ) {
302 RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
305 _SuspendSync = true ;
306 RetVal = true ; // Il faut tout de meme attendre ci-apres ...
309 if ( pthread_mutex_unlock( &_MutexWait ) ) {
310 perror("ResumeAction pthread_mutex_unlock ") ;
315 if ( pthread_mutex_lock( &_MutexWait ) ) {
316 perror("ResumeAction pthread_mutex_lock ") ;
319 if ( !_ResumeSync ) {
320 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
321 << Name() << " ResumeAction pthread_cond_wait _ResumeWait "
322 << Automaton()->StateName( State() ) << endl ;
324 if ( pthread_cond_wait( &_ResumeWait , &_MutexWait ) ) {
325 perror("ResumeAction pthread_cond_wait ") ;
327 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
328 << Name() << " ResumeAction pthread_cond_waited _ResumeWait"
329 << Automaton()->StateName( State() ) << endl ;
333 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
334 << Name() << " NO ResumeAction pthread_cond_wait _ResumeWait"
335 << Automaton()->StateName( State() ) << endl ;
338 _ResumeSync = false ;
339 if ( pthread_mutex_unlock( &_MutexWait ) ) {
340 perror("ResumeAction pthread_mutex_unlock ") ;
344 cdebug << pthread_self() << "/" << ThreadNo()
345 << "GraphExecutor::InNodeThreads::ResumeAction RetVal " << RetVal << endl ;
349 bool GraphExecutor::InNode::ReStartAction( GraphExecutor::InNode * aReStartNode ,
350 GraphExecutor::NodeEvent anEvent ) {
351 GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
352 _aReStartNode = aReStartNode ;
353 _aReStartEvent = anEvent ;
354 cdebug << pthread_self() << " GraphExecutor::InNodeThreads::ReStartAction from "
355 << Name() << " " << Automaton()->StateName( State() ) << " to "
356 << aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
357 << Automaton()->StateName( aReStartNode->State() ) ;
358 if ( oldReStartNode ) {
359 cdebug << " oldReStartNode " << oldReStartNode->Name() << endl ;
364 return ResumeAction( GraphExecutor::ToReStartEvent ) ;
367 void GraphExecutor::InNode::KilledAction() {
368 if ( pthread_mutex_lock( &_MutexWait ) ) {
369 perror("Killed pthread_mutex_lock ") ;
373 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_wait"
376 if ( pthread_cond_wait( &_KillWait , &_MutexWait ) ) {
377 perror("Killed pthread_cond_wait ") ;
379 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_waited"
383 cdebug << "pthread_cond " << Name() << " NO Killed pthread_cond_wait"
387 if ( pthread_mutex_unlock( &_MutexWait ) ) {
388 perror("Killed pthread_mutex_unlock ") ;
393 void GraphExecutor::InNode::KillAction() {
394 if ( pthread_mutex_lock( &_MutexWait ) ) {
395 perror("Kill pthread_mutex_lock ") ;
399 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signal"
401 // if ( pthread_cond_broadcast( &_KillWait ) ) {
402 if ( pthread_cond_signal( &_KillWait ) ) {
403 perror("Kill pthread_cond_broadcast ") ;
405 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signaled"
409 cdebug << "pthread_cond " << Name() << " NO Kill pthread_cond_signal"
413 if ( pthread_mutex_unlock( &_MutexWait ) ) {
414 perror("Kill pthread_mutex_unlock ") ;
419 void GraphExecutor::InNode::StoppedAction() {
420 if ( pthread_mutex_lock( &_MutexWait ) ) {
421 perror("Stopped pthread_mutex_lock ") ;
424 if ( pthread_cond_wait( &_StopWait , &_MutexWait ) ) {
425 perror("Stopped pthread_cond_wait ") ;
427 if ( pthread_mutex_unlock( &_MutexWait ) ) {
428 perror("Stopped pthread_mutex_unlock ") ;
433 void GraphExecutor::InNode::StopAction() {
434 if ( pthread_mutex_lock( &_MutexWait ) ) {
435 perror("Stop pthread_mutex_lock ") ;
438 if ( pthread_cond_broadcast( &_StopWait ) ) {
439 perror("Stop pthread_cond_broadcast ") ;
441 if ( pthread_mutex_unlock( &_MutexWait ) ) {
442 perror("Stop pthread_mutex_unlock ") ;
447 void GraphExecutor::InNode::ThreadStartedAction() {
448 if ( pthread_mutex_lock( &_MutexWait ) ) {
449 perror("ThreadStarted pthread_mutex_lock ") ;
452 if ( !_ThreadStartedSync ) {
453 cdebug << pthread_self() << "/" << ThreadNo()
454 << "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait"
456 _ThreadStartedSync = true ;
457 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
458 perror("ThreadStarted pthread_cond_wait ") ;
460 cdebug << pthread_self() << "/" << ThreadNo()
461 << "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited"
465 cdebug << pthread_self() << "/" << ThreadNo()
466 << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait"
469 _ThreadStartedSync = false ;
470 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
471 perror("ThreadStart pthread_cond_signal ") ;
474 cdebug << pthread_self() << "/" << ThreadNo()
475 << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled"
478 if ( pthread_mutex_unlock( &_MutexWait ) ) {
479 perror("ThreadStarted pthread_mutex_unlock ") ;
484 void GraphExecutor::InNode::ThreadStartAction() {
485 if ( pthread_mutex_lock( &_MutexWait ) ) {
486 perror("ThreadStart pthread_mutex_lock ") ;
489 if ( _ThreadStartedSync ) {
490 cdebug << pthread_self() << "/" << ThreadNo()
491 << "pthread_cond " << Name() << " ThreadStart pthread_cond_signal"
493 _ThreadStartedSync = false ;
494 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
495 perror("ThreadStart pthread_cond_broadcast ") ;
497 cdebug << pthread_self() << "/" << ThreadNo()
498 << "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled"
502 cdebug << pthread_self() << "/" << ThreadNo()
503 << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal"
505 _ThreadStartedSync = true ;
507 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
508 perror("ThreadStarted pthread_cond_wait ") ;
511 cdebug << pthread_self() << "/" << ThreadNo()
512 << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited"
515 if ( pthread_mutex_unlock( &_MutexWait ) ) {
516 perror("ThreadStart pthread_mutex_unlock ") ;
521 int GraphExecutor::InNode::executeAction() {
522 int oldRewindStack = ( _RewindStack > MAXSTACKTHREADSIZE ) ;
523 if ( !CreateNewThread() && oldRewindStack ) {
524 cdebug << pthread_self() << "/" << ThreadNo()
525 << " executeAction start Thread _RewindStack " << _RewindStack << " > "
526 << MAXSTACKTHREADSIZE << " CreateNewThread "
527 << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
529 CreateNewThread( true ) ;
532 if ( CreateNewThread() ) {
533 CreateNewThread( false ) ;
534 if ( ThreadNo() == 0 ) {
536 cdebug << pthread_self() << "/" << ThreadNo()
537 << " executeAction start Thread _RewindStack " << _RewindStack << " "
538 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
541 int pthread_sts = 1 ;
542 // _OutNode->PushEvent( NULL , GraphExecutor::NewThreadEvent ,
543 // GraphExecutor::ExecutingState ) ;
544 while ( (pthread_sts = pthread_create(&T, NULL, run_function, this )) ) {
545 char * msg = "Cannot pthread_create " ;
547 cdebug << ThreadNo() << " " << msg << " --> sleep(5)" << endl ;
548 cdebug << ThreadNo() << " PTHREAD_THREADS_MAX : "
549 << PTHREAD_THREADS_MAX << " pthread_create status : " ;
550 if ( pthread_sts == EAGAIN ) {
551 cdebug << "EAGAIN(" << pthread_sts << ")" << endl ;
552 cdebug << "It seems to me that with gdb we are limited to 256 threads because of defunct" << endl ;
555 cdebug << pthread_sts << endl ;
559 pthread_exit( msg ) ;
561 cdebug << pthread_self() << "/" << ThreadNo()
562 << "executeAction has created thread " << T << endl ;
563 ThreadStartedAction() ;
564 cdebug << pthread_self() << "/" << ThreadNo()
565 << "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
569 cdebug << pthread_self() << "/" << ThreadNo()
570 << " executeAction restart Thread _RewindStack " << _RewindStack << " "
571 << Automaton()->StateName( State() ) << " "
572 << Automaton()->ActionName( _NextAction ) << "(" << Name()
573 << ") ReStartAction ==>" << endl;
574 State( GraphExecutor::SuspendedSuccessedState ) ;
575 if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
576 cdebug << pthread_self() << "/" << ThreadNo()
577 << " executeAction STATE & CALLED "
578 << Automaton()->ActionName( _NextAction ) << "(" << Name()
579 << ") ERROR-DEBUG " << endl;
582 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
583 << Automaton()->ActionName( _NextAction ) << "(" << Name()
589 if ( _CurrentEvent == ExecuteEvent ) {
592 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
593 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
595 return ExecuteAction() ;
600 void GraphExecutor::InNode::coutbegin() {
601 cdebug << pthread_self() << "/" << ThreadNo() << " run_function begin"
602 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
604 void GraphExecutor::InNode::coutexit() {
605 cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit _RewindStack " << _RewindStack
606 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
608 void * run_function(void *p) {
609 GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
611 aNode->NewThread( pthread_self() ) ;
612 if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) {
613 perror("pthread_setcanceltype ") ;
616 if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) {
617 perror("pthread_setcancelstate ") ;
620 aNode->ThreadStartAction() ;
621 // cout << "run_function " << aNode->Name() << "->ExecuteAction() Coupled : " << aNode->CoupledNode()
623 aNode->ExecuteAction() ;
624 char * msg = new char[40] ;
625 sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
626 strcat( msg , " thread exit" ) ;
628 aNode->ExitThread() ;
631 pthread_exit( (void * ) smsg.c_str() ) ;
635 int GraphExecutor::InNode::ExecuteAction() {
638 const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
639 const char * statename = Automaton()->StateName( State() ) ;
640 const char * nextstatename = Automaton()->StateName( _NextState ) ;
641 cdebug_in << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction "
642 << nextactionname << " " << statename << " NextState "
643 << nextstatename << endl ;
645 State( _NextState ) ;
646 switch ( _NextAction ) {
647 case GraphExecutor::ErrorAction : {
648 sts = ErrorAction() ;
651 case GraphExecutor::VoidAction : {
655 case GraphExecutor::DataWaiting_SomeDataReadyAction : {
656 sts = DataWaiting_SomeDataReadyAction() ;
659 case GraphExecutor::DataUndef_NotAllDataReadyAction : {
660 sts = DataUndef_NotAllDataReadyAction() ;
663 case GraphExecutor::DataUndef_AllDataReadyAction : {
664 sts = DataUndef_AllDataReadyAction() ;
667 case GraphExecutor::DataReady_SuspendAction : {
668 sts = DataReady_SuspendAction() ;
671 case GraphExecutor::SuspendedReady_ResumeAction : {
672 sts = SuspendedReady_ResumeAction() ;
675 case GraphExecutor::DataReady_KillAction : {
676 sts = DataReady_KillAction() ;
679 case GraphExecutor::DataReady_StopAction : {
680 sts = DataReady_StopAction() ;
683 case GraphExecutor::DataReady_ExecuteAction : {
684 sts = DataReady_ExecuteAction() ;
687 case GraphExecutor::Executing_SuspendAction : {
688 sts = Executing_SuspendAction() ;
691 case GraphExecutor::SuspendedExecuting_ResumeAction : {
692 sts = SuspendedExecuting_ResumeAction() ;
695 case GraphExecutor::Executing_KillAction : {
696 sts = Executing_KillAction() ;
699 case GraphExecutor::Executing_StopAction : {
700 sts = Executing_StopAction() ;
703 case GraphExecutor::Executing_SuccessAction : {
704 sts = Executing_SuccessAction() ;
707 case GraphExecutor::Executing_ErrorAction : {
708 sts = Executing_ErrorAction() ;
711 case GraphExecutor::Successed_SuccessAction : {
712 sts = Successed_SuccessAction() ;
715 case GraphExecutor::Errored_ErrorAction : {
716 sts = Errored_ErrorAction() ;
719 case GraphExecutor::Successed_SuspendAction : {
720 sts = Successed_SuspendAction() ;
723 case GraphExecutor::Errored_SuspendAction : {
724 sts = Errored_SuspendAction() ;
727 case GraphExecutor::SuspendedSuccessed_ResumeAction : {
728 sts = SuspendedSuccessed_ResumeAction() ;
731 case GraphExecutor::SuspendedErrored_ResumeAction : {
732 sts = SuspendedErrored_ResumeAction() ;
735 case GraphExecutor::Successed_KillAction : {
736 sts = Successed_KillAction() ;
739 case GraphExecutor::Errored_KillAction : {
740 sts = Errored_KillAction() ;
743 case GraphExecutor::Successed_StopAction : {
744 sts = Successed_StopAction() ;
747 case GraphExecutor::Errored_StopAction : {
748 sts = Errored_StopAction() ;
751 case GraphExecutor::SuspendedSuccessed_ReStartAction : {
752 sts = SuspendedSuccessed_ReStartAction() ;
755 case GraphExecutor::SuspendedErrored_ReStartAction : {
756 sts = SuspendedErrored_ReStartAction() ;
759 case GraphExecutor::SuspendedSuccessed_ReStartAndSuspendAction : {
760 sts = SuspendedSuccessed_ReStartAndSuspendAction() ;
763 case GraphExecutor::SuspendedErrored_ReStartAndSuspendAction : {
764 sts = SuspendedErrored_ReStartAndSuspendAction() ;
768 cdebug << pthread_self() << "/" << ThreadNo()
769 << " GraphExecutor::InNodeThreads::SendEvent Error Undefined Action : "
770 << _NextAction << endl ;
774 cdebug_out << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
775 << nextactionname << endl ;
779 int GraphExecutor::InNode::ErrorAction() {
780 cdebug << pthread_self() << "/" << ThreadNo() << " Automaton ErrorAction Node "
785 int GraphExecutor::InNode::VoidAction() {
786 cdebug << pthread_self() << "/" << ThreadNo() << " VoidAction " << Name() << endl;
791 int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
792 cdebug << pthread_self() << "/" << ThreadNo()
793 << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
794 << " to " << Name() << endl;
798 bool LoopBeginning = false ;
799 bool LoopFinished = false ;
800 bool SwitchFinished = false ;
802 if ( IsLoopNode() ) {
803 GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ;
804 if ( anOutLoopPort && anOutLoopPort->BoolValue() ) {
805 LoopBeginning = true ; // Beginning of Loop
808 if ( IsEndLoopNode() ) {
809 GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ;
810 if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) {
811 LoopFinished = true ; // End of Loop
814 if ( IsEndSwitchNode() ) {
815 GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ;
816 if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
817 SwitchFinished = true ; // End of Switch
820 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
821 << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << endl ;
822 for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
823 GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
824 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
825 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " << anInPort->PortName() << " " << anInPort->State() << " " << anInPort->PortStatus() << endl ;
826 if ( anInPort->IsGate() && anOutPort == NULL ) {
828 anInPort->State( SUPERV::ReadyState ) ;
829 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
830 << anInPort->PortName() << " ControlPort inactive." << endl ;
832 // That InPort get its value from an other node
833 else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
834 if ( anInPort->State() == SUPERV::ReadyState ) {
836 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
837 << anInPort->PortName() << " Was Done from Node "
838 << anOutPort->NodeName() << "( " << anOutPort->PortName()
841 if ( GraphBase::Base::_prof_debug ) {
842 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
847 else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
848 anInPort->State( SUPERV::ReadyState ) ;
850 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
851 << anInPort->PortName() << " Was Done from Node "
852 << anOutPort->NodeName() << "( " << anOutPort->PortName()
853 << ") LoopBeginning " << LoopBeginning ;
855 if ( GraphBase::Base::_prof_debug ) {
856 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
861 else if ( LoopFinished ) {
862 anInPort->State( SUPERV::ReadyState ) ;
864 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
865 << anInPort->PortName() << " Was Done from Node "
866 << anOutPort->NodeName() << "( " << anOutPort->PortName()
867 << ") LoopFinished" ;
869 if ( GraphBase::Base::_prof_debug ) {
870 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
875 else if ( anInPort->IsGate() && SwitchFinished ) {
876 anInPort->State( SUPERV::ReadyState ) ;
878 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
879 << anInPort->PortName() << " Was Done from Node "
880 << anOutPort->NodeName() << "( " << anOutPort->PortName()
881 << ") SwitchFinished" ;
883 if ( GraphBase::Base::_prof_debug ) {
884 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
889 else if ( anInPort->IsGate() &&
890 _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->IsGOTONode() ) {
891 // GateOutPort of GOTONodes are always opened
892 anInPort->State( SUPERV::ReadyState ) ;
894 CORBA::Any * anAny = new CORBA::Any() ;
895 *anAny <<= (long ) 1 ;
896 _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->GetChangeNodeOutGate()->Value( anAny ) ;
897 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
898 << anInPort->PortName() << " Was Done from Node "
899 << anOutPort->NodeName() << "( " << anOutPort->PortName()
902 if ( GraphBase::Base::_prof_debug ) {
903 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
909 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
910 << anInPort->PortName() << " Was NOT Done from Node "
911 << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
912 << " " << Automaton()->StateName( State() ) << " DataConnected "
913 << anInPort->IsDataConnected() << " LoopBeginning "
914 << LoopBeginning << endl ;
917 // That InPort get its value from the sending node
918 else if ( anInPort->IsGate() ) {
919 const CORBA::Any * theValue = anOutPort->Value() ;
921 (*theValue) >>= GateOpened ;
922 if ( GateOpened != 0 ) {
924 anInPort->State( SUPERV::ReadyState ) ;
925 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
926 << anInPort->PortName() << " Gate is Opened from Node "
927 << anOutPort->NodeName() << "( " << anOutPort->PortName()
930 if ( GraphBase::Base::_prof_debug ) {
931 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
936 else if ( LoopFinished ) {
937 anInPort->State( SUPERV::ReadyState ) ;
938 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
939 << anInPort->PortName() << " GATE IS CLOSED from Node "
940 << anOutPort->NodeName() << "( " << anOutPort->PortName()
941 << ") LoopFinished" ;
943 if ( GraphBase::Base::_prof_debug ) {
944 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
950 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
951 << anInPort->PortName() << " GATE IS CLOSED from Node "
952 << anOutPort->NodeName() << "( " << anOutPort->PortName()
955 if ( GraphBase::Base::_prof_debug ) {
956 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
962 else if ( anOutPort->Done() ) {
964 anInPort->State( SUPERV::ReadyState ) ;
965 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
966 << anInPort->PortName() << " " << anInPort->PortStatus() << " is Done from Node "
967 << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
968 << anOutPort->PortStatus() << " " ;
970 if ( GraphBase::Base::_prof_debug ) {
971 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
975 // MacroNode : give immediately the value to the corresponding graph
976 if ( IsMacroNode() ) {
977 cout << "SomeDataReadyAction " << GraphMacroNode() << " " << GraphMacroNode()->Name()
978 << " coupled to " << GraphMacroNode()->CoupledNode() << endl ;
979 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
980 cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Graph()->Name() << " --> InputOfAny "
981 << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready" << endl ;
982 // GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
983 aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
987 cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( "
988 << anInPort->PortName() << ") " << anInPort->PortStatus()
989 << " is NOT Done from Node "
990 << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
991 << anOutPort->PortStatus() << " " ;
995 if ( InReady == GetNodeInPortsSize() ) { // All Flags != 0 :
996 res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
998 else { // At least one Flag == 0 :
999 res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
1002 cdebug << pthread_self() << "/" << ThreadNo()
1003 << " <-- DataWaiting_SomeDataReadyAction " << Name() << endl;
1008 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
1009 CreateNewThreadIf( false ) ;
1010 // cdebug << pthread_self() << " for " << ThreadNo()
1011 // << " DataUndef_NotAllDataReadyAction " << Name() << endl;
1015 int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
1016 // cdebug << pthread_self() << "/" << ThreadNo()
1017 // << " --> DataUndef_AllDataReadyAction " << Name()
1018 // << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
1019 // << IsLockedDataWait() ;
1020 if ( IsLockedDataWait() ) {
1021 cdebug << "DataUndef_AllDataReadyAction() WOULD DEAD-LOCK" << endl ;
1022 return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
1025 CreateNewThread( CreateNewThreadIf() ) ;
1026 if ( !CreateNewThread() ) {
1027 // cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
1028 ThreadNo( pthread_self() ) ;
1030 _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
1031 GraphExecutor::DataReadyState ) ;
1033 SUPERV::ControlState aControl = ControlState() ;
1034 switch ( aControl ) {
1035 case SUPERV::VoidState : {
1036 SendEvent( GraphExecutor::ExecuteEvent ) ;
1039 case SUPERV::ToSuspendState : {
1040 SendEvent( GraphExecutor::SuspendEvent ) ;
1043 case SUPERV::ToSuspendStartState : {
1044 SendEvent( GraphExecutor::SuspendEvent ) ;
1047 case SUPERV::ToSuspendDoneState : {
1048 SendEvent( GraphExecutor::ExecuteEvent ) ;
1051 case SUPERV::ToKillState : {
1052 SendEvent( GraphExecutor::KillEvent ) ;
1055 case SUPERV::ToKillDoneState : {
1056 SendEvent( GraphExecutor::ExecuteEvent ) ;
1059 case SUPERV::ToStopState : {
1060 SendEvent( GraphExecutor::StopEvent ) ;
1064 cdebug << ThreadNo()
1065 << " GraphExecutor::InNodeThreads::DataUndef_AllDataReadyAction Error Undefined Control : "
1066 << aControl << endl ;
1070 // cdebug << pthread_self() << "/" << ThreadNo()
1071 // << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
1075 int GraphExecutor::InNode::DataReady_SuspendAction() {
1076 cdebug << pthread_self() << "/" << ThreadNo()
1077 << "DataReady_SuspendAction --> Suspend " << Name()
1078 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
1079 << _OutNode->SuspendedThreads() << endl;
1080 _OutNode->PushEvent( this , GraphExecutor::SuspendedReadyEvent ,
1081 GraphExecutor::SuspendedReadyState ) ;
1082 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1083 cdebug << pthread_self() << "/" << ThreadNo()
1084 << "DataReady_SuspendAction Resumed " << Name() << endl;
1085 if ( aReStartNode ) {
1086 _aReStartNode = NULL ;
1087 aReStartNode->SendEvent( _aReStartEvent ) ;
1090 SendEvent( GraphExecutor::ExecuteEvent ) ;
1095 int GraphExecutor::InNode::SuspendedReady_ResumeAction() {
1096 cdebug << pthread_self() << "/" << ThreadNo() << "SuspendedReady_ResumeAction "
1099 _OutNode->PushEvent( this , GraphExecutor::ResumedReadyEvent ,
1100 GraphExecutor::ResumedReadyState ) ;
1104 int GraphExecutor::InNode::DataReady_KillAction() {
1105 _OutNode->PushEvent( this , GraphExecutor::KilledReadyEvent ,
1106 GraphExecutor::KilledReadyState ) ;
1108 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_KillAction " << Name()
1109 << " will pthread_exit()" << endl;
1113 int GraphExecutor::InNode::DataReady_StopAction() {
1114 _OutNode->PushEvent( this , GraphExecutor::StoppedReadyEvent ,
1115 GraphExecutor::StoppedReadyState ) ;
1117 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_StopAction " << Name()
1118 << " will pthread_exit()" << endl;
1124 int GraphExecutor::InNode::DataReady_ExecuteAction() {
1127 // cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
1128 // << Name() << endl;
1129 _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
1130 GraphExecutor::ExecutingState ) ;
1136 SUPERV::GraphState PortState = SUPERV::ReadyState ;
1137 GraphExecutor::AutomatonState NewState = GraphExecutor::DataUndefState ;
1138 GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
1141 ServicesAnyData * InParametersList ;
1143 ServicesAnyData * OutParametersList ;
1145 nInParams = GetNodeInPortsSize() ;
1146 InParametersList = new ServicesAnyData[nInParams];
1147 InParametersSet( Err , nInParams , InParametersList ) ;
1149 nOutParams = GetNodeOutPortsSize() ;
1150 OutParametersList = new ServicesAnyData[nOutParams];
1151 InOutParametersSet( nOutParams , OutParametersList ) ;
1153 if ( !IsMacroNode() ) {
1155 Engines::Container_var myContainer ;
1156 Engines::Component_var myObjComponent ;
1157 if ( !IsFactoryNode() ) {
1158 // cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
1159 if ( IsComputingNode() ) {
1160 ObjInterface( true ) ;
1161 CORBA::Object_ptr obj ;
1162 InParametersList[0].Value >>= obj ;
1163 CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
1164 myObjComponent = Engines::Component::_narrow( objvar ) ;
1169 else if ( CORBA::is_nil( Component() ) ) {
1170 // ostringstream astr ;
1171 // astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name()
1172 // << " : load of component " << ComponentName() << " in container "
1174 // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1175 Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() ,
1176 my_strdup( ComponentName() ) ,
1177 myContainer , myObjComponent ) ;
1178 ObjInterface( false ) ;
1179 SetContainer( myContainer ) ;
1180 SetComponent( myObjComponent ) ;
1183 myContainer = Container() ;
1184 myObjComponent = Component() ;
1185 // cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
1188 myObjComponent->ping() ;
1191 cdebug << "ping() catched" << endl ;
1196 if ( Err || ControlState() == SUPERV::ToKillState ||
1197 ControlState() == SUPERV::ToKillDoneState ||
1198 ControlState() == SUPERV::ToStopState ) {
1199 cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
1200 MESSAGE(pthread_self() << "Executor::InNode::DataReady_ExecuteAction of " << Name()
1201 << " ControlState " << Automaton()->ControlStateName( ControlState() )
1202 << " BEFORE execution ThreadNo " << ThreadNo() ) ;
1206 if ( ControlState() == SUPERV::ToSuspendState ) {
1207 cdebug << ThreadNo() << "ToSuspendState before running." << endl ;
1208 MESSAGE(ThreadNo() << "ToSuspendState before running.") ;
1211 // ostringstream astr ;
1212 // astr << "Graph " << _OutNode->Graph()->Name() << " Run of Node " << Name() ;
1213 // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1214 cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
1215 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1216 cdebug << " , " << InParametersList[ i ].Name << "[kind"
1217 << InParametersList[ i ].Value.type()->kind() << "]" ;
1219 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1220 cdebug << " , " << OutParametersList[ i ].Name << "[kind"
1221 << OutParametersList[ i ].Value.type()->kind() << "]" ;
1223 if ( IsOneOfInLineNodes() ) {
1224 cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
1225 << InLineNode()->PyRunMethod() << " length "
1226 << (*InLineNode()->PythonFunction()).length() ;
1228 cdebug << ")" << endl ;
1230 if ( IsOneOfInLineNodes() ) {
1231 bool StsPyDynInvoke = true;
1232 _OutNode->PyThreadLock() ;
1235 // if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
1236 bool ItIsaLoop = false ;
1237 bool CopyInOut = false ;
1238 if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
1239 strlen( InLineNode()->PyFuncName() ) ) {
1240 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1241 << InLineNode()->PyFuncName()
1242 << "' IsInLineNode PyDynInvoke" << endl ;
1243 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1244 InLineNode()->PyFuncName() ,
1245 &InParametersList[0] , ServiceInParameter().length() ,
1246 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1247 if ( !StsPyDynInvoke ) {
1248 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1250 else if ( IsLoopNode() ) {
1252 bool CopyOutIn = false ;
1253 // Switch between Init() and Next()
1254 // if InLoop port is true and does not come from EndLoop ==> execute Init
1255 // if InLoop port is false or come from EndLoop ==> execute Next
1256 // GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
1257 // if ( GetNodeInLoop()->GetOutPort()->BoolValue() &&
1259 if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init()
1260 cdebug << ThreadNo() << " !ObjInterface " << Name()
1261 << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
1262 << "' InitLoop " << LoopNode()->PyRunMethod() << endl ;
1263 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1264 InLineNode()->PyFuncName() ,
1265 &InParametersList[1] , ServiceInParameter().length() ,
1266 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1267 if ( !StsPyDynInvoke ) {
1268 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1273 cdebug << ThreadNo() << " !ObjInterface " << Name()
1274 << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ;
1276 cdebug << ThreadNo() << " !ObjInterface " << Name()
1277 << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ;
1280 else if ( LoopNode()->PyNextMethod() &&
1281 strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next()
1282 cdebug << ThreadNo() << " !ObjInterface " << Name()
1283 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
1284 << "' " << LoopNode()->PyNextMethod() << endl ;
1285 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
1286 LoopNode()->PyNextName() ,
1287 &InParametersList[1] , ServiceInParameter().length() ,
1288 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1289 if ( !StsPyDynInvoke ) {
1290 RemovePyDynInvoke( LoopNode()->PyNextName() ) ;
1295 cdebug << ThreadNo() << " !ObjInterface " << Name()
1296 << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ;
1298 if ( StsPyDynInvoke ) {
1300 cdebug << ThreadNo() << " !ObjInterface " << Name()
1301 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
1302 << "' Copy of " << ServiceInParameter().length()
1303 << " OutParameters" << endl ;
1305 // Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next )
1306 for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
1307 InParametersList[i].Value = OutParametersList[i].Value ;
1308 InParametersList[i].Name = OutParametersList[i].Name ;
1310 switch ( InParametersList[i].Value.type()->kind() ) {
1311 case CORBA::tk_string :
1313 InParametersList[i].Value >>= t ;
1314 cdebug << "ArgOut->In" << i << " : "
1315 << InParametersList[i].Name.c_str()
1316 << " Value(string) " << t << endl ;
1318 case CORBA::tk_double :
1320 InParametersList[i].Value >>= d;
1321 cdebug << "ArgOut->In" << i << " : "
1322 << InParametersList[i].Name.c_str()
1323 << " Value(double) " << d << endl ;
1325 case CORBA::tk_long :
1327 InParametersList[i].Value >>= l;
1328 cdebug << "ArgOut->In" << i << " : "
1329 << InParametersList[i].Name.c_str()
1330 << " Value(long) " << l << endl ;
1332 case CORBA::tk_objref :
1333 CORBA::Object_ptr obj ;
1336 InParametersList[i].Value >>= obj ;
1337 retstr = ObjectToString( obj );
1338 cdebug << "ArgOut->In" << i << " : "
1339 << InParametersList[i].Name.c_str()
1340 << " Value(object reference) " << retstr << endl ;
1343 cdebug << "ArgOut->In" << i << " : "
1344 << InParametersList[i].Name.c_str()
1345 << " Value(object reference) Catched ERROR" << endl ;
1349 cdebug << "ArgOut->In" << i << " : "
1350 << InParametersList[i].Name.c_str()
1351 << " Value(other) ERROR" << endl ;
1356 if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
1357 cdebug << ThreadNo() << " !ObjInterface " << Name()
1358 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
1359 << "' " << LoopNode()->PyMoreMethod() << endl ;
1360 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
1361 LoopNode()->PyMoreName() ,
1362 &InParametersList[1] , ServiceInParameter().length() ,
1363 &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
1364 if ( !StsPyDynInvoke ) {
1365 RemovePyDynInvoke( LoopNode()->PyMoreName() ) ;
1369 cdebug << ThreadNo() << " !ObjInterface " << Name()
1370 << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
1371 << "' No MoreMethod" << endl ;
1377 cdebug << ThreadNo() << " InLineNode " << Name() << " "
1378 << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
1379 << " Python Dynamic Call Error"
1383 else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
1384 strlen( InLineNode()->PyFuncName() ) ) {
1385 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1386 // << InLineNode()->PyFuncName()
1387 // << "' IsSwitchNode PyDynInvoke" << endl ;
1388 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1389 InLineNode()->PyFuncName() ,
1390 &InParametersList[0] , ServiceInParameter().length() ,
1391 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1392 if ( !StsPyDynInvoke ) {
1393 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1396 // else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
1397 else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
1398 strlen( InLineNode()->PyFuncName() ) ) {
1399 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1400 // << InLineNode()->PyFuncName()
1401 // << "' IsGOTONode PyDynInvoke" << endl ;
1402 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1403 InLineNode()->PyFuncName() ,
1404 &InParametersList[0] , ServiceInParameter().length() ,
1405 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1406 if ( !StsPyDynInvoke ) {
1407 RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
1410 // else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
1411 else if ( ( IsEndSwitchNode() ) &&
1412 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1413 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1414 // << InLineNode()->PyFuncName()
1415 // << "' IsSwitchNode PyDynInvoke" << endl ;
1416 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1417 InLineNode()->PyFuncName() ,
1418 &InParametersList[0] , ServiceInParameter().length() ,
1419 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1420 if ( !StsPyDynInvoke ) {
1421 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1424 else if ( ( IsEndLoopNode() ) &&
1425 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1426 cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1427 << InLineNode()->PyFuncName()
1428 << "' IsSwitchNode PyDynInvoke" << endl ;
1429 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1430 InLineNode()->PyFuncName() ,
1431 &InParametersList[0] , ServiceInParameter().length() + 1 ,
1432 &OutParametersList[0] , ServiceOutParameter().length() + 1 ) ;
1433 if ( !StsPyDynInvoke ) {
1434 RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
1438 // else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
1439 if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL ||
1440 strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) {
1441 // This is a void Python Function : without code (No PyFuncName)
1442 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1443 // << " Copy of " << ServiceInParameter().length()
1444 // << " OutParameters" << endl ;
1448 if ( IsLoopNode() || IsEndLoopNode() ) {
1450 argin0 = 1 ; // after DoLoop
1451 if ( IsLoopNode() ) { // More() is void
1452 // OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
1453 cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)"
1455 GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
1456 OutParametersList[0].Value = *anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
1459 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1460 OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
1462 switch ( InParametersList[argin0 + i].Value.type()->kind() ) {
1463 case CORBA::tk_string :
1464 cdebug << "ArgOut->In" << argin0 + i << " : "
1465 << InParametersList[argin0 + i].Name.c_str()
1466 << " Value(string) "
1467 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1469 case CORBA::tk_double :
1470 cdebug << "ArgOut->In" << argin0 + i << " : "
1471 << InParametersList[argin0 + i].Name.c_str()
1472 << " Value(double) "
1473 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1475 case CORBA::tk_long :
1476 cdebug << "ArgOut->In" << argin0 + i << " : "
1477 << InParametersList[argin0 + i].Name.c_str()
1479 << OutParametersList[argout0 + i ].Name.c_str() << endl ;
1481 case CORBA::tk_objref :
1482 cdebug << "ArgOut->In" << argin0 + i << " : "
1483 << InParametersList[argin0 + i].Name.c_str()
1484 << " Value(object reference) "
1485 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1488 cdebug << "ArgOut->In" << argin0 + i << " : "
1489 << InParametersList[argin0 + i].Name.c_str()
1490 << " Value(other) ERROR "
1491 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1496 if ( !StsPyDynInvoke ) {
1498 cdebug << ThreadNo() << " InLineNode " << Name()
1499 << " Python Dynamic Call Error"
1505 cdebug << ThreadNo() << " InLineNode " << Name()
1506 << " Python Dynamic Call Exception catched ERROR"
1510 _OutNode->PyThreadUnLock() ;
1515 cdebug << "DynInvoke -> Names " << _OutNode->Graph()->Name() << " " << Name() << endl ;
1516 DynInvoke( myObjComponent, "Names" ,
1517 _OutNode->Graph()->Name() , Name() ) ;
1520 cdebug << "DynInvoke Names catched ERROR" << endl ;
1522 // for DataStreamNodes : call of SetProperties ===> environment variables in the component/container
1523 if ( ComputingNode()->HasDataStream() ) {
1525 cdebug << "DynInvoke -> SetProperties " << _OutNode->Graph()->Name() << " " << Name() << endl ;
1526 Engines::FieldsDict_var dict = new Engines::FieldsDict;
1528 dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
1529 // myContainer->getHostName() ne renvoit pas le nom complet (avec domaine).
1530 // dict[ 0 ].value <<= myContainer->getHostName() ;
1531 char FullyQualifiedDomainName[256]="";
1532 gethostname(FullyQualifiedDomainName,255);
1533 dict[ 0 ].value <<= FullyQualifiedDomainName ;
1534 dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
1535 dict[ 1 ].value <<= "/tmp" ;
1536 dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
1537 stringstream ofst1 ;
1538 ofst1 << ComputingNode()->SubStreamGraph() ;
1539 string cpl = string( "/tmp/" ) + string( _OutNode->Graph()->Name() ) + string( "_" ) +
1540 ofst1.str() + string( ".cpl" );
1541 dict[ 2 ].value <<= cpl.c_str() ;
1542 dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
1543 string uname = Name();
1545 dict[ 3 ].value <<= uname.c_str() ;
1547 myObjComponent->setProperties( dict ) ;
1550 cdebug << "DynInvoke setProperties catched ERROR" << endl ;
1554 if ( !Err && IsComputingNode() ) {
1555 cdebug << ThreadNo() << " !ObjInterface " << Name()
1556 << " IsComputingNode DynInvoke" << endl ;
1557 cdebug << ServiceInParameter().length()-1 << " input parameters and "
1558 << ServiceOutParameter().length() << " output parameters" << endl ;
1559 IsLoading( false ) ;
1560 DynInvoke( myObjComponent,
1562 &InParametersList[1] , ServiceInParameter().length()-1 ,
1563 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1565 else if ( !Err && IsFactoryNode() ) {
1566 cdebug << ThreadNo() << " !ObjInterface " << Name()
1567 << " IsFactoryNode DynInvoke" << endl ;
1568 cdebug << ServiceInParameter().length() << " input parameters and "
1569 << ServiceOutParameter().length() << " output parameters" << endl ;
1570 IsLoading( false ) ;
1571 DynInvoke( myObjComponent,
1573 &InParametersList[0] , ServiceInParameter().length() ,
1574 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1576 // cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
1577 // << myObjComponent->CpuUsed_impl() << endl ;
1581 cdebug << ThreadNo() << " !ObjInterface " << Name()
1582 << " Node(Component) Dynamic Call Exception catched ERROR"
1584 //Reset of _ThreadId in the Container ...
1586 myObjComponent->Kill_impl() ;
1596 // ostringstream astr ;
1597 // astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() << " is done : "
1598 // << Automaton()->StateName( State() ) ;
1599 // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
1603 // if exception or something else - IsLoading( false ) may not NOT has been called
1607 if ( ControlState() == SUPERV::ToKillState ||
1608 ControlState() == SUPERV::ToKillDoneState ||
1609 ControlState() == SUPERV::ToStopState ) {
1610 PortState = SUPERV::ErrorState ;
1611 NewState = GraphExecutor::KilledState ;
1612 NewEvent = GraphExecutor::KillEvent ;
1615 PortState = SUPERV::ErrorState ;
1616 NewState = GraphExecutor::ErroredState ;
1617 NewEvent = GraphExecutor::ErrorEvent ;
1621 PortState = SUPERV::ReadyState ;
1622 NewState = GraphExecutor::DataReadyState ;
1623 NewEvent = GraphExecutor::SuccessEvent ;
1626 if ( !IsMacroNode() ) {
1627 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1629 NewEvent = GraphExecutor::ErrorEvent ;
1631 delete [] InParametersList ;
1632 delete [] OutParametersList ;
1635 if ( !IsMacroNode() ) {
1636 SendEvent( NewEvent ) ;
1639 GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
1640 cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " "
1641 << aMacroGraph->Graph()->Name() << " ->DoneWait()"
1642 << " State " << aMacroGraph->State() << endl;
1643 aMacroGraph->DoneWait() ;
1644 cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State " << aMacroGraph->State() << endl;
1645 if ( aMacroGraph->State() == SUPERV::DoneState ) {
1646 PortState = SUPERV::ReadyState ;
1647 NewState = GraphExecutor::DataReadyState ;
1648 NewEvent = GraphExecutor::SuccessEvent ;
1652 if ( ControlState() == SUPERV::ToKillState ||
1653 ControlState() == SUPERV::ToKillDoneState ||
1654 ControlState() == SUPERV::ToStopState ) {
1655 PortState = SUPERV::ErrorState ;
1656 NewState = GraphExecutor::KilledState ;
1657 NewEvent = GraphExecutor::KillEvent ;
1660 PortState = SUPERV::ErrorState ;
1661 NewState = GraphExecutor::ErroredState ;
1662 NewEvent = GraphExecutor::ErrorEvent ;
1665 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1667 NewEvent = GraphExecutor::ErrorEvent ;
1669 delete [] InParametersList ;
1670 delete [] OutParametersList ;
1671 SendEvent( NewEvent ) ;
1674 // cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
1678 int GraphExecutor::InNode::Executing_SuspendAction() {
1679 _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
1680 GraphExecutor::SuspendedExecutingState ) ;
1681 cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
1685 int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
1686 cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
1687 GraphExecutor::AutomatonState next_state ;
1688 next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
1689 _OutNode->NewThread() ; // Only for Threads count
1690 _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
1692 State( next_state ) ;
1696 int GraphExecutor::InNode::Executing_KillAction() {
1697 cdebug << ThreadNo() << " Executing_KillAction " << Name() << " Thread " << ThreadNo()<< endl;
1699 if ( pthread_self() == ThreadNo() ) {
1700 cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
1702 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
1703 GraphExecutor::KilledExecutingState ) ;
1706 else if ( pthread_cancel( ThreadNo() ) ) {
1707 perror("Executing_KillAction pthread_cancel error") ;
1710 cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
1711 << " pthread_canceled" << endl ;
1713 _OutNode->ExitThread( ThreadNo() ) ;
1714 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
1715 GraphExecutor::KilledExecutingState ) ;
1720 int GraphExecutor::InNode::Executing_StopAction() {
1721 cdebug << ThreadNo() << " Executing_StopAction " << Name() << " Thread " << ThreadNo() << endl;
1723 if ( pthread_cancel( ThreadNo() ) ) {
1724 perror("Executing_KillAction pthread_cancel error") ;
1727 cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
1728 << " pthread_canceled" << endl ;
1730 _OutNode->ExitThread( ThreadNo() ) ;
1731 _OutNode->PushEvent( this , GraphExecutor::StoppedExecutingEvent ,
1732 GraphExecutor::StoppedExecutingState ) ;
1737 int GraphExecutor::InNode::Executing_SuccessAction() {
1738 // cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
1739 _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
1740 GraphExecutor::SuccessedState ) ;
1741 MESSAGE(pthread_self() << "Executor::InNode::Executing_SuccessAction of " << Name()
1742 << " ControlState " << Automaton()->ControlStateName( ControlState() )
1743 << " AFTER execution ThreadNo " << ThreadNo() ) ;
1744 SUPERV::ControlState aControl = ControlState() ;
1745 switch ( aControl ) {
1746 case SUPERV::VoidState : {
1747 SendEvent( SuccessEvent ) ;
1750 case SUPERV::ToSuspendState : {
1751 SendEvent( SuccessEvent ) ;
1754 case SUPERV::ToSuspendDoneState : {
1755 SendEvent( GraphExecutor::SuspendEvent ) ;
1758 case SUPERV::ToKillState : {
1759 SendEvent( GraphExecutor::KillEvent ) ;
1762 case SUPERV::ToKillDoneState : {
1763 SendEvent( GraphExecutor::KillEvent ) ;
1766 case SUPERV::ToStopState : {
1767 SendEvent( GraphExecutor::StopEvent ) ;
1771 cdebug << ThreadNo()
1772 << " GraphExecutor::InNodeThreads::Executing_SuccessAction Error Undefined Control : "
1773 << aControl << endl ;
1777 // cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
1781 int GraphExecutor::InNode::Executing_ErrorAction() {
1782 cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
1783 _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
1784 GraphExecutor::ErroredState ) ;
1786 SUPERV::ControlState aControl = ControlState() ;
1787 switch ( aControl ) {
1788 case SUPERV::VoidState : {
1789 SendEvent( ErrorEvent ) ;
1792 case SUPERV::ToSuspendState : {
1793 SendEvent( ErrorEvent ) ;
1796 case SUPERV::ToSuspendDoneState : {
1797 SendEvent( GraphExecutor::SuspendEvent ) ;
1800 case SUPERV::ToKillState : {
1801 SendEvent( GraphExecutor::KillEvent ) ;
1804 case SUPERV::ToKillDoneState : {
1805 SendEvent( GraphExecutor::KillEvent ) ;
1808 case SUPERV::ToStopState : {
1809 SendEvent( GraphExecutor::StopEvent ) ;
1813 cdebug << ThreadNo()
1814 << " GraphExecutor::InNodeThreads::Executing_ErrorAction Error Undefined Control : "
1815 << aControl << endl ;
1819 cdebug << ThreadNo() << " <-- Executing_ErrorAction " << Name() << endl;
1823 // Set SUPERV::WaitingState to all InPorts
1824 void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
1827 bool docdebug = false ;
1828 State( GraphExecutor::DataWaitingState ) ;
1829 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1830 GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
1831 cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
1832 << anInPort->PortStatus() << " " << anInPort->State() << endl ;
1833 // JR Debug 07.01.2005 : Close the Gates instead of open !!!
1834 if ( anInPort->IsGate() ) { // Loop : Close the doors
1835 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1837 CORBA::Any * anAny = new CORBA::Any() ;
1838 // *anAny <<= (long ) 1 ;
1839 *anAny <<= (long ) 0 ;
1840 anOutPort->Value( anAny ) ;
1841 anInPort->State( SUPERV::WaitingState ) ;
1844 else if ( anInPort->State() != SUPERV::WaitingState &&
1845 !anInPort->IsDataConnected() ) {
1847 cdebug << ThreadNo()
1848 << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
1851 if ( !anInPort->IsDataStream() ) {
1852 anInPort->State( SUPERV::WaitingState ) ;
1855 cdebug << " --> " << Name() << "( " << anInPort->PortName() << " ) "
1856 << anInPort->PortStatus() << " " << anInPort->State() << endl ;
1858 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1859 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
1860 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
1861 if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
1862 !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) &&
1863 !anOutPort->IsDataStream() &&
1864 !anOutPort->ChangeInPorts( j )->IsDataStream() &&
1865 !anOutPort->ChangeInPorts( j )->IsExternConnected() ) {
1866 cdebug << ThreadNo()
1867 << " InNodeThreads::SetWaitingStates OutPort "
1868 << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
1869 << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
1870 << anOutPort->ChangeInPorts( j )->NodeName() << "( "
1871 << anOutPort->ChangeInPorts( j )->PortName() << " "
1872 << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
1873 GraphBase::ComputingNode * aToNode ;
1874 aToNode = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() ) ;
1875 // JR 12.01.2005 : the OutPort linked to the InPort of a EndSwitchNode was changed so final
1876 // values of InPorts of EndSwitchNode may be wrong
1877 if ( !aToNode->IsEndSwitchNode() &&
1878 strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
1879 // After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from
1880 // EndLoopNode or GOTONode. But if there is several nested loops we should re-establish.
1881 cdebug << ThreadNo()
1882 << " InNodeThreads::SetWaitingStates Node " << Name() << " "
1883 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
1884 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
1885 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
1886 << anOutPort->PortName() << " )" << endl ;
1887 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
1889 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ;
1890 if ( aNode != EndNode ) {
1891 aNode->SetWaitingStates( EndNode ) ;
1898 int GraphExecutor::InNode::Successed_SuccessAction() {
1899 cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
1901 int linkednodesnumber = LinkedNodesSize() ;
1902 GraphExecutor::InNode *firstzeroNode = NULL ;
1903 GraphExecutor::InNode *firsttoNode = NULL ;
1904 GraphExecutor::InNode *toNode ;
1907 list<GraphExecutor::InNode *> SomeDataNodes ;
1911 if ( IsMacroNode() ) {
1912 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done"
1917 if ( IsGOTONode() ||
1918 ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
1919 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
1920 << " SetWaitingStates " << endl ;
1921 const GraphBase::OutPort * aGateOutPort ;
1922 if ( IsGOTONode() ) {
1923 aGateOutPort = GetNodeOutGate() ;
1926 aGateOutPort = GetNodeOutLoop() ;
1928 if ( aGateOutPort->InPortsSize() != 1 ) {
1929 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction aGateOutPort->InPortsSize "
1930 << aGateOutPort->InPortsSize() << " != 1 ERROR " << Name() << endl ;
1932 GraphExecutor::InNode * aLabelNode = NULL ;
1933 for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
1934 const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
1935 aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
1936 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
1937 << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
1938 aLabelNode->SetWaitingStates( this ) ;
1939 // JR 07.01.2005 Debug : Open the Gate of the coupledNode closed by SetWaitingStates
1940 GraphBase::OutPort * anOutPort = aLabelNode->GetChangeNodeInGate()->GetOutPort() ;
1942 CORBA::Any * anAny = new CORBA::Any() ;
1943 *anAny <<= (long ) 1 ;
1944 anOutPort->Value( anAny ) ;
1945 aLabelNode->GetChangeNodeInGate()->State( SUPERV::ReadyState ) ;
1947 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
1948 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
1949 if ( anInPort->GetOutPort() ) {
1950 cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
1951 << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
1955 for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
1956 GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
1957 if ( !aBusParamOutPort->IsGate() ) {
1958 GraphBase::InPort * aBusParamChangeInPort = NULL ;
1959 if ( aBusParamOutPort->IsLoop() ) {
1960 // For EndLoop do not copy EndLoop(DoLoop) in Loop(InLoop)
1961 // aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
1964 aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
1966 if ( aBusParamChangeInPort ) {
1967 aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
1968 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
1969 << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
1970 << aBusParamOutPort->PortName() << endl ;
1976 if ( aLabelNode && !aLabelNode->IsLockedDataWait() ) {
1977 res = aLabelNode->SendSomeDataReady( Name() ) ;
1979 if ( firsttoNode == NULL &&
1980 aLabelNode->ThreadNo() == pthread_self() ) {
1981 firsttoNode = aLabelNode ;
1982 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
1983 << aLabelNode->Name() << endl ;
1985 else if ( firstzeroNode == NULL &&
1986 aLabelNode->ThreadNo() == 0 ) {
1987 firstzeroNode = aLabelNode ;
1990 SomeDataNodes.push_back( aLabelNode ) ;
1991 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1992 << aLabelNode->Name() << " " << SomeDataNodes.size()
1997 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
1998 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
1999 if ( anInPort->GetOutPort() ) {
2000 cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
2001 << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
2005 const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
2006 if ( aGateInPort ) {
2007 if ( aGateInPort->GetOutPort() ) {
2008 aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
2010 if ( !aLabelNode->IsLockedDataWait() ) {
2011 res = aLabelNode->SendSomeDataReady( Name() ) ;
2013 if ( firsttoNode == NULL &&
2014 aLabelNode->ThreadNo() == pthread_self() ) {
2015 firsttoNode = aLabelNode ;
2016 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
2017 << aLabelNode->Name() << endl ;
2019 else if ( firstzeroNode == NULL &&
2020 aLabelNode->ThreadNo() == 0 ) {
2021 firstzeroNode = aLabelNode ;
2024 SomeDataNodes.push_back( aLabelNode ) ;
2025 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
2026 << aLabelNode->Name() << " " << SomeDataNodes.size()
2033 cdebug << pthread_self() << "/" << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
2034 << " NO port " << aGateOutPort->PortName() << " in "
2035 << aLabelNode->Name() << endl;
2041 cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
2042 << " with " << LinkedNodesSize() << " linked nodes :" ;
2043 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2044 if ( LinkedNodes( i )->IsDataFlowNode() ) {
2045 linkednodesnumber -= 1 ;
2047 cdebug << " " << LinkedNodes( i )->Name() ;
2050 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
2051 bool IgnoreForEndLoop = false ;
2052 GraphBase::ComputingNode * aComputingNode ;
2053 aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
2054 toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
2055 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction of " << Name()
2056 << " [" << i << "] " << LinkedNodes( i )->Name() << " toNode " << toNode << " IgnoreForEndLoop "
2057 << IgnoreForEndLoop ;
2059 cdebug << " " << toNode->Kind() << endl ;
2061 if ( toNode && !toNode->IsDataFlowNode() ) {
2062 if ( IsComputingNode() && toNode->IsInLineNode() ) {
2063 GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
2064 toGateInPort->State( SUPERV::ReadyState ) ;
2065 GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
2066 if ( GateOutPort ) {
2067 GateOutPort->PortStatus( DataConnected );
2068 GateOutPort->State( SUPERV::ReadyState ) ;
2069 GateOutPort->Done( true ) ;
2073 if ( toNode && IsLoopNode() ) {
2074 GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
2075 if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
2076 if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
2077 IgnoreForEndLoop = true ;
2079 else { // toNode is the EndLoopNode
2080 GraphBase::InPort * toLoopInPort ;
2081 toLoopInPort = toNode->GetChangeNodeInLoop() ;
2082 if ( toLoopInPort->State() != SUPERV::ReadyState ) {
2083 toLoopInPort->State( SUPERV::ReadyState ) ;
2088 else if ( toNode && IsSwitchNode() ) {
2090 else if ( toNode && toNode->IsInLineNode() ) {
2092 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
2093 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
2096 if ( toNode && !IgnoreForEndLoop ) {
2097 if ( toNode && toNode->IsLoopNode() ) {
2098 GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
2099 toLoopInPort->State( SUPERV::ReadyState ) ;
2100 GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
2101 LoopOutPort->PortStatus( DataConnected );
2102 LoopOutPort->State( SUPERV::ReadyState ) ;
2103 LoopOutPort->Done( true ) ;
2104 CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
2105 *anAny <<= (long ) 1 ;
2106 LoopOutPort->Value( anAny ) ;
2108 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
2109 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
2112 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << toNode->Name() << "->SendSomeDataReady( "
2113 << Name() << " )" << endl ;
2114 res = toNode->SendSomeDataReady( Name() ) ;
2116 if ( firsttoNode == NULL &&
2117 toNode->ThreadNo() == pthread_self() ) {
2118 firsttoNode = toNode ;
2119 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
2120 << toNode->Name() << endl ;
2122 else if ( firstzeroNode == NULL &&
2123 toNode->ThreadNo() == 0 ) {
2124 firstzeroNode = toNode ;
2127 SomeDataNodes.push_back( toNode ) ;
2128 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
2129 << toNode->Name() << " " << SomeDataNodes.size() << endl ;
2136 if ( firsttoNode == NULL && firstzeroNode ) {
2137 firsttoNode = firstzeroNode ;
2138 cdebug << pthread_self() << "/" << ThreadNo()
2139 << " Successed_SuccessAction firsttoNode = firstzeroNode "
2142 else if ( firsttoNode && firstzeroNode ) {
2143 SomeDataNodes.push_back( firstzeroNode ) ;
2144 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode "
2145 << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ;
2148 cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " firsttoNode " << firsttoNode
2149 << " firstzeroNode " << firstzeroNode << endl ;
2152 while ( SomeDataNodes.size() ) {
2153 GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
2154 SomeDataNodes.pop_front() ;
2155 // cdebug << pthread_self() << "/" << ThreadNo()
2156 // << " Successed_SuccessAction pop "
2157 // << SomeDataNodes.size() << " " << aNode->Name() << endl ;
2158 if ( aNode->State() == GraphExecutor::DataReadyState ) {
2159 aNode->CreateNewThreadIf( true ) ;
2160 aNode->UnLockDataWait() ;
2161 res = aNode->DataUndef_AllDataReadyAction() ;
2164 // cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
2165 // << aNode->Name() << " "
2166 // << Automaton()->StateName( aNode->State() ) << endl ;
2170 if ( firsttoNode ) {
2171 // cdebug << pthread_self() << "/" << ThreadNo()
2172 // << " Successed_SuccessAction start firsttoNode "
2173 // << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
2174 firsttoNode->CreateNewThreadIf( false ) ;
2175 firsttoNode->RewindStack( RewindStack() ) ;
2176 if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
2177 // cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
2178 // << " : " << firsttoNode->Name() << " "
2179 // << Automaton()->StateName( firsttoNode->State() )
2180 // << " --> DataWaitingState for Thread "
2181 // << firsttoNode->ThreadNo() << endl ;
2182 firsttoNode->State( GraphExecutor::DataWaitingState ) ;
2184 // pthread_t OldT = firsttoNode->ThreadNo() ;
2185 firsttoNode->ThreadNo( pthread_self() ) ;
2186 // On continue avec le meme thread
2187 // cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
2188 // << firsttoNode->Name() << "Thread(" << OldT << "-->"
2189 // << firsttoNode->ThreadNo() << ")" << endl ;
2191 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
2192 // << " for " << firsttoNode->Name()
2193 // << " !firsttoNode->CreateNewThreadIf() "
2194 // << !firsttoNode->CreateNewThreadIf()
2195 // << " " << Automaton()->StateName( firsttoNode->State() ) ;
2196 if ( firsttoNode->State() == GraphExecutor::DataReadyState ) {
2198 firsttoNode->UnLockDataWait() ;
2199 res = firsttoNode->DataUndef_AllDataReadyAction() ;
2202 cdebug << " ERROR " << endl ;
2206 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
2207 // << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
2211 // if ( linkednodesnumber == 0 && firsttoNode == NULL ) {
2212 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodesSize " << LinkedNodesSize()
2213 // << " firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << " CHECK" << endl ;
2214 // _OutNode->CheckAllDone() ;
2217 // cdebug << pthread_self() << "/" << ThreadNo()
2218 // << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
2219 // << linkednodesnumber << endl;
2223 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
2224 bool RetVal = false ;
2225 if ( IsDataFlowNode() ) {
2226 cdebug << ThreadNo() << "InNode::SendSomeDataReady ----> " << Name()
2227 << " send Result to graph " << Name() << endl;
2230 // cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
2231 // << " send SomeDataReady to " << Name() << " "
2232 // << Automaton()->StateName( State() )
2233 // << " CreateNewThreadIf() " << CreateNewThreadIf()
2234 // << " LockedDataWait " << IsLockedDataWait() << endl;
2236 //cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
2237 << " send SomeDataReady to " << Name() << " "
2238 << Automaton()->StateName( State() )
2239 << " CreateNewThreadIf() " << CreateNewThreadIf()
2240 << " LockedDataWait " << IsLockedDataWait() << endl;
2242 if ( State() == GraphExecutor::SuccessedState ||
2243 State() == GraphExecutor::SuspendedSuccessedState ||
2244 State() == GraphExecutor::SuspendedSuccessedToReStartState ) {
2245 // cdebug << ThreadNo() << " " << FromNodeName
2246 // << " : " << Name() << " " << Automaton()->StateName( State() )
2247 // << " --> DataWaitingState for Thread "
2248 // << ThreadNo() << " " << endl ;
2249 State( GraphExecutor::DataWaitingState ) ;
2251 // We begin that LoopNode if SendSomeDataReady does not come from the corresponding EndLoopNode
2252 if ( IsLoopNode() && strcmp( LoopNode()->CoupledNodeName() , FromNodeName ) ) {
2253 cdebug << ThreadNo() << "InNode::SendSomeDataReady " << Name() << " Set _InitLoop from "
2254 << FromNodeName << endl ;
2258 DataFromNode( FromNodeName ) ;
2259 RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
2267 int GraphExecutor::InNode::Errored_ErrorAction() {
2268 cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
2269 << " will pthread_exit" << endl;
2274 int GraphExecutor::InNode::Successed_SuspendAction() {
2275 cdebug << ThreadNo() << " Successed_SuspendAction -->Suspend " << Name()
2276 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
2277 << _OutNode->SuspendedThreads() << endl;
2278 _OutNode->PushEvent( this , GraphExecutor::SuspendedSuccessedEvent ,
2279 GraphExecutor::SuspendedSuccessedState ) ;
2281 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
2282 cdebug << ThreadNo() << " Successed_SuspendAction Resumed " << Name() ;
2283 if ( aReStartNode ) {
2284 _aReStartNode = NULL ;
2285 cdebug << " for " << aReStartNode->Name() << endl;
2286 aReStartNode->SendEvent( _aReStartEvent ) ;
2290 SendEvent( GraphExecutor::ResumeEvent ) ;
2295 int GraphExecutor::InNode::Errored_SuspendAction() {
2296 cdebug << ThreadNo() << " Errored_SuspendAction -->Suspend " << Name()
2297 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
2298 << _OutNode->SuspendedThreads() << endl;
2299 _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
2300 GraphExecutor::SuspendedErroredState ) ;
2302 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
2303 cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
2305 if ( aReStartNode ) {
2306 _aReStartNode = NULL ;
2307 aReStartNode->SendEvent( _aReStartEvent ) ;
2310 SendEvent( GraphExecutor::ResumeEvent ) ;
2315 int GraphExecutor::InNode::SuspendedSuccessed_ResumeAction() {
2316 cdebug << ThreadNo() << " SuspendedSuccessed_ResumeAction " << Name() << endl;
2318 _OutNode->PushEvent( this , GraphExecutor::ResumedSuccessedEvent ,
2319 GraphExecutor::ResumedSuccessedState ) ;
2320 SendEvent( ResumedSuccessedEvent ) ;
2324 int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
2325 cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
2327 _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
2328 GraphExecutor::ResumedErroredState ) ;
2329 SendEvent( ResumedErroredEvent ) ;
2333 int GraphExecutor::InNode::Successed_KillAction() {
2335 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2336 GraphExecutor::KilledSuccessedState ) ;
2337 cdebug << ThreadNo() << " Successed_KillAction " << Name() << endl;
2341 int GraphExecutor::InNode::Errored_KillAction() {
2343 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2344 GraphExecutor::KilledErroredState ) ;
2345 cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
2349 int GraphExecutor::InNode::Successed_StopAction() {
2351 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2352 GraphExecutor::StoppedSuccessedState ) ;
2353 cdebug << ThreadNo() << " Successed_StopAction " << Name() << endl;
2357 int GraphExecutor::InNode::Errored_StopAction() {
2359 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2360 GraphExecutor::StoppedErroredState ) ;
2361 cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
2365 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
2366 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2367 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2368 GraphExecutor::ReStartedState ) ;
2370 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2371 GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
2373 SendEvent( ExecuteEvent ) ;
2374 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2378 int GraphExecutor::InNode::SuspendedErrored_ReStartAction() {
2379 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2380 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2381 GraphExecutor::ReStartedState ) ;
2383 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2384 GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
2386 SendEvent( ExecuteEvent ) ;
2387 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2391 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAndSuspendAction() {
2392 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2394 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2395 GraphExecutor::ReStartedState ) ;
2396 State( GraphExecutor::DataWaitingState ) ;
2398 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2401 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2402 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2406 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2411 int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
2412 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2414 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2415 GraphExecutor::ReStartedState ) ;
2416 State( GraphExecutor::DataWaitingState ) ;
2418 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2421 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2422 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2426 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2431 void GraphExecutor::InNode::InParametersSet( bool & Err ,
2433 ServicesAnyData * InParametersList ) {
2435 cdebug << ThreadNo() << " InParametersSet " << Name() << endl ;
2436 for ( i = 0 ; i < nInParams ; i++ ) {
2437 ServicesAnyData D = InParametersList[i];
2438 GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
2439 GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
2440 if ( anInPort->IsGate() && theOutPort == NULL ) {
2441 cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
2442 << anInPort->GetServicesParameter().Parametertype
2443 << " is inactive. " << anInPort->Kind() << endl ;
2445 else if ( anInPort->State() == SUPERV::ReadyState ) {
2446 if ( anInPort->IsGate() ) {
2447 CORBA::Any * anAny = new CORBA::Any() ;
2448 *anAny <<= (long ) 0 ;
2449 theOutPort->Value( anAny ) ;
2451 if ( !anInPort->IsDataStream() &&
2452 !anInPort->IsDataConnected() ) {
2453 anInPort->State( SUPERV::WaitingState ) ;
2455 D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
2456 cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind()
2457 << " " << anInPort->State() ;
2458 cdebug << " " << D.Name << " " << anInPort->GetServicesParameter().Parametertype << " : " ;
2459 D.Value = *theOutPort->Value() ; // CORBA::Any
2460 string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
2461 const char * Type = _Type.c_str() ;
2462 switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
2463 case CORBA::tk_string:
2466 cdebug << t << " (string)" ;
2467 if ( !strcmp( Type , "string" ) ) {
2469 else if ( !strcmp( Type , "boolean" ) ) {
2472 sscanf( t , "%ld" , &d ) ;
2474 D.Value <<= (CORBA::Any::from_boolean ) b ;
2475 // theOutPort->Value( D.Value ) ;
2477 else if ( !strcmp( Type , "char" ) ) {
2480 sscanf( t , "%ld" , &d ) ;
2482 D.Value <<= (CORBA::Any::from_char ) c ;
2483 cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
2484 // theOutPort->Value( D.Value ) ;
2486 else if ( !strcmp( Type , "short" ) ) {
2489 sscanf( t , "%ld" , &d ) ;
2492 cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
2493 // theOutPort->Value( D.Value ) ;
2495 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2497 sscanf( t , "%ld" , &l ) ;
2499 cdebug << "string '" << t << " --> long " << l ;
2500 // theOutPort->Value( D.Value ) ;
2502 else if ( !strcmp( Type , "float" ) ) {
2504 sscanf( t , "%lf" , &d ) ;
2507 cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
2508 << setw(25) << setprecision(18) << f ;
2509 // theOutPort->Value( D.Value ) ;
2511 else if ( !strcmp( Type , "double" ) ) {
2513 sscanf( t , "%lf" , &d ) ;
2515 cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
2516 // theOutPort->Value( D.Value ) ;
2518 // else if ( !strcmp( Type , "objref" ) ) {
2520 CORBA::Object_ptr ObjRef ;
2522 ObjRef = StringToObject( t ) ;
2523 D.Value <<= ObjRef ;
2526 D.Value <<= CORBA::Object::_nil() ;
2528 // theOutPort->Value( D.Value ) ;
2531 // cdebug << " (other ERROR)" << endl ;
2533 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2535 case CORBA::tk_long:
2538 cdebug << l << " (long)" << endl ;
2539 if ( !strcmp( Type , "string" ) ) {
2541 sprintf( t , "%ld" , l ) ;
2543 // theOutPort->Value( D.Value ) ;
2545 else if ( !strcmp( Type , "boolean" ) ) {
2548 D.Value <<= (CORBA::Any::from_boolean ) b ;
2549 // theOutPort->Value( D.Value ) ;
2551 else if ( !strcmp( Type , "char" ) ) {
2553 c = (unsigned char ) l ;
2554 D.Value <<= (CORBA::Any::from_char ) c ;
2555 // theOutPort->Value( D.Value ) ;
2557 else if ( !strcmp( Type , "short" ) ) {
2561 // theOutPort->Value( D.Value ) ;
2563 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2565 else if ( !strcmp( Type , "float" ) ) {
2569 // theOutPort->Value( D.Value ) ;
2571 else if ( !strcmp( Type , "double" ) ) {
2575 // theOutPort->Value( D.Value ) ;
2577 // else if ( !strcmp( Type , "objref" ) ) {
2579 D.Value <<= CORBA::Object::_nil() ;
2580 // theOutPort->Value( D.Value ) ;
2583 // cdebug << " (other ERROR)" << endl ;
2585 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2587 case CORBA::tk_double:
2590 cdebug << d << " (double)" << endl ;
2591 if ( !strcmp( Type , "string" ) ) {
2593 sprintf( t , "%lf" , d ) ;
2595 // theOutPort->Value( D.Value ) ;
2597 else if ( !strcmp( Type , "boolean" ) ) {
2600 D.Value <<= (CORBA::Any::from_boolean ) b ;
2601 // theOutPort->Value( D.Value ) ;
2603 else if ( !strcmp( Type , "char" ) ) {
2605 c = (unsigned char ) d ;
2606 D.Value <<= (CORBA::Any::from_char ) c ;
2607 // theOutPort->Value( D.Value ) ;
2609 else if ( !strcmp( Type , "short" ) ) {
2613 // theOutPort->Value( D.Value ) ;
2615 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2619 // theOutPort->Value( D.Value ) ;
2621 else if ( !strcmp( Type , "float" ) ) {
2625 // theOutPort->Value( D.Value ) ;
2627 else if ( !strcmp( Type , "double" ) ) {
2629 // else if ( !strcmp( Type , "objref" ) ) {
2631 D.Value <<= CORBA::Object::_nil() ;
2632 // theOutPort->Value( D.Value ) ;
2635 // cdebug << " (other ERROR)" << endl ;
2637 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2639 case CORBA::tk_objref:
2640 if ( !strcmp( Type , "string" ) ) {
2641 CORBA::Object_ptr ObjRef ;
2644 D.Value >>= ObjRef ;
2645 retstr = ObjectToString( ObjRef ) ;
2646 D.Value <<= retstr ;
2647 // theOutPort->Value( D.Value ) ;
2653 cdebug << "ToString( object ) Catched ERROR" << endl ;
2656 else if ( !strcmp( Type , "boolean" ) ) {
2658 D.Value <<= (CORBA::Any::from_boolean ) b ;
2659 // theOutPort->Value( D.Value ) ;
2661 else if ( !strcmp( Type , "char" ) ) {
2662 unsigned char c = 0 ;
2663 D.Value <<= (CORBA::Any::from_char ) c ;
2664 // theOutPort->Value( D.Value ) ;
2666 else if ( !strcmp( Type , "short" ) ) {
2669 // theOutPort->Value( D.Value ) ;
2671 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2674 // theOutPort->Value( D.Value ) ;
2676 else if ( !strcmp( Type , "float" ) ) {
2679 // theOutPort->Value( D.Value ) ;
2681 else if ( !strcmp( Type , "double" ) ) {
2684 // theOutPort->Value( D.Value ) ;
2686 // else if ( !strcmp( Type , "objref" ) ) {
2688 CORBA::Object_ptr obj ;
2692 retstr = ObjectToString( obj ) ;
2693 cdebug << retstr << endl ;
2699 cdebug << "ToString( object ) Catched ERROR" << endl ;
2703 // cdebug << " (other ERROR)" << endl ;
2705 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2708 cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
2712 cdebug << ThreadNo() << " In" << i << " : wrong state ERROR State "
2713 << anInPort->State() << " NameState "
2714 << Automaton()->StateName( anInPort->State() ) << " PortName "
2715 << anInPort->PortName() << " Parametername "
2716 << anInPort->GetServicesParameter().Parametername << endl ;
2719 InParametersList[i] = D ;
2723 void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
2724 ServicesAnyData * OutParametersList ) {
2726 for ( i = 0 ; i < nOutParams ; i++ ) {
2727 ServicesAnyData D = OutParametersList[i] ;
2729 D.Name = GetChangeNodeOutPort(i)->GetServicesParameter().Parametername;
2730 string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
2731 const char * Type = _Type.c_str() ;
2732 bool OutDone = GetChangeNodeOutPort(i)->Done() ;
2733 cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " Done("
2734 << OutDone << ") " << Type << " : " << endl ;
2735 if ( !strcmp( Type , "string" ) ) {
2736 D.Value <<= (char *) NULL ;
2738 else if ( !strcmp( Type , "boolean" ) ) {
2740 D.Value <<= (CORBA::Any::from_boolean ) b ;
2742 else if ( !strcmp( Type , "char" ) ) {
2743 unsigned char c = 0 ;
2744 D.Value <<= (CORBA::Any::from_char ) c ;
2746 else if ( !strcmp( Type , "short" ) ) {
2750 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2751 D.Value <<= (long ) 0 ;
2753 else if ( !strcmp( Type , "float" ) ) {
2757 else if ( !strcmp( Type , "double" ) ) {
2762 D.Value <<= CORBA::Object::_nil() ;
2765 switch (D.Value.type()->kind()) { // { string , long , double , objref }
2766 case CORBA::tk_string:
2769 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
2771 case CORBA::tk_boolean:
2773 D.Value >>= (CORBA::Any::to_boolean ) b;
2774 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
2776 case CORBA::tk_char:
2778 D.Value >>= (CORBA::Any::to_char ) c;
2779 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
2781 case CORBA::tk_short:
2784 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
2786 case CORBA::tk_long:
2789 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
2791 case CORBA::tk_float:
2794 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
2796 case CORBA::tk_double:
2799 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
2801 case CORBA::tk_objref:
2803 CORBA::Object_ptr obj ;
2806 retstr = ObjectToString( obj ) ;
2807 cdebug << ThreadNo() << retstr << endl ;
2810 cdebug << "ToString( object ) Catched ERROR" << endl ;
2814 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
2817 OutParametersList[i] = D ;
2821 bool GraphExecutor::InNode::OutParametersSet( bool Err ,
2822 SUPERV::GraphState NewState ,
2824 ServicesAnyData * OutParametersList ) {
2825 bool RetVal = true ;
2827 GraphBase::OutPort * aGateOutPort = NULL ;
2828 bool OrSwitch = false ;
2829 cdebug_in << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState "
2830 << NewState << endl ;
2831 // cout << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState " << NewState << endl ;
2832 if ( nOutParams && !IsMacroNode() ) {
2833 GraphBase::OutPort * anOutPort ;
2834 for ( i = 0 ; i < nOutParams ; i++ ) {
2835 anOutPort = GetChangeNodeOutPort(i) ;
2837 anOutPort->State( NewState ) ;
2838 anOutPort->Done( true ) ;
2841 cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
2842 << anOutPort->PortName() << " " << anOutPort->Kind() ;
2843 ServicesAnyData D = OutParametersList[i] ;
2844 switch (D.Value.type()->kind()) { // { string , long , double , objref }
2845 case CORBA::tk_string: {
2848 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
2851 case CORBA::tk_boolean: {
2853 D.Value >>= (CORBA::Any::to_boolean ) b;
2854 long l = (long ) b ;
2856 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
2859 case CORBA::tk_char: {
2861 D.Value >>= (CORBA::Any::to_char ) c;
2862 long l = (long ) c ;
2864 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
2867 case CORBA::tk_short: {
2870 long l = (long ) s ;
2872 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
2875 case CORBA::tk_long: {
2878 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
2881 case CORBA::tk_float: {
2884 double d = (double ) f ;
2886 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
2889 case CORBA::tk_double: {
2892 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
2895 case CORBA::tk_objref: {
2897 CORBA::Object_ptr obj ;
2900 retstr = ObjectToString( obj ) ;
2901 cdebug << ThreadNo() << retstr << endl ;
2904 cdebug << "ToString( object ) Catched ERROR" << endl ;
2909 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
2912 OutParametersList[i] = D ;
2913 if ( !anOutPort->IsDataStream() ) {
2914 if ( anOutPort->IsGate() ) {
2915 aGateOutPort = anOutPort ;
2916 cdebug << " Gate " ;
2918 OutParametersList[i].Value <<= l;
2919 anOutPort->Value( OutParametersList[i].Value );
2921 else if ( anOutPort->IsLoop() ) {
2922 cdebug << " Loop " ;
2923 anOutPort->Value( OutParametersList[i].Value );
2924 // InLoop Port of EndLoopNode is ready :
2925 anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
2927 else if ( anOutPort->IsSwitch() ) {
2928 cdebug << " Switch " ;
2929 anOutPort->Value( OutParametersList[i].Value );
2930 if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
2931 if ( OrSwitch && anOutPort->BoolValue() ) {
2932 cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true ERROR"
2937 OrSwitch = OrSwitch | anOutPort->BoolValue() ;
2938 cdebug << "InNodeThreads::OutParameters OrSwitch = true" << endl ;
2941 cdebug << "OutParametersSet OrSwitch " << OrSwitch ;
2944 cdebug << " Param " ;
2945 anOutPort->Value( OutParametersList[i].Value );
2947 anOutPort->State( NewState ) ;
2948 anOutPort->Done( true ) ;
2951 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
2952 bool fromGOTO = false ;
2953 const char * ToNodeName = anOutPort->ChangeInPorts( j )->NodeName() ;
2954 if ( !strcmp( ToNodeName , _OutNode->Graph()->Name() ) && _OutNode->Graph()->GraphMacroLevel() != 0 ) {
2955 cdebug << "OutParametersSet ToNodeName " << _OutNode->Graph()->Name() << " CoupledNode "
2956 << _OutNode->Graph()->CoupledNodeName() << _OutNode->Graph()->CoupledNode()
2958 cdebug << " GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
2959 _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor()->OutputOfAny( _OutNode->Graph()->CoupledNodeName() ,
2960 anOutPort->ChangeInPorts( j )->PortName() ,
2961 *anOutPort->Value() ) ;
2964 GraphBase::ComputingNode * ToNode = _OutNode->Graph()->GetChangeGraphNode( ToNodeName ) ;
2966 // cout << "OutParametersSet ToNodeName " << ToNodeName << endl ;
2967 cdebug << "OutParametersSet ToNodeName " << ToNodeName << " " << ToNode->Name() << endl ;
2968 GraphBase::OutPort * aGOTOPort = ToNode->GetChangeNodeInGate()->GetOutPort() ;
2970 fromGOTO = aGOTOPort->IsGOTO() ;
2972 if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
2973 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
2974 << anOutPort->ChangeInPorts( j )->PortName() << ","
2975 << anOutPort->ChangeInPorts( j )->Kind() << ") WILL BE changed from "
2976 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
2978 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
2979 << ") to " << anOutPort->NodeName() << "("
2980 << anOutPort->PortName() << ")" << endl ;
2981 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2984 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
2985 << anOutPort->ChangeInPorts( j )->PortName() << ","
2986 << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
2987 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
2989 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
2990 << ") to " << anOutPort->NodeName() << "("
2991 << anOutPort->PortName() << ")" << endl ;
2997 switch (anOutPort->Value()->type()->kind()) {
2998 case CORBA::tk_string:
3000 (*anOutPort->Value()) >>= t;
3001 cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
3003 case CORBA::tk_boolean:
3005 (*anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
3006 cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
3008 case CORBA::tk_char:
3010 (*anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
3011 cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
3013 case CORBA::tk_short:
3015 (*anOutPort->Value()) >>= s;
3016 cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
3018 case CORBA::tk_long:
3020 (*anOutPort->Value()) >>= l;
3021 cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
3023 case CORBA::tk_float:
3025 (*anOutPort->Value()) >>= f;
3026 cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
3028 case CORBA::tk_double:
3030 (*anOutPort->Value()) >>= d;
3031 cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
3033 case CORBA::tk_objref:
3034 CORBA::Object_ptr obj ;
3037 (*anOutPort->Value()) >>= obj ;
3038 retstr = ObjectToString( obj );
3039 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
3043 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
3044 << "Catched ERROR" << endl ;
3048 cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
3054 if ( aGateOutPort && IsSwitchNode() ) {
3056 cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
3057 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
3059 OutParametersList[0].Value <<= l ;
3060 aGateOutPort->Value( OutParametersList[0].Value ) ;
3063 cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
3064 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
3066 OutParametersList[0].Value <<= l ;
3067 aGateOutPort->Value( OutParametersList[0].Value ) ;
3069 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
3070 GraphBase::InPort * anInPort ;
3071 anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
3073 anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
3079 cdebug_out << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState "
3080 << NewState << " RetVal " << RetVal << endl ;