+// SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : DataFlowBase_InNodeThreads.cxx
+// Author : Jean Rahuel, CEA
+// Module : SUPERV
+// $Header:
+
using namespace std;
-//=============================================================================
-// File : DataFlowBase_InNodeThreads.cxx
-// Created : 2002
-// Author : Jean Rahuel, CEA
-// Project : SALOME
-// $Header:
-//=============================================================================
#include <stdlib.h>
#include <iostream>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOME_Component)
-#include "SALOME_NamingService.hxx"
+//#include "SALOME_NamingService.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
//#include "DataFlowExecutor_InNode.hxx"
#include "DataFlowExecutor_OutNode.hxx"
-static char *containerName = "FactoryServer" ;
+//static char *containerName = "FactoryServer" ;
int GraphExecutor::InNode::SendEvent(
const GraphExecutor::NodeEvent anEvent ) {
- SUPERV::AutomatonState old_state ;
+ _CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
cdebug << pthread_self() << "/" << ThreadNo() << " -->SendEvent Node " << Name()
<< " ControlState : "
<< Automaton()->ControlStateName( ControlState() )
<< " Event : " << Automaton()->EventName( anEvent )
- << " State : " << Automaton()->StateName( State() ) << endl;
+ << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack << endl;
- old_state = State() ;
- _NextState = Automaton()->NextState( old_state , anEvent ) ;
- if ( _NextState == old_state ) {
+ _OldState = State() ;
+ _NextState = Automaton()->NextState( _OldState , anEvent ) ;
+ if ( _NextState == _OldState ) {
cdebug << pthread_self() << "/" << ThreadNo()
<< " GraphExecutor::InNodeThreads::SendEvent SameStates "
- << old_state << endl ;
+ << _OldState << endl ;
_NextAction = GraphExecutor::VoidAction ;
}
else {
}
// State( _NextState ) ;
-// if ( old_state == SUPERV::SuccessedExecutingState ||
-// old_state == SUPERV::ErroredExecutingState ) {
+// if ( _OldState == SUPERV::SuccessedExecutingState ||
+// _OldState == SUPERV::ErroredExecutingState ) {
// DoneAction() ;
// }
cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
<< Name() << endl << " ControlState : "
<< Automaton()->ControlStateName( ControlState() ) << endl
- << " OldState : " << Automaton()->StateName( old_state ) << endl
+ << " OldState : " << Automaton()->StateName( _OldState ) << endl
<< " Event : " << Automaton()->EventName( anEvent ) << endl
<< " NextState : " << Automaton()->StateName( _NextState ) << endl
<< " Action : " << Automaton()->ActionName( _NextAction ) << endl
- << " CreateNewThread " << CreateNewThread() << endl ;
+ << " CreateNewThread " << CreateNewThread() << endl
+ << " _RewindStack " << _RewindStack << endl ;
#if 0
cout << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
<< endl << " ControlState : "
<< Automaton()->ControlStateName( ControlState() ) << endl
- << " OldState : " << Automaton()->StateName( old_state ) << endl
+ << " OldState : " << Automaton()->StateName( _OldState ) << endl
<< " Event : " << Automaton()->EventName( anEvent ) << endl
<< " NextState : " << Automaton()->StateName( _NextState ) << endl
<< " Action : " << Automaton()->ActionName( _NextAction ) << endl
int sts = executeAction() ;
- cdebug << pthread_self() << "/" << ThreadNo() << " <- SendEvent Node " << Name()
+ cdebug << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
<< " Event : " << Automaton()->EventName( anEvent )
<< " State : " << Automaton()->StateName( State() )
<< endl;
}
int GraphExecutor::InNode::executeAction() {
+ if ( !CreateNewThread() && _RewindStack > 101 ) {
+ CreateNewThread( true ) ;
+ ThreadNo( 0 ) ;
+ }
if ( CreateNewThread() ) {
CreateNewThread( false ) ;
if ( ThreadNo() == 0 ) {
+ _RewindStack = 1 ;
cdebug << pthread_self() << "/" << ThreadNo()
- << " executeAction start Thread "
+ << " executeAction start Thread _RewindStack " << _RewindStack << " "
<< Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
<< endl;
pthread_t T;
while ( (pthread_sts = pthread_create(&T, NULL, run_function, this )) ) {
char * msg = "Cannot pthread_create " ;
perror( msg ) ;
- cdebug << ThreadNo() << " " << msg << endl ;
+ cdebug << ThreadNo() << " " << msg << " --> sleep(5)" << endl ;
cdebug << ThreadNo() << " PTHREAD_THREADS_MAX : "
- << PTHREAD_THREADS_MAX << " " << pthread_sts << endl ;
-// sleep( 1 ) ;
+ << PTHREAD_THREADS_MAX << " pthread_create status : " ;
+ if ( pthread_sts == EAGAIN ) {
+ cdebug << "EAGAIN(" << pthread_sts << ")" << endl ;
+ cdebug << "It seems to me that with gdb we are limited to 256 threads because of defunct" << endl ;
+ }
+ else {
+ cdebug << pthread_sts << endl ;
+ }
+ string smsg = msg ;
+ delete [] msg ;
pthread_exit( msg ) ;
}
cdebug << pthread_self() << "/" << ThreadNo()
}
else {
cdebug << pthread_self() << "/" << ThreadNo()
- << " executeAction restart Thread "
+ << " executeAction restart Thread _RewindStack " << _RewindStack << " "
<< Automaton()->StateName( State() ) << " "
<< Automaton()->ActionName( _NextAction ) << "(" << Name()
<< ") ReStartAction ==>" << endl;
- SUPERV::AutomatonState oldstate = State() ;
State( SUPERV::SuspendedSuccessedState ) ;
if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
-// State( oldstate ) ;
cdebug << pthread_self() << "/" << ThreadNo()
<< " executeAction STATE & CALLED "
<< Automaton()->ActionName( _NextAction ) << "(" << Name()
<< ") ERROR-DEBUG " << endl;
-// return ExecuteAction() ;
}
else {
cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
}
}
else {
+ if ( _CurrentEvent == ExecuteEvent ) {
+ _RewindStack += 1 ;
+ }
cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
- << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
+ << Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
<< endl;
return ExecuteAction() ;
}
- return 1;
+ return 1 ;
}
void GraphExecutor::InNode::coutbegin() {
cdebug << ThreadNo() << " " << pthread_self() << " run_function begin"
- << " " << Name() << " " << Automaton()->StateName( State() )
- << endl ;
+ << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
}
void GraphExecutor::InNode::coutexit() {
- cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit"
- << " " << Name() << " " << Automaton()->StateName( State() )
- << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit _RewindStack " << _RewindStack
+ << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
}
void * run_function(void *p) {
GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
}
aNode->ExecuteAction() ;
char * msg = new char[40] ;
- sprintf( msg , "%d" , aNode->ThreadNo() ) ;
+ sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
strcat( msg , " thread exit" ) ;
aNode->coutexit() ;
aNode->ExitThread() ;
string smsg = msg ;
+ delete [] msg ;
pthread_exit( (void * ) smsg.c_str() ) ;
return msg ;
}
bool LoopBeginning = false ;
bool SwitchFinished = false ;
- if ( IsEndLoopNode() && !GetChangeNodeInPort( 0 )->GetOutPort()->BoolValue() ) {
+ if ( IsEndLoopNode() && !GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
LoopFinished = true ; // End of Loop
}
- if ( IsLoopNode() && GetChangeNodeInPort( 1 )->GetOutPort()->BoolValue() ) {
+ if ( IsLoopNode() && GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
LoopBeginning = true ; // Beginning of Loop
}
- if ( IsEndSwitchNode() && !GetChangeNodeInPort( 0 )->GetOutPort()->BoolValue() ) {
+ if ( IsEndSwitchNode() && !GetChangeNodeInGate()->GetOutPort()->BoolValue() ) {
SwitchFinished = true ;
}
- for ( k = 0 ; k < GetNodeInPortsSize() ; k++ ) {
+ for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
if ( anInPort->IsGate() && anOutPort == NULL ) {
#endif
cdebug << endl ;
}
-// else if ( LoopBeginning && anInPort->IsDataConnected() ) {
else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
anInPort->State( SUPERV::ReadyState ) ;
InReady += 1 ;
bool Err = false ;
int nInParams = GetNodeInPortsSize() ;
- ServicesAnyData * aListOfInParameters = new ServicesAnyData[nInParams];
- InParametersSet( Err , nInParams , aListOfInParameters ) ;
+ ServicesAnyData * InParametersList = new ServicesAnyData[nInParams];
+ InParametersSet( Err , nInParams , InParametersList ) ;
Engines::Container_var myContainer ;
Engines::Component_var myObjComponent ;
if ( IsComputingNode() ) {
ObjInterface( true ) ;
CORBA::Object_ptr obj ;
- aListOfInParameters[1].Value >>= obj ;
+ InParametersList[0].Value >>= obj ;
CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
myObjComponent = Engines::Component::_narrow( objvar ) ;
}
myContainer , myObjComponent ) ;
// if ( !Err && nInParams > 1 &&
// strcmp( ComponentName() , InterfaceName() ) &&
-// aListOfInParameters[ 1 ].Value.type()->kind() ==
+// InParametersList[ 1 ].Value.type()->kind() ==
// CORBA::tk_objref ) {
// }
// else {
}
int nOutParams = GetNodeOutPortsSize() ;
- ServicesAnyData * aListOfOutParameters = new ServicesAnyData[nOutParams];
- InOutParameters( nOutParams , aListOfOutParameters ) ;
+ ServicesAnyData * OutParametersList = new ServicesAnyData[nOutParams];
+ InOutParametersSet( nOutParams , OutParametersList ) ;
// if ( strlen( ComponentName() ) ) {
if ( Err || ControlState() == SUPERV::ToKillState ||
else {
if ( !Err ) {
cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
- for ( i = 0 ; i < nInParams ; i++ ) {
- cdebug << " , " << aListOfInParameters[ i ].Name ;
+ for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
+ cdebug << " , " << InParametersList[ i ].Name << "[kind"
+ << InParametersList[ i ].Value.type()->kind() << "]" ;
+ }
+ for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
+ cdebug << " , " << OutParametersList[ i ].Name << "[kind"
+ << OutParametersList[ i ].Value.type()->kind() << "]" ;
}
cdebug << ")" << endl ;
if ( IsOneOfInLineNodes() ) {
bool StsPyDynInvoke = true ;
- _OutNode->PThreadLock() ;
+ _OutNode->PyThreadLock() ;
+ SetPyCpuUsed() ;
try {
if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
strlen( InLineNode()->PyFuncName() ) ) {
<< "' IsInLineNode PyDynInvoke" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
InLineNode()->PyFuncName() ,
- &aListOfInParameters[1] , ServiceInParameter().length() ,
- &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
else if ( IsLoopNode() ) {
- if ( GetNodeInPort( 1 )->GetOutPort()->BoolValue() ) { // InLoop Port
+ if ( GetNodeInLoop()->GetOutPort()->BoolValue() ) { // InLoop Port
cdebug << ThreadNo() << " !ObjInterface " << Name()
<< " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
<< "'" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
InLineNode()->PyFuncName() ,
- &aListOfInParameters[2] , ServiceInParameter().length() ,
- &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[1] , ServiceOutParameter().length() ) ;
}
else {
cdebug << ThreadNo() << " !ObjInterface " << Name()
<< "'" << endl ;
StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
LoopNode()->PyNextName() ,
- &aListOfInParameters[2] , ServiceInParameter().length() ,
- &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[1] , ServiceOutParameter().length() ) ;
}
if ( StsPyDynInvoke ) {
cdebug << ThreadNo() << " !ObjInterface " << Name()
<< "' Copy of " << ServiceInParameter().length()
<< " OutParameters" << endl ;
int i ;
- for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
- aListOfInParameters[2 + i].Value = aListOfOutParameters[1+ i].Value ;
- aListOfInParameters[2 + i].Name = aListOfOutParameters[1+ i].Name ;
- switch ( aListOfInParameters[2 + i].Value.type()->kind() ) {
+ for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
+ InParametersList[i].Value = OutParametersList[i].Value ;
+ InParametersList[i].Name = OutParametersList[i].Name ;
+//#if 0
+ switch ( InParametersList[i].Value.type()->kind() ) {
case CORBA::tk_string :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[2 + i].Name.c_str()
- << " Value(string) " << endl ;
+ char * t;
+ InParametersList[i].Value >>= t ;
+ cdebug << "ArgOut->In" << i << " : "
+ << InParametersList[i].Name.c_str()
+ << " Value(string) " << t << endl ;
break ;
case CORBA::tk_double :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[2 + i].Name.c_str()
- << " Value(double) " << endl ;
+ double d;
+ InParametersList[i].Value >>= d;
+ cdebug << "ArgOut->In" << i << " : "
+ << InParametersList[i].Name.c_str()
+ << " Value(double) " << d << endl ;
break ;
case CORBA::tk_long :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[2 + i].Name.c_str()
- << " Value(long) " << endl ;
+ long l;
+ InParametersList[i].Value >>= l;
+ cdebug << "ArgOut->In" << i << " : "
+ << InParametersList[i].Name.c_str()
+ << " Value(long) " << l << endl ;
break ;
case CORBA::tk_objref :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[2 + i].Name.c_str()
- << " Value(object reference) " << endl ;
+ CORBA::Object_ptr obj ;
+ char * retstr ;
+ try {
+ InParametersList[i].Value >>= obj ;
+ retstr = ObjectToString( obj );
+ cdebug << "ArgOut->In" << i << " : "
+ << InParametersList[i].Name.c_str()
+ << " Value(object reference) " << retstr << endl ;
+ }
+ catch ( ... ) {
+ cdebug << "ArgOut->In" << i << " : "
+ << InParametersList[i].Name.c_str()
+ << " Value(object reference) Catched ERROR" << endl ;
+ }
break ;
default :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[2 + i].Name.c_str()
+ cdebug << "ArgOut->In" << i << " : "
+ << InParametersList[i].Name.c_str()
<< " Value(other) ERROR" << endl ;
}
+//#endif
}
StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
LoopNode()->PyMoreName() ,
- &aListOfInParameters[2] , ServiceInParameter().length() ,
- &aListOfOutParameters[0] , ServiceOutParameter().length()+1 ) ;
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
}
else {
Err = true ;
<< "' IsSwitchNode PyDynInvoke" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
InLineNode()->PyFuncName() ,
- &aListOfInParameters[1] , ServiceInParameter().length() ,
- &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
strlen( InLineNode()->PyFuncName() ) ) {
<< "' IsGOTONode PyDynInvoke" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
InLineNode()->PyFuncName() ,
- &aListOfInParameters[1] , ServiceInParameter().length() ,
- &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
strlen( InLineNode()->PyFuncName() ) ) {
<< "' IsSwitchNode PyDynInvoke" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
InLineNode()->PyFuncName() ,
- &aListOfInParameters[1] , ServiceInParameter().length() ,
- &aListOfOutParameters[0] , ServiceOutParameter().length() ) ;
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
strlen( InLineNode()->PyFuncName() ) == 0 ) {
<< " Copy of " << ServiceInParameter().length()
<< " OutParameters" << endl ;
int i ;
- int argind0 = 0 ;
- if ( IsEndSwitchNode() ) {
- argind0 = 0 ;
+ int argout0 = 0 ;
+ int argin0 = 0 ;
+ if ( IsEndLoopNode() ) {
+ argout0 = 1 ;
+ argin0 = 1 ; // after DoLoop
}
- else if ( IsEndLoopNode() || IsGOTONode() ) {
- argind0 = 1 ;
- }
- for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
- aListOfOutParameters[argind0 + i].Value = aListOfInParameters[ 1 + i].Value ;
-// aListOfOutParameters[argind0 + i].Name = aListOfInParameters[argind0 + i].Name ;
- switch ( aListOfInParameters[ 1 + i].Value.type()->kind() ) {
+ for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
+ OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
+//#if 0
+ switch ( InParametersList[argin0 + i].Value.type()->kind() ) {
case CORBA::tk_string :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[ 1 + i].Name.c_str()
+ cdebug << "ArgOut->In" << argin0 + i << " : "
+ << InParametersList[argin0 + i].Name.c_str()
<< " Value(string) "
- << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ << OutParametersList[argin0 + i].Name.c_str() << endl ;
break ;
case CORBA::tk_double :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[ 1 + i].Name.c_str()
+ cdebug << "ArgOut->In" << argin0 + i << " : "
+ << InParametersList[argin0 + i].Name.c_str()
<< " Value(double) "
- << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ << OutParametersList[argin0 + i].Name.c_str() << endl ;
break ;
case CORBA::tk_long :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[ 1 + i].Name.c_str()
+ cdebug << "ArgOut->In" << argin0 + i << " : "
+ << InParametersList[argin0 + i].Name.c_str()
<< " Value(long) "
- << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ << OutParametersList[ i ].Name.c_str() << endl ;
break ;
case CORBA::tk_objref :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[ 1 + i].Name.c_str()
+ cdebug << "ArgOut->In" << argin0 + i << " : "
+ << InParametersList[argin0 + i].Name.c_str()
<< " Value(object reference) "
- << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ << OutParametersList[argin0 + i].Name.c_str() << endl ;
break ;
default :
- cdebug << "Arg" << i << " : "
- << aListOfInParameters[ 1 + i].Name.c_str()
+ cdebug << "ArgOut->In" << argin0 + i << " : "
+ << InParametersList[argin0 + i].Name.c_str()
<< " Value(other) ERROR "
- << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ << OutParametersList[argin0 + i].Name.c_str() << endl ;
}
+//#endif
}
}
if ( !StsPyDynInvoke ) {
<< " Python Dynamic Call Exception catched ERROR"
<< endl ;
}
- _OutNode->PThreadUnLock() ;
+ CpuUsed( true ) ;
+ _OutNode->PyThreadUnLock() ;
}
-// else if ( !ObjInterface() ) {
- else if ( IsFactoryNode() ) {
+ else {
try {
try {
DynInvoke( myObjComponent, "Names" ,
<< " IsComputingNode DynInvoke" << endl ;
DynInvoke( myObjComponent,
ServiceName() ,
- &aListOfInParameters[1] , ServiceInParameter().length() ,
- &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ &InParametersList[1] , ServiceInParameter().length()-1 ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
else if ( IsFactoryNode() ) {
cdebug << ThreadNo() << " !ObjInterface " << Name()
<< " IsFactoryNode DynInvoke" << endl ;
DynInvoke( myObjComponent,
ServiceName() ,
- &aListOfInParameters[1] , ServiceInParameter().length() ,
- &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
}
catch( ... ) {
<< endl ;
}
}
- else {
- try {
- try {
- DynInvoke( myObjComponent, "Names" ,
- _OutNode->Name() , Name() ) ;
- }
- catch( ... ) {
- }
- cdebug << ThreadNo() << " ObjInterface " << Name() << " DynInvoke"
- << endl ;
- DynInvoke( myObjComponent ,
- ServiceName() ,
- &aListOfInParameters[2] , ServiceInParameter().length()-1 ,
- &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
- }
- catch( ... ) {
- Err = true ;
- cdebug << ThreadNo() << " ObjInterface " << Name()
- << " Node(Interface) Dynamic Call Exception catched ERROR"
- << endl ;
- }
- }
}
}
// }
NewEvent = GraphExecutor::SuccessEvent ;
}
- bool ErrOut = OutParameters( Err , PortState , nOutParams , aListOfOutParameters ) ;
+ bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
if ( !ErrOut ) {
NewEvent = GraphExecutor::ErrorEvent ;
}
- delete [] aListOfInParameters ;
- delete [] aListOfOutParameters ;
+ delete [] InParametersList ;
+ delete [] OutParametersList ;
SendEvent( NewEvent );
else if ( anInPort->State() != SUPERV::WaitingState ) {
if ( !docdebug ) {
cdebug << ThreadNo()
- << " --> GraphExecutor::InNodeThreads::SetWaitingStates "
- << Name() << endl;
+ << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
docdebug = true ;
}
anInPort->State( SUPERV::WaitingState ) ;
}
}
for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
- if ( !( IsGOTONode() && i == 0 ) && !( IsEndLoopNode() && i <= 1 ) ) {
- for ( j = 0 ; j < GetChangeNodeOutPort( i )->InPortsSize() ; j++ ) {
- GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->GetChangeGraphNode( GetChangeNodeOutPort( i )->ChangeInPorts( j )->NodeName() )->GetInNode() ;
+ for ( j = 0 ; j < GetChangeNodeOutPort( i )->InPortsSize() ; j++ ) {
+ GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
+// if ( !( IsGOTONode() && i == 0 ) && !( IsEndLoopNode() && i <= 1 ) ) {
+ if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
+ !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ;
if ( aNode != EndNode ) {
aNode->SetWaitingStates( EndNode ) ;
}
DoneAction() ;
if ( IsGOTONode() ||
- ( IsEndLoopNode() && GetNodeInPort(0)->GetOutPort()->BoolValue() ) ) {
-// int index ;
-// if ( IsGOTONode() ) {
-// index = 0 ;
-// }
-// else {
-// index = 1 ;
-// CORBA::Any * anAny = new CORBA::Any() ;
-// *anAny <<= (long ) 0 ;
-// GetChangeNodeOutPort(1)->Value( anAny ) ; // Loop(InLoop) = false
-// }
-// const GraphBase::OutPort * GateOutPort = GetNodeOutPort(index) ;
- const GraphBase::OutPort * GateOutPort = GetNodeOutPort(0) ;
- for ( i = 0 ; i < GateOutPort->InPortsSize() ; i++ ) {
- const GraphBase::InPort * anInPort = GateOutPort->InPorts( i ) ;
+ ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
+ const GraphBase::OutPort * aGateOutPort ;
+ if ( IsGOTONode() ) {
+ aGateOutPort = GetNodeOutGate() ;
+ }
+ else {
+ aGateOutPort = GetNodeOutLoop() ;
+ }
+ for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
+ const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
+ cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
+ << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
aLabelNode->SetWaitingStates( this ) ;
- for ( j = 1 ; j < GetNodeOutPortsSize() ; j++ ) {
+ for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
+ const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
+ if ( anInPort->GetOutPort() ) {
+ cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
+ << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
+ << endl ;
+ }
+ }
+ for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
- GraphBase::InPort * aBusParamChangeInPort = NULL ;
-// if ( aBusParamOutPort->IsLoop() ) {
-// aBusParamChangeInPort = aLabelNode->GetChangeInPort( "InitLoop" ) ;
-// }
-// else {
- aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
-// }
- if ( aBusParamChangeInPort ) {
- aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
- if ( !aLabelNode->IsLockedDataWait() ) {
- res = aLabelNode->SendSomeDataReady( Name() ) ;
- if ( res ) {
- if ( firsttoNode == NULL &&
- aLabelNode->ThreadNo() == pthread_self() ) {
- firsttoNode = aLabelNode ;
- cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
- << aLabelNode->Name() << endl ;
- }
- else if ( firstzeroNode == NULL &&
- aLabelNode->ThreadNo() == 0 ) {
- firstzeroNode = aLabelNode ;
- }
- else {
- SomeDataNodes.push_back( aLabelNode ) ;
- cdebug << ThreadNo() << " Successed_SuccessAction push "
- << SomeDataNodes.size() << " " << aLabelNode->Name()
- << endl ;
+ if ( !aBusParamOutPort->IsGate() ) {
+ GraphBase::InPort * aBusParamChangeInPort = NULL ;
+ if ( aBusParamOutPort->IsLoop() ) {
+ aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
+ }
+ else {
+ aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
+ }
+ if ( aBusParamChangeInPort ) {
+ aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
+ cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
+ << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
+ << aBusParamOutPort->PortName() << endl ;
+ if ( !aLabelNode->IsLockedDataWait() ) {
+ res = aLabelNode->SendSomeDataReady( Name() ) ;
+ if ( res ) {
+ if ( firsttoNode == NULL &&
+ aLabelNode->ThreadNo() == pthread_self() ) {
+ firsttoNode = aLabelNode ;
+ cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
+ << aLabelNode->Name() << endl ;
+ }
+ else if ( firstzeroNode == NULL &&
+ aLabelNode->ThreadNo() == 0 ) {
+ firstzeroNode = aLabelNode ;
+ }
+ else {
+ SomeDataNodes.push_back( aLabelNode ) ;
+ cdebug << ThreadNo() << " Successed_SuccessAction push "
+ << SomeDataNodes.size() << " " << aLabelNode->Name()
+ << endl ;
+ }
}
}
- }
+ else {
+ cdebug << ThreadNo()
+ << " Successed_SuccessAction Loop to HeadNode "
+ << aLabelNode->Name() << " with datas from " << Name() << "("
+ << aBusParamOutPort->PortName() << ") to port "
+ << aBusParamChangeInPort->PortName() << endl;
+ }
+ }
else {
- cdebug << ThreadNo()
- << " Successed_SuccessAction Loop to HeadNode "
- << aLabelNode->Name() << " with datas from "
- << aBusParamOutPort->PortName() << " to port "
- << aBusParamChangeInPort->PortName() << endl;
+ cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
+ << " NO port " << aBusParamOutPort->PortName() << " in "
+ << aLabelNode->Name() << endl;
}
- }
- else {
- cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
- << " NO port " << aBusParamOutPort->PortName() << " in "
- << aLabelNode->Name() << endl;
}
}
-// const GraphBase::OutPort * aGateOutPort = GetNodeOutPort( index ) ;
-// const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInPort( index ) ;
- const GraphBase::OutPort * aGateOutPort = GetNodeOutPort( 0 ) ; // DoLoop or OutGate
- const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInPort( 0 ) ;
+ for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
+ const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
+ if ( anInPort->GetOutPort() ) {
+ cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
+ << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
+ << endl ;
+ }
+ }
+// const GraphBase::OutPort * aGateOutPort = GetNodeOutPort( 0 ) ; // DoLoop or OutGate
+ const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
if ( aGateInPort ) {
if ( aGateInPort->GetOutPort() ) {
aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
cdebug << " " << LinkedNodes( i )->Name() ;
}
cdebug << endl;
- SUPERV::ControlState aControl = ControlState() ;
+// SUPERV::ControlState aControl = ControlState() ;
for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
bool IgnoreForEndLoop = false ;
toNode = (GraphExecutor::InNode *) LinkedNodes( i )->GetInNode() ;
cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
<< " [" << i << "] " << LinkedNodes( i )->Name() << endl ;
if ( toNode && !toNode->IsDataFlowNode() ) {
- GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInPort(0) ;
if ( IsComputingNode() && toNode->IsInLineNode() ) {
+ GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
toGateInPort->State( SUPERV::ReadyState ) ;
GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
if ( GateOutPort ) {
}
}
if ( toNode && IsLoopNode() ) {
- GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutPort(0) ;
- if ( !fromLoopOutPort->BoolValue() ) {
+ GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
+ if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
- IgnoreForEndLoop = true ; // toNode is the EndLoopNode
+ IgnoreForEndLoop = true ;
}
- else {
+ else { // toNode is the EndLoopNode
GraphBase::InPort * toLoopInPort ;
- toLoopInPort = toNode->GetChangeNodeInPort(1) ;
+// toLoopInPort = toNode->GetChangeNodeInPort(1) ;
+ toLoopInPort = toNode->GetChangeNodeInLoop() ;
if ( toLoopInPort->State() != SUPERV::ReadyState ) {
toLoopInPort->State( SUPERV::ReadyState ) ;
}
}
if ( toNode && !IgnoreForEndLoop ) {
if ( toNode && toNode->IsLoopNode() ) {
- GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInPort(1) ;
+// GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInPort(1) ;
+ GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
toLoopInPort->State( SUPERV::ReadyState ) ;
GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
LoopOutPort->PortStatus( DataConnected );
<< " Successed_SuccessAction pop firsttoNode "
<< SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
firsttoNode->CreateNewThreadIf( false ) ;
+ firsttoNode->RewindStack( RewindStack() ) ;
if ( firsttoNode->State() == SUPERV::SuccessedState ) {
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
<< " : " << firsttoNode->Name() << " "
void GraphExecutor::InNode::InParametersSet(
bool & Err ,
int nInParams ,
- ServicesAnyData * aListOfInParameters ) {
+ ServicesAnyData * InParametersList ) {
int i ;
for ( i = 0 ; i < nInParams ; i++ ) {
- ServicesAnyData D = aListOfInParameters[i];
+ ServicesAnyData D = InParametersList[i];
GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
if ( anInPort->IsGate() && theOutPort == NULL ) {
<< anInPort->GetServicesParameter().Parametertype
<< " is inactive. " << anInPort->Kind() << endl ;
}
-// else if ( theOutPort->State() == SUPERV::ReadyState ) {
else if ( anInPort->State() == SUPERV::ReadyState ) {
if ( anInPort->IsGate() ) {
CORBA::Any * anAny = new CORBA::Any() ;
theOutPort->Value( anAny ) ;
}
anInPort->State( SUPERV::WaitingState ) ;
-// const CORBA::Any * theValue = theOutPort->Value() ;
D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
-// D.Value = *theValue ; // CORBA::Any
- D.Value = *theOutPort->Value() ; // CORBA::Any
cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() ;
- cdebug << D.Name << " " << anInPort->GetServicesParameter().Parametertype
- << " : " ;
+ cdebug << " " << D.Name << " " << anInPort->GetServicesParameter().Parametertype << " : " ;
+ D.Value = *theOutPort->Value() ; // CORBA::Any
string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
const char * Type = _Type.c_str() ;
- switch (D.Value.type()->kind()) {
+ switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
case CORBA::tk_string:
char * t;
D.Value >>= t;
- cdebug << t << " (string)" << endl ;
+ cdebug << t << " (string)" ;
if ( !strcmp( Type , "string" ) ) {
}
- else if ( !strcmp( Type , "double" ) ) {
- double d ;
- sscanf( t , "%lf" , &d ) ;
- D.Value <<= d ;
- theOutPort->Value( D.Value ) ;
+ else if ( !strcmp( Type , "boolean" ) ) {
+ bool b ;
+ long d ;
+ sscanf( t , "%ld" , &d ) ;
+ b = (bool ) d ;
+ D.Value <<= (CORBA::Any::from_boolean ) b ;
+// theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "char" ) ) {
+ unsigned char c ;
+ long d ;
+ sscanf( t , "%ld" , &d ) ;
+ c = (short ) d ;
+ D.Value <<= (CORBA::Any::from_char ) c ;
+ cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
+// theOutPort->Value( D.Value ) ;
}
- else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+ else if ( !strcmp( Type , "short" ) ) {
+ short s ;
+ long d ;
+ sscanf( t , "%ld" , &d ) ;
+ s = (short ) d ;
+ D.Value <<= s ;
+ cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
+// theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
long l ;
sscanf( t , "%ld" , &l ) ;
D.Value <<= l ;
- theOutPort->Value( D.Value ) ;
+ cdebug << "string '" << t << " --> long " << l ;
+// theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "float" ) ) {
+ double d ;
+ sscanf( t , "%lf" , &d ) ;
+ float f = d ;
+ D.Value <<= f ;
+ cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
+ << setw(25) << setprecision(18) << f ;
+// theOutPort->Value( D.Value ) ;
}
- else if ( !strcmp( Type , "objref" ) ) {
+ else if ( !strcmp( Type , "double" ) ) {
+ double d ;
+ sscanf( t , "%lf" , &d ) ;
+ D.Value <<= d ;
+ cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
+// theOutPort->Value( D.Value ) ;
+ }
+// else if ( !strcmp( Type , "objref" ) ) {
+ else { // Default
CORBA::Object_ptr ObjRef ;
- ObjRef = StringToObject( t ) ;
- D.Value <<= ObjRef ;
- theOutPort->Value( D.Value ) ;
+ try {
+ ObjRef = StringToObject( t ) ;
+ D.Value <<= ObjRef ;
+ }
+ catch( ... ) {
+ D.Value <<= CORBA::Object::_nil() ;
+ }
+// theOutPort->Value( D.Value ) ;
}
- else {
+// else {
+// cdebug << " (other ERROR)" << endl ;
+// }
+ cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
+ break;
+ case CORBA::tk_long:
+ long l;
+ D.Value >>= l;
+ cdebug << l << " (long)" << endl ;
+ if ( !strcmp( Type , "string" ) ) {
+ char t[40] ;
+ sprintf( t , "%ld" , l ) ;
+ D.Value <<= t ;
+// theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "boolean" ) ) {
+ bool b ;
+ b = (bool ) l ;
+ D.Value <<= (CORBA::Any::from_boolean ) b ;
+// theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "char" ) ) {
+ unsigned char c ;
+ c = (unsigned char ) l ;
+ D.Value <<= (CORBA::Any::from_char ) c ;
+// theOutPort->Value( D.Value ) ;
}
+ else if ( !strcmp( Type , "short" ) ) {
+ short s ;
+ s = (short ) l ;
+ D.Value <<= s ;
+// theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
+ }
+ else if ( !strcmp( Type , "float" ) ) {
+ float f ;
+ f = (float ) l ;
+ D.Value <<= f ;
+// theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "double" ) ) {
+ double d ;
+ d = (double ) l ;
+ D.Value <<= d ;
+// theOutPort->Value( D.Value ) ;
+ }
+// else if ( !strcmp( Type , "objref" ) ) {
+ else { // Default
+ D.Value <<= CORBA::Object::_nil() ;
+// theOutPort->Value( D.Value ) ;
+ }
+// else {
+// cdebug << " (other ERROR)" << endl ;
+// }
+ cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
break;
case CORBA::tk_double:
double d;
cdebug << d << " (double)" << endl ;
if ( !strcmp( Type , "string" ) ) {
char t[40] ;
- sprintf( t , "lf" , d ) ;
+ sprintf( t , "%lf" , d ) ;
D.Value <<= t ;
- theOutPort->Value( D.Value ) ;
+// theOutPort->Value( D.Value ) ;
}
- else if ( !strcmp( Type , "double" ) ) {
+ else if ( !strcmp( Type , "boolean" ) ) {
+ bool b ;
+ b = (bool ) d ;
+ D.Value <<= (CORBA::Any::from_boolean ) b ;
+// theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "char" ) ) {
+ unsigned char c ;
+ c = (unsigned char ) d ;
+ D.Value <<= (CORBA::Any::from_char ) c ;
+// theOutPort->Value( D.Value ) ;
}
- else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+ else if ( !strcmp( Type , "short" ) ) {
+ short s ;
+ s = (short ) d ;
+ D.Value <<= s ;
+// theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
long l ;
l = (long ) d ;
D.Value <<= l ;
- theOutPort->Value( D.Value ) ;
+// theOutPort->Value( D.Value ) ;
}
- else if ( !strcmp( Type , "objref" ) ) {
+ else if ( !strcmp( Type , "float" ) ) {
+ float f ;
+ f = (float ) d ;
+ D.Value <<= f ;
+// theOutPort->Value( D.Value ) ;
}
- else {
+ else if ( !strcmp( Type , "double" ) ) {
}
+// else if ( !strcmp( Type , "objref" ) ) {
+ else { // Default
+ D.Value <<= CORBA::Object::_nil() ;
+// theOutPort->Value( D.Value ) ;
+ }
+// else {
+// cdebug << " (other ERROR)" << endl ;
+// }
+ cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
break;
- case CORBA::tk_long:
- long l;
- D.Value >>= l;
- cdebug << l << " (long)" << endl ;
+ case CORBA::tk_objref:
if ( !strcmp( Type , "string" ) ) {
- char t[40] ;
- sprintf( t , "lf" , l ) ;
- D.Value <<= t ;
- theOutPort->Value( D.Value ) ;
+ CORBA::Object_ptr ObjRef ;
+ char * retstr ;
+ try {
+ D.Value >>= ObjRef ;
+ retstr = ObjectToString( ObjRef ) ;
+ D.Value <<= retstr ;
+// theOutPort->Value( D.Value ) ;
+ }
+ catch( ... ) {
+ if ( i != 0 ) {
+ Err = true ;
+ }
+ cdebug << "ToString( object ) Catched ERROR" << endl ;
+ }
}
- else if ( !strcmp( Type , "double" ) ) {
- double d ;
- d = l ;
- D.Value <<= d ;
- theOutPort->Value( D.Value ) ;
+ else if ( !strcmp( Type , "boolean" ) ) {
+ bool b = 0 ;
+ D.Value <<= (CORBA::Any::from_boolean ) b ;
+// theOutPort->Value( D.Value ) ;
}
- else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+ else if ( !strcmp( Type , "char" ) ) {
+ unsigned char c = 0 ;
+ D.Value <<= (CORBA::Any::from_char ) c ;
+// theOutPort->Value( D.Value ) ;
}
- else if ( !strcmp( Type , "objref" ) ) {
+ else if ( !strcmp( Type , "short" ) ) {
+ short s = 0 ;
+ D.Value <<= s ;
+// theOutPort->Value( D.Value ) ;
}
- else {
+ else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
+ long l = 0 ;
+ D.Value <<= l ;
+// theOutPort->Value( D.Value ) ;
}
- break;
- case CORBA::tk_objref:
- CORBA::Object_ptr obj ;
- char * retstr ;
- try {
- D.Value >>= obj ;
-// retstr = _Orb->object_to_string(obj );
- retstr = ObjectToString( obj ) ;
- cdebug << retstr << endl ;
+ else if ( !strcmp( Type , "float" ) ) {
+ float f = 0 ;
+ D.Value <<= f ;
+// theOutPort->Value( D.Value ) ;
}
- catch( ... ) {
- if ( i != 0 ) {
- Err = true ;
- }
- cdebug << "ToString( object ) Catched ERROR" << endl ;
+ else if ( !strcmp( Type , "double" ) ) {
+ double d = 0 ;
+ D.Value <<= d ;
+// theOutPort->Value( D.Value ) ;
}
+// else if ( !strcmp( Type , "objref" ) ) {
+ else { // Default
+ CORBA::Object_ptr obj ;
+ char * retstr ;
+ try {
+ D.Value >>= obj ;
+ retstr = ObjectToString( obj ) ;
+ cdebug << retstr << endl ;
+ }
+ catch( ... ) {
+ if ( i != 0 ) {
+ Err = true ;
+ }
+ cdebug << "ToString( object ) Catched ERROR" << endl ;
+ }
+ }
+// else {
+// cdebug << " (other ERROR)" << endl ;
+// }
+ cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
break;
default:
- cdebug << " (other ERROR)" << endl ;
+ cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
}
}
else {
<< anInPort->GetServicesParameter().Parametername << endl ;
Err = true ;
}
- aListOfInParameters[i] = D ;
+ InParametersList[i] = D ;
}
}
-void GraphExecutor::InNode::InOutParameters(
+void GraphExecutor::InNode::InOutParametersSet(
int nOutParams ,
- ServicesAnyData * aListOfOutParameters ) {
+ ServicesAnyData * OutParametersList ) {
int i ;
for ( i = 0 ; i < nOutParams ; i++ ) {
- ServicesAnyData D = aListOfOutParameters[i] ;
+ ServicesAnyData D = OutParametersList[i] ;
D.Name = GetChangeNodeOutPort(i)->GetServicesParameter().Parametername;
string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
if ( !strcmp( Type , "string" ) ) {
D.Value <<= (char *) NULL ;
}
- else if ( !strcmp( Type , "double" ) ) {
- D.Value <<= 0. ;
+ else if ( !strcmp( Type , "boolean" ) ) {
+ bool b = 0 ;
+ D.Value <<= (CORBA::Any::from_boolean ) b ;
+ }
+ else if ( !strcmp( Type , "char" ) ) {
+ unsigned char c = 0 ;
+ D.Value <<= (CORBA::Any::from_char ) c ;
+ }
+ else if ( !strcmp( Type , "short" ) ) {
+ short s = 0 ;
+ D.Value <<= s ;
}
- else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+ else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
D.Value <<= (long ) 0 ;
}
+ else if ( !strcmp( Type , "float" ) ) {
+ float f = 0 ;
+ D.Value <<= f ;
+ }
+ else if ( !strcmp( Type , "double" ) ) {
+ double d = 0 ;
+ D.Value <<= d ;
+ }
else {
-// D.Value.replace(CORBA::_tc_Object, NULL);
D.Value <<= CORBA::Object::_nil() ;
}
-// GetChangeNodeOutPort(i)->Value( D.Value ) ;
//#if 0
- switch (D.Value.type()->kind()) {
+ switch (D.Value.type()->kind()) { // { string , long , double , objref }
case CORBA::tk_string:
char * t;
D.Value >>= t;
cdebug << ThreadNo() << " " << t << "(string)" << endl ;
break;
- case CORBA::tk_double:
- double d;
- D.Value >>= d;
- cdebug << ThreadNo() << " " << d << "(double)" << endl ;
+ case CORBA::tk_boolean:
+ bool b ;
+ D.Value >>= (CORBA::Any::to_boolean ) b;
+ cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
+ break;
+ case CORBA::tk_char:
+ unsigned char c ;
+ D.Value >>= (CORBA::Any::to_char ) c;
+ cdebug << ThreadNo() << " " << c << "(char)" << endl ;
+ break;
+ case CORBA::tk_short:
+ short s;
+ D.Value >>= s;
+ cdebug << ThreadNo() << " " << s << "(short)" << endl ;
break;
case CORBA::tk_long:
long l;
D.Value >>= l;
cdebug << ThreadNo() << " " << l << "(long)" << endl ;
break;
+ case CORBA::tk_float:
+ float f;
+ D.Value >>= f;
+ cdebug << ThreadNo() << " " << f << "(float)" << endl ;
+ break;
+ case CORBA::tk_double:
+ double d;
+ D.Value >>= d;
+ cdebug << ThreadNo() << " " << d << "(double)" << endl ;
+ break;
case CORBA::tk_objref:
- cdebug << ThreadNo() << " " << "(object)" << endl ;
+ try {
+ CORBA::Object_ptr obj ;
+ char * retstr ;
+ D.Value >>= obj ;
+ retstr = ObjectToString( obj ) ;
+ cdebug << ThreadNo() << retstr << endl ;
+ }
+ catch( ... ) {
+ cdebug << "ToString( object ) Catched ERROR" << endl ;
+ }
break;
default:
cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
}
//#endif
- aListOfOutParameters[i] = D ;
+ OutParametersList[i] = D ;
}
}
-bool GraphExecutor::InNode::OutParameters(
+bool GraphExecutor::InNode::OutParametersSet(
bool Err ,
SUPERV::GraphState NewState ,
int nOutParams ,
- ServicesAnyData * aListOfOutParameters ) {
+ ServicesAnyData * OutParametersList ) {
bool RetVal = true ;
int i ;
GraphBase::OutPort * aGateOutPort = NULL ;
bool OrSwitch = false ;
- GraphBase::OutPort * anOutPort = GetChangeNodeOutPort(0) ;
- for ( i = 0 ; i < nOutParams ; i++ ) {
- anOutPort = GetChangeNodeOutPort(i) ;
- if ( Err ) {
- anOutPort->State( NewState ) ;
- anOutPort->Done( true ) ;
- }
- else {
- cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
- << anOutPort->PortName() << " " << anOutPort->Kind() ;
- if ( anOutPort->IsGate() ) {
- aGateOutPort = anOutPort ;
- cdebug << " Gate " ;
- long l = 1;
- aListOfOutParameters[i].Value <<= l;
- anOutPort->Value( aListOfOutParameters[i].Value );
- }
- else if ( anOutPort->IsLoop() ) {
- cdebug << " Loop " ;
- anOutPort->Value( aListOfOutParameters[i].Value );
-// InLoop Port of EndLoopNode is ready :
- anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
- }
- else if ( anOutPort->IsSwitch() ) {
- cdebug << " Switch " ;
- anOutPort->Value( aListOfOutParameters[i].Value );
- if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
- if ( OrSwitch && anOutPort->BoolValue() ) {
- cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true WARNING"
- << endl ;
-// RetVal = false ;
- }
- else {
- OrSwitch = OrSwitch | anOutPort->BoolValue() ;
- }
- }
- cdebug << "OrSwitch " << OrSwitch ;
+ if ( nOutParams ) {
+ GraphBase::OutPort * anOutPort ;
+ for ( i = 0 ; i < nOutParams ; i++ ) {
+ anOutPort = GetChangeNodeOutPort(i) ;
+ if ( Err ) {
+ anOutPort->State( NewState ) ;
+ anOutPort->Done( true ) ;
}
else {
- cdebug << " Param " ;
- anOutPort->Value( aListOfOutParameters[i].Value );
- }
-// else if ( anOutPort->IsBus() ) {
-// cdebug << " Bus " ;
-// anOutPort->Value( GetNodeInPort( anOutPort->PortIndex() )->GetOutPort()->Value() );
-// }
- anOutPort->State( NewState ) ;
- anOutPort->Done( true ) ;
- int j ;
- for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
- bool fromGOTO = false ;
- GraphBase::OutPort * aGOTOPort = _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetChangeNodeInPort( 0 )->GetOutPort() ;
- if ( aGOTOPort ) {
- fromGOTO = aGOTOPort->IsGOTO() ;
+ cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
+ << anOutPort->PortName() << " " << anOutPort->Kind() ;
+ ServicesAnyData D = OutParametersList[i] ;
+ switch (D.Value.type()->kind()) { // { string , long , double , objref }
+ case CORBA::tk_string: {
+ char * t;
+ D.Value >>= t;
+ cdebug << ThreadNo() << " " << t << "(string)" << endl ;
+ break;
}
- if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
- cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
- << anOutPort->ChangeInPorts( j )->PortName() << ","
- << anOutPort->ChangeInPorts( j )->Kind() << ") WILL BE changed from "
- << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
- << "("
- << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
- << ") to " << anOutPort->NodeName() << "("
- << anOutPort->PortName() << ")" << endl ;
- anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
+ case CORBA::tk_boolean: {
+ bool b ;
+ D.Value >>= (CORBA::Any::to_boolean ) b;
+ long l = (long ) b ;
+ D.Value <<= l ;
+ cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
+ break;
}
- else {
- cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
- << anOutPort->ChangeInPorts( j )->PortName() << ","
- << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
- << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
- << "("
- << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
- << ") to " << anOutPort->NodeName() << "("
- << anOutPort->PortName() << ")" << endl ;
+ case CORBA::tk_char: {
+ unsigned char c ;
+ D.Value >>= (CORBA::Any::to_char ) c;
+ long l = (long ) c ;
+ D.Value <<= l ;
+ cdebug << ThreadNo() << " " << c << "(char)" << endl ;
+ break;
}
- }
-#if 0
- switch (anOutPort->Value()->type()->kind()) {
- case CORBA::tk_string:
- char * t;
- (*anOutPort->Value()) >>= t;
- cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
- break;
- case CORBA::tk_double:
- double d;
- (*anOutPort->Value()) >>= d;
- cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
- break;
- case CORBA::tk_long:
- long l;
- (*anOutPort->Value()) >>= l;
- cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
- break;
- case CORBA::tk_objref:
- CORBA::Object_ptr obj ;
- char * retstr ;
- try {
- (*anOutPort->Value()) >>= obj ;
- retstr = _Orb->object_to_string(obj );
- cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
- << retstr << endl ;
+ case CORBA::tk_short: {
+ short s;
+ D.Value >>= s;
+ long l = (long ) s ;
+ D.Value <<= l ;
+ cdebug << ThreadNo() << " " << s << "(short)" << endl ;
+ break;
}
- catch ( ... ) {
- cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
- << "Catched ERROR" << endl ;
+ case CORBA::tk_long: {
+ long l;
+ D.Value >>= l;
+ cdebug << ThreadNo() << " " << l << "(long)" << endl ;
+ break;
}
- break;
- default:
- cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
- RetVal = false ;
+ case CORBA::tk_float: {
+ float f;
+ D.Value >>= f;
+ double d = (double ) f ;
+ D.Value <<= d ;
+ cdebug << ThreadNo() << " " << f << "(float)" << endl ;
+ break;
+ }
+ case CORBA::tk_double: {
+ double d;
+ D.Value >>= d;
+ cdebug << ThreadNo() << " " << d << "(double)" << endl ;
+ break;
+ }
+ case CORBA::tk_objref: {
+ try {
+ CORBA::Object_ptr obj ;
+ char * retstr ;
+ D.Value >>= obj ;
+ retstr = ObjectToString( obj ) ;
+ cdebug << ThreadNo() << retstr << endl ;
+ }
+ catch( ... ) {
+ cdebug << "ToString( object ) Catched ERROR" << endl ;
+ }
+ break;
+ }
+ default: {
+ cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
+ }
+ }
+ OutParametersList[i] = D ;
+ if ( anOutPort->IsGate() ) {
+ aGateOutPort = anOutPort ;
+ cdebug << " Gate " ;
+ long l = 1;
+ OutParametersList[i].Value <<= l;
+ anOutPort->Value( OutParametersList[i].Value );
+ }
+ else if ( anOutPort->IsLoop() ) {
+ cdebug << " Loop " ;
+ anOutPort->Value( OutParametersList[i].Value );
+// InLoop Port of EndLoopNode is ready :
+ anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
+ }
+ else if ( anOutPort->IsSwitch() ) {
+ cdebug << " Switch " ;
+ anOutPort->Value( OutParametersList[i].Value );
+ if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
+ if ( OrSwitch && anOutPort->BoolValue() ) {
+ cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true WARNING"
+ << endl ;
+ }
+ else {
+ OrSwitch = OrSwitch | anOutPort->BoolValue() ;
+ }
+ }
+ cdebug << "OrSwitch " << OrSwitch ;
+ }
+ else {
+ cdebug << " Param " ;
+ anOutPort->Value( OutParametersList[i].Value );
+ }
+ anOutPort->State( NewState ) ;
+ anOutPort->Done( true ) ;
+ int j ;
+ for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
+ bool fromGOTO = false ;
+ GraphBase::OutPort * aGOTOPort = _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetChangeNodeInGate()->GetOutPort() ;
+ if ( aGOTOPort ) {
+ fromGOTO = aGOTOPort->IsGOTO() ;
+ }
+ if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
+ cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
+ << anOutPort->ChangeInPorts( j )->PortName() << ","
+ << anOutPort->ChangeInPorts( j )->Kind() << ") WILL BE changed from "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
+ << "("
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
+ << ") to " << anOutPort->NodeName() << "("
+ << anOutPort->PortName() << ")" << endl ;
+ anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
+ }
+ else {
+ cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
+ << anOutPort->ChangeInPorts( j )->PortName() << ","
+ << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
+ << "("
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
+ << ") to " << anOutPort->NodeName() << "("
+ << anOutPort->PortName() << ")" << endl ;
+ }
+ }
+//#if 0
+ switch (anOutPort->Value()->type()->kind()) {
+ case CORBA::tk_string:
+ char * t;
+ (*anOutPort->Value()) >>= t;
+ cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
+ break;
+ case CORBA::tk_boolean:
+ bool b ;
+ (*anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
+ cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
+ break;
+ case CORBA::tk_char:
+ unsigned char c ;
+ (*anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
+ cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
+ break;
+ case CORBA::tk_short:
+ short s;
+ (*anOutPort->Value()) >>= s;
+ cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
+ break;
+ case CORBA::tk_long:
+ long l;
+ (*anOutPort->Value()) >>= l;
+ cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
+ break;
+ case CORBA::tk_float:
+ float f;
+ (*anOutPort->Value()) >>= f;
+ cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
+ break;
+ case CORBA::tk_double:
+ double d;
+ (*anOutPort->Value()) >>= d;
+ cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
+ break;
+ case CORBA::tk_objref:
+ CORBA::Object_ptr obj ;
+ char * retstr ;
+ try {
+ (*anOutPort->Value()) >>= obj ;
+ retstr = ObjectToString( obj );
+ cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
+ << retstr << endl ;
+ }
+ catch ( ... ) {
+ cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
+ << "Catched ERROR" << endl ;
+ }
+ break;
+ default:
+ cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
+ RetVal = false ;
+ }
+//#endif
}
-#endif
- }
- }
- if ( aGateOutPort && IsSwitchNode() ) {
- if ( OrSwitch ) {
- cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
- << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
- long l = 0;
- aListOfOutParameters[0].Value <<= l ;
- aGateOutPort->Value( aListOfOutParameters[0].Value ) ;
}
- else {
- cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
- << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
- long l = 1;
- aListOfOutParameters[0].Value <<= l ;
- aGateOutPort->Value( aListOfOutParameters[0].Value ) ;
- int i ;
- for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
- GraphBase::InPort * anInPort ;
- anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
- if ( anInPort ) {
- anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
- }
+ if ( aGateOutPort && IsSwitchNode() ) {
+ if ( OrSwitch ) {
+// cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
+// << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
+ long l = 0;
+ OutParametersList[0].Value <<= l ;
+ aGateOutPort->Value( OutParametersList[0].Value ) ;
+ }
+ else {
+// cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
+// << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
+ long l = 1;
+ OutParametersList[0].Value <<= l ;
+ aGateOutPort->Value( OutParametersList[0].Value ) ;
+ int i ;
+ for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+ GraphBase::InPort * anInPort ;
+ anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
+ if ( anInPort ) {
+ anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
+ }
+ }
}
}
}