From: rahuel Date: Tue, 30 Aug 2005 07:06:20 +0000 (+0000) Subject: Debug for ObjectReferences with omniORB4 X-Git-Tag: V_3_0_2~15 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsuperv.git;a=commitdiff_plain;h=edc8f793a7891d98fef7b087798303a02bf6757f Debug for ObjectReferences with omniORB4 --- diff --git a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx index 1f54017..2c33cd8 100644 --- a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx +++ b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx @@ -19,6 +19,8 @@ using namespace std; using namespace CORBA ; +extern GraphExecutor::FiniteStateMachine * theAutomaton ; + //static PyObject * MyPyObjSignal = NULL ; static PyObject * MyPyObjRef = NULL ; static PyObject * MyPyObjIor = NULL ; @@ -223,22 +225,24 @@ extern "C" PyObject * PyRunMethod( PyObject * dummy , PyObject * Args ) { return Result ; } -#define PyDynInvokeTrace 0 +#define PyDynInvokeTrace 1 bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , const char *method , - ServicesAnyData * inParams , int nInParams , - ServicesAnyData * outParams , int nOutParams ) { + ServicesAnyData * InParametersList , int nInParams , + ServicesAnyData * OutParametersList , int nOutParams ) { int i ; bool RetVal = true ; - int n_in = nInParams ; - int n_out = nOutParams ; const char * sname; #if PyDynInvokeTrace - cdebug_in << ThreadNo() << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " method " << method - << " " << n_in << " InArgs " << n_out << " OutArgs MyPyRunMethod " ; + cdebug_in << ThreadNo() << "GraphExecutor::InNode::PyDynInvoke Node " << Name() + << " method " << method + << " InParametersList " << InParametersList + << " OutParametersList " << OutParametersList + << " " << nInParams << " InArgs " << nOutParams + << " OutArgs MyPyRunMethod " ; #endif if ( MyPyRunMethod ) { #if PyDynInvokeTrace @@ -263,6 +267,7 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , PyObject * ResultIor = NULL ; CORBA::Object_ptr ObjRef ; + char * IORObjRef ; if ( !PyCallable_Check( MyPyRunMethod ) ) { @@ -270,11 +275,11 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , RetVal = false ; } else { - ArgsList = PyTuple_New( n_in ) ; + ArgsList = PyTuple_New( nInParams ) ; - for ( i = 0 ; i < n_in ; i++ ) { - data = inParams[i].Value ; - sname = inParams[i].Name.c_str() ; + for ( i = 0 ; i < nInParams ; i++ ) { + data = InParametersList[i].Value ; + sname = InParametersList[i].Name.c_str() ; switch ( data.type()->kind() ) { case CORBA::tk_string : { char * t ; @@ -418,9 +423,9 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , RetVal = false ; } else { - for ( i = 0 ; i < n_out ; i++ ) { - data = outParams[i].Value ; - sname = outParams[i].Name.c_str() ; + for ( i = 0 ; i < nOutParams ; i++ ) { + data = OutParametersList[i].Value ; + sname = OutParametersList[i].Name.c_str() ; switch ( data.type()->kind() ) { case CORBA::tk_string : { char * t = "" ; @@ -481,7 +486,8 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , } //JR 04.04.2005 Debug if ( !PyInt_Check( ArgValue ) ) { //Difficult to understand that behavior ... Python char type is a string of length 1 ! - if ( !PyString_Check( ArgValue ) ) { +// or type is int ... + if ( !PyString_Check( ArgValue ) && !PyInt_Check( ArgValue ) ) { cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (char)" << endl ; RetVal = false ; } @@ -629,18 +635,62 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , char * IOR = NULL ; IOR = PyString_AsString( ResultIor ) ; ObjRef = StringToObject( IOR ) ; +//JR 05.08.2005 BUG OMNIORB4 ? : that line does run with SALOME_3 (OMNIOrb4) for +// object references ... (It's Ok with OMNIOrb3) +// IOR and ObjRef and IORObjRef are Ok +// BUT data contains a nil reference !!! +#if !omniORB_4_0_5 data <<= ObjRef ; +#else + SUPERV::SuperG_var mySuperVisionComponent ; + mySuperVisionComponent = theAutomaton->SuperVisionComponent() ; + if ( CORBA::is_nil( mySuperVisionComponent ) ) { + Engines::Container_var myContainer ; + Engines::Component_var myObjComponent ; + _OutNode->Graph()->StartComponent( ThreadNo() , "SuperVisionContainer" , + "SUPERV" , + myContainer , myObjComponent ) ; + mySuperVisionComponent = SUPERV::SuperG::_narrow( myObjComponent ) ; + theAutomaton->SuperVisionComponent( mySuperVisionComponent ) ; + } +//JR 24.08.2005 BUG OMNIORB4 ? : That does not run also ==> Comments +// CORBA::Object_ptr ObjRef1 ; +// ObjRef1 = mySuperVisionComponent->ToObject( ObjRef ) ; +// data <<= ObjRef1 ; +//JR 24.08.2005 BUG OMNIORB4 ? : BUT THAT RUNS WITH THE "IDENTITY METHOD ToObject of SUPERV.idl : +// Object ToObject( in Object anObject ) ; +//CODE of that method !!! : +//CORBA::Object_ptr SuperV_Impl::ToObject( CORBA::Object_ptr anObjectRef ) { +// beginService( "SuperV_Impl::ToObject" ); +// CORBA::Object_ptr anObject ; +// anObject = CORBA::Object::_duplicate( anObjectRef ) ; +// endService( "SuperV_Impl::ToObject" ); +// return anObject ; +//} +//BUT THAT RUNS ONLY IF WE USE Dynamic invocation of CORBA (DynInvoke) + ServicesAnyData anInParametersList ; + anInParametersList.Name = "anObjRef" ; + anInParametersList.Value <<= ObjRef ; + DynInvoke( mySuperVisionComponent , "ToObject" , + &anInParametersList , 1 , &OutParametersList[i] , 1 ) ; + data = OutParametersList[i].Value ; +#endif IORObjRef = ObjectToString( ObjRef ) ; #if PyDynInvokeTrace - cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << IORObjRef << " (objref) " - << endl ; + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value IORPy " + << IOR << " IORObjRef " << IORObjRef << " (objref) " << endl ; #endif if ( CORBA::is_nil( ObjRef ) ) { +#if PyDynInvokeTrace + cdebug << "ObjRef ERROR(nil reference) ResultIor->ob_refcnt " + << ResultIor->ob_refcnt-1 << endl ; +#endif ResultIor = NULL ; } else { #if PyDynInvokeTrace - cdebug << "ResultIor->ob_refcnt " << ResultIor->ob_refcnt-1 << endl ; + cdebug << "ObjRef NOT(nil reference)ResultIor->ob_refcnt " + << ResultIor->ob_refcnt-1 << endl ; #endif Py_DECREF( ResultIor ) ; } @@ -657,33 +707,78 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , RetVal = false ; } } - outParams[i].Value = data ; +//JR 05.08.2005 BUG OMNIORB4 ? : that line does run with SALOME_3 (OMNIOrb4) for +// object references ... + OutParametersList[i].Value = data ; +// if ( data.type()->kind() == CORBA::tk_objref ) { +// IORObjRef = ObjectToString( ObjRef ) ; +//#if PyDynInvokeTrace +// cdebug << ThreadNo() << "GraphExecutor::InNode::PyDynInvoke Node " << Name() +// << "ArgOut" << i << " : " << sname << " " << method << " ObjRef " +// << IORObjRef << " (objref) " << endl ; +// Engines::Component_var theObjComponent ; +// theObjComponent = Engines::Component::_narrow( ObjRef ) ; +// DynInvoke( theObjComponent , "ping" , NULL , 0 , NULL , 0 ) ; +//#endif +// Engines::Container_var myContainer ; +// Engines::Component_var myObjComponent ; +// _OutNode->Graph()->StartComponent( ThreadNo() , "SuperVisionContainer" , +// "SUPERV" , +// myContainer , myObjComponent ) ; +// SUPERV::SuperG_var mySuperVisionComponent ; +// mySuperVisionComponent = SUPERV::SuperG::_narrow( myObjComponent ) ; +// CORBA::Object_ptr ObjRef1 ; +// ObjRef1 = mySuperVisionComponent->ToObject( IORObjRef ) ; +//#if PyDynInvokeTrace +// IORObjRef = ObjectToString( ObjRef1 ) ; +// cdebug << ThreadNo() << "GraphExecutor::InNode::PyDynInvoke Node " << Name() +// << "ArgOut" << i << " : " << sname << " " << method << " ToObject " +// << IORObjRef << " (objref) " << endl ; +//#endif + +// ServicesAnyData anInParametersList ; +// anInParametersList.Name = "anIORObjRef" ; +// anInParametersList.Value <<= IORObjRef ; +// DynInvoke( mySuperVisionComponent , "ToObject" , +// &anInParametersList , 1 , &OutParametersList[i] , 1 ) ; +//#if PyDynInvokeTrace +// OutParametersList[i].Value >>= ObjRef1 ; +// IORObjRef = ObjectToString( ObjRef1 ) ; +// cdebug << ThreadNo() << "GraphExecutor::InNode::PyDynInvoke Node " << Name() +// << "ArgOut" << i << " : " << sname << " " << method +// << " DynInvoke(ToObject) " << IORObjRef << " (objref) " << endl ; +//#endif +// } } -// int k ; -// for ( k = 0 ; k < n_out ; k++ ) { -// cdebug << "Result" << k << "->ob_refcnt " << PyTuple_GetItem( Result , k )->ob_refcnt << endl ; -// Py_DECREF( PyTuple_GetItem( Result , k ) ) ; -// } - #if PyDynInvokeTrace cdebug << "InNode::PyDynInvoke Result->ob_refcnt " << Result->ob_refcnt-1 << endl ; #endif Py_DECREF( Result ) ; } -// int k ; -// for ( k = 0 ; k < n_in ; k++ ) { -// cdebug << "ArgsList" << k << "->ob_refcnt " << PyTuple_GetItem( ArgsList , k )->ob_refcnt << endl ; -// Py_DECREF( PyTuple_GetItem( ArgsList , k ) ) ; -// } - #if PyDynInvokeTrace cdebug << "InNode::PyDynInvoke ArgsList->ob_refcnt " << ArgsList->ob_refcnt-1 << endl ; #endif Py_DECREF( ArgsList ) ; } +#if 0 + { + int i ; + for ( i = 0 ; i < nInParams ; i++ ) { // Without Gates + cdebug << "InParametersList[" << i << "] : " + << InParametersList[i].Name << " " + << AnyValue( InParametersList[i].Value ) << endl ; + } + for ( i = 0 ; i < nOutParams ; i++ ) { // Without Gates + cdebug << "OutParametersList[" << i << "] : " + << OutParametersList[i].Name << " " + << AnyValue( OutParametersList[i].Value ) << endl ; + } + } +#endif + #if PyDynInvokeTrace cdebug_out << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " method " << method << " " << RetVal << endl ; @@ -698,15 +793,15 @@ bool GraphExecutor::InNode::PyRunSimpleString( char* thePyString ) const bool ErrorValue = true; bool aRet; try { - MESSAGE( pthread_self() << "Python method beginning : " << thePyString ); #if PyDynInvokeTrace + MESSAGE( pthread_self() << "Python method beginning : " << thePyString ); cdebug_in << pthread_self() << "Python method beginning : " << thePyString << endl ; #endif aRet = PyRun_SimpleString( thePyString ); // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL //aRet = _OutNode->SuperVisionContainer()->ActivatePythonExecution( thePyString ) ; - MESSAGE( pthread_self() << "Python method finished." ); #if PyDynInvokeTrace + MESSAGE( pthread_self() << "Python method finished." ); cdebug_out << pthread_self() << "Python method finished." << endl ; #endif } catch( ... ) {