+#if TraceDataReady_ExecuteAction
+ cdebug_in << pthread_self() << "/" << ThreadNo()
+ << " DataReady_ExecuteActionInLineNodes " << Name()
+ << " InParametersList " << InParametersList
+ << " OutParametersList " << OutParametersList << endl;
+#endif
+ bool Err = false ;
+ bool StsPyDynInvoke = true ;
+ _OutNode->PyThreadLock() ;
+ SetPyCpuUsed() ;
+ try {
+ bool ItIsaLoop = false ;
+ bool CopyInOut = false ;
+ if ( IsInLineNode() &&
+ strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsInLineNode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() ,
+ OutParametersList , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ }
+ else if ( IsLoopNode() ) {
+ ItIsaLoop = true ;
+ Err = DataReady_ExecuteActionLoopNodes( InParametersList ,
+ OutParametersList ,
+ CopyInOut ) ;
+ }
+ else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
+ strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() ,
+ OutParametersList , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ }
+ else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
+ strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsGOTONode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() ,
+ OutParametersList , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
+ }
+ }
+ else if ( ( IsEndSwitchNode() ) &&
+ InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() ,
+ OutParametersList , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ }
+ else if ( IsEndLoopNode() &&
+ InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() + 1 ,
+ OutParametersList , ServiceOutParameter().length() + 1 ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ }
+
+ if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL ||
+ strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) {
+// This is a void Python Function : without code (No PyFuncName)
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " Copy of " << ServiceInParameter().length()
+ << " OutParameters" << endl ;
+#endif
+ int i ;
+ int argout0 = 0 ;
+ int argin0 = 0 ;
+ if ( IsLoopNode() || IsEndLoopNode() ) {
+ argout0 = 1 ;
+ argin0 = 1 ; // after DoLoop
+ if ( IsLoopNode() ) { // More() is void
+#if TraceDataReady_ExecuteAction
+ cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)"
+ << endl ;
+#endif
+ GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
+ OutParametersList[0].Value = anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
+ }
+ }
+//PAL8072 ==> PAL8512
+//JR 24.03.2005 : Debug : void InLine Python function : check of the number of Input Ports
+// equals the number of Output Ports was missing
+ if ( ServiceInParameter().length() != ServiceOutParameter().length() ) {
+ string anErrorMessage = string( "Inconsistent number of In<->Out parameters for the vois Python function of the node " ) +
+ string( Name() ) ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ StsPyDynInvoke = false ;
+ }
+ else {
+ for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
+ OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
+#if TraceDataReady_ExecuteAction
+ cdebug << "ArgOut->In" << InParametersList[argin0 + i].Name.c_str()
+ << " " << AnyValue( InParametersList[argin0 + i].Value )
+ << endl ;
+#endif
+ }
+ }
+ }
+ if ( !StsPyDynInvoke ) {
+ Err = true ;
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << ThreadNo() << " InLineNode " << Name()
+ << " Python Dynamic Call Error"
+ << endl ;
+ }
+ }
+ catch( ... ) {
+ Err = true ;
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " catched." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << ThreadNo() << " InLineNode " << Name()
+ << " Python Dynamic Call Exception catched ERROR"
+ << endl ;
+ }
+ CpuUsed( true ) ;
+ _OutNode->PyThreadUnLock() ;
+#if TraceDataReady_ExecuteAction
+ cdebug_out << pthread_self() << "/" << ThreadNo()
+ << " DataReady_ExecuteActionInLineNodes " << Name() << endl;
+#endif
+ return Err ;
+}
+
+int GraphExecutor::InNode::DataReady_ExecuteActionLoopNodes( ServicesAnyData * InParametersList ,
+ ServicesAnyData * OutParametersList ,
+ bool & CopyInOut ) {
+
+#if TraceDataReady_ExecuteAction
+ cdebug_in << pthread_self() << "/" << ThreadNo()
+ << " DataReady_ExecuteActionLoopNodes " << Name()
+ << " InParametersList " << InParametersList
+ << " OutParametersList " << OutParametersList << endl;
+#endif
+ bool Err = false ;
+ bool StsPyDynInvoke = true ;
+ bool CopyOutIn = false ;
+// Switch between Init() and Next()
+// if InLoop port is true and does not come from EndLoop ==> execute Init
+// if InLoop port is false or come from EndLoop ==> execute Next
+ if ( _InitLoop ) {
+ if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init()
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
+ << "' InitLoop " << LoopNode()->PyRunMethod() << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[1] , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ CopyOutIn = true ;
+ }
+ else {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ;
+#endif
+ }
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ;
+#endif
+ _InitLoop = false ;
+ }
+ else if ( LoopNode()->PyNextMethod() &&
+ strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next()
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
+ << "' " << LoopNode()->PyNextMethod() << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
+ LoopNode()->PyNextName() ,
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[1] , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ LoopNode()->PyNextName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( LoopNode()->PyNextName() ) ;
+ }
+ CopyOutIn = true ;
+ }
+ else {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ;
+#endif
+ }
+ if ( StsPyDynInvoke ) {
+ if ( CopyOutIn ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+ << "' Copy of " << ServiceInParameter().length()
+ << " OutParameters" << endl ;
+#endif
+ int i ;
+// Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next )
+ for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
+ InParametersList[i].Value = OutParametersList[i].Value ;
+ InParametersList[i].Name = OutParametersList[i].Name ;
+#if TraceDataReady_ExecuteAction
+ cdebug << "ArgOut->In" << InParametersList[ i].Name.c_str()
+ << " " << AnyValue( InParametersList[ i].Value )
+ << endl ;
+#endif
+ }
+ }
+ if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+ << "' " << LoopNode()->PyMoreMethod() << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
+ LoopNode()->PyMoreName() ,
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ LoopNode()->PyMoreName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( LoopNode()->PyMoreName() ) ;
+ }
+ }
+ else {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+ << "' No MoreMethod" << endl ;
+#endif
+ CopyInOut = true ;
+ }
+ }
+ else {
+ Err = true ;
+ cdebug << ThreadNo() << " InLineNode " << Name() << " "
+ << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
+ << " Python Dynamic Call Error"
+ << endl ;
+ }
+#if TraceDataReady_ExecuteAction
+ cdebug_out << pthread_self() << "/" << ThreadNo()
+ << " DataReady_ExecuteActionLoopNodes " << Name() << endl;
+#endif
+ return Err ;
+}
+
+int GraphExecutor::InNode::Executing_SuspendAction() {
+ _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
+ GraphExecutor::SuspendedExecutingState ) ;
+ cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
+ cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
+ GraphExecutor::AutomatonState next_state ;
+ next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
+ _OutNode->NewThread() ; // Only for Threads count
+ _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
+ next_state ) ;
+ State( next_state ) ;
+ return 1 ;
+}