1 // SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowBase_InNodeThreads.cxx
25 // Author : Jean Rahuel, CEA
40 #include <SALOMEconfig.h>
41 #include CORBA_CLIENT_HEADER(SALOME_Component)
42 //#include "SALOME_NamingService.hxx"
43 #include "SALOME_LifeCycleCORBA.hxx"
45 //#include "DataFlowExecutor_InNode.hxx"
47 #include "DataFlowExecutor_OutNode.hxx"
49 //static char *containerName = "FactoryServer" ;
51 int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {
53 _CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
54 cdebug << pthread_self() << "/" << ThreadNo() << " -->SendEvent Node " << Name()
56 << Automaton()->ControlStateName( ControlState() )
57 << " Event : " << Automaton()->EventName( anEvent )
58 << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack << endl;
61 _NextState = Automaton()->NextState( _OldState , anEvent ) ;
62 if ( _NextState == _OldState ) {
63 cdebug << pthread_self() << "/" << ThreadNo()
64 << " GraphExecutor::InNodeThreads::SendEvent SameStates "
65 << _OldState << endl ;
66 _NextAction = GraphExecutor::VoidAction ;
69 _NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
72 // State( _NextState ) ;
73 // if ( _OldState == SUPERV::SuccessedExecutingState ||
74 // _OldState == SUPERV::ErroredExecutingState ) {
78 cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
79 << Name() << endl << " ControlState : "
80 << Automaton()->ControlStateName( ControlState() ) << endl
81 << " OldState : " << Automaton()->StateName( _OldState ) << endl
82 << " Event : " << Automaton()->EventName( anEvent ) << endl
83 << " NextState : " << Automaton()->StateName( _NextState ) << endl
84 << " Action : " << Automaton()->ActionName( _NextAction ) << endl
85 << " CreateNewThread " << CreateNewThread() << endl
86 << " _RewindStack " << _RewindStack << endl ;
89 cout << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
90 << endl << " ControlState : "
91 << Automaton()->ControlStateName( ControlState() ) << endl
92 << " OldState : " << Automaton()->StateName( _OldState ) << endl
93 << " Event : " << Automaton()->EventName( anEvent ) << endl
94 << " NextState : " << Automaton()->StateName( _NextState ) << endl
95 << " Action : " << Automaton()->ActionName( _NextAction ) << endl
96 << " CreateNewThread " << CreateNewThread() << endl ;
99 int sts = executeAction() ;
101 cdebug << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
102 << " Event : " << Automaton()->EventName( anEvent )
103 << " State : " << Automaton()->StateName( State() )
110 // ReadyAction - RunningAction - DoneAction - SuspendedAction :
111 // for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
112 void GraphExecutor::InNode::ReadyAction() {
113 if ( pthread_mutex_lock( &_MutexWait ) ) {
114 perror("Ready pthread_mutex_lock ") ;
117 cdebug << pthread_self() << "/" << ThreadNo()
118 << "ReadyAction pthread_cond_broadcast _ReadyWait "
120 if ( pthread_cond_broadcast( &_ReadyWait ) ) {
121 perror("Ready pthread_cond_broadcast ") ;
123 if ( pthread_mutex_unlock( &_MutexWait ) ) {
124 perror("Ready pthread_mutex_unlock ") ;
129 void GraphExecutor::InNode::RunningAction() {
130 if ( pthread_mutex_lock( &_MutexWait ) ) {
131 perror("Running pthread_mutex_lock ") ;
134 cdebug << pthread_self() << "/" << ThreadNo()
135 << "RunningAction pthread_cond_broadcast _RunningWait "
137 if ( pthread_cond_broadcast( &_RunningWait ) ) {
138 perror("Running pthread_cond_broadcast ") ;
140 if ( pthread_mutex_unlock( &_MutexWait ) ) {
141 perror("Running pthread_mutex_unlock ") ;
146 void GraphExecutor::InNode::DoneAction() {
147 if ( pthread_mutex_lock( &_MutexWait ) ) {
148 perror("Done pthread_mutex_lock ") ;
151 cdebug << pthread_self() << "/" << ThreadNo()
152 << "DoneAction pthread_cond_broadcast _DoneWait "
154 if ( pthread_cond_broadcast( &_DoneWait ) ) {
155 perror("Done pthread_cond_broadcast ") ;
157 if ( pthread_mutex_unlock( &_MutexWait ) ) {
158 perror("Done pthread_mutex_unlock ") ;
163 void GraphExecutor::InNode::SuspendedAction() {
164 if ( pthread_mutex_lock( &_MutexWait ) ) {
165 perror("Suspended pthread_mutex_lock ") ;
168 cdebug << pthread_self() << "/" << ThreadNo()
169 << "SuspendedAction pthread_cond_broadcast _SuspendedWait "
171 if ( pthread_cond_broadcast( &_SuspendedWait ) ) {
172 perror("Suspended pthread_cond_broadcast ") ;
174 if ( pthread_mutex_unlock( &_MutexWait ) ) {
175 perror("Suspended pthread_mutex_unlock ") ;
180 // SuspendAction <--> { ResumeAction - ReStartAction }
181 GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() {
183 if ( pthread_mutex_lock( &_MutexWait ) ) {
184 perror("Suspend pthread_mutex_lock ") ;
187 if ( !_SuspendSync ) {
188 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
189 << " SuspendAction pthread_cond_wait _SuspendWait "
190 << Automaton()->StateName( State() ) << endl ;
191 _SuspendSync = true ;
192 _OutNode->SuspendThread() ;
193 if ( pthread_cond_wait( &_SuspendWait , &_MutexWait ) ) {
194 perror("SuspendAction pthread_cond_wait ") ;
196 _OutNode->ResumeThread() ;
197 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
198 << " SuspendAction pthread_cond_waited"
199 << Automaton()->StateName( State() ) << endl ;
202 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
203 << " NO SuspendAction pthread_cond_wait"
204 << Automaton()->StateName( State() ) << endl ;
206 // SendEvent( _aResumeEvent ) ; ===> Mutex with myself !
207 _SuspendSync = false ;
208 if ( ControlState() == SUPERV::ToSuspendStartState ||
209 ControlState() == SUPERV::ToSuspendState ) {
210 ControlState( SUPERV::VoidState ) ;
212 if ( pthread_mutex_unlock( &_MutexWait ) ) {
213 perror("SuspendAction pthread_mutex_unlock ") ;
217 SendEvent( _aResumeEvent ) ;
218 // if ( ControlState() == SUPERV::ToSuspendStartState ) {
219 // ControlState( SUPERV::VoidState ) ;
222 if ( pthread_mutex_lock( &_MutexWait ) ) {
223 perror("SuspendAction pthread_mutex_lock ") ;
227 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
228 << " SuspendAction pthread_cond_signal _ResumeWait" << endl ;
229 if ( pthread_cond_signal( &_ResumeWait ) ) {
230 perror("SuspendAction pthread_cond_signal _ResumeWait ") ;
232 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
233 << " SuspendAction pthread_cond_signaled _ResumeWait " << endl ;
236 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
237 << " NO SuspendAction pthread_cond_signal _ResumeWait" << endl ;
240 if ( pthread_mutex_unlock( &_MutexWait ) ) {
241 perror("SuspendAction pthread_mutex_unlock ") ;
244 if ( _aReStartNode ) {
245 cdebug << Name() << " " << Automaton()->StateName( State() )
246 << "aReStartNode : " << _aReStartNode->Name() << " "
247 << Automaton()->StateName( _aReStartNode->State() ) << endl ;
248 _aReStartNode->SendEvent( _aResumeEvent ) ;
251 cdebug << "NO aReStartNode"
252 << Automaton()->StateName( State() ) << endl ;
254 return _aReStartNode ;
257 bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent ) {
259 if ( pthread_mutex_lock( &_MutexWait ) ) {
260 perror("ResumeAction pthread_mutex_lock ") ;
263 _aResumeEvent = aResumeEvent ;
264 if ( _SuspendSync ) {
265 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
266 << " ResumeAction pthread_cond_signal" << endl ;
267 if ( pthread_cond_signal( &_SuspendWait ) ) {
268 perror("ResumeAction pthread_cond_signal ") ;
270 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
271 << " ResumeAction pthread_cond_signaled _SuspendWait " << endl ;
275 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
276 << " NO ResumeAction pthread_cond_signal" << endl ;
277 if ( pthread_self() == ThreadNo() ) {
278 RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
281 _SuspendSync = true ;
282 RetVal = true ; // Il faut tout de meme attendre ci-apres ...
285 if ( pthread_mutex_unlock( &_MutexWait ) ) {
286 perror("ResumeAction pthread_mutex_unlock ") ;
291 if ( pthread_mutex_lock( &_MutexWait ) ) {
292 perror("ResumeAction pthread_mutex_lock ") ;
295 if ( !_ResumeSync ) {
296 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
297 << Name() << " ResumeAction pthread_cond_wait _ResumeWait "
298 << Automaton()->StateName( State() ) << endl ;
300 if ( pthread_cond_wait( &_ResumeWait , &_MutexWait ) ) {
301 perror("ResumeAction pthread_cond_wait ") ;
303 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
304 << Name() << " ResumeAction pthread_cond_waited _ResumeWait"
305 << Automaton()->StateName( State() ) << endl ;
309 cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
310 << Name() << " NO ResumeAction pthread_cond_wait _ResumeWait"
311 << Automaton()->StateName( State() ) << endl ;
314 _ResumeSync = false ;
315 if ( pthread_mutex_unlock( &_MutexWait ) ) {
316 perror("ResumeAction pthread_mutex_unlock ") ;
320 cdebug << pthread_self() << "/" << ThreadNo()
321 << "GraphExecutor::InNodeThreads::ResumeAction RetVal " << RetVal << endl ;
325 bool GraphExecutor::InNode::ReStartAction( GraphExecutor::InNode * aReStartNode ,
326 GraphExecutor::NodeEvent anEvent ) {
327 GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
328 _aReStartNode = aReStartNode ;
329 _aReStartEvent = anEvent ;
330 cdebug << pthread_self() << " GraphExecutor::InNodeThreads::ReStartAction from "
331 << Name() << " " << Automaton()->StateName( State() ) << " to "
332 << aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
333 << Automaton()->StateName( aReStartNode->State() ) ;
334 if ( oldReStartNode ) {
335 cdebug << " oldReStartNode " << oldReStartNode->Name() << endl ;
340 return ResumeAction( GraphExecutor::ToReStartEvent ) ;
343 void GraphExecutor::InNode::KilledAction() {
344 if ( pthread_mutex_lock( &_MutexWait ) ) {
345 perror("Killed pthread_mutex_lock ") ;
349 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_wait"
352 if ( pthread_cond_wait( &_KillWait , &_MutexWait ) ) {
353 perror("Killed pthread_cond_wait ") ;
355 cdebug << "pthread_cond " << Name() << " Killed pthread_cond_waited"
359 cdebug << "pthread_cond " << Name() << " NO Killed pthread_cond_wait"
363 if ( pthread_mutex_unlock( &_MutexWait ) ) {
364 perror("Killed pthread_mutex_unlock ") ;
369 void GraphExecutor::InNode::KillAction() {
370 if ( pthread_mutex_lock( &_MutexWait ) ) {
371 perror("Kill pthread_mutex_lock ") ;
375 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signal"
377 // if ( pthread_cond_broadcast( &_KillWait ) ) {
378 if ( pthread_cond_signal( &_KillWait ) ) {
379 perror("Kill pthread_cond_broadcast ") ;
381 cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signaled"
385 cdebug << "pthread_cond " << Name() << " NO Kill pthread_cond_signal"
389 if ( pthread_mutex_unlock( &_MutexWait ) ) {
390 perror("Kill pthread_mutex_unlock ") ;
395 void GraphExecutor::InNode::StoppedAction() {
396 if ( pthread_mutex_lock( &_MutexWait ) ) {
397 perror("Stopped pthread_mutex_lock ") ;
400 if ( pthread_cond_wait( &_StopWait , &_MutexWait ) ) {
401 perror("Stopped pthread_cond_wait ") ;
403 if ( pthread_mutex_unlock( &_MutexWait ) ) {
404 perror("Stopped pthread_mutex_unlock ") ;
409 void GraphExecutor::InNode::StopAction() {
410 if ( pthread_mutex_lock( &_MutexWait ) ) {
411 perror("Stop pthread_mutex_lock ") ;
414 if ( pthread_cond_broadcast( &_StopWait ) ) {
415 perror("Stop pthread_cond_broadcast ") ;
417 if ( pthread_mutex_unlock( &_MutexWait ) ) {
418 perror("Stop pthread_mutex_unlock ") ;
423 void GraphExecutor::InNode::ThreadStartedAction() {
424 if ( pthread_mutex_lock( &_MutexWait ) ) {
425 perror("ThreadStarted pthread_mutex_lock ") ;
428 if ( !_ThreadStartedSync ) {
429 cdebug << "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait"
431 _ThreadStartedSync = true ;
432 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
433 perror("ThreadStarted pthread_cond_wait ") ;
435 cdebug << "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited"
439 cdebug << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait"
442 _ThreadStartedSync = false ;
443 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
444 perror("ThreadStart pthread_cond_signal ") ;
447 cdebug << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled"
450 if ( pthread_mutex_unlock( &_MutexWait ) ) {
451 perror("ThreadStarted pthread_mutex_unlock ") ;
456 void GraphExecutor::InNode::ThreadStartAction() {
457 if ( pthread_mutex_lock( &_MutexWait ) ) {
458 perror("ThreadStart pthread_mutex_lock ") ;
461 if ( _ThreadStartedSync ) {
462 cdebug << "pthread_cond " << Name() << " ThreadStart pthread_cond_signal"
464 _ThreadStartedSync = false ;
465 if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
466 perror("ThreadStart pthread_cond_broadcast ") ;
468 cdebug << "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled"
472 cdebug << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal"
474 _ThreadStartedSync = true ;
476 if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
477 perror("ThreadStarted pthread_cond_wait ") ;
480 cdebug << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited"
483 if ( pthread_mutex_unlock( &_MutexWait ) ) {
484 perror("ThreadStart pthread_mutex_unlock ") ;
489 int GraphExecutor::InNode::executeAction() {
490 int oldRewindStack = ( _RewindStack > 101 ) ;
491 if ( !CreateNewThread() && oldRewindStack ) {
492 cdebug << pthread_self() << "/" << ThreadNo()
493 << " executeAction start Thread _RewindStack " << _RewindStack << " > 101 CreateNewThread "
494 << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
496 CreateNewThread( true ) ;
499 if ( CreateNewThread() ) {
500 CreateNewThread( false ) ;
501 if ( ThreadNo() == 0 ) {
503 cdebug << pthread_self() << "/" << ThreadNo()
504 << " executeAction start Thread _RewindStack " << _RewindStack << " "
505 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
508 int pthread_sts = 1 ;
509 // _OutNode->PushEvent( NULL , GraphExecutor::NewThreadEvent ,
510 // SUPERV::ExecutingState ) ;
511 while ( (pthread_sts = pthread_create(&T, NULL, run_function, this )) ) {
512 char * msg = "Cannot pthread_create " ;
514 cdebug << ThreadNo() << " " << msg << " --> sleep(5)" << endl ;
515 cdebug << ThreadNo() << " PTHREAD_THREADS_MAX : "
516 << PTHREAD_THREADS_MAX << " pthread_create status : " ;
517 if ( pthread_sts == EAGAIN ) {
518 cdebug << "EAGAIN(" << pthread_sts << ")" << endl ;
519 cdebug << "It seems to me that with gdb we are limited to 256 threads because of defunct" << endl ;
522 cdebug << pthread_sts << endl ;
526 pthread_exit( msg ) ;
528 cdebug << pthread_self() << "/" << ThreadNo()
529 << "executeAction has created thread " << T << endl ;
530 ThreadStartedAction() ;
531 cdebug << pthread_self() << "/" << ThreadNo()
532 << "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
536 cdebug << pthread_self() << "/" << ThreadNo()
537 << " executeAction restart Thread _RewindStack " << _RewindStack << " "
538 << Automaton()->StateName( State() ) << " "
539 << Automaton()->ActionName( _NextAction ) << "(" << Name()
540 << ") ReStartAction ==>" << endl;
541 State( SUPERV::SuspendedSuccessedState ) ;
542 if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
543 cdebug << pthread_self() << "/" << ThreadNo()
544 << " executeAction STATE & CALLED "
545 << Automaton()->ActionName( _NextAction ) << "(" << Name()
546 << ") ERROR-DEBUG " << endl;
549 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
550 << Automaton()->ActionName( _NextAction ) << "(" << Name()
556 if ( _CurrentEvent == ExecuteEvent ) {
559 cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
560 << Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
562 return ExecuteAction() ;
567 void GraphExecutor::InNode::coutbegin() {
568 cdebug << ThreadNo() << " " << pthread_self() << " run_function begin"
569 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
571 void GraphExecutor::InNode::coutexit() {
572 cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit _RewindStack " << _RewindStack
573 << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
575 void * run_function(void *p) {
576 GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
578 aNode->NewThread( pthread_self() ) ;
579 if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) {
580 perror("pthread_setcanceltype ") ;
583 if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) {
584 perror("pthread_setcancelstate ") ;
587 aNode->ThreadStartAction() ;
588 aNode->ExecuteAction() ;
589 char * msg = new char[40] ;
590 sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
591 strcat( msg , " thread exit" ) ;
593 aNode->ExitThread() ;
596 pthread_exit( (void * ) smsg.c_str() ) ;
600 int GraphExecutor::InNode::ExecuteAction() {
603 // const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
604 // const char * statename = Automaton()->StateName( State() ) ;
605 // const char * nextstatename = Automaton()->StateName( _NextState ) ;
606 // cdebug << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction "
607 // << nextactionname << " " << statename << " NextState "
608 // << nextstatename << endl ;
610 State( _NextState ) ;
611 switch ( _NextAction ) {
612 case GraphExecutor::ErrorAction : {
613 sts = ErrorAction() ;
616 case GraphExecutor::VoidAction : {
620 case GraphExecutor::DataWaiting_SomeDataReadyAction : {
621 sts = DataWaiting_SomeDataReadyAction() ;
624 case GraphExecutor::DataUndef_NotAllDataReadyAction : {
625 sts = DataUndef_NotAllDataReadyAction() ;
628 case GraphExecutor::DataUndef_AllDataReadyAction : {
629 sts = DataUndef_AllDataReadyAction() ;
632 case GraphExecutor::DataReady_SuspendAction : {
633 sts = DataReady_SuspendAction() ;
636 case GraphExecutor::SuspendedReady_ResumeAction : {
637 sts = SuspendedReady_ResumeAction() ;
640 case GraphExecutor::DataReady_KillAction : {
641 sts = DataReady_KillAction() ;
644 case GraphExecutor::DataReady_StopAction : {
645 sts = DataReady_StopAction() ;
648 case GraphExecutor::DataReady_ExecuteAction : {
649 sts = DataReady_ExecuteAction() ;
652 case GraphExecutor::Executing_SuspendAction : {
653 sts = Executing_SuspendAction() ;
656 case GraphExecutor::SuspendedExecuting_ResumeAction : {
657 sts = SuspendedExecuting_ResumeAction() ;
660 case GraphExecutor::Executing_KillAction : {
661 sts = Executing_KillAction() ;
664 case GraphExecutor::Executing_StopAction : {
665 sts = Executing_StopAction() ;
668 case GraphExecutor::Executing_SuccessAction : {
669 sts = Executing_SuccessAction() ;
672 case GraphExecutor::Executing_ErrorAction : {
673 sts = Executing_ErrorAction() ;
676 case GraphExecutor::Successed_SuccessAction : {
677 sts = Successed_SuccessAction() ;
680 case GraphExecutor::Errored_ErrorAction : {
681 sts = Errored_ErrorAction() ;
684 case GraphExecutor::Successed_SuspendAction : {
685 sts = Successed_SuspendAction() ;
688 case GraphExecutor::Errored_SuspendAction : {
689 sts = Errored_SuspendAction() ;
692 case GraphExecutor::SuspendedSuccessed_ResumeAction : {
693 sts = SuspendedSuccessed_ResumeAction() ;
696 case GraphExecutor::SuspendedErrored_ResumeAction : {
697 sts = SuspendedErrored_ResumeAction() ;
700 case GraphExecutor::Successed_KillAction : {
701 sts = Successed_KillAction() ;
704 case GraphExecutor::Errored_KillAction : {
705 sts = Errored_KillAction() ;
708 case GraphExecutor::Successed_StopAction : {
709 sts = Successed_StopAction() ;
712 case GraphExecutor::Errored_StopAction : {
713 sts = Errored_StopAction() ;
716 case GraphExecutor::SuspendedSuccessed_ReStartAction : {
717 sts = SuspendedSuccessed_ReStartAction() ;
720 case GraphExecutor::SuspendedErrored_ReStartAction : {
721 sts = SuspendedErrored_ReStartAction() ;
724 case GraphExecutor::SuspendedSuccessed_ReStartAndSuspendAction : {
725 sts = SuspendedSuccessed_ReStartAndSuspendAction() ;
728 case GraphExecutor::SuspendedErrored_ReStartAndSuspendAction : {
729 sts = SuspendedErrored_ReStartAndSuspendAction() ;
733 cdebug << pthread_self() << "/" << ThreadNo()
734 << " GraphExecutor::InNodeThreads::SendEvent Error Undefined Action : "
735 << _NextAction << endl ;
739 // cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
740 // << Automaton()->ActionName( nextaction ) << endl ;
744 int GraphExecutor::InNode::ErrorAction() {
745 cdebug << pthread_self() << "/" << ThreadNo() << " Automaton ErrorAction Node "
750 int GraphExecutor::InNode::VoidAction() {
751 cdebug << pthread_self() << "/" << ThreadNo() << " VoidAction " << Name() << endl;
756 int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
757 // cdebug << pthread_self() << "/" << ThreadNo()
758 // << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
759 // << " to " << Name() << endl;
763 bool LoopFinished = false ;
764 bool LoopBeginning = false ;
765 bool SwitchFinished = false ;
767 if ( IsEndLoopNode() && !GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
768 LoopFinished = true ; // End of Loop
770 if ( IsLoopNode() && GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
771 LoopBeginning = true ; // Beginning of Loop
773 if ( IsEndSwitchNode() && !GetChangeNodeInGate()->GetOutPort()->BoolValue() ) {
774 SwitchFinished = true ; // End of Switch
776 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
777 << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << endl ;
778 for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
779 GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
780 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
781 if ( anInPort->IsGate() && anOutPort == NULL ) {
783 anInPort->State( SUPERV::ReadyState ) ;
784 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
785 << anInPort->PortName() << " ControlPort inactive." << endl ;
787 else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
788 if ( anInPort->State() == SUPERV::ReadyState ) {
790 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
791 << anInPort->PortName() << " Was Done from "
792 << anOutPort->NodeName() << " " << anOutPort->PortName()
795 if ( GraphBase::Base::_prof_debug ) {
796 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
801 else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
802 anInPort->State( SUPERV::ReadyState ) ;
804 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
805 << anInPort->PortName() << " Was Done from "
806 << anOutPort->NodeName() << " " << anOutPort->PortName()
807 << " LoopBeginning " << LoopBeginning ;
809 if ( GraphBase::Base::_prof_debug ) {
810 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
815 else if ( LoopFinished ) {
816 anInPort->State( SUPERV::ReadyState ) ;
818 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
819 << anInPort->PortName() << " Was Done from "
820 << anOutPort->NodeName() << " " << anOutPort->PortName()
823 if ( GraphBase::Base::_prof_debug ) {
824 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
829 else if ( anInPort->IsGate() && SwitchFinished ) {
830 anInPort->State( SUPERV::ReadyState ) ;
832 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
833 << anInPort->PortName() << " Was Done from "
834 << anOutPort->NodeName() << " " << anOutPort->PortName()
835 << " SwitchFinished" ;
837 if ( GraphBase::Base::_prof_debug ) {
838 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
844 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
845 << anInPort->PortName() << " Was NOT Done from "
846 << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
847 << " " << Automaton()->StateName( State() ) << " DataConnected "
848 << anInPort->IsDataConnected() << " LoopBeginning "
849 << LoopBeginning << endl ;
852 else if ( anInPort->IsGate() ) {
853 const CORBA::Any * theValue = anOutPort->Value() ;
855 (*theValue) >>= GateOpened ;
856 if ( GateOpened != 0 ) {
858 anInPort->State( SUPERV::ReadyState ) ;
859 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
860 << anInPort->PortName() << " Gate is Opened from "
861 << anOutPort->NodeName() << " " << anOutPort->PortName()
864 if ( GraphBase::Base::_prof_debug ) {
865 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
870 else if ( LoopFinished ) {
871 anInPort->State( SUPERV::ReadyState ) ;
872 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
873 << anInPort->PortName() << " GATE IS CLOSED from "
874 << anOutPort->NodeName() << " " << anOutPort->PortName()
877 if ( GraphBase::Base::_prof_debug ) {
878 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
884 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
885 << anInPort->PortName() << " GATE IS CLOSED from "
886 << anOutPort->NodeName() << " " << anOutPort->PortName()
889 if ( GraphBase::Base::_prof_debug ) {
890 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
898 anInPort->State( SUPERV::ReadyState ) ;
899 cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
900 << anInPort->PortName() << " is Done from "
901 << anOutPort->NodeName() << " " << anOutPort->PortName() << " " ;
903 if ( GraphBase::Base::_prof_debug ) {
904 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
911 if ( InReady == GetNodeInPortsSize() ) { // All Flags != 0 :
912 res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
914 else { // At least one Flag == 0 :
915 res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
918 cdebug << pthread_self() << "/" << ThreadNo()
919 << " <-- DataWaiting_SomeDataReadyAction " << Name() << endl;
924 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
925 CreateNewThreadIf( false ) ;
926 // cdebug << pthread_self() << " for " << ThreadNo()
927 // << " DataUndef_NotAllDataReadyAction " << Name() << endl;
931 int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
932 // cdebug << pthread_self() << "/" << ThreadNo()
933 // << " --> DataUndef_AllDataReadyAction " << Name()
934 // << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
935 // << IsLockedDataWait() ;
936 if ( IsLockedDataWait() ) {
937 // cdebug << " WOULD DEAD-LOCK" << endl ;
938 return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
941 CreateNewThread( CreateNewThreadIf() ) ;
942 if ( !CreateNewThread() ) {
943 // cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
944 ThreadNo( pthread_self() ) ;
946 _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
947 SUPERV::DataReadyState ) ;
949 SUPERV::ControlState aControl = ControlState() ;
950 switch ( aControl ) {
951 case SUPERV::VoidState : {
952 SendEvent( GraphExecutor::ExecuteEvent ) ;
955 case SUPERV::ToSuspendState : {
956 SendEvent( GraphExecutor::SuspendEvent ) ;
959 case SUPERV::ToSuspendStartState : {
960 SendEvent( GraphExecutor::SuspendEvent ) ;
963 case SUPERV::ToSuspendDoneState : {
964 SendEvent( GraphExecutor::ExecuteEvent ) ;
967 case SUPERV::ToKillState : {
968 SendEvent( GraphExecutor::KillEvent ) ;
971 case SUPERV::ToKillDoneState : {
972 SendEvent( GraphExecutor::ExecuteEvent ) ;
975 case SUPERV::ToStopState : {
976 SendEvent( GraphExecutor::StopEvent ) ;
981 << " GraphExecutor::InNodeThreads::DataUndef_AllDataReadyAction Error Undefined Control : "
982 << aControl << endl ;
986 // cdebug << pthread_self() << "/" << ThreadNo()
987 // << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
991 int GraphExecutor::InNode::DataReady_SuspendAction() {
992 cdebug << pthread_self() << "/" << ThreadNo()
993 << "DataReady_SuspendAction --> Suspend " << Name()
994 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
995 << _OutNode->SuspendedThreads() << endl;
996 _OutNode->PushEvent( this , GraphExecutor::SuspendedReadyEvent ,
997 SUPERV::SuspendedReadyState ) ;
998 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
999 cdebug << pthread_self() << "/" << ThreadNo()
1000 << "DataReady_SuspendAction Resumed " << Name() << endl;
1001 if ( aReStartNode ) {
1002 _aReStartNode = NULL ;
1003 aReStartNode->SendEvent( _aReStartEvent ) ;
1006 SendEvent( GraphExecutor::ExecuteEvent ) ;
1011 int GraphExecutor::InNode::SuspendedReady_ResumeAction() {
1012 cdebug << pthread_self() << "/" << ThreadNo() << "SuspendedReady_ResumeAction "
1015 _OutNode->PushEvent( this , GraphExecutor::ResumedReadyEvent ,
1016 SUPERV::ResumedReadyState ) ;
1020 int GraphExecutor::InNode::DataReady_KillAction() {
1021 _OutNode->PushEvent( this , GraphExecutor::KilledReadyEvent ,
1022 SUPERV::KilledReadyState ) ;
1024 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_KillAction " << Name()
1025 << " will pthread_exit()" << endl;
1029 int GraphExecutor::InNode::DataReady_StopAction() {
1030 _OutNode->PushEvent( this , GraphExecutor::StoppedReadyEvent ,
1031 SUPERV::StoppedReadyState ) ;
1033 cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_StopAction " << Name()
1034 << " will pthread_exit()" << endl;
1040 int GraphExecutor::InNode::DataReady_ExecuteAction() {
1043 // cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
1044 // << Name() << endl;
1045 _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
1046 SUPERV::ExecutingState ) ;
1049 SUPERV::GraphState PortState = SUPERV::ReadyState ;
1050 SUPERV::AutomatonState NewState = SUPERV::DataUndefState ;
1051 GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
1055 int nInParams = GetNodeInPortsSize() ;
1056 ServicesAnyData * InParametersList = new ServicesAnyData[nInParams];
1057 InParametersSet( Err , nInParams , InParametersList ) ;
1059 Engines::Container_var myContainer ;
1060 Engines::Component_var myObjComponent ;
1061 if ( !IsFactoryNode() ) {
1062 // cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
1063 if ( IsComputingNode() ) {
1064 ObjInterface( true ) ;
1065 CORBA::Object_ptr obj ;
1066 InParametersList[0].Value >>= obj ;
1067 CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
1068 myObjComponent = Engines::Component::_narrow( objvar ) ;
1073 else if ( CORBA::is_nil( Component() ) ) {
1074 Err = !_OutNode->StartComponent( ThreadNo() , Computer() ,
1075 my_strdup( ComponentName() ) ,
1076 myContainer , myObjComponent ) ;
1077 ObjInterface( false ) ;
1078 SetContainer( myContainer ) ;
1079 SetComponent( myObjComponent ) ;
1082 myContainer = Container() ;
1083 myObjComponent = Component() ;
1084 // cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
1086 myObjComponent->ping() ;
1089 int nOutParams = GetNodeOutPortsSize() ;
1090 ServicesAnyData * OutParametersList = new ServicesAnyData[nOutParams];
1091 InOutParametersSet( nOutParams , OutParametersList ) ;
1093 if ( Err || ControlState() == SUPERV::ToKillState ||
1094 ControlState() == SUPERV::ToKillDoneState ||
1095 ControlState() == SUPERV::ToStopState ) {
1096 cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
1101 cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
1102 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1103 cdebug << " , " << InParametersList[ i ].Name << "[kind"
1104 << InParametersList[ i ].Value.type()->kind() << "]" ;
1106 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1107 cdebug << " , " << OutParametersList[ i ].Name << "[kind"
1108 << OutParametersList[ i ].Value.type()->kind() << "]" ;
1110 if ( IsOneOfInLineNodes() ) {
1111 cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
1112 << InLineNode()->PyRunMethod() << " length " << (*InLineNode()->PythonFunction()).length() ;
1114 cdebug << ")" << endl ;
1116 if ( IsOneOfInLineNodes() ) {
1117 bool StsPyDynInvoke = true;
1118 _OutNode->PyThreadLock() ;
1121 // if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
1122 bool CopyInOut = false ;
1123 if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
1124 strlen( InLineNode()->PyFuncName() ) ) {
1125 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1126 // << InLineNode()->PyFuncName()
1127 // << "' IsInLineNode PyDynInvoke" << endl ;
1128 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1129 InLineNode()->PyFuncName() ,
1130 &InParametersList[0] , ServiceInParameter().length() ,
1131 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1133 else if ( IsLoopNode() ) {
1134 bool CopyOutIn = false ;
1135 if ( GetNodeInLoop()->GetOutPort()->BoolValue() && /*InLineNode()->PyRunMethod() &&*/
1136 strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port
1137 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1138 // << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
1140 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1141 InLineNode()->PyFuncName() ,
1142 &InParametersList[1] , ServiceInParameter().length() ,
1143 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1146 else if ( LoopNode()->PyNextMethod() &&
1147 strlen( LoopNode()->PyNextName() ) ){
1148 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1149 // << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
1151 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
1152 LoopNode()->PyNextName() ,
1153 &InParametersList[1] , ServiceInParameter().length() ,
1154 &OutParametersList[1] , ServiceOutParameter().length() ) ;
1157 if ( StsPyDynInvoke && CopyOutIn ) {
1158 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1159 // << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
1160 // << "' Copy of " << ServiceInParameter().length()
1161 // << " OutParameters" << endl ;
1163 for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
1164 InParametersList[i].Value = OutParametersList[i].Value ;
1165 InParametersList[i].Name = OutParametersList[i].Name ;
1167 switch ( InParametersList[i].Value.type()->kind() ) {
1168 case CORBA::tk_string :
1170 InParametersList[i].Value >>= t ;
1171 cdebug << "ArgOut->In" << i << " : "
1172 << InParametersList[i].Name.c_str()
1173 << " Value(string) " << t << endl ;
1175 case CORBA::tk_double :
1177 InParametersList[i].Value >>= d;
1178 cdebug << "ArgOut->In" << i << " : "
1179 << InParametersList[i].Name.c_str()
1180 << " Value(double) " << d << endl ;
1182 case CORBA::tk_long :
1184 InParametersList[i].Value >>= l;
1185 cdebug << "ArgOut->In" << i << " : "
1186 << InParametersList[i].Name.c_str()
1187 << " Value(long) " << l << endl ;
1189 case CORBA::tk_objref :
1190 CORBA::Object_ptr obj ;
1193 InParametersList[i].Value >>= obj ;
1194 retstr = ObjectToString( obj );
1195 cdebug << "ArgOut->In" << i << " : "
1196 << InParametersList[i].Name.c_str()
1197 << " Value(object reference) " << retstr << endl ;
1200 cdebug << "ArgOut->In" << i << " : "
1201 << InParametersList[i].Name.c_str()
1202 << " Value(object reference) Catched ERROR" << endl ;
1206 cdebug << "ArgOut->In" << i << " : "
1207 << InParametersList[i].Name.c_str()
1208 << " Value(other) ERROR" << endl ;
1212 if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
1213 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
1214 LoopNode()->PyMoreName() ,
1215 &InParametersList[1] , ServiceInParameter().length() ,
1216 &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
1222 else if ( !StsPyDynInvoke ) {
1224 cdebug << ThreadNo() << " InLineNode " << Name() << " "
1225 << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
1226 << " Python Dynamic Call Error"
1230 else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
1231 strlen( InLineNode()->PyFuncName() ) ) {
1232 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1233 // << InLineNode()->PyFuncName()
1234 // << "' IsSwitchNode PyDynInvoke" << endl ;
1235 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1236 InLineNode()->PyFuncName() ,
1237 &InParametersList[0] , ServiceInParameter().length() ,
1238 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1240 // else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
1241 else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
1242 strlen( InLineNode()->PyFuncName() ) ) {
1243 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1244 // << InLineNode()->PyFuncName()
1245 // << "' IsGOTONode PyDynInvoke" << endl ;
1246 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1247 InLineNode()->PyFuncName() ,
1248 &InParametersList[0] , ServiceInParameter().length() ,
1249 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1251 // else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
1252 else if ( ( IsEndSwitchNode() ) &&
1253 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1254 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1255 // << InLineNode()->PyFuncName()
1256 // << "' IsSwitchNode PyDynInvoke" << endl ;
1257 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1258 InLineNode()->PyFuncName() ,
1259 &InParametersList[0] , ServiceInParameter().length() ,
1260 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1262 else if ( ( IsEndLoopNode() ) &&
1263 InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
1264 // cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
1265 // << InLineNode()->PyFuncName()
1266 // << "' IsSwitchNode PyDynInvoke" << endl ;
1267 StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
1268 InLineNode()->PyFuncName() ,
1269 &InParametersList[0] , ServiceInParameter().length() + 1 ,
1270 &OutParametersList[0] , ServiceOutParameter().length() + 1 ) ;
1272 // else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
1273 if ( InLineNode()->PyRunMethod() == NULL ||
1274 strlen( InLineNode()->PyFuncName() ) == 0 || CopyInOut ) {
1275 // cdebug << ThreadNo() << " !ObjInterface " << Name()
1276 // << " Copy of " << ServiceInParameter().length()
1277 // << " OutParameters" << endl ;
1281 if ( IsLoopNode() || IsEndLoopNode() ) {
1283 argin0 = 1 ; // after DoLoop
1284 if ( IsLoopNode() ) {
1285 OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
1288 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1289 OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
1291 switch ( InParametersList[argin0 + i].Value.type()->kind() ) {
1292 case CORBA::tk_string :
1293 cdebug << "ArgOut->In" << argin0 + i << " : "
1294 << InParametersList[argin0 + i].Name.c_str()
1295 << " Value(string) "
1296 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1298 case CORBA::tk_double :
1299 cdebug << "ArgOut->In" << argin0 + i << " : "
1300 << InParametersList[argin0 + i].Name.c_str()
1301 << " Value(double) "
1302 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1304 case CORBA::tk_long :
1305 cdebug << "ArgOut->In" << argin0 + i << " : "
1306 << InParametersList[argin0 + i].Name.c_str()
1308 << OutParametersList[argout0 + i ].Name.c_str() << endl ;
1310 case CORBA::tk_objref :
1311 cdebug << "ArgOut->In" << argin0 + i << " : "
1312 << InParametersList[argin0 + i].Name.c_str()
1313 << " Value(object reference) "
1314 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1317 cdebug << "ArgOut->In" << argin0 + i << " : "
1318 << InParametersList[argin0 + i].Name.c_str()
1319 << " Value(other) ERROR "
1320 << OutParametersList[argout0 + i].Name.c_str() << endl ;
1325 if ( !StsPyDynInvoke ) {
1327 cdebug << ThreadNo() << " InLineNode " << Name()
1328 << " Python Dynamic Call Error"
1334 cdebug << ThreadNo() << " InLineNode " << Name()
1335 << " Python Dynamic Call Exception catched ERROR"
1339 _OutNode->PyThreadUnLock() ;
1344 cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ;
1345 DynInvoke( myObjComponent, "Names" ,
1346 _OutNode->Name() , Name() ) ;
1349 cdebug << "DynInvoke Names catched ERROR" << endl ;
1351 cdebug << ServiceInParameter().length() << " input parameters and "
1352 << ServiceOutParameter().length() << " output parameters" << endl ;
1353 if ( IsComputingNode() ) {
1354 cdebug << ThreadNo() << " !ObjInterface " << Name()
1355 << " IsComputingNode DynInvoke" << endl ;
1356 DynInvoke( myObjComponent,
1358 &InParametersList[1] , ServiceInParameter().length()-1 ,
1359 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1361 else if ( IsFactoryNode() ) {
1362 cdebug << ThreadNo() << " !ObjInterface " << Name()
1363 << " IsFactoryNode DynInvoke" << endl ;
1364 DynInvoke( myObjComponent,
1366 &InParametersList[0] , ServiceInParameter().length() ,
1367 &OutParametersList[0] , ServiceOutParameter().length() ) ;
1369 // cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
1370 // << myObjComponent->CpuUsed_impl() << endl ;
1374 cdebug << ThreadNo() << " !ObjInterface " << Name()
1375 << " Node(Component) Dynamic Call Exception catched ERROR"
1387 if ( ControlState() == SUPERV::ToKillState ||
1388 ControlState() == SUPERV::ToKillDoneState ||
1389 ControlState() == SUPERV::ToStopState ) {
1390 PortState = SUPERV::ErrorState ;
1391 NewState = SUPERV::KilledState ;
1392 NewEvent = GraphExecutor::KillEvent ;
1395 PortState = SUPERV::ErrorState ;
1396 NewState = SUPERV::ErroredState ;
1397 NewEvent = GraphExecutor::ErrorEvent ;
1401 PortState = SUPERV::ReadyState ;
1402 NewState = SUPERV::DataReadyState ;
1403 NewEvent = GraphExecutor::SuccessEvent ;
1406 bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
1409 NewEvent = GraphExecutor::ErrorEvent ;
1412 delete [] InParametersList ;
1413 delete [] OutParametersList ;
1416 SendEvent( NewEvent );
1418 // cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
1422 int GraphExecutor::InNode::Executing_SuspendAction() {
1423 _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
1424 SUPERV::SuspendedExecutingState ) ;
1425 cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
1429 int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
1430 cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
1431 SUPERV::AutomatonState next_state ;
1432 next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
1433 _OutNode->NewThread() ; // Only for Threads count
1434 _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
1436 State( next_state ) ;
1440 int GraphExecutor::InNode::Executing_KillAction() {
1441 cdebug << ThreadNo() << " Executing_KillAction " << Name() << endl;
1443 if ( pthread_self() == ThreadNo() ) {
1444 cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
1446 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
1447 SUPERV::KilledExecutingState ) ;
1450 else if ( pthread_cancel( ThreadNo() ) ) {
1451 perror("Executing_KillAction pthread_cancel error") ;
1454 cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
1455 << " pthread_canceled" << endl ;
1457 _OutNode->ExitThread() ;
1458 _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
1459 SUPERV::KilledExecutingState ) ;
1464 int GraphExecutor::InNode::Executing_StopAction() {
1465 cdebug << ThreadNo() << " Executing_StopAction " << Name() << endl;
1467 if ( pthread_cancel( ThreadNo() ) ) {
1468 perror("Executing_KillAction pthread_cancel error") ;
1471 cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
1472 << " pthread_canceled" << endl ;
1474 _OutNode->ExitThread() ;
1475 _OutNode->PushEvent( this , GraphExecutor::StoppedExecutingEvent ,
1476 SUPERV::StoppedExecutingState ) ;
1481 int GraphExecutor::InNode::Executing_SuccessAction() {
1482 // cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
1483 _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
1484 SUPERV::SuccessedState ) ;
1485 SUPERV::ControlState aControl = ControlState() ;
1486 switch ( aControl ) {
1487 case SUPERV::VoidState : {
1488 SendEvent( SuccessEvent ) ;
1491 case SUPERV::ToSuspendState : {
1492 SendEvent( SuccessEvent ) ;
1495 case SUPERV::ToSuspendDoneState : {
1496 SendEvent( GraphExecutor::SuspendEvent ) ;
1499 case SUPERV::ToKillState : {
1500 SendEvent( GraphExecutor::KillEvent ) ;
1503 case SUPERV::ToKillDoneState : {
1504 SendEvent( GraphExecutor::KillEvent ) ;
1507 case SUPERV::ToStopState : {
1508 SendEvent( GraphExecutor::StopEvent ) ;
1512 cdebug << ThreadNo()
1513 << " GraphExecutor::InNodeThreads::Executing_SuccessAction Error Undefined Control : "
1514 << aControl << endl ;
1518 // cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
1522 int GraphExecutor::InNode::Executing_ErrorAction() {
1523 cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
1524 _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
1525 SUPERV::ErroredState ) ;
1527 SUPERV::ControlState aControl = ControlState() ;
1528 switch ( aControl ) {
1529 case SUPERV::VoidState : {
1530 SendEvent( ErrorEvent ) ;
1533 case SUPERV::ToSuspendState : {
1534 SendEvent( ErrorEvent ) ;
1537 case SUPERV::ToSuspendDoneState : {
1538 SendEvent( GraphExecutor::SuspendEvent ) ;
1541 case SUPERV::ToKillState : {
1542 SendEvent( GraphExecutor::KillEvent ) ;
1545 case SUPERV::ToKillDoneState : {
1546 SendEvent( GraphExecutor::KillEvent ) ;
1549 case SUPERV::ToStopState : {
1550 SendEvent( GraphExecutor::StopEvent ) ;
1554 cdebug << ThreadNo()
1555 << " GraphExecutor::InNodeThreads::Executing_ErrorAction Error Undefined Control : "
1556 << aControl << endl ;
1560 cdebug << ThreadNo() << " <-- Executing_ErrorAction " << Name() << endl;
1564 // Set SUPERV::WaitingState to all InPorts
1565 void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
1568 bool docdebug = false ;
1569 State( SUPERV::DataWaitingState ) ;
1570 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1571 GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
1572 if ( anInPort->IsGate() ) { // Loop : Open the doors
1573 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1575 CORBA::Any * anAny = new CORBA::Any() ;
1576 *anAny <<= (long ) 1 ;
1577 anOutPort->Value( anAny ) ;
1578 anInPort->State( SUPERV::ReadyState ) ;
1581 else if ( anInPort->State() != SUPERV::WaitingState ) {
1583 // cdebug << ThreadNo()
1584 // << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
1587 anInPort->State( SUPERV::WaitingState ) ;
1590 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1591 for ( j = 0 ; j < GetChangeNodeOutPort( i )->InPortsSize() ; j++ ) {
1592 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
1593 if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
1594 !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) ) {
1595 GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ;
1596 if ( aNode != EndNode ) {
1597 aNode->SetWaitingStates( EndNode ) ;
1604 int GraphExecutor::InNode::Successed_SuccessAction() {
1605 // cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
1607 int linkednodesnumber = LinkedNodesSize() ;
1608 GraphExecutor::InNode *firstzeroNode = NULL ;
1609 GraphExecutor::InNode *firsttoNode = NULL ;
1610 GraphExecutor::InNode *toNode ;
1613 list<GraphExecutor::InNode *> SomeDataNodes ;
1617 if ( IsGOTONode() ||
1618 ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
1619 const GraphBase::OutPort * aGateOutPort ;
1620 if ( IsGOTONode() ) {
1621 aGateOutPort = GetNodeOutGate() ;
1624 aGateOutPort = GetNodeOutLoop() ;
1626 for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
1627 const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
1628 GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
1629 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
1630 // << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
1631 aLabelNode->SetWaitingStates( this ) ;
1632 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
1633 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
1634 if ( anInPort->GetOutPort() ) {
1635 // cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
1636 // << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
1640 for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
1641 GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
1642 if ( !aBusParamOutPort->IsGate() ) {
1643 GraphBase::InPort * aBusParamChangeInPort = NULL ;
1644 if ( aBusParamOutPort->IsLoop() ) {
1645 aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
1648 aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
1650 if ( aBusParamChangeInPort ) {
1651 aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
1652 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
1653 // << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
1654 // << aBusParamOutPort->PortName() << endl ;
1655 if ( !aLabelNode->IsLockedDataWait() ) {
1656 res = aLabelNode->SendSomeDataReady( Name() ) ;
1658 if ( firsttoNode == NULL &&
1659 aLabelNode->ThreadNo() == pthread_self() ) {
1660 firsttoNode = aLabelNode ;
1661 // cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
1662 // << aLabelNode->Name() << endl ;
1664 else if ( firstzeroNode == NULL &&
1665 aLabelNode->ThreadNo() == 0 ) {
1666 firstzeroNode = aLabelNode ;
1669 SomeDataNodes.push_back( aLabelNode ) ;
1670 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1671 // << aLabelNode->Name() << " " << SomeDataNodes.size()
1677 // cdebug << ThreadNo()
1678 // << " Successed_SuccessAction Loop to HeadNode "
1679 // << aLabelNode->Name() << " with datas from " << Name() << "("
1680 // << aBusParamOutPort->PortName() << ") to port "
1681 // << aBusParamChangeInPort->PortName() << endl;
1685 // cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
1686 // << " NO port " << aBusParamOutPort->PortName() << " in "
1687 // << aLabelNode->Name() << endl;
1691 for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
1692 const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
1693 if ( anInPort->GetOutPort() ) {
1694 // cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
1695 // << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
1699 const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
1700 if ( aGateInPort ) {
1701 if ( aGateInPort->GetOutPort() ) {
1702 aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
1704 if ( !aLabelNode->IsLockedDataWait() ) {
1705 res = aLabelNode->SendSomeDataReady( Name() ) ;
1707 if ( firsttoNode == NULL &&
1708 aLabelNode->ThreadNo() == pthread_self() ) {
1709 firsttoNode = aLabelNode ;
1710 // cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
1711 // << aLabelNode->Name() << endl ;
1713 else if ( firstzeroNode == NULL &&
1714 aLabelNode->ThreadNo() == 0 ) {
1715 firstzeroNode = aLabelNode ;
1718 SomeDataNodes.push_back( aLabelNode ) ;
1719 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1720 // << aLabelNode->Name() << " " << SomeDataNodes.size()
1727 cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
1728 << " NO port " << aGateOutPort->PortName() << " in "
1729 << aLabelNode->Name() << endl;
1735 // cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
1736 // << " with " << LinkedNodesSize() << " linked nodes :" ;
1737 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
1738 if ( LinkedNodes( i )->IsDataFlowNode() ) {
1739 linkednodesnumber -= 1 ;
1741 // cdebug << " " << LinkedNodes( i )->Name() ;
1744 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
1745 bool IgnoreForEndLoop = false ;
1746 toNode = (GraphExecutor::InNode *) LinkedNodes( i )->GetInNode() ;
1747 // cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
1748 // << " [" << i << "] " << LinkedNodes( i )->Name() << endl ;
1749 if ( toNode && !toNode->IsDataFlowNode() ) {
1750 if ( IsComputingNode() && toNode->IsInLineNode() ) {
1751 GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
1752 toGateInPort->State( SUPERV::ReadyState ) ;
1753 GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
1754 if ( GateOutPort ) {
1755 GateOutPort->PortStatus( DataConnected );
1756 GateOutPort->State( SUPERV::ReadyState ) ;
1757 GateOutPort->Done( true ) ;
1761 if ( toNode && IsLoopNode() ) {
1762 GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
1763 if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
1764 if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
1765 IgnoreForEndLoop = true ;
1767 else { // toNode is the EndLoopNode
1768 GraphBase::InPort * toLoopInPort ;
1769 toLoopInPort = toNode->GetChangeNodeInLoop() ;
1770 if ( toLoopInPort->State() != SUPERV::ReadyState ) {
1771 toLoopInPort->State( SUPERV::ReadyState ) ;
1776 else if ( toNode && IsSwitchNode() ) {
1778 else if ( toNode && toNode->IsInLineNode() ) {
1780 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
1781 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
1784 if ( toNode && !IgnoreForEndLoop ) {
1785 if ( toNode && toNode->IsLoopNode() ) {
1786 GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
1787 toLoopInPort->State( SUPERV::ReadyState ) ;
1788 GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
1789 LoopOutPort->PortStatus( DataConnected );
1790 LoopOutPort->State( SUPERV::ReadyState ) ;
1791 LoopOutPort->Done( true ) ;
1792 CORBA::Any * anAny = new CORBA::Any() ;
1793 *anAny <<= (long ) 1 ;
1794 LoopOutPort->Value( anAny ) ;
1796 for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
1797 toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
1800 res = toNode->SendSomeDataReady( Name() ) ;
1802 if ( firsttoNode == NULL &&
1803 toNode->ThreadNo() == pthread_self() ) {
1804 firsttoNode = toNode ;
1805 // cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
1806 // << toNode->Name() << endl ;
1808 else if ( firstzeroNode == NULL &&
1809 toNode->ThreadNo() == 0 ) {
1810 firstzeroNode = toNode ;
1813 SomeDataNodes.push_back( toNode ) ;
1814 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
1815 // << toNode->Name() << " " << SomeDataNodes.size() << endl ;
1822 if ( firsttoNode == NULL && firstzeroNode ) {
1823 firsttoNode = firstzeroNode ;
1824 // cdebug << ThreadNo()
1825 // << " Successed_SuccessAction firsttoNode = firstzeroNode "
1828 else if ( firsttoNode && firstzeroNode ) {
1829 SomeDataNodes.push_back( firstzeroNode ) ;
1830 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode "
1831 // << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ;
1834 while ( SomeDataNodes.size() ) {
1835 GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
1836 SomeDataNodes.pop_front() ;
1837 // cdebug << pthread_self() << "/" << ThreadNo()
1838 // << " Successed_SuccessAction pop "
1839 // << SomeDataNodes.size() << " " << aNode->Name() << endl ;
1840 if ( aNode->State() == SUPERV::DataReadyState ) {
1841 aNode->CreateNewThreadIf( true ) ;
1842 aNode->UnLockDataWait() ;
1843 res = aNode->DataUndef_AllDataReadyAction() ;
1846 // cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
1847 // << aNode->Name() << " "
1848 // << Automaton()->StateName( aNode->State() ) << endl ;
1852 if ( firsttoNode ) {
1853 // cdebug << pthread_self() << "/" << ThreadNo()
1854 // << " Successed_SuccessAction start firsttoNode "
1855 // << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
1856 firsttoNode->CreateNewThreadIf( false ) ;
1857 firsttoNode->RewindStack( RewindStack() ) ;
1858 if ( firsttoNode->State() == SUPERV::SuccessedState ) {
1859 // cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
1860 // << " : " << firsttoNode->Name() << " "
1861 // << Automaton()->StateName( firsttoNode->State() )
1862 // << " --> DataWaitingState for Thread "
1863 // << firsttoNode->ThreadNo() << endl ;
1864 firsttoNode->State( SUPERV::DataWaitingState ) ;
1866 // pthread_t OldT = firsttoNode->ThreadNo() ;
1867 firsttoNode->ThreadNo( pthread_self() ) ;
1868 // On continue avec le meme thread
1869 // cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
1870 // << firsttoNode->Name() << "Thread(" << OldT << "-->"
1871 // << firsttoNode->ThreadNo() << ")" << endl ;
1873 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
1874 // << " for " << firsttoNode->Name()
1875 // << " !firsttoNode->CreateNewThreadIf() "
1876 // << !firsttoNode->CreateNewThreadIf()
1877 // << " " << Automaton()->StateName( firsttoNode->State() ) ;
1878 if ( firsttoNode->State() == SUPERV::DataReadyState ) {
1880 firsttoNode->UnLockDataWait() ;
1881 res = firsttoNode->DataUndef_AllDataReadyAction() ;
1884 cdebug << " ERROR " << endl ;
1888 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
1889 // << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
1893 // if ( linkednodesnumber == 0 && firsttoNode == NULL ) {
1894 // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodesSize " << LinkedNodesSize()
1895 // << " firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << " CHECK" << endl ;
1896 // _OutNode->CheckAllDone() ;
1899 // cdebug << pthread_self() << "/" << ThreadNo()
1900 // << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
1901 // << linkednodesnumber << endl;
1905 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
1906 bool RetVal = false ;
1907 if ( IsDataFlowNode() ) {
1908 // cdebug << ThreadNo() << " ----> " << Name()
1909 // << " send Result to graph " << Name() << endl;
1912 // cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
1913 // << " send SomeDataReady to " << Name() << " "
1914 // << Automaton()->StateName( State() )
1915 // << " CreateNewThreadIf() " << CreateNewThreadIf()
1916 // << " LockedDataWait " << IsLockedDataWait() << endl;
1918 cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
1919 << " send SomeDataReady to " << Name() << " "
1920 << Automaton()->StateName( State() )
1921 << " CreateNewThreadIf() " << CreateNewThreadIf()
1922 << " LockedDataWait " << IsLockedDataWait() << endl;
1924 if ( State() == SUPERV::SuccessedState ||
1925 State() == SUPERV::SuspendedSuccessedState ||
1926 State() == SUPERV::SuspendedSuccessedToReStartState ) {
1927 // cdebug << ThreadNo() << " " << FromNodeName
1928 // << " : " << Name() << " " << Automaton()->StateName( State() )
1929 // << " --> DataWaitingState for Thread "
1930 // << ThreadNo() << " " << endl ;
1931 State( SUPERV::DataWaitingState ) ;
1934 DataFromNode( FromNodeName ) ;
1935 RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
1943 int GraphExecutor::InNode::Errored_ErrorAction() {
1944 cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
1945 << " will pthread_exit" << endl;
1950 int GraphExecutor::InNode::Successed_SuspendAction() {
1951 cdebug << ThreadNo() << " Successed_SuspendAction -->Suspend " << Name()
1952 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
1953 << _OutNode->SuspendedThreads() << endl;
1954 _OutNode->PushEvent( this , GraphExecutor::SuspendedSuccessedEvent ,
1955 SUPERV::SuspendedSuccessedState ) ;
1957 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1958 cdebug << ThreadNo() << " Successed_SuspendAction Resumed " << Name() ;
1959 if ( aReStartNode ) {
1960 _aReStartNode = NULL ;
1961 cdebug << " for " << aReStartNode->Name() << endl;
1962 aReStartNode->SendEvent( _aReStartEvent ) ;
1966 SendEvent( GraphExecutor::ResumeEvent ) ;
1971 int GraphExecutor::InNode::Errored_SuspendAction() {
1972 cdebug << ThreadNo() << " Errored_SuspendAction -->Suspend " << Name()
1973 << " Threads " << _OutNode->Threads() << " SuspendedThreads "
1974 << _OutNode->SuspendedThreads() << endl;
1975 _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
1976 SUPERV::SuspendedErroredState ) ;
1978 GraphExecutor::InNode * aReStartNode = SuspendAction() ;
1979 cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
1981 if ( aReStartNode ) {
1982 _aReStartNode = NULL ;
1983 aReStartNode->SendEvent( _aReStartEvent ) ;
1986 SendEvent( GraphExecutor::ResumeEvent ) ;
1991 int GraphExecutor::InNode::SuspendedSuccessed_ResumeAction() {
1992 cdebug << ThreadNo() << " SuspendedSuccessed_ResumeAction " << Name() << endl;
1994 _OutNode->PushEvent( this , GraphExecutor::ResumedSuccessedEvent ,
1995 SUPERV::ResumedSuccessedState ) ;
1996 SendEvent( ResumedSuccessedEvent ) ;
2000 int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
2001 cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
2003 _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
2004 SUPERV::ResumedErroredState ) ;
2005 SendEvent( ResumedErroredEvent ) ;
2009 int GraphExecutor::InNode::Successed_KillAction() {
2011 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2012 SUPERV::KilledSuccessedState ) ;
2013 cdebug << ThreadNo() << " Successed_KillAction " << Name() << endl;
2017 int GraphExecutor::InNode::Errored_KillAction() {
2019 _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
2020 SUPERV::KilledErroredState ) ;
2021 cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
2025 int GraphExecutor::InNode::Successed_StopAction() {
2027 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2028 SUPERV::StoppedSuccessedState ) ;
2029 cdebug << ThreadNo() << " Successed_StopAction " << Name() << endl;
2033 int GraphExecutor::InNode::Errored_StopAction() {
2035 _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
2036 SUPERV::StoppedErroredState ) ;
2037 cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
2041 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
2042 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2043 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2044 SUPERV::ReStartedState ) ;
2046 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2047 GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
2049 SendEvent( ExecuteEvent ) ;
2050 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
2054 int GraphExecutor::InNode::SuspendedErrored_ReStartAction() {
2055 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2056 _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
2057 SUPERV::ReStartedState ) ;
2059 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
2060 GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
2062 SendEvent( ExecuteEvent ) ;
2063 cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
2067 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAndSuspendAction() {
2068 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2070 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2071 SUPERV::ReStartedState ) ;
2072 State( SUPERV::DataWaitingState ) ;
2074 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2077 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2078 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2082 cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
2087 int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
2088 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2090 _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
2091 SUPERV::ReStartedState ) ;
2092 State( SUPERV::DataWaitingState ) ;
2094 cdebug << "InNode::Suspend() Node " << Name() << endl ;
2097 else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
2098 cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
2102 cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
2107 void GraphExecutor::InNode::InParametersSet( bool & Err ,
2109 ServicesAnyData * InParametersList ) {
2111 for ( i = 0 ; i < nInParams ; i++ ) {
2112 ServicesAnyData D = InParametersList[i];
2113 GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
2114 GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
2115 if ( anInPort->IsGate() && theOutPort == NULL ) {
2116 cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
2117 << anInPort->GetServicesParameter().Parametertype
2118 << " is inactive. " << anInPort->Kind() << endl ;
2120 else if ( anInPort->State() == SUPERV::ReadyState ) {
2121 if ( anInPort->IsGate() ) {
2122 CORBA::Any * anAny = new CORBA::Any() ;
2123 *anAny <<= (long ) 0 ;
2124 theOutPort->Value( anAny ) ;
2126 anInPort->State( SUPERV::WaitingState ) ;
2127 D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
2128 cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() ;
2129 cdebug << " " << D.Name << " " << anInPort->GetServicesParameter().Parametertype << " : " ;
2130 D.Value = *theOutPort->Value() ; // CORBA::Any
2131 string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
2132 const char * Type = _Type.c_str() ;
2133 switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
2134 case CORBA::tk_string:
2137 cdebug << t << " (string)" ;
2138 if ( !strcmp( Type , "string" ) ) {
2140 else if ( !strcmp( Type , "boolean" ) ) {
2143 sscanf( t , "%ld" , &d ) ;
2145 D.Value <<= (CORBA::Any::from_boolean ) b ;
2146 // theOutPort->Value( D.Value ) ;
2148 else if ( !strcmp( Type , "char" ) ) {
2151 sscanf( t , "%ld" , &d ) ;
2153 D.Value <<= (CORBA::Any::from_char ) c ;
2154 cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
2155 // theOutPort->Value( D.Value ) ;
2157 else if ( !strcmp( Type , "short" ) ) {
2160 sscanf( t , "%ld" , &d ) ;
2163 cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
2164 // theOutPort->Value( D.Value ) ;
2166 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2168 sscanf( t , "%ld" , &l ) ;
2170 cdebug << "string '" << t << " --> long " << l ;
2171 // theOutPort->Value( D.Value ) ;
2173 else if ( !strcmp( Type , "float" ) ) {
2175 sscanf( t , "%lf" , &d ) ;
2178 cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
2179 << setw(25) << setprecision(18) << f ;
2180 // theOutPort->Value( D.Value ) ;
2182 else if ( !strcmp( Type , "double" ) ) {
2184 sscanf( t , "%lf" , &d ) ;
2186 cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
2187 // theOutPort->Value( D.Value ) ;
2189 // else if ( !strcmp( Type , "objref" ) ) {
2191 CORBA::Object_ptr ObjRef ;
2193 ObjRef = StringToObject( t ) ;
2194 D.Value <<= ObjRef ;
2197 D.Value <<= CORBA::Object::_nil() ;
2199 // theOutPort->Value( D.Value ) ;
2202 // cdebug << " (other ERROR)" << endl ;
2204 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2206 case CORBA::tk_long:
2209 cdebug << l << " (long)" << endl ;
2210 if ( !strcmp( Type , "string" ) ) {
2212 sprintf( t , "%ld" , l ) ;
2214 // theOutPort->Value( D.Value ) ;
2216 else if ( !strcmp( Type , "boolean" ) ) {
2219 D.Value <<= (CORBA::Any::from_boolean ) b ;
2220 // theOutPort->Value( D.Value ) ;
2222 else if ( !strcmp( Type , "char" ) ) {
2224 c = (unsigned char ) l ;
2225 D.Value <<= (CORBA::Any::from_char ) c ;
2226 // theOutPort->Value( D.Value ) ;
2228 else if ( !strcmp( Type , "short" ) ) {
2232 // theOutPort->Value( D.Value ) ;
2234 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2236 else if ( !strcmp( Type , "float" ) ) {
2240 // theOutPort->Value( D.Value ) ;
2242 else if ( !strcmp( Type , "double" ) ) {
2246 // theOutPort->Value( D.Value ) ;
2248 // else if ( !strcmp( Type , "objref" ) ) {
2250 D.Value <<= CORBA::Object::_nil() ;
2251 // theOutPort->Value( D.Value ) ;
2254 // cdebug << " (other ERROR)" << endl ;
2256 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2258 case CORBA::tk_double:
2261 cdebug << d << " (double)" << endl ;
2262 if ( !strcmp( Type , "string" ) ) {
2264 sprintf( t , "%lf" , d ) ;
2266 // theOutPort->Value( D.Value ) ;
2268 else if ( !strcmp( Type , "boolean" ) ) {
2271 D.Value <<= (CORBA::Any::from_boolean ) b ;
2272 // theOutPort->Value( D.Value ) ;
2274 else if ( !strcmp( Type , "char" ) ) {
2276 c = (unsigned char ) d ;
2277 D.Value <<= (CORBA::Any::from_char ) c ;
2278 // theOutPort->Value( D.Value ) ;
2280 else if ( !strcmp( Type , "short" ) ) {
2284 // theOutPort->Value( D.Value ) ;
2286 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2290 // theOutPort->Value( D.Value ) ;
2292 else if ( !strcmp( Type , "float" ) ) {
2296 // theOutPort->Value( D.Value ) ;
2298 else if ( !strcmp( Type , "double" ) ) {
2300 // else if ( !strcmp( Type , "objref" ) ) {
2302 D.Value <<= CORBA::Object::_nil() ;
2303 // theOutPort->Value( D.Value ) ;
2306 // cdebug << " (other ERROR)" << endl ;
2308 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2310 case CORBA::tk_objref:
2311 if ( !strcmp( Type , "string" ) ) {
2312 CORBA::Object_ptr ObjRef ;
2315 D.Value >>= ObjRef ;
2316 retstr = ObjectToString( ObjRef ) ;
2317 D.Value <<= retstr ;
2318 // theOutPort->Value( D.Value ) ;
2324 cdebug << "ToString( object ) Catched ERROR" << endl ;
2327 else if ( !strcmp( Type , "boolean" ) ) {
2329 D.Value <<= (CORBA::Any::from_boolean ) b ;
2330 // theOutPort->Value( D.Value ) ;
2332 else if ( !strcmp( Type , "char" ) ) {
2333 unsigned char c = 0 ;
2334 D.Value <<= (CORBA::Any::from_char ) c ;
2335 // theOutPort->Value( D.Value ) ;
2337 else if ( !strcmp( Type , "short" ) ) {
2340 // theOutPort->Value( D.Value ) ;
2342 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2345 // theOutPort->Value( D.Value ) ;
2347 else if ( !strcmp( Type , "float" ) ) {
2350 // theOutPort->Value( D.Value ) ;
2352 else if ( !strcmp( Type , "double" ) ) {
2355 // theOutPort->Value( D.Value ) ;
2357 // else if ( !strcmp( Type , "objref" ) ) {
2359 CORBA::Object_ptr obj ;
2363 retstr = ObjectToString( obj ) ;
2364 cdebug << retstr << endl ;
2370 cdebug << "ToString( object ) Catched ERROR" << endl ;
2374 // cdebug << " (other ERROR)" << endl ;
2376 cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
2379 cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
2383 cdebug << ThreadNo() << " In" << i << " : wrong state ERROR State "
2384 << anInPort->State() << " NameState "
2385 << Automaton()->StateName( anInPort->State() ) << " PortName "
2386 << anInPort->PortName() << " Parametername "
2387 << anInPort->GetServicesParameter().Parametername << endl ;
2390 InParametersList[i] = D ;
2394 void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
2395 ServicesAnyData * OutParametersList ) {
2397 for ( i = 0 ; i < nOutParams ; i++ ) {
2398 ServicesAnyData D = OutParametersList[i] ;
2400 D.Name = GetChangeNodeOutPort(i)->GetServicesParameter().Parametername;
2401 string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
2402 const char * Type = _Type.c_str() ;
2403 bool OutDone = GetChangeNodeOutPort(i)->Done() ;
2404 cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " Done("
2405 << OutDone << ") " << Type << " : " << endl ;
2406 if ( !strcmp( Type , "string" ) ) {
2407 D.Value <<= (char *) NULL ;
2409 else if ( !strcmp( Type , "boolean" ) ) {
2411 D.Value <<= (CORBA::Any::from_boolean ) b ;
2413 else if ( !strcmp( Type , "char" ) ) {
2414 unsigned char c = 0 ;
2415 D.Value <<= (CORBA::Any::from_char ) c ;
2417 else if ( !strcmp( Type , "short" ) ) {
2421 else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
2422 D.Value <<= (long ) 0 ;
2424 else if ( !strcmp( Type , "float" ) ) {
2428 else if ( !strcmp( Type , "double" ) ) {
2433 D.Value <<= CORBA::Object::_nil() ;
2436 switch (D.Value.type()->kind()) { // { string , long , double , objref }
2437 case CORBA::tk_string:
2440 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
2442 case CORBA::tk_boolean:
2444 D.Value >>= (CORBA::Any::to_boolean ) b;
2445 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
2447 case CORBA::tk_char:
2449 D.Value >>= (CORBA::Any::to_char ) c;
2450 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
2452 case CORBA::tk_short:
2455 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
2457 case CORBA::tk_long:
2460 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
2462 case CORBA::tk_float:
2465 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
2467 case CORBA::tk_double:
2470 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
2472 case CORBA::tk_objref:
2474 CORBA::Object_ptr obj ;
2477 retstr = ObjectToString( obj ) ;
2478 cdebug << ThreadNo() << retstr << endl ;
2481 cdebug << "ToString( object ) Catched ERROR" << endl ;
2485 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
2488 OutParametersList[i] = D ;
2492 bool GraphExecutor::InNode::OutParametersSet( bool Err ,
2493 SUPERV::GraphState NewState ,
2495 ServicesAnyData * OutParametersList ) {
2496 bool RetVal = true ;
2498 GraphBase::OutPort * aGateOutPort = NULL ;
2499 bool OrSwitch = false ;
2501 GraphBase::OutPort * anOutPort ;
2502 for ( i = 0 ; i < nOutParams ; i++ ) {
2503 anOutPort = GetChangeNodeOutPort(i) ;
2505 anOutPort->State( NewState ) ;
2506 anOutPort->Done( true ) ;
2509 cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
2510 << anOutPort->PortName() << " " << anOutPort->Kind() ;
2511 ServicesAnyData D = OutParametersList[i] ;
2512 switch (D.Value.type()->kind()) { // { string , long , double , objref }
2513 case CORBA::tk_string: {
2516 cdebug << ThreadNo() << " " << t << "(string)" << endl ;
2519 case CORBA::tk_boolean: {
2521 D.Value >>= (CORBA::Any::to_boolean ) b;
2522 long l = (long ) b ;
2524 cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
2527 case CORBA::tk_char: {
2529 D.Value >>= (CORBA::Any::to_char ) c;
2530 long l = (long ) c ;
2532 cdebug << ThreadNo() << " " << c << "(char)" << endl ;
2535 case CORBA::tk_short: {
2538 long l = (long ) s ;
2540 cdebug << ThreadNo() << " " << s << "(short)" << endl ;
2543 case CORBA::tk_long: {
2546 cdebug << ThreadNo() << " " << l << "(long)" << endl ;
2549 case CORBA::tk_float: {
2552 double d = (double ) f ;
2554 cdebug << ThreadNo() << " " << f << "(float)" << endl ;
2557 case CORBA::tk_double: {
2560 cdebug << ThreadNo() << " " << d << "(double)" << endl ;
2563 case CORBA::tk_objref: {
2565 CORBA::Object_ptr obj ;
2568 retstr = ObjectToString( obj ) ;
2569 cdebug << ThreadNo() << retstr << endl ;
2572 cdebug << "ToString( object ) Catched ERROR" << endl ;
2577 cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
2580 OutParametersList[i] = D ;
2581 if ( anOutPort->IsGate() ) {
2582 aGateOutPort = anOutPort ;
2583 cdebug << " Gate " ;
2585 OutParametersList[i].Value <<= l;
2586 anOutPort->Value( OutParametersList[i].Value );
2588 else if ( anOutPort->IsLoop() ) {
2589 cdebug << " Loop " ;
2590 anOutPort->Value( OutParametersList[i].Value );
2591 // InLoop Port of EndLoopNode is ready :
2592 anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
2594 else if ( anOutPort->IsSwitch() ) {
2595 cdebug << " Switch " ;
2596 anOutPort->Value( OutParametersList[i].Value );
2597 if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
2598 if ( OrSwitch && anOutPort->BoolValue() ) {
2599 cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true WARNING"
2603 OrSwitch = OrSwitch | anOutPort->BoolValue() ;
2606 cdebug << "OrSwitch " << OrSwitch ;
2609 cdebug << " Param " ;
2610 anOutPort->Value( OutParametersList[i].Value );
2612 anOutPort->State( NewState ) ;
2613 anOutPort->Done( true ) ;
2615 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
2616 bool fromGOTO = false ;
2617 GraphBase::OutPort * aGOTOPort = _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetChangeNodeInGate()->GetOutPort() ;
2619 fromGOTO = aGOTOPort->IsGOTO() ;
2621 if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
2622 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
2623 << anOutPort->ChangeInPorts( j )->PortName() << ","
2624 << anOutPort->ChangeInPorts( j )->Kind() << ") WILL BE changed from "
2625 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
2627 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
2628 << ") to " << anOutPort->NodeName() << "("
2629 << anOutPort->PortName() << ")" << endl ;
2630 anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
2633 cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
2634 << anOutPort->ChangeInPorts( j )->PortName() << ","
2635 << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
2636 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
2638 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
2639 << ") to " << anOutPort->NodeName() << "("
2640 << anOutPort->PortName() << ")" << endl ;
2644 switch (anOutPort->Value()->type()->kind()) {
2645 case CORBA::tk_string:
2647 (*anOutPort->Value()) >>= t;
2648 cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
2650 case CORBA::tk_boolean:
2652 (*anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
2653 cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
2655 case CORBA::tk_char:
2657 (*anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
2658 cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
2660 case CORBA::tk_short:
2662 (*anOutPort->Value()) >>= s;
2663 cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
2665 case CORBA::tk_long:
2667 (*anOutPort->Value()) >>= l;
2668 cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
2670 case CORBA::tk_float:
2672 (*anOutPort->Value()) >>= f;
2673 cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
2675 case CORBA::tk_double:
2677 (*anOutPort->Value()) >>= d;
2678 cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
2680 case CORBA::tk_objref:
2681 CORBA::Object_ptr obj ;
2684 (*anOutPort->Value()) >>= obj ;
2685 retstr = ObjectToString( obj );
2686 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
2690 cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
2691 << "Catched ERROR" << endl ;
2695 cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
2701 if ( aGateOutPort && IsSwitchNode() ) {
2703 // cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
2704 // << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
2706 OutParametersList[0].Value <<= l ;
2707 aGateOutPort->Value( OutParametersList[0].Value ) ;
2710 // cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
2711 // << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
2713 OutParametersList[0].Value <<= l ;
2714 aGateOutPort->Value( OutParametersList[0].Value ) ;
2716 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
2717 GraphBase::InPort * anInPort ;
2718 anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
2720 anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;