#endif
}
-#define SendEventTrace 0
+#define SendEventTrace 1
int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {
_CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
#if SendEventTrace
- cdebug_in << pthread_self() << "/" << ThreadNo() << " -->SendEvent Node " << Name()
- << " ControlState : "
- << Automaton()->ControlStateName( ControlState() )
- << " Event : " << Automaton()->EventName( anEvent )
- << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack << endl;
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " SendEvent Graph " << _OutNode->Name()
+ << " Node " << Name() << " Event : " << Automaton()->EventName( anEvent )
+ << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack
+ << " ControlState : " << Automaton()->ControlStateName( ControlState() )
+ << endl;
#endif
_OldState = State() ;
_NextState = Automaton()->NextState( _OldState , anEvent ) ;
if ( _NextState == _OldState ) {
- cdebug << pthread_self() << "/" << ThreadNo()
- << " GraphExecutor::InNodeThreads::SendEvent SameStates "
- << _OldState << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " GraphExecutor::InNodeThreads::SendEvent SameStates ERROR _OldState/_NextState "
+ << _OldState << " Event " << Automaton()->EventName( anEvent ) << endl ;
_NextAction = GraphExecutor::VoidAction ;
+ return 0 ;
}
else {
_NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
<< " _RewindStack " << _RewindStack << endl ;
#endif
- int sts = executeAction() ;
+ int sts = true ;
+#if ExitWhenNodeAborted
+ if ( _OutNode->IsNodeAborted() ) {
+#if SendEventTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
+ << " will exit : a node was aborted ..." << endl ;
+ State( _NextState ) ;
+#endif
+ }
+ else {
+ sts = executeAction() ;
+ }
+#else
+ sts = executeAction() ;
+#endif
#if SendEventTrace
cdebug_out << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
}
-#define ActionsTrace 0
+#define ActionsTrace 1
// ReadyAction - RunningAction - DoneAction - SuspendedAction :
// for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
void GraphExecutor::InNode::ReadyAction() {
GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
_aReStartNode = aReStartNode ;
_aReStartEvent = anEvent ;
- cdebug << pthread_self() << " GraphExecutor::InNodeThreads::ReStartAction from "
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " GraphExecutor::InNodeThreads::ReStartAction from "
<< Name() << " " << Automaton()->StateName( State() ) << " to "
<< aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
<< Automaton()->StateName( aReStartNode->State() ) ;
cdebug << pthread_self() << "/" << ThreadNo()
<< " executeAction start Thread _RewindStack " << _RewindStack << " > "
<< MAXSTACKTHREADSIZE << " CreateNewThread "
- << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
- << endl;
+ << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "("
+ << Name() << ")" << endl;
#endif
CreateNewThread( true ) ;
_OutNode->IncrCreatedThreads() ;
}
if ( CreateNewThread() ) {
CreateNewThread( false ) ;
- if ( ThreadNo() == 0 ) {
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// if ( ThreadNo() == 0 ) {
_RewindStack = 1 ;
#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
pthread_exit( msg ) ;
}
#if ActionsTrace
- cdebug << pthread_self() << "/" << ThreadNo()
- << "executeAction has created thread " << T << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " executeAction has created thread " << T << endl ;
#endif
ThreadStartedAction() ;
#if ActionsTrace
- cdebug << pthread_self() << "/" << ThreadNo()
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
<< "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
<< Name() << endl ;
#endif
}
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+#if 0
else {
#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
}
}
}
+#endif
else {
if ( _CurrentEvent == ExecuteEvent ) {
_RewindStack += 1 ;
const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
const char * statename = Automaton()->StateName( State() ) ;
const char * nextstatename = Automaton()->StateName( _NextState ) ;
- cdebug_in << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction "
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name() << " --> ExecuteAction "
<< nextactionname << " " << statename << " NextState "
<< nextstatename << endl ;
#endif
sts = Executing_SuccessAction() ;
break ;
}
- case GraphExecutor::Executing_ErrorAction : {
- sts = Executing_ErrorAction() ;
+ case GraphExecutor::Errored_ExecutingAction : {
+ sts = Errored_ExecutingAction() ;
break ;
}
case GraphExecutor::Successed_SuccessAction : {
return 1;
}
-#define SomeDataReadyTrace 0
+#define SomeDataReadyActionTrace 1
int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
-#if SomeDataReadyTrace
- cdebug << pthread_self() << "/" << ThreadNo()
- << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
- << " to " << Name() << endl;
+#if SomeDataReadyActionTrace
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " DataWaiting_SomeDataReadyAction from " << DataFromNode() << endl;
#endif
unsigned int k;
int InReady = 0 ;
bool LoopBeginning = false ;
bool LoopFinished = false ;
bool SwitchFinished = false ;
+ bool SwitchDefault = false ;
+ bool DoAllDataReadyIf = true ;
if ( IsLoopNode() ) {
GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
LoopBeginning = true ; // Beginning of Loop
}
}
- if ( IsEndLoopNode() ) {
+ else if ( IsEndLoopNode() ) {
GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) {
LoopFinished = true ; // End of Loop
}
}
- if ( IsEndSwitchNode() && strcmp( GOTONode()->CoupledNode()->Name() , DataFromNode() ) ) {
- GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default Port
-//JR 09.02.2005 : SomeDataReady is not from the SwitchNode
- if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
+ else if ( IsEndSwitchNode() ) {
+ if ( strcmp( GOTONode()->CoupledNode()->Name() , DataFromNode() ) ) {
+ GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default Port
+//JR 09.02.2005 : SomeDataReady is NOT from the SwitchNode
+ if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
//JR 09.02.2005 : the OutPort of the SwitchNode connected to the default port is closed ===>
-// Here after we consider that that DefaultPort is Ready (even if it's value is false)
- SwitchFinished = true ; // End of Switch
+// Here after we consider that that DefaultPort is Ready (even if it's value is false) in
+// order to have the good count of InPorts Ready in the EndSwitchNode
+// SwitchFinished = true ; // End of Switch
+//JR 25.08.2005 :
+// But we do that only if the InDefaultPort of the EndSwitchNode is not connected or
+// is connected from the OutDefaultPort of the corresponding SwitchNode
+ if ( !strcmp( GOTONode()->CoupledNode()->Name() , anOutGateSwitchPort->NodeName() ) ) {
+ SwitchFinished = true ; // End of Switch
+ }
+ }
+ }
+ else {
+//JR 20.04.2005 : SomeDataReady is FROM the SwitchNode to that EndSwitchNode
+//PAL8518
+//JR 16.02.2005 Debug : Change InPorts of EndSwitchNode that have the same name as an OutPort of
+// the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
+ GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default P
+//JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is activated :
+ if ( anOutGateSwitchPort ) {
+ if ( anOutGateSwitchPort->BoolValue() ) {
+ SwitchDefault = true ;
+ }
+//JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is NOT activated :
+// a SwitchBranch should be activated
+ else {
+ DoAllDataReadyIf = false ;
+ }
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " activated from CoupledNode " << GOTONode()->CoupledNode()->Name() << " "
+ << anOutGateSwitchPort->NodeName() << "( " << anOutGateSwitchPort->PortName()
+ << " ) to InDefault " ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutGateSwitchPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+#endif
+ }
+//JR 28.06.2005 : SomeDataReady is from the SwitchNode and the InDefault is not connected :
+// a SwitchBranch should be activated
+ else {
+ DoAllDataReadyIf = false ;
+ }
}
}
-#if SomeDataReadyTrace
+
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
- << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << endl ;
+ << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished
+ << " SwitchDefault " << SwitchDefault << " DoAllDataReadyIf " << DoAllDataReadyIf << endl ;
#endif
for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
- GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
-#if SomeDataReadyTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " << anInPort->PortName() << " " << anInPort->PortState() << " " << anInPort->PortStatus() ;
+ GraphBase::OutPort * anOutPort ;
+ if ( SwitchDefault && !anInPort->IsDataStream() ) {
+//Get or Set the field OutPort of that InPort of the EndSwitchNode to the corresponding OutPort
+// of the SwitchNode
+ anOutPort = anInPort->GetOutPort() ;
+ if ( anOutPort ) {
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " already setted to OutPort " << anOutPort->NodeName()
+ << "( " << anOutPort->PortName() << " )" << endl ;
+#endif
+ }
+ else {
+ anOutPort = CoupledNode()->GetChangeOutPort( anInPort->PortName() ) ;
+ if ( anOutPort ) {
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " change of OutPort from "
+ << anInPort->GetOutPort()->NodeName() << "( " << anInPort->GetOutPort()->PortName()
+ << " ) to " << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )"
+ << endl ;
+#endif
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " have NO OutPort ERROR " << endl ;
+ return 0 ;
+ }
+ anInPort->ChangeOutPort( anOutPort ) ;
+ }
+ }
+ else {
+ anOutPort = anInPort->GetOutPort() ;
+ }
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " " << anInPort->PortState() << " "
+ << anInPort->PortStatus() << " " << anInPort->Kind() ;
if ( anOutPort ) {
cdebug << " from OutPort " << anOutPort->NodeName() << "( " << anOutPort->PortName()
<< " )" ;
}
+ else {
+ cdebug << " without OutPort " ;
+ }
cdebug<< endl ;
#endif
if ( anInPort->IsGate() && anOutPort == NULL ) {
InReady += 1 ;
anInPort->PortState( SUPERV::ReadyState ) ;
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " ControlPort inactive." << endl ;
#endif
}
+
// That InPort get its value from an other node : the node of anOutPort linked to that anInPort is
-// different from the sender of SomeDataReady (DataFromNode)
+// different from the sender of SomeDataReady (DataFromNode) :
else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
if ( anInPort->PortState() == SUPERV::ReadyState ) {
InReady += 1 ;
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
- << anInPort->PortName() << " Was Done from Node "
- << anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") ReadyState " ;
+ << anInPort->PortName() << " " << anInPort->PortState() << " Was Done from Node "
+ << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
+ << anOutPort->PortState() << " ) PortDone " << anOutPort->PortDone() << " " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") LoopBeginning " << LoopBeginning ;
+ << ") LoopBeginning " << LoopBeginning << " " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
else if ( LoopFinished ) {
anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") LoopFinished" ;
+ << ") LoopFinished " << LoopFinished << " " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
else if ( anInPort->IsGate() && SwitchFinished ) {
anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") SwitchFinished" ;
+ << ") SwitchFinished " << SwitchFinished << " " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
CORBA::Any anAny = CORBA::Any() ;
//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
anAny <<= (long ) 1 ;
- _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->GetChangeNodeOutGate()->Value( anAny ) ;
-#if SomeDataReadyTrace
+ _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->GetChangeNodeOutGate()->SetValue( anAny ) ;
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") GOTONode" ;
+ << ") GOTONode " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
#endif
}
else {
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
- << anInPort->PortName() << " Was NOT Done from Node "
- << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
- << " " << Automaton()->StateName( State() ) << " DataConnected "
- << anInPort->IsDataConnected() << " LoopBeginning "
- << LoopBeginning << endl ;
+ << " " << Automaton()->StateName( State() ) << " LoopBeginning "
+ << LoopBeginning << " " << anInPort->PortName() << " DataConnected "
+ << anInPort->IsDataConnected() << " Was NOT Done from Node "
+ << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
+ << anOutPort->PortState() << " , PortDone " << anOutPort->PortDone() << ") "
+ << endl ;
#endif
}
}
+
// That InPort get its value from the sending node (DataFromNode)
else if ( anInPort->IsGate() ) {
//JR 30.03.2005 const CORBA::Any * theValue = anOutPort->Value() ;
if ( GateOpened != 0 ) {
InReady += 1 ;
anInPort->PortState( SUPERV::ReadyState ) ;
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Gate is Opened from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
else if ( LoopFinished ) {
anInPort->PortState( SUPERV::ReadyState ) ;
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " GATE IS CLOSED from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
#endif
}
else {
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " GATE IS CLOSED from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
}
else if ( anOutPort->PortDone() ) {
- InReady += 1 ;
- anInPort->PortState( SUPERV::ReadyState ) ;
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
<< anInPort->PortName() << " " << anInPort->PortStatus() << " "
<< Automaton()->StateName( anInPort->PortState() ) << " is Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
- << anOutPort->PortStatus() << " " ;
+ << anOutPort->PortStatus() << " --> ReadyState " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
#endif
cdebug << endl ;
#endif
+ InReady += 1 ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
// MacroNode : give immediately the value to the corresponding graph
if ( IsMacroNode() ) {
- cout << "SomeDataReadyAction " << GraphMacroNode() << " " << GraphMacroNode()->Name()
- << " coupled to " << GraphMacroNode()->CoupledNode() << endl ;
GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
- cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Graph()->Name() << " --> InputOfAny "
- << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready" << endl ;
+ cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name() << " --> InputOfAny "
+ << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready ( "
+ << anInPort->PortName() << " ) ===> InputOfAny" << endl ;
// GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
//JR 30.03.2005 aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
}
}
else {
-#if SomeDataReadyTrace
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( "
<< anInPort->PortName() << ") " << anInPort->PortStatus()
<< " is NOT Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
- << anOutPort->PortStatus() << " " << endl ;
+ << anOutPort->PortStatus() << " " << anOutPort->PortDone() << endl ;
#endif
}
}
- if ( InReady == GetNodeInPortsSize() ) { // All Flags != 0 :
- res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
+ if ( InReady == GetNodeInPortsSize() && DoAllDataReadyIf ) { // All Flags != 0 :
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << " HasAllDataReady"
+ << endl ;
+#endif
+ HasAllDataReady( true ) ; // ==> Ready to execute
+ res = 1 ;
}
else { // At least one Flag == 0 :
+ HasAllDataReady( false ) ;
res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
}
-#if SomeDataReadyTrace
- cdebug << pthread_self() << "/" << ThreadNo()
- << " <-- DataWaiting_SomeDataReadyAction " << Name() << endl;
+#if SomeDataReadyActionTrace
+ cdebug_out << pthread_self() << "/" << ThreadNo() << Name()
+ << " DataWaiting_SomeDataReadyAction " << endl;
#endif
return res ;
}
-#define TraceDataReadyAction 0
+#define NotAllDataReadyActionTrace 1
int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
- CreateNewThreadIf( false ) ;
-#if TraceDataReadyAction
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// CreateNewThreadIf( false ) ;
+#if NotAllDataReadyActionTrace
cdebug << pthread_self() << " for " << ThreadNo()
<< " DataUndef_NotAllDataReadyAction " << Name() << endl;
#endif
return 1;
}
+#define AllDataReadyActionTrace 1
int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
-#if TraceDataReadyAction
+#if AllDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo()
- << " --> DataUndef_AllDataReadyAction " << Name()
- << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
- << IsLockedDataWait() ;
-#endif
- if ( IsLockedDataWait() ) {
-#if TraceDataReadyAction
- cdebug << "DataUndef_AllDataReadyAction() " << Name() << "WOULD DEAD-LOCK" << endl ;
-#endif
- return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
- }
-#if TraceDataReadyAction
- cdebug << "InNode::DataUndef_AllDataReadyAction CreateNewThread( CreateNewThreadIf() ) "
- << CreateNewThreadIf() << endl ;
+ << " --> DataUndef_AllDataReadyAction " << Name() << endl ;
+// << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
+// << IsLockedDataWait() ;
#endif
- CreateNewThread( CreateNewThreadIf() ) ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
if ( !CreateNewThread() ) {
-#if TraceDataReadyAction
- cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
+#if AllDataReadyActionTrace
+ cdebug << "Thread " << ThreadNo() << " --> " << pthread_self() << endl ;
#endif
ThreadNo( pthread_self() ) ;
}
return 0;
}
}
-#if TraceDataReadyAction
+#if AllDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< " <-- DataUndef_AllDataReadyAction " << Name() << endl;
#endif
#include <CORBA.h>
-#define TraceDataReady_ExecuteAction 0
+#define TraceDataReady_ExecuteAction 1
int GraphExecutor::InNode::DataReady_ExecuteAction() {
#if TraceDataReady_ExecuteAction
- cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
- << Name() << endl;
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " DataReady_ExecuteAction "
+ << Name() << endl;
#endif
_OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
GraphExecutor::ExecutingState ) ;
bool Err = false ;
+ Engines::Container_var myContainer ;
+ Engines::Component_var myObjComponent ;
+
SUPERV::GraphState PortState = SUPERV::ReadyState ;
GraphExecutor::AutomatonState NewState = GraphExecutor::DataUndefState ;
GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
int nInParams ;
- ServicesAnyData * InParametersList ;
+ ServicesAnyData * InParametersList = NULL ;
int nOutParams ;
- ServicesAnyData * OutParametersList ;
+ ServicesAnyData * OutParametersList = NULL ;
nInParams = GetNodeInPortsSize() ;
+#if TraceDataReady_ExecuteAction
+ char * aName = Name() ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << aName
+ << " nInParams " << nInParams << " InParametersList "
+ << (void * ) InParametersList << endl ;
+#endif
InParametersList = new ServicesAnyData[nInParams];
InParametersSet( Err , nInParams , InParametersList ) ;
nOutParams = GetNodeOutPortsSize() ;
OutParametersList = new ServicesAnyData[nOutParams];
InOutParametersSet( nOutParams , OutParametersList ) ;
+#if 0
+ if ( !Err && IsComputingNode() ) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " after creation of InParametersList : nInParams " << nInParams
+ << " :" << endl;
+ int i ;
+ for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+ cdebug << "InParametersList[" << i << "] : "
+ << InParametersList[i].Name << " "
+ << AnyValue( InParametersList[i].Value ) << endl ;
+ }
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ Engines::Component_var theObjComponent ;
+ theObjComponent = Engines::Component::_narrow( obj ) ;
+ DynInvoke( theObjComponent , "ping" ,
+ NULL , 0 , NULL , 0 ) ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " ping done "
+ << endl ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " after creation of OutParametersList :" << endl;
+ for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
+ cdebug << "OutParametersList[" << i << "] : "
+ << OutParametersList[i].Name << " "
+ << AnyValue( OutParametersList[i].Value ) << endl ;
+ }
+ }
+#endif
if ( !IsMacroNode() ) {
- Engines::Container_var myContainer ;
- Engines::Component_var myObjComponent ;
if ( !IsFactoryNode() ) {
#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
#endif
if ( IsComputingNode() ) {
ObjInterface( true ) ;
+//JR 05.08.2005 DEBUG : that code runs with SALOME_3 (OMNIOrb4) ...
+#if OMNIORB_VERSION >= 4
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ myObjComponent = Engines::Component::_narrow( obj ) ;
+//JR 05.08.2005 DEBUG : the folowing code runs with OMNIOrb3 but gives
+// unpredictable results with SALOME_3 (OMNIOrb4) ...
+#else
CORBA::Object_ptr obj ;
InParametersList[0].Value >>= obj ;
CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
- myObjComponent = Engines::Component::_narrow( objvar ) ;
+ myObjComponent = Engines::Component::_duplicate( Engines::Component::_narrow( objvar ) ) ;
+#endif
}
else {
}
}
else if ( CORBA::is_nil( Component() ) ) {
-// ostringstream astr ;
-// astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name()
-// << " : load of component " << ComponentName() << " in container "
-// << Computer() ;
-// _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() ,
//JR 17.02.2005 Memory Leak my_strdup( ComponentName() ) ,
ComponentName() ,
#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
<< endl ;
-#endif
try {
myObjComponent->ping() ;
}
catch( ... ) {
- cdebug << "ping() catched" << endl ;
+ cdebug << "ping() ERROR catched" << endl ;
Err = true ;
}
+#endif
}
if ( Err || ControlState() == SUPERV::ToKillState ||
ControlState() == SUPERV::ToStopState ) {
#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
-// MESSAGE(pthread_self() << "Executor::InNode::DataReady_ExecuteAction of " << Name()
-// << " ControlState " << Automaton()->ControlStateName( ControlState() )
-// << " BEFORE execution ThreadNo " << ThreadNo() ) ;
#endif
Err = true ;
}
MESSAGE(ThreadNo() << "ToSuspendState before running.") ;
#endif
}
- if ( !Err ) {
-// ostringstream astr ;
-// astr << "Graph " << _OutNode->Graph()->Name() << " Run of Node " << Name() ;
-// _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
#if TraceDataReady_ExecuteAction
- int i;
- cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
- 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() << "]" ;
- }
- if ( IsOneOfInLineNodes() ) {
- cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
- << InLineNode()->PyRunMethod() << " length "
- << (*InLineNode()->PythonFunction()).length() ;
- }
- cdebug << ")" << endl ;
+ int i;
+ cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
+ 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() << "]" ;
+ }
+ if ( IsOneOfInLineNodes() ) {
+ cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
+ << InLineNode()->PyRunMethod() << " length "
+ << (*InLineNode()->PythonFunction()).length()
+ << " InParametersList " << InParametersList
+ << " OutParametersList " << OutParametersList ;
+ }
+ cdebug << ")" << endl ;
#endif
- if ( IsOneOfInLineNodes() ) {
- bool StsPyDynInvoke = true;
- _OutNode->PyThreadLock() ;
- SetPyCpuUsed() ;
- try {
-// if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
- bool ItIsaLoop = false ;
- bool CopyInOut = false ;
- if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
- strlen( InLineNode()->PyFuncName() ) ) {
-#if TraceDataReady_ExecuteAction
- cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
- << InLineNode()->PyFuncName()
- << "' IsInLineNode PyDynInvoke" << endl ;
-#endif
- StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
- } }
- else if ( IsLoopNode() ) {
- ItIsaLoop = 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
-// GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
-// if ( GetNodeInLoop()->GetOutPort()->BoolValue() &&
- 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 ) {
- 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 ) {
- 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
- switch ( InParametersList[i].Value.type()->kind() ) {
- case CORBA::tk_string :
- char * t;
- InParametersList[i].Value >>= t ;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(string) " << t << endl ;
- break ;
- case CORBA::tk_boolean:
- bool b ;
- InParametersList[i].Value >>= (CORBA::Any::to_boolean ) b;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(boolean) " << b << endl ;
- break ;
- case CORBA::tk_char:
- unsigned char c ;
- InParametersList[i].Value >>= (CORBA::Any::to_char ) c;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(char) " << c << endl ;
- break ;
- case CORBA::tk_short:
- short s ;
- InParametersList[i].Value >>= s;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(short) " << s << endl ;
- break ;
- case CORBA::tk_long :
- long l;
- InParametersList[i].Value >>= l;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(long) " << l << endl ;
- break ;
- case CORBA::tk_float :
- float f;
- InParametersList[i].Value >>= f;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(float) " << f << endl ;
- break ;
- case CORBA::tk_double :
- double d;
- InParametersList[i].Value >>= d;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(double) " << d << endl ;
- break ;
- case CORBA::tk_objref :
- 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 << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(other) ERROR" << 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 ) {
- 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 ;
- }
- }
- 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[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
- }
- }
-// else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
- 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[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
- }
- }
-// else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
- 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[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- 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[0] , ServiceInParameter().length() + 1 ,
- &OutParametersList[0] , ServiceOutParameter().length() + 1 ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
- }
- }
+ if ( IsOneOfInLineNodes() ) {
+ Err = DataReady_ExecuteActionInLineNodes( InParametersList ,
+ OutParametersList ) ;
+ }
-// else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
- 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
-// OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
-#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() ;
-//JR 30.03.2005 OutParametersList[0].Value = *anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
- 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() ) {
- StsPyDynInvoke = false ;
- }
- else {
- for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
- OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
-#if TraceDataReady_ExecuteAction
- switch ( InParametersList[argin0 + i].Value.type()->kind() ) {
- case CORBA::tk_string :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(string) "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- break ;
- case CORBA::tk_boolean:
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(boolean) "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- break ;
- case CORBA::tk_char:
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(char) "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- break ;
- case CORBA::tk_short:
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(short) "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- break ;
- case CORBA::tk_long :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(long) "
- << OutParametersList[argout0 + i ].Name.c_str() << endl ;
- break ;
- case CORBA::tk_double :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(double) "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- break ;
- case CORBA::tk_objref :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(object reference) "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- break ;
- default :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(other) ERROR "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- }
+ else {
+#if 0
+ if ( IsComputingNode() ) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " myObjComponent " << myObjComponent << " "
+ << ObjectToString( myObjComponent ) << endl ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " before DynInvoke nInParams " << nInParams
+ << " :" << endl;
+ int i ;
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ Engines::Component_var theObjComponent ;
+ theObjComponent = Engines::Component::_narrow( obj ) ;
+ DynInvoke( theObjComponent , "ping" ,
+ NULL , 0 , NULL , 0 ) ;
+ for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+ cdebug << "InParametersList[" << i << "] : "
+ << InParametersList[i].Name << " "
+ << AnyValue( InParametersList[i].Value ) << endl ;
+ }
+ }
#endif
- }
- }
- }
- if ( !StsPyDynInvoke ) {
- Err = true ;
- cdebug << ThreadNo() << " InLineNode " << Name()
- << " Python Dynamic Call Error"
- << endl ;
- }
- }
- catch( ... ) {
- Err = true ;
- cdebug << ThreadNo() << " InLineNode " << Name()
- << " Python Dynamic Call Exception catched ERROR"
- << endl ;
- }
- CpuUsed( true ) ;
- _OutNode->PyThreadUnLock() ;
- }
- else {
- try {
- try {
+ try {
#if TraceDataReady_ExecuteAction
- cdebug << "DynInvoke -> Names " << _OutNode->Graph()->Name() << " " << Name() << endl ;
+ cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ;
#endif
- DynInvoke( myObjComponent, "Names" ,
- _OutNode->Graph()->Name() , Name() ) ;
- }
- catch( ... ) {
- cdebug << "DynInvoke Names catched ERROR" << endl ;
- }
+ DynInvoke( myObjComponent, "Names" ,
+ _OutNode->Name() , Name() ) ;
+ }
+ catch( ... ) {
+ string anErrorMessage = string( "Dynamic CORBA call to Names for node " ) +
+ string( Name() ) + " catched." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << "DynInvoke Names catched ERROR" << endl ;
+ }
// for DataStreamNodes : call of SetProperties ===> environment variables in the component/container
- if ( ComputingNode()->HasDataStream() ) {
- try {
+ if ( ComputingNode()->HasDataStream() ) {
+ try {
#if TraceDataReady_ExecuteAction
- cdebug << "DynInvoke -> SetProperties " << _OutNode->Graph()->Name() << " " << Name() << endl ;
+ cdebug << "DynInvoke -> SetProperties " << _OutNode->Name() << " " << Name() << endl ;
#endif
- Engines::FieldsDict_var dict = new Engines::FieldsDict;
- dict->length( 4 );
- dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
+ Engines::FieldsDict_var dict = new Engines::FieldsDict;
+ dict->length( 4 );
+ dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
// myContainer->getHostName() ne renvoit pas le nom complet (avec domaine).
// dict[ 0 ].value <<= myContainer->getHostName() ;
- char FullyQualifiedDomainName[256]="";
- gethostname(FullyQualifiedDomainName,255);
- dict[ 0 ].value <<= FullyQualifiedDomainName ;
- dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
- dict[ 1 ].value <<= "/tmp" ;
- dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
- stringstream ofst1 ;
- ofst1 << ComputingNode()->SubStreamGraph() ;
- string cpl = string( "/tmp/" ) + string( _OutNode->Graph()->Name() ) + string( "_" ) +
- ofst1.str() + string( ".cpl" );
- dict[ 2 ].value <<= cpl.c_str() ;
- dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
- string uname = Name();
- UpperCase( uname);
- dict[ 3 ].value <<= uname.c_str() ;
-
- myObjComponent->setProperties( dict ) ;
- }
- catch( ... ) {
- cdebug << "DynInvoke setProperties catched ERROR" << endl ;
- Err = true;
- }
- }
- if ( !Err && IsComputingNode() ) {
+ char FullyQualifiedDomainName[256]="";
+ gethostname(FullyQualifiedDomainName,255);
+ dict[ 0 ].value <<= FullyQualifiedDomainName ;
+ dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
+ dict[ 1 ].value <<= "/tmp" ;
+ dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
+ stringstream ofst1 ;
+ ofst1 << ComputingNode()->SubStreamGraph() ;
+ string cpl = string( "/tmp/" ) + string( _OutNode->Name() ) + string( "_" ) +
+ ofst1.str() + string( ".cpl" );
+ dict[ 2 ].value <<= cpl.c_str() ;
+ dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
+ string uname = Name();
+ UpperCase( uname);
+ dict[ 3 ].value <<= uname.c_str() ;
+
+ myObjComponent->setProperties( dict ) ;
+ }
+ catch( ... ) {
+ string anErrorMessage = string( "Dynamic CORBA call to setProperties for node " ) +
+ string( Name() ) + " catched." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << "DynInvoke setProperties catched ERROR" << endl ;
+ Err = true;
+ }
+ }
+
+ try {
+ if ( !Err && IsComputingNode() ) {
#if TraceDataReady_ExecuteAction
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsComputingNode DynInvoke" << endl ;
- cdebug << ServiceInParameter().length()-1 << " input parameters and "
- << ServiceOutParameter().length() << " output parameters" << endl ;
-#endif
- IsLoading( false ) ;
- DynInvoke( myObjComponent,
- ServiceName() ,
- &InParametersList[1] , ServiceInParameter().length()-1 ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- }
- else if ( !Err && IsFactoryNode() ) {
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsComputingNode DynInvoke" << endl ;
+ cdebug << ServiceInParameter().length()-1 << " input parameters and "
+ << ServiceOutParameter().length() << " output parameters" << endl ;
+#endif
+ IsLoading( false ) ;
+ DynInvoke( myObjComponent,
+ ServiceName() ,
+ &InParametersList[1] , ServiceInParameter().length()-1 ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
+#if 0
+ { cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " myObjComponent " << myObjComponent << " "
+ << ObjectToString( myObjComponent ) << endl ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " after DynInvoke nInParams " << nInParams
+ << " :" << endl;
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ Engines::Component_var theObjComponent ;
+ theObjComponent = Engines::Component::_narrow( obj ) ;
+ DynInvoke( theObjComponent , "ping" ,
+ NULL , 0 , NULL , 0 ) ;
+ for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+ cdebug << "InParametersList[" << i << "] : "
+ << InParametersList[i].Name << " "
+ << AnyValue( InParametersList[i].Value ) << endl ;
+ }
+ }
+#endif
+ }
+ else if ( !Err && IsFactoryNode() ) {
#if TraceDataReady_ExecuteAction
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsFactoryNode DynInvoke" << endl ;
- cdebug << ServiceInParameter().length() << " input parameters and "
- << ServiceOutParameter().length() << " output parameters" << endl ;
-#endif
- IsLoading( false ) ;
- DynInvoke( myObjComponent,
- ServiceName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- }
+ cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
+ << " IsFactoryNode DynInvoke" << endl ;
+ cdebug << ServiceInParameter().length() << " input parameters and "
+ << ServiceOutParameter().length() << " output parameters" << endl ;
+#endif
+ IsLoading( false ) ;
+ DynInvoke( myObjComponent,
+ ServiceName() ,
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
+ }
// cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
// << myObjComponent->CpuUsed_impl() << endl ;
- }
- catch( ... ) {
- Err = true ;
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " Node(Component) Dynamic Call Exception catched ERROR"
- << endl ;
+ }
+ catch( ... ) {
+ Err = true ;
+ string anErrorMessage = string( "Dynamic CORBA call for node " ) +
+ string( Name() ) + " catched." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
+ << " Node(Component) Dynamic Call Exception catched ERROR"
+ << endl ;
//Reset of _ThreadId in the Container ...
- try {
- myObjComponent->Kill_impl() ;
- }
- catch( ... ) {
- }
- }
+// try {
+// myObjComponent->Kill_impl() ;
+// }
+// catch( ... ) {
+// }
}
}
}
}
-// ostringstream astr ;
-// astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() << " is done : "
-// << Automaton()->StateName( State() ) ;
-// _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
-
if ( Err ) {
// if exception or something else - IsLoading( false ) may not NOT has been called
}
if ( !IsMacroNode() ) {
+//JRStep A
bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
if ( !ErrOut ) {
NewEvent = GraphExecutor::ErrorEvent ;
}
- delete [] InParametersList ;
- delete [] OutParametersList ;
- }
-
- if ( !IsMacroNode() ) {
+#if 0
+ if ( !Err && IsComputingNode() ) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " myObjComponent " << myObjComponent << " "
+ << ObjectToString( myObjComponent ) << endl ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " delete [] InParametersList nInParams " << nInParams
+ << " :" << endl;
+ int i ;
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ Engines::Component_var theObjComponent ;
+ theObjComponent = Engines::Component::_narrow( obj ) ;
+ DynInvoke( theObjComponent , "ping" ,
+ NULL , 0 , NULL , 0 ) ;
+ for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+ cdebug << "InParametersList[" << i << "] : "
+ << InParametersList[i].Name << " "
+ << AnyValue( InParametersList[i].Value ) << endl ;
+ }
+ }
+#endif
+ try {
+ delete [] InParametersList ;
+ }
+ catch(...) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " catch ERROR of delete [] InParametersList" << endl ;
+ }
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " delete [] OutParametersList :" << endl;
+ int i ;
+ for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
+ cdebug << "OutParametersList[" << i << "] : "
+ << OutParametersList[i].Name << " "
+ << AnyValue( OutParametersList[i].Value ) << endl ;
+ }
+#endif
+ try {
+ delete [] OutParametersList ;
+ }
+ catch(...) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " catch ERROR of delete [] OutParametersList" << endl ;
+ }
SendEvent( NewEvent ) ;
}
else {
GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
#if TraceDataReady_ExecuteAction
+ int i ;
+ for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
+ cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
+ << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
+ << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
+ if ( GraphBase::Base::_prof_debug ) {
+ GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+ if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
+ cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
+ }
+ cdebug << endl ;
+ }
cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " "
- << aMacroGraph->Graph()->Name() << " ->DoneWait()"
+ << aMacroGraph->Name() << " ->DoneWait()"
<< " State " << aMacroGraph->State() << endl;
#endif
aMacroGraph->DoneWait() ;
#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State "
+ << aMacroGraph->State() << endl;
+#endif
+
+//JR 29.09.2005 Debug for CEA (examples/GraphMacroNodes1) :
+// Set of value of the OutGate of the corresponding MacroNode was missing
+ CORBA::Any anAny = CORBA::Any() ;
+ anAny <<= (long ) 1 ;
+ GraphMacroNode()->GraphEditor()->Executor()->OutputOfAny( Name() , "Gate" , anAny ) ;
+#if TraceDataReady_ExecuteAction
+ cdebug << "DataReady_ExecuteAction OutputOfAny( " << Name() << " , Gate , 1 )" << endl ;
+
+ for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
+ cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
+ << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
+ << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
+ if ( GraphBase::Base::_prof_debug ) {
+ GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+ if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
+ cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
+ }
+ cdebug << endl ;
+ }
cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State " << aMacroGraph->State() << endl;
#endif
if ( aMacroGraph->State() == SUPERV::DoneState ) {
}
#if TraceDataReady_ExecuteAction
- cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
+ cdebug_out << ThreadNo() << " DataReady_ExecuteAction " << Name() << endl;
#endif
return 1 ;
}
-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 ;
-}
+int GraphExecutor::InNode::DataReady_ExecuteActionInLineNodes( ServicesAnyData * InParametersList ,
+ ServicesAnyData * OutParametersList ) {
-int GraphExecutor::InNode::Executing_KillAction() {
- cdebug << ThreadNo() << " Executing_KillAction " << Name() << " Thread " << ThreadNo()<< endl;
- int RetVal = 0 ;
- if ( pthread_self() == ThreadNo() ) {
+#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 ;
+}
+
+int GraphExecutor::InNode::Executing_KillAction() {
+ cdebug << ThreadNo() << " Executing_KillAction " << Name() << " Thread " << ThreadNo()<< endl;
+ int RetVal = 0 ;
+ if ( pthread_self() == ThreadNo() ) {
cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
KillAction() ;
_OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
return 1 ;
}
-int GraphExecutor::InNode::Executing_ErrorAction() {
- cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
+int GraphExecutor::InNode::Errored_ExecutingAction() {
+ cdebug << ThreadNo() << " --> Errored_ExecutingAction " << Name() << endl;
_OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
GraphExecutor::ErroredState ) ;
+ _OutNode->NodeAborted( Name() ) ;
+
SUPERV::ControlState aControl = ControlState() ;
switch ( aControl ) {
case SUPERV::VoidState : {
}
default : {
cdebug << ThreadNo()
- << " GraphExecutor::InNodeThreads::Executing_ErrorAction Error Undefined Control : "
+ << " GraphExecutor::InNodeThreads::Errored_ExecutingAction Error Undefined Control : "
<< aControl << endl ;
return 0;
}
}
- cdebug << ThreadNo() << " <-- Executing_ErrorAction " << Name() << endl;
+ cdebug << ThreadNo() << " <-- Errored_ExecutingAction " << Name() << endl;
return 1 ;
}
+#define SetWaitingStatesTrace 0
// Set SUPERV::WaitingState to all InPorts
void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
int i ;
int j ;
bool docdebug = false ;
State( GraphExecutor::DataWaitingState ) ;
-// cdebug << "SetWaitingStates " << Name() << " " << Automaton()->StateName( State() ) << endl ;
+#if SetWaitingStatesTrace
+ cdebug << "SetWaitingStates " << Name() << " " << Automaton()->StateName( State() ) << endl ;
+#endif
for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
-// cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
-// << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+#if SetWaitingStatesTrace
+ cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
+ << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
+#endif
// PAL8513
// JR Debug 07.01.2005 : Close the Gates instead of open !!!
if ( anInPort->IsGate() ) { // Loop : Close the doors
// *anAny <<= (long ) 1 ;
//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 0 ;
anAny <<= (long ) 0 ;
- anOutPort->Value( anAny ) ;
+ anOutPort->SetValue( anAny ) ;
anInPort->PortState( SUPERV::WaitingState ) ;
// delete anAny ;
}
else if ( anInPort->PortState() != SUPERV::WaitingState &&
!anInPort->IsDataConnected() ) {
if ( !docdebug ) {
-// cdebug << ThreadNo()
-// << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
+#if SetWaitingStatesTrace
+ cdebug << ThreadNo()
+ << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
+#endif
docdebug = true ;
}
if ( !anInPort->IsDataStream() ) {
anInPort->PortState( SUPERV::WaitingState ) ;
}
}
-// cdebug << " --> " << Name() << "( " << anInPort->PortName() << " ) "
-// << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+#if SetWaitingStatesTrace
+ cdebug << " --> InPort " << Name() << "( " << anInPort->PortName() << " ) "
+ << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
+#endif
}
for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
//JR 07.03.2005 Debug : Reset of Done flag in OutPorts !... :
if ( !anOutPort->IsDataStream() ) {
anOutPort->PortDone( false ) ;
+ anOutPort->PortState( SUPERV::WaitingState ) ;
}
for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
!anOutPort->IsDataStream() &&
!anOutPort->ChangeInPorts( j )->IsDataStream() &&
!anOutPort->ChangeInPorts( j )->IsExternConnected() ) {
-// cdebug << ThreadNo()
-// << " InNodeThreads::SetWaitingStates OutPort "
-// << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
-// << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
-// << anOutPort->ChangeInPorts( j )->NodeName() << "( "
-// << anOutPort->ChangeInPorts( j )->PortName() << " "
-// << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
+#if SetWaitingStatesTrace
+ cdebug << ThreadNo()
+ << " InNodeThreads::SetWaitingStates OutPort "
+ << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
+ << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
+ << anOutPort->ChangeInPorts( j )->NodeName() << "( "
+ << anOutPort->ChangeInPorts( j )->PortName() << " "
+ << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
+#endif
GraphBase::ComputingNode * aToNode ;
aToNode = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() ) ;
// JR 12.01.2005 Debug : the OutPort linked to the InPort of a EndSwitchNode was changed so final
-// values of InPorts of EndSwitchNode may be wrong
+// values of InPorts of EndSwitchNode may be wrong
+// (depending of order of linkednodes)
if ( !aToNode->IsEndSwitchNode() &&
strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
// After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from
// EndLoopNode or GOTONode. But if there is several nested loops we should re-establish.
-// cdebug << ThreadNo()
-// << " InNodeThreads::SetWaitingStates Node " << Name() << " "
-// << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
-// << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
-// << Name() << " : Restored to " << anOutPort->NodeName() << "( "
-// << anOutPort->PortName() << " )" << endl ;
+#if SetWaitingStatesTrace
+ cdebug << ThreadNo()
+ << " InNodeThreads::SetWaitingStates Node " << Name() << " "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
+ << Name() << " : Restored to " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " )" << endl ;
+#endif
anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
}
+//PAL8624
+//JR 21.04.2005 Debug : the OutPort field of InPorts of EndSwitchNodes must be an OutPort
+// of a SwitchBranch or of a NOTSwitchBranch if a link exist
+// (if not there is no change)
+ else if ( !IsSwitchNode() && aToNode->IsEndSwitchNode() &&
+ strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
+#if SetWaitingStatesTrace
+ cdebug << ThreadNo()
+ << " InNodeThreads::SetWaitingStates Node " << Name() << " "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
+ << Name() << " : Restored to " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " )" << endl ;
+#endif
+ anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
+ }
GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ;
if ( aNode != EndNode ) {
aNode->SetWaitingStates( EndNode ) ;
}
}
}
+#if SetWaitingStatesTrace
+ cdebug << " --> OutPort " << Name() << "( " << anOutPort->PortName() << " ) "
+ << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
+#endif
}
}
-#define SuccessActionTrace 0
+#define SuccessActionTrace 1
+//JR Step B
int GraphExecutor::InNode::Successed_SuccessAction() {
- cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
+#if SuccessActionTrace
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
+ << endl;
+#endif
int res = 1;
- int linkednodesnumber = LinkedNodesSize() ;
- GraphExecutor::InNode *firstzeroNode = NULL ;
+//PAL8624
+//JR 15.04.2005 Debug RetroConception :
+//The behavior of firstzeroNode and firsttoNode is not reliable and must be removed
+//The real problem is :
+// 1. send "SomeDataReady" event to linked nodes of the current node
+// 2. DO NOT send "AllDataReady" event even if all data are ready in SomeDataReady Action
+// but register only that all data are ready :
+// MAJOR ENHANCEMENT OF GRAPHEXECUTOR
+// 3. activate AllDataReady Action for each node (except the first one ) which have all
+// its data ready with a creation of a new thread
+// 3. activate AllDataReady Action for the first node which have all its data
+// ready in the current thread
+//The difficult problem (that I had in the past) was to clearly identify the above behavior ==>
+// firstzeroNode, firsttoNode, createnewthreadif, loackdatawait, "would dead lock" etc...
+// because if SomeDataReady Action see that all data were ready, it called immediately
+// AllDataReady Action ==> bugs difficult to understand and to reproduce
+//And the MAJOR DEBUG is (since the first "maquette") : we may have concurrent executions
+// of "SomeDataReady" in several threads and there WAS NO MUTEX to protect that
+// concurrent actions on the same node
+// int linkednodesnumber = LinkedNodesSize() ;
+// GraphExecutor::InNode *firstzeroNode = NULL ;
GraphExecutor::InNode *firsttoNode = NULL ;
GraphExecutor::InNode *toNode ;
int i ;
if ( IsMacroNode() ) {
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done"
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done for that MacroNode"
<< endl ;
#endif
return 1;
#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
<< aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
- aLabelNode->SetWaitingStates( this ) ;
#endif
+ State( GraphExecutor::DataWaitingState ) ;
+ aLabelNode->SetWaitingStates( this ) ;
// JR 07.01.2005 Debug : Open the Gate of the coupledNode closed by SetWaitingStates
GraphBase::OutPort * anOutPort = aLabelNode->GetChangeNodeInGate()->GetOutPort() ;
if ( anOutPort ) {
CORBA::Any anAny = CORBA::Any() ;
//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
anAny <<= (long ) 1 ;
- anOutPort->Value( anAny ) ;
+ anOutPort->SetValue( anAny ) ;
aLabelNode->GetChangeNodeInGate()->PortState( SUPERV::ReadyState ) ;
// delete anAny ;
}
}
}
- if ( aLabelNode && !aLabelNode->IsLockedDataWait() ) {
- res = aLabelNode->SendSomeDataReady( Name() ) ;
- if ( res ) {
- if ( firsttoNode == NULL &&
- aLabelNode->ThreadNo() == pthread_self() ) {
- firsttoNode = aLabelNode ;
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
- << aLabelNode->Name() << endl ;
-#endif
- }
- else if ( firstzeroNode == NULL &&
- aLabelNode->ThreadNo() == 0 ) {
- firstzeroNode = aLabelNode ;
- }
- else {
- SomeDataNodes.push_back( aLabelNode ) ;
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
- << aLabelNode->Name() << " " << SomeDataNodes.size()
- << endl ;
-#endif
- }
- }
-
-// 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 ;
-// }
-// }
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// THERE IS ONLY ONE NODE COUPLED TO A GOTONODE OR AN ENDLOOPNODE BUT Mutex/Lock for consistency
+ if ( aLabelNode ) {
const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
if ( aGateInPort ) {
if ( aGateInPort->GetOutPort() ) {
//JR 21.02.2005 Debug Memory leak : aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
//JR 30.03.2005 aGateInPort->GetOutPort()->Value( *aGateOutPort->Value() ) ;
- aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
+ aGateInPort->GetOutPort()->SetValue( aGateOutPort->Value() ) ;
}
- if ( !aLabelNode->IsLockedDataWait() ) {
- res = aLabelNode->SendSomeDataReady( Name() ) ;
- if ( res ) {
- if ( firsttoNode == NULL &&
- aLabelNode->ThreadNo() == pthread_self() ) {
- firsttoNode = aLabelNode ;
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
- << aLabelNode->Name() << endl ;
-#endif
- }
- else if ( firstzeroNode == NULL &&
- aLabelNode->ThreadNo() == 0 ) {
- firstzeroNode = aLabelNode ;
- }
- else {
- SomeDataNodes.push_back( aLabelNode ) ;
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
- << aLabelNode->Name() << " " << SomeDataNodes.size()
- << endl ;
-#endif
- }
- }
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ if ( !aLabelNode->SendSomeDataReady( Name() ) ) {
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << Name() << " SendSomeDataReady to " << aLabelNode->Name() << " ERROR"
+ << endl ;
+//JR 30.06.2005 :
+ SendEvent( GraphExecutor::ErrorEvent ) ;
+ return 0 ;
+ }
+ if ( aLabelNode->HasAllDataReady() ) {
+ aLabelNode->ThreadNo( pthread_self() ) ;
+ aLabelNode->CreateNewThread( false ) ;
+ aLabelNode->RewindStack( RewindStack() ) ;
+ aLabelNode->HasAllDataReady( false ) ;
+ res = aLabelNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
}
}
else {
}
}
+//JR Step B
+//==================================================
// JR 09.02.2005 : this is not a EndLoop or a GOTO :
- else {
+//==================================================
+ else { // Not a EndLoop or a GOTO
#if SuccessActionTrace
cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
<< " with " << LinkedNodesSize() << " linked nodes :" ;
-#endif
for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
- if ( LinkedNodes( i )->IsDataFlowNode() ) {
- linkednodesnumber -= 1 ;
- }
-#if SuccessActionTrace
cdebug << " " << LinkedNodes( i )->Name() ;
-#endif
}
-#if SuccessActionTrace
cdebug << endl;
#endif
- for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
+//JR 15.04.2005 Debug PAL8624 RetroConception :
// If this is a LoopNode and if DoLoopPort == false, we go directly to the EndOfLoopNode and
// we do not activate Nodes within the loop
- bool IgnoreForEndLoop = false ;
-// If this is a SwitchNode and if DefaultOutPort == true, we may activate Nodes within Switch
-// or we may activate directly the EnSwitch
+ bool IgnoreForEndLoop = false ;
+// If this is a SwitchNode and if DefaultOutPort == true, we do not activate Nodes within Switch
+// We activate directly the EnSwitch
// BUT the NotSwitchBranch(es) are NOT activated :
- bool IgnoreForDefaultSwitch = false ;
+ bool IgnoreForDefaultSwitch = false ;
+ if ( IsLoopNode() ) {
+ GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
+ if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
+ IgnoreForEndLoop = true ;
+ }
+ }
+ else if ( IsSwitchNode() ) {
+ const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
+ if ( anOutGatePort->BoolValue() && anOutGatePort->InPortsSize() ) { // DefaultPort is activated
+// The DefaultOutPort of that SwitchNode is true and is connected
+ IgnoreForDefaultSwitch = true ;
+ }
+ }
+
+//Loop of LinkedNodes for SendSomeDataReady :
+ for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
GraphBase::ComputingNode * aComputingNode ;
aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
cdebug << " " << toNode->Kind() << endl ;
}
#endif
- if ( toNode && !toNode->IsDataFlowNode() ) {
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ if ( toNode ) {
+//JR 18.05.2005 : we must lock because of concurrent SendEvent if NotAllDataReady :
+ toNode->LockDataReady() ;
if ( IsComputingNode() && toNode->IsInLineNode() ) {
GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
toGateInPort->PortState( SUPERV::ReadyState ) ;
GateOutPort->PortDone( true ) ;
}
}
- }
- if ( toNode && IsLoopNode() ) {
- GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
- if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
- if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
- IgnoreForEndLoop = true ;
- }
- else { // toNode is the EndLoopNode
+
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ if ( IsLoopNode() ) {
+ if ( IgnoreForEndLoop && !strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
GraphBase::InPort * toLoopInPort ;
toLoopInPort = toNode->GetChangeNodeInLoop() ;
if ( toLoopInPort->PortState() != SUPERV::ReadyState ) {
toLoopInPort->PortState( SUPERV::ReadyState ) ;
}
}
- }
- }
- else if ( toNode && IsSwitchNode() ) {
- const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
- if ( anOutGatePort->BoolValue() && anOutGatePort->InPortsSize() ) { // DefaultPort is activated
- IgnoreForDefaultSwitch = true ;
- }
- }
- else if ( toNode && toNode->IsInLineNode() ) {
- int j ;
- for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
- toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
- }
- }
- if ( toNode && !IgnoreForEndLoop ) {
- if ( toNode && toNode->IsLoopNode() ) {
- GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
- toLoopInPort->PortState( SUPERV::ReadyState ) ;
- GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
- LoopOutPort->PortStatus( DataConnected );
- LoopOutPort->PortState( SUPERV::ReadyState ) ;
- LoopOutPort->PortDone( true ) ;
-//JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
- CORBA::Any anAny = CORBA::Any() ; // InitLoop
-//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
- anAny <<= (long ) 1 ;
- LoopOutPort->Value( anAny ) ;
-// delete anAny ;
+ }
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ else if ( toNode->IsInLineNode() ) {
int j ;
for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
}
}
-// If the DefaultPort of that SwitchNode is connected to the DefaultPort od the EndSwitchNode
-// the NotSwitchBranch(es) are NOT activated :
-// If the DefaultPort of that SwitchNode is connected to SwitchBranch(es)
-// the NotSwitchBranch(es) are NOT activated :
+
bool activatetoNode = true ;
+//We have to execute the loop :
+ if ( !IgnoreForEndLoop ) {
+//The loop is not finished :
+ if ( toNode->IsLoopNode() ) {
+//We enter in a new loop :
+ GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
+ toLoopInPort->PortState( SUPERV::ReadyState ) ;
+ GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
+ LoopOutPort->PortStatus( DataConnected );
+ LoopOutPort->PortState( SUPERV::ReadyState ) ;
+ LoopOutPort->PortDone( true ) ;
+//JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
+ CORBA::Any anAny = CORBA::Any() ; // InitLoop
+//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
+ anAny <<= (long ) 1 ;
+ LoopOutPort->SetValue( anAny ) ;
+ int j ;
+ for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
+ toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
+ }
+ }
+ }
+//The loop is finished :
+ else if ( IsLoopNode() ) {
+ if ( toNode->IsEndLoopNode() ) {
+//Not the corresponding EndLoopNode :
+ if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction NO activate EndLoopNode " << toNode->Name()
+ << endl ;
+#endif
+ activatetoNode = false ;
+ }
+ }
+//Not a EndLoopNode :
+ else {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction NO activate node " << toNode->Name() << endl ;
+#endif
+ activatetoNode = false ;
+ }
+ }
+
+// If the DefaultPort of that SwitchNode is connected to the DefaultPort of the EndSwitchNode
+// the NotSwitchBranch(es) are NOT activated :
if ( IgnoreForDefaultSwitch ) {
+//We have to activate Default to EndSwitchNode
#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction search "
- << toNode->Name() << " among linked nodes to DefaultPort of " << Name() << endl ;
+ << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
+ << "IgnoreForDefaultSwitch" << IgnoreForDefaultSwitch << endl ;
#endif
activatetoNode = false ;
const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
}
if ( aNode && (const GraphBase::ComputingNode * ) toNode->ComputingNode() == aNode ) {
// toNode is connected to the DefaultPort of that SwitchNode :
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction activate node " << aNode->Name() << endl ;
+#endif
activatetoNode = true ;
break ;
}
+ else {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction NO activate node " << aNode->Name() << endl ;
+#endif
+ }
}
-// if ( activatetoNode ) {
-// cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction found "
-// << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
-// << endl ;
-// }
-// else {
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " Successed_SuccessAction does NOT found "
-// << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
-// << endl ;
-// }
}
+//JR 19.04.2005 Debug : Do not activate the EndSwitchNode if DefaultGate is close.
+//JR 20.04.2005 : it is false : an outport of the SwitchNode may be connected to an
+// input port of the EndSwitchNode
if ( activatetoNode ) {
#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
<< toNode->Name() << "->SendSomeDataReady( " << Name() << " )" << endl ;
#endif
- res = toNode->SendSomeDataReady( Name() ) ;
- if ( res ) {
- if ( firsttoNode == NULL &&
- toNode->ThreadNo() == pthread_self() ) {
- firsttoNode = toNode ;
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo()
- << " Successed_SuccessAction firsttoNode " << toNode->Name() << endl ;
-#endif
- }
- else if ( firstzeroNode == NULL &&
- toNode->ThreadNo() == 0 ) {
- firstzeroNode = toNode ;
- }
- else {
- SomeDataNodes.push_back( toNode ) ;
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
- << Name() << " push "
- << toNode->Name() << " " << SomeDataNodes.size() << endl ;
-#endif
- }
+ if ( !toNode->SendSomeDataReady( Name() ) ) {
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << Name() << " SendSomeDataReady to " << toNode->Name() << " ERROR"
+ << endl ;
+//JR 30.06.2005 :
+ toNode->UnLockDataReady() ;
+ SendEvent( GraphExecutor::ErrorEvent ) ;
+ return 0 ;
}
}
+ toNode->UnLockDataReady() ;
}
- }
- }
+ } //End of Loop of LinkedNodes for SendSomeDataReady
-//PAL8517
//JR 10.02.2005 : Debug at the end of execution of a SwitchNode :
// Here after we may start execution of only one SwitchBranch or of the Default
// But with activation of only one SwitchBranch we may activate several nodes of that SwitchBranch and
// we may activate several nodes of NotSwitchBranch ( a NotSwitchBranch is a Branch of the Switch
// where GatePorts of Nodes are not connected ; that Branches are always executed for each of SwitchBranch
// BUT are not executed when Default is activated).
+ if ( IsSwitchNode() ) {
+ GraphBase::InLineNode * anEndSwitchNode = GOTONode()->CoupledNode() ;
+//The InPorts of the EndSwitchNode may be connected from that SwitchNode
+//So at first, if we activate a SwitchBranch, we have to establish the correct OutPort in the InPorts
+// of the EndSwitchNode (for the SwitchBranch and the NOTSwitchBranch[es] :
+//PAL8517
// So the bug is that all input ports of the corresponding EndSwitchNode must have the status NOTDONE !
-// (Only if Default OutPort is closed and Default InPort is closed)
- if ( IsSwitchNode() ) {
- GraphBase::InLineNode * anEndSwitchNode = GOTONode()->CoupledNode() ;
- if ( !GetNodeOutGate()->BoolValue() && anEndSwitchNode->GetNodeInGate()->GetOutPort() &&
- !anEndSwitchNode->GetNodeInGate()->GetOutPort()->BoolValue() ) {
+// (Only if Default OutPort is closed and Default InPort is closed) :
+ if ( !GetNodeOutGate()->BoolValue() && anEndSwitchNode->GetNodeInGate()->GetOutPort() &&
+ !anEndSwitchNode->GetNodeInGate()->GetOutPort()->BoolValue() ) {
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << anEndSwitchNode->Name()
- << " reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << anEndSwitchNode->Name()
+ << " reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
#endif
- int i ;
- for ( i = 0 ; i < anEndSwitchNode->GetNodeInPortsSize() ; i++ ) {
- GraphBase::OutPort * anOutPort = anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort() ;
+ int i ;
+ for ( i = 0 ; i < anEndSwitchNode->GetNodeInPortsSize() ; i++ ) {
+ GraphBase::OutPort * anOutPort = anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort() ;
//PAL8519
//JR 08.03.2005 Debug : update of state only if not a StreamPort
- if ( anOutPort && strcmp( anOutPort->NodeName() , Name() ) &&
- !anOutPort->IsDataStream() ) {
+ if ( anOutPort && strcmp( anOutPort->NodeName() , Name() ) &&
+ !anOutPort->IsDataStream() ) {
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
- << anEndSwitchNode->Name() << " InPort "
- << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOTDONE from "
- << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << anEndSwitchNode->Name() << " InPort "
+ << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOTDONE from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
#endif
- anEndSwitchNode->GetChangeNodeInPort( i )->PortState( SUPERV::WaitingState ) ;
- anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort()->PortDone( false ) ;
- }
- else {
+ anEndSwitchNode->GetChangeNodeInPort( i )->PortState( SUPERV::WaitingState ) ;
+ anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort()->PortDone( false ) ;
+ }
+ else {
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
- << anEndSwitchNode->Name() << " InPort "
- << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOT Changed : directly from "
- << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << anEndSwitchNode->Name() << " InPort "
+ << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOT Changed : directly from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
#endif
- }
+ }
+ }
}
- }
- else {
+ else {
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
- << " " << Kind() << " OutGate->Value " << GetNodeOutGate()->BoolValue()
- << " NO reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
+ << " " << Kind() << " OutGate->Value " << GetNodeOutGate()->BoolValue()
+ << " NO reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
#endif
+ }
}
- }
-// firsttoNode : node that has the same ThreadNo() as the current node and that have to be activated
-// firstzeroNode : node that has a null ThreadNo() and that have to be activated
- if ( firsttoNode == NULL && firstzeroNode ) {
- firsttoNode = firstzeroNode ;
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo()
- << " Successed_SuccessAction firsttoNode = firstzeroNode " << firsttoNode->Name()
- << endl ;
-#endif
- }
- else if ( firsttoNode && firstzeroNode ) {
- SomeDataNodes.push_back( firstzeroNode ) ;
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode "
- << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ;
-#endif
- firstzeroNode = NULL ;
- }
- else {
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//Make the list of nodes to activate :
+ for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
+ GraphBase::ComputingNode * aComputingNode ;
+ aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
+ toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
+ if ( toNode ) { // Only Not DataFlowNode :
+ toNode->LockDataReady() ; // Only ONE Node may send AllDataReadyEvent to an other node
+ if ( toNode->HasAllDataReady() ) {
+ SomeDataNodes.push_back( toNode ) ;
+ toNode->HasAllDataReady( false ) ;
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " firsttoNode " << firsttoNode
- << " firstzeroNode " << firstzeroNode << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << Name() << " push "
+ << toNode->Name() << " " << SomeDataNodes.size() << endl ;
#endif
- }
+ }
+ toNode->UnLockDataReady() ;
+ }
+ }
- while ( SomeDataNodes.size() ) {
- GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
- SomeDataNodes.pop_front() ;
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo()
- << " Successed_SuccessAction pop size "
- << SomeDataNodes.size() << " " << aNode->Name() << endl ;
-#endif
- if ( aNode->State() == GraphExecutor::DataReadyState ) {
+// firsttoNode : node that has the same ThreadNo() as the current node and that have to be activated
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//Activation of nodes that have AllDataReady in a new thread except one :
+ while ( SomeDataNodes.size() > 1 ) {
+ GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
+ SomeDataNodes.pop_front() ;
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction pop CreateNewThreadIf( true )"
- << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction pop size "
+ << SomeDataNodes.size() << " " << aNode->Name() << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << aNode->Name()
+ << " Successed_SuccessAction poped and will start in a new thread" << endl ;
#endif
- aNode->CreateNewThreadIf( true ) ;
+ aNode->CreateNewThread( true ) ;
_OutNode->IncrCreatedThreads() ;
- aNode->UnLockDataWait() ;
- res = aNode->DataUndef_AllDataReadyAction() ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ res = aNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
}
- else {
-#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
- << aNode->Name() << " "
- << Automaton()->StateName( aNode->State() ) << endl ;
-#endif
- }
- }
- if ( firsttoNode ) {
+//Activation of the last node that have AllDataReady in the same thread :
+ if ( SomeDataNodes.size() ) {
+ firsttoNode = SomeDataNodes.front() ;
+ SomeDataNodes.pop_front() ;
+ }
+ if ( firsttoNode ) {
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo()
- << " Successed_SuccessAction start firsttoNode "
- << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction start firsttoNode "
+ << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
#endif
- firsttoNode->CreateNewThreadIf( false ) ;
- firsttoNode->RewindStack( RewindStack() ) ;
- if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
+// firsttoNode->CreateNewThreadIf( false ) ;
+ firsttoNode->CreateNewThread( false ) ;
+ firsttoNode->RewindStack( RewindStack() ) ;
+ if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
- << " : " << firsttoNode->Name() << " "
- << Automaton()->StateName( firsttoNode->State() )
- << " --> DataWaitingState for Thread "
- << firsttoNode->ThreadNo() << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " : " << firsttoNode->Name() << " "
+ << Automaton()->StateName( firsttoNode->State() )
+ << " --> DataWaitingState for Thread "
+ << firsttoNode->ThreadNo() << endl ;
#endif
- firsttoNode->State( GraphExecutor::DataWaitingState ) ;
- }
- firsttoNode->ThreadNo( pthread_self() ) ;
+ firsttoNode->State( GraphExecutor::DataWaitingState ) ;
+ }
+ firsttoNode->ThreadNo( pthread_self() ) ;
// On continue avec le meme thread
- ThreadNo( 0 ) ;
+ ThreadNo( 0 ) ;
#if SuccessActionTrace
- cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
- << " for " << firsttoNode->Name()
- << " !firsttoNode->CreateNewThreadIf() "
- << !firsttoNode->CreateNewThreadIf()
- << " " << Automaton()->StateName( firsttoNode->State() ) ;
- if ( firsttoNode->State() == GraphExecutor::DataReadyState ) {
- cdebug << endl ;
- else {
- cdebug << " ERROR " << endl ;
- }
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
+ << " for firsttoNode " << firsttoNode->Name()
+ << " " << Automaton()->StateName( firsttoNode->State() ) << endl ;
#endif
- if ( firsttoNode->State() == GraphExecutor::DataReadyState ) {
- firsttoNode->UnLockDataWait() ;
- res = firsttoNode->DataUndef_AllDataReadyAction() ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//No creation of thread and with LockDataReady, an other node in an other thread cannot be
+// waiting for that lock ( if it was the case we could not find AllDataReady for firsttoNode
+ res = firsttoNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
}
- }
- else {
+ else {
#if SuccessActionTrace
- cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
- << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
+ cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+ << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL" << endl ;
#endif
- ThreadNo( 0 ) ;
+ ThreadNo( 0 ) ;
+ }
}
-
-// if ( linkednodesnumber == 0 && firsttoNode == NULL ) {
-// cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodesSize " << LinkedNodesSize()
-// << " firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << " CHECK" << endl ;
-// _OutNode->CheckAllDone() ;
-// }
-
#if SuccessActionTrace
- cdebug << pthread_self() << "/" << ThreadNo()
- << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
- << linkednodesnumber << endl;
+ cdebug_out << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction " << Name() << endl;
#endif
return 1 ;
}
-#define SendSomeDataReadyTrace 0
+#define SendSomeDataReadyTrace 1
bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
bool RetVal = false ;
if ( IsDataFlowNode() ) {
#if SendSomeDataReadyTrace
- cdebug << ThreadNo() << "InNode::SendSomeDataReady ----> " << Name()
- << " send Result to graph " << Name() << endl;
+ cdebug_in << ThreadNo() << "InNode::SendSomeDataReady " << FromNodeName
+ << " send Result to graph " << Name() << endl;
#endif
}
else {
#if SendSomeDataReadyTrace
- cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
- << " send SomeDataReady to " << Name() << " "
- << Automaton()->StateName( State() )
- << " CreateNewThreadIf() " << CreateNewThreadIf()
- << " LockedDataWait " << IsLockedDataWait() << endl;
-#endif
-#if 0
- //cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
- << " send SomeDataReady to " << Name() << " "
- << Automaton()->StateName( State() )
- << " CreateNewThreadIf() " << CreateNewThreadIf()
- << " LockedDataWait " << IsLockedDataWait() << endl;
+ cdebug_in << pthread_self() << "/" << ThreadNo() << FromNodeName
+ << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
+ << Automaton()->StateName( State() ) << endl;
#endif
if ( State() == GraphExecutor::SuccessedState ||
State() == GraphExecutor::SuspendedSuccessedState ||
}
// We begin that LoopNode if SendSomeDataReady does not come from the corresponding EndLoopNode
if ( IsLoopNode() && strcmp( LoopNode()->CoupledNodeName() , FromNodeName ) ) {
+#if SendSomeDataReadyTrace
cdebug << ThreadNo() << "InNode::SendSomeDataReady " << Name() << " Set _InitLoop from "
<< FromNodeName << endl ;
+#endif
_InitLoop = true ;
}
- LockDataWait() ;
+#if SendSomeDataReadyTrace
+ cdebug << "SendEvent( SomeDataReadyEvent )" << endl ;
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
DataFromNode( FromNodeName ) ;
- RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
- if ( !RetVal ) {
- UnLockDataWait() ;
- }
+// RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
+ RetVal = SendEvent( GraphExecutor::SomeDataReadyEvent );
+//JR 15.04.2005 Debug PAL8624 RetroConception :
}
+#if SendSomeDataReadyTrace
+ cdebug_out << pthread_self() << "/" << ThreadNo() << FromNodeName
+ << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
+ << Automaton()->StateName( State() ) << " " << RetVal << endl;
+#endif
return RetVal ;
}
int GraphExecutor::InNode::Errored_ErrorAction() {
cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
<< " will pthread_exit" << endl;
+
+ _OutNode->NodeAborted( Name() ) ;
+
DoneAction() ;
return 1 ;
}
<< _OutNode->SuspendedThreads() << endl;
_OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
GraphExecutor::SuspendedErroredState ) ;
+
+ _OutNode->NodeAborted( Name() ) ;
+
DoneAction() ;
GraphExecutor::InNode * aReStartNode = SuspendAction() ;
cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
// ResumeAction() ;
_OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
GraphExecutor::ResumedErroredState ) ;
+
+ _OutNode->NodeAborted( Name() ) ;
+
SendEvent( ResumedErroredEvent ) ;
return 1 ;
}
KillAction() ;
_OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
GraphExecutor::KilledErroredState ) ;
+
+ _OutNode->NodeAborted( Name() ) ;
+
cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
return 1 ;
}
StopAction() ;
_OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
GraphExecutor::StoppedErroredState ) ;
+
+ _OutNode->NodeAborted( Name() ) ;
+
cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
return 1 ;
}
return 1 ;
}
-#define InParametersSetTrace 0
+#define InParametersSetTrace 1
void GraphExecutor::InNode::InParametersSet( bool & Err ,
int nInParams ,
ServicesAnyData * InParametersList ) {
CORBA::Any anAny = CORBA::Any() ;
//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 0 ;
anAny <<= (long ) 0 ;
- theOutPort->Value( anAny ) ;
+ theOutPort->SetValue( anAny ) ;
// delete anAny ;
}
if ( !anInPort->IsDataStream() &&
CORBA::Object_ptr ObjRef ;
char * retstr ;
try {
+#if OMNIORB_VERSION >= 4
+ D.Value >>= (CORBA::Any::to_object ) ObjRef ;
+#else
D.Value >>= ObjRef ;
+#endif
retstr = ObjectToString( ObjRef ) ;
D.Value <<= retstr ;
// theOutPort->Value( D.Value ) ;
CORBA::Object_ptr obj ;
char * retstr ;
try {
+#if OMNIORB_VERSION >= 4
+ D.Value >>= (CORBA::Any::to_object ) obj ;
+#else
D.Value >>= obj ;
+#endif
retstr = ObjectToString( obj ) ;
#if InParametersSetTrace
cdebug << retstr << endl ;
<< Type << endl ;
#endif
if ( !strcmp( Type , "string" ) ) {
- char* ch = "";
- D.Value <<= (char *) ch;
+// D.Value <<= (char *) NULL ;
+ D.Value <<= "" ;
}
else if ( !strcmp( Type , "boolean" ) ) {
bool b = 0 ;
try {
CORBA::Object_ptr obj ;
char * retstr ;
+#if OMNIORB_VERSION >= 4
+ D.Value >>= (CORBA::Any::to_object ) obj ;
+#else
D.Value >>= obj ;
+#endif
retstr = ObjectToString( obj ) ;
cdebug << ThreadNo() << retstr << endl ;
}
}
}
-#define OutParametersSetTrace 0
+#define OutParametersSetTrace 1
bool GraphExecutor::InNode::OutParametersSet( bool Err ,
SUPERV::GraphState PortState ,
int nOutParams ,
case CORBA::tk_objref: {
try {
CORBA::Object_ptr obj ;
+#if OMNIORB_VERSION >= 4
+ D.Value >>= (CORBA::Any::to_object ) obj ;
+#else
D.Value >>= obj ;
+#endif
#if OutParametersSetTrace
char * retstr ;
retstr = ObjectToString( obj ) ;
#endif
long l = 1;
OutParametersList[i].Value <<= l;
- anOutPort->Value( OutParametersList[i].Value );
+ anOutPort->SetValue( OutParametersList[i].Value );
}
else if ( anOutPort->IsLoop() ) {
#if OutParametersSetTrace
cdebug << " Loop " ;
#endif
- anOutPort->Value( OutParametersList[i].Value );
+ anOutPort->SetValue( OutParametersList[i].Value );
// InLoop Port of EndLoopNode is ready :
anOutPort->ChangeInPorts(0)->PortState( SUPERV::ReadyState ) ;
}
#if OutParametersSetTrace
cdebug << " Switch " ;
#endif
- anOutPort->Value( OutParametersList[i].Value );
+ anOutPort->SetValue( OutParametersList[i].Value );
if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
-//JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches :
+//We have a SwitchBranch or the DefaultBranch .
+//JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches (SwitchParameters) :
//It controls that there is only one SwitchBranch activated
//If it's final value is false ==> activation of the Default to GOTO to EndSwitchNode
//DefaultSwitch is true if a SwitchPort is linked to the DefaultPort of the EndSwitchNode
if ( OrSwitch && anOutPort->BoolValue() ) {
- cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true ERROR"
+ string anErrorMessage = string( "More than one SwitchBranch should be activated in SwitchNode " ) +
+ string( Name() ) + string( "( " ) +
+ string( anOutPort->PortName() ) + string( " )" ) ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << "Executor::InNodeThreads::OutParameters more than one SwitchBranch is true ERROR"
<< endl ;
RetVal = false ;
}
#if OutParametersSetTrace
cdebug << " Param " ;
#endif
- anOutPort->Value( OutParametersList[i].Value );
+ anOutPort->SetValue( OutParametersList[i].Value );
}
anOutPort->PortState( PortState ) ;
anOutPort->PortDone( true ) ;
#endif
bool fromGOTO = false ;
const char * ToNodeName = anOutPort->ChangeInPorts( j )->NodeName() ;
- if ( !strcmp( ToNodeName , _OutNode->Graph()->Name() ) && _OutNode->Graph()->GraphMacroLevel() != 0 ) {
+ if ( !strcmp( ToNodeName , _OutNode->Name() ) &&
+ _OutNode->Graph()->GraphMacroLevel() != 0 ) {
#if OutParametersSetTrace
- cdebug << "OutParametersSet ToNodeName " << _OutNode->Graph()->Name() << " CoupledNode "
+ cdebug << "OutParametersSet ToNodeName " << _OutNode->Name() << " CoupledNode "
<< _OutNode->Graph()->CoupledNodeName() << _OutNode->Graph()->CoupledNode()
<< endl ;
- cdebug << " GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
+ cdebug << "OutParametersSet GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
#endif
_OutNode->Graph()->CoupledNode()->GraphEditor()->Executor()->OutputOfAny( _OutNode->Graph()->CoupledNodeName() ,
anOutPort->ChangeInPorts( j )->PortName() ,
//JR 30.03.2005 *anOutPort->Value() ) ;
anOutPort->Value() ) ;
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet OutputOfAny( "
+ << _OutNode->Graph()->CoupledNodeName() << " , "
+ << anOutPort->ChangeInPorts( j )->PortName() << " , value )" << endl ;
+#endif
+
}
else {
GraphBase::ComputingNode * ToNode = _OutNode->Graph()->GetChangeGraphNode( ToNodeName ) ;
switch ( anOutPort->Value().type()->kind() ) {
case CORBA::tk_string:
char * t;
- anOutPort->Value() >>= 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;
+ (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;
+ (anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
break;
case CORBA::tk_short:
short s;
- anOutPort->Value() >>= s;
+ (anOutPort->Value()) >>= s;
cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
break;
case CORBA::tk_long:
long l;
- anOutPort->Value() >>= l;
+ (anOutPort->Value()) >>= l;
cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
break;
case CORBA::tk_float:
float f;
- anOutPort->Value() >>= f;
+ (anOutPort->Value()) >>= f;
cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
break;
case CORBA::tk_double:
double d;
- anOutPort->Value() >>= 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 ;
+//JR 02.08.2005 Debug SEGV anOutPort->Value() >>= obj ;
+ CORBA::Any anAny ;
+ anAny = anOutPort->Value() ;
+#if OMNIORB_VERSION >= 4
+ anAny >>= (CORBA::Any::to_object ) obj ;
+#else
+ anAny >>= obj ;
+#endif
retstr = ObjectToString( obj );
cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
<< retstr << endl ;
}
#endif
}
- }
- if ( aGateOutPort && IsSwitchNode() ) {
+ } // End of : for ( i = 0 ; i < nOutParams ; i++ ) {
+#if OutParametersSetTrace
+ cdebug << ThreadNo() << "OutParametersSet End of loop with " << nOutParams
+ << " OutParams. aGateOutPort " << (void *) aGateOutPort << " IsSwitchNode "
+ << IsSwitchNode() << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch
+ << endl ;
+#endif
+
+//In SwitchNodes :
+ if ( IsSwitchNode() && aGateOutPort ) {
//JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches :
//It controls that there is only one SwitchBranch activated
-//If it's final value is false ==> activation of the Default to GOTO to EndSwitchNode
+//If it's final value is false ==> activation of the Default in order to GOTO to EndSwitchNode
//DefaultSwitch is true if a SwitchPort (SwitchBranch) is linked to the DefaultPort of the EndSwitchNode
if ( !OrSwitch && !DefaultSwitch ) {
if ( aGateOutPort->InPortsSize() && aGateOutPort->ChangeInPorts( 0 ) ) {
+//Dynamic activation of the Default OutPort :
#if OutParametersSetTrace
cdebug << ThreadNo() << " " << "OutGate " << Name() << " Open of "
- << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " WITH DefaultPort" << endl ;
+ << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " WITH DefaultPort"
+ << endl ;
#endif
long l = 1;
OutParametersList[0].Value <<= l ;
- aGateOutPort->Value( OutParametersList[0].Value ) ;
+ aGateOutPort->SetValue( OutParametersList[0].Value ) ;
}
else {
+//The Default OutPort is not linked ==> error
+ string anErrorMessage = string( "DefaultPort of SwitchNode " ) +
+ string( Name() ) + " is not connected." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
#if OutParametersSetTrace
cdebug << ThreadNo() << " " << "OutGate " << Name() << " "
- << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NOT CONNECTED ERROR" << endl ;
+ << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NOT CONNECTED ERROR"
+ << endl ;
#endif
RetVal = false ;
}
}
//JR 07.04.2005 Debug : reset only if it is not a default switch (SwitchBranch or
-// SwitchParameter of SwitchNode connected to the InDefaultPort of
+// SwitchParameter of SwitchNode connected to the DefaultInPort of
// EndSwitchNode)
// else {
else if ( !DefaultSwitch ) {
#endif
long l = 0;
OutParametersList[0].Value <<= l ;
- aGateOutPort->Value( OutParametersList[0].Value ) ;
+ aGateOutPort->SetValue( OutParametersList[0].Value ) ;
}
- if ( !OrSwitch || DefaultSwitch ) { // DefaultPort or DefaultSwitch
+ if ( RetVal ) {
+// The OutPort field of InPorts of EndSwitchNode may be updated from each OutPort of that SwitchNode :
+ GraphBase::EndOfSwitchNode * anEndSwitchNode = (GraphBase::EndOfSwitchNode * ) CoupledNode() ;
int i ;
- for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
- GraphBase::InPort * anInPort ;
- anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
//PAL8518
-//JR 16.02.2005 Debug : Change InPorts of EndSwitchNode that have the same name as an OutPort of
+//JR 16.02.2005 Debug : At first Change InPorts of EndSwitchNode that have the same name as an OutPort of
// the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
-// if ( anInPort && !anInPort->IsGate() ) {
- if ( anInPort && anInPort->GetOutPort() ) {
+//STEP A : InPorts of EndSwitchNode that have the same name as an OutPort of the SwitchNode
+ for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+ GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
+ GraphBase::InPort * anInPort = NULL ;
+ anInPort = anEndSwitchNode->GetChangeInPort( anOutPort->PortName() ) ;
+ if ( anInPort ) {
#if OutParametersSetTrace
- cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName() << "( "
- << anInPort->PortName() << " ) linked from " << anInPort->GetOutPort()->NodeName()
- << "( " << anInPort->GetOutPort()->PortName() << " ) CHANGED TO linked from "
- << GetChangeNodeOutPort( i )->NodeName() << "( "
- << GetChangeNodeOutPort( i )->PortName() << " )" << endl ;
+ cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
+ << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) with same name " ;
+ if ( anInPort->GetOutPort() ) {
+ cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
+ << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
+ }
+ else {
+ cdebug << "NOT linked " ;
+ }
+ cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " )" << endl ;
#endif
- anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
- }
+ anInPort->ChangeOutPort( anOutPort ) ;
+ }
}
+//STEP B : InPorts of EndSwitchNode directly connected from an OutPort of the SwitchNode
+ for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+ GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
+ GraphBase::InPort * anInPort ;
+ int j ;
+ for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
+ anInPort = anOutPort->ChangeInPorts( j ) ;
+//Update the OutPort field in the Inports directly connected of the EndSwitchNode :
+ if ( !strcmp( anInPort->NodeName() , anEndSwitchNode->Name() ) ) {
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
+ << "( " << anInPort->PortName() << " , " << anInPort->Kind()
+ << " ) directly connected " ;
+ if ( anInPort->GetOutPort() ) {
+ cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
+ << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
+ }
+ else {
+ cdebug << "NOT linked " ;
+ }
+ cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " )" << endl ;
+#endif
+ anInPort->ChangeOutPort( anOutPort ) ;
+ }
+ }
+ }
+//STEP C : If it is not the DefaultBranch, explore the SwitchBranch and all NOTSwitchBranch[es]
+//Change recursively InPorts of EndSwitchNode linked to that Branch (or that SwitchNode)
+ if ( OrSwitch ) {
+ for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
+ GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
+ if ( aNode != anEndSwitchNode && !aNode->IsGOTONode() &&
+ !aNode->IsDataFlowNode() && !aNode->IsDataStreamNode() ) {
+ const GraphBase::InPort * anInGate = aNode->GetNodeInGate() ;
+ GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aNode->GetInNode() ;
+//STEP C1 : SwitchBranch :
+ if ( anInGate->GetOutPort() ) {
+ if ( anInGate->GetOutPort()->BoolValue() ) {
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet " << Name() << " SWITCHBranch " << aNode->Name() << endl ;
+#endif
+ int j ;
+ for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+ GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
+ anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
+ }
+ }
+ }
+//STEP C2 : NOTSwitchBranch :
+ else {
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet " << Name() << " NOTSWITCHBranch " << aNode->Name() << endl ;
+#endif
+ int j ;
+ for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+ GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
+ anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
+ }
+ }
+ }
+ }
+ }
}
}
}
#endif
return RetVal ;
}
+
+
+void GraphExecutor::InNode::SetOutPortsOfInportsOfEndSwitch( GraphBase::OutPort * anOutPort ,
+ const char * anEndSwitchNodeName ) {
+#if OutParametersSetTrace
+ cdebug_in << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " ) with " << anOutPort->InPortsSize() << " links." << endl ;
+#endif
+ GraphBase::InPort * anInPort ;
+ int i ;
+ for ( i = 0 ; i < anOutPort->InPortsSize() ; i++ ) {
+ anInPort = anOutPort->ChangeInPorts( i ) ;
+ if ( !anInPort->IsDataStream() ) {
+//Update the OutPort field in the Inports of the EndSwitchNode :
+ if ( !strcmp( anInPort->NodeName() , anEndSwitchNodeName ) ) {
+#if OutParametersSetTrace
+ cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
+ << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " ;
+ if ( anInPort->GetOutPort() ) {
+ cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
+ << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
+ }
+ else {
+ cdebug << "NOT linked ERROR " ;
+ }
+ cdebug << "CHANGED TO linked from "
+ << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " )" << endl ;
+#endif
+ anInPort->ChangeOutPort( anOutPort ) ;
+ }
+ else {
+#if OutParametersSetTrace
+ cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
+ << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " << endl ;
+#endif
+ GraphBase::ComputingNode * aComputingNode ;
+ aComputingNode = _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
+ if ( aComputingNode && !aComputingNode->IsGOTONode() &&
+ !( IsEndLoopNode() && GOTONode()->CoupledNode() == aComputingNode ) ) {
+ GraphExecutor::InNode * aNode ;
+ aNode = (GraphExecutor::InNode * ) aComputingNode->GetInNode() ;
+ if ( aNode ) {
+ int j ;
+ for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+ GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
+ aNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNodeName ) ;
+ }
+ }
+ }
+ }
+ }
+ }
+#if OutParametersSetTrace
+ cdebug_out << "SetOutPortsOfInportsOfEndSwitch " << Name() << " OutPort " << anOutPort->PortName()
+ << endl ;
+#endif
+}
+