From 15f06e93c33a48b744ecf86699795dcee27b5cd0 Mon Sep 17 00:00:00 2001 From: rahuel Date: Fri, 10 Jun 2005 08:02:04 +0000 Subject: [PATCH] PAL8624 - PAL8518 - PAL8519 Traces + Comments --- .../DataFlowExecutor_InNodeThreads.cxx | 929 ++++++++++-------- 1 file changed, 513 insertions(+), 416 deletions(-) diff --git a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx index 5a28405..77c337c 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx @@ -75,20 +75,21 @@ 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 ) ; @@ -386,7 +387,8 @@ bool GraphExecutor::InNode::ReStartAction( GraphExecutor::InNode * aReStartNode 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() ) ; @@ -576,8 +578,8 @@ int GraphExecutor::InNode::executeAction() { 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() ; @@ -585,7 +587,8 @@ int GraphExecutor::InNode::executeAction() { } 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() @@ -616,16 +619,18 @@ int GraphExecutor::InNode::executeAction() { 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() @@ -650,6 +655,7 @@ int GraphExecutor::InNode::executeAction() { } } } +#endif else { if ( _CurrentEvent == ExecuteEvent ) { _RewindStack += 1 ; @@ -710,7 +716,7 @@ int GraphExecutor::InNode::ExecuteAction() { 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 @@ -862,12 +868,11 @@ int GraphExecutor::InNode::VoidAction() { return 1; } -#define SomeDataReadyTrace 0 +#define SomeDataReadyActionTrace 0 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 ; @@ -875,6 +880,8 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { bool LoopBeginning = false ; bool LoopFinished = false ; bool SwitchFinished = false ; + bool SwitchDefault = false ; + bool DoAllDataReadyIf = true ; if ( IsLoopNode() ) { GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port @@ -882,54 +889,110 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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 + SwitchFinished = true ; // End of Switch + } + } + else { +//JR 20.04.2005 : SomeDataReady is FROM the SwitchNode +//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 + } } } -#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() ) { +//Set the field OutPort of that InPort of the EndSwitchNode to the corresponding OutPort +// of the SwitchNode + anOutPort = CoupledNode()->GetChangeOutPort( anInPort->PortName() ) ; +#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 + 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) 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 ) ; @@ -941,11 +1004,11 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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 ) ; @@ -957,11 +1020,11 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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 ) ; @@ -973,11 +1036,11 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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 ) ; @@ -995,12 +1058,12 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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 ) ; @@ -1010,16 +1073,18 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { #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() ; @@ -1030,7 +1095,7 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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() @@ -1045,7 +1110,7 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { } 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() @@ -1059,7 +1124,7 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { #endif } else { -#if SomeDataReadyTrace +#if SomeDataReadyActionTrace cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " << anInPort->PortName() << " GATE IS CLOSED from Node " << anOutPort->NodeName() << "( " << anOutPort->PortName() @@ -1074,14 +1139,12 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { } } 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 ) ; @@ -1089,39 +1152,48 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { #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 ; @@ -1129,7 +1201,8 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { #define TraceDataReadyAction 0 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() { - CreateNewThreadIf( false ) ; +//JR 15.04.2005 Debug PAL8624 RetroConception : +// CreateNewThreadIf( false ) ; #if TraceDataReadyAction cdebug << pthread_self() << " for " << ThreadNo() << " DataUndef_NotAllDataReadyAction " << Name() << endl; @@ -1140,24 +1213,14 @@ int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() { int GraphExecutor::InNode::DataUndef_AllDataReadyAction() { #if TraceDataReadyAction cdebug << pthread_self() << "/" << ThreadNo() - << " --> DataUndef_AllDataReadyAction " << Name() - << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait " - << IsLockedDataWait() ; -#endif - if ( IsLockedDataWait() ) { -#if TraceDataReadyAction - cdebug << "DataUndef_AllDataReadyAction() " << Name() << "WOULD DEAD-LOCK" << endl ; + << " --> DataUndef_AllDataReadyAction " << Name() << endl ; +// << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait " +// << IsLockedDataWait() ; #endif - return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait() - } -#if TraceDataReadyAction - cdebug << "InNode::DataUndef_AllDataReadyAction CreateNewThread( CreateNewThreadIf() ) " - << CreateNewThreadIf() << endl ; -#endif - CreateNewThread( CreateNewThreadIf() ) ; +//JR 15.04.2005 Debug PAL8624 RetroConception : if ( !CreateNewThread() ) { #if TraceDataReadyAction - cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ; + cdebug << "Thread " << ThreadNo() << " --> " << pthread_self() << endl ; #endif ThreadNo( pthread_self() ) ; } @@ -1311,7 +1374,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } else if ( CORBA::is_nil( Component() ) ) { // ostringstream astr ; -// astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() +// astr << "Graph " << _OutNode->Name() << " Node " << Name() // << " : load of component " << ComponentName() << " in container " // << Computer() ; // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ; @@ -1359,7 +1422,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } if ( !Err ) { // ostringstream astr ; -// astr << "Graph " << _OutNode->Graph()->Name() << " Run of Node " << Name() ; +// astr << "Graph " << _OutNode->Name() << " Run of Node " << Name() ; // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ; #if TraceDataReady_ExecuteAction int i; @@ -1751,10 +1814,10 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { 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() ) ; + _OutNode->Name() , Name() ) ; } catch( ... ) { cdebug << "DynInvoke Names catched ERROR" << endl ; @@ -1763,7 +1826,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { 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 ); @@ -1778,7 +1841,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE"); stringstream ofst1 ; ofst1 << ComputingNode()->SubStreamGraph() ; - string cpl = string( "/tmp/" ) + string( _OutNode->Graph()->Name() ) + string( "_" ) + + 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"); @@ -1808,7 +1871,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } else if ( !Err && IsFactoryNode() ) { #if TraceDataReady_ExecuteAction - cdebug << ThreadNo() << " !ObjInterface " << Name() + cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name() << " IsFactoryNode DynInvoke" << endl ; cdebug << ServiceInParameter().length() << " input parameters and " << ServiceOutParameter().length() << " output parameters" << endl ; @@ -1824,7 +1887,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } catch( ... ) { Err = true ; - cdebug << ThreadNo() << " !ObjInterface " << Name() + cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name() << " Node(Component) Dynamic Call Exception catched ERROR" << endl ; //Reset of _ThreadId in the Container ... @@ -1840,7 +1903,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } // ostringstream astr ; -// astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() << " is done : " +// astr << "Graph " << _OutNode->Name() << " Node " << Name() << " is done : " // << Automaton()->StateName( State() ) ; // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ; @@ -1870,6 +1933,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } if ( !IsMacroNode() ) { +//JRStep A bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ; if ( !ErrOut ) { NewEvent = GraphExecutor::ErrorEvent ; @@ -1879,13 +1943,14 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } if ( !IsMacroNode() ) { +//JR ==> Step B SendEvent( NewEvent ) ; } else { GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ; #if TraceDataReady_ExecuteAction cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " " - << aMacroGraph->Graph()->Name() << " ->DoneWait()" + << aMacroGraph->Name() << " ->DoneWait()" << " State " << aMacroGraph->State() << endl; #endif aMacroGraph->DoneWait() ; @@ -2072,17 +2137,22 @@ int GraphExecutor::InNode::Executing_ErrorAction() { 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 @@ -2093,7 +2163,7 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { // *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 ; } @@ -2101,16 +2171,20 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { 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 ) ; @@ -2118,6 +2192,7 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { //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() ) && @@ -2125,44 +2200,92 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { !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 +//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 ; @@ -2204,8 +2327,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() { #if SuccessActionTrace cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode " << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ; - aLabelNode->SetWaitingStates( this ) ; #endif + 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 ) { @@ -2213,7 +2336,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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 ; } @@ -2272,70 +2395,29 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } } - 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 ; + 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 { @@ -2346,31 +2428,50 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } } +//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 +//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 do not activate Nodes within Switch +// We activate directly the EnSwitch +// BUT the NotSwitchBranch(es) are NOT activated : + 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 ; + } + } + 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 ; GraphBase::ComputingNode * aComputingNode ; aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ; toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ; @@ -2382,7 +2483,10 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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 ) ; @@ -2393,62 +2497,88 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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() ) { +// GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ; +// if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle +// if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) { + if ( IgnoreForEndLoop && !strcmp( toNode->Name() , CoupledNode()->Name() ) ) { +// IgnoreForEndLoop = true ; +// } +// else { // toNode is the EndLoopNode 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 ( 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 ; +// } +// } + 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 + + 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() ) ) { + cdebug << pthread_self() << "/" << ThreadNo() + << " Successed_SuccessAction NO activate EndLoopNode " << toNode->Name() + << endl ; + activatetoNode = false ; + } + } +//Not a EndLoopNode : + else { + cdebug << pthread_self() << "/" << ThreadNo() + << " Successed_SuccessAction NO activate node " << toNode->Name() << endl ; + activatetoNode = false ; + } + } +// If the DefaultPort of that SwitchNode is connected to the DefaultPort of 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 ; 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() ; @@ -2467,54 +2597,35 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } if ( aNode && (const GraphBase::ComputingNode * ) toNode->ComputingNode() == aNode ) { // toNode is connected to the DefaultPort of that SwitchNode : + cdebug << pthread_self() << "/" << ThreadNo() + << " Successed_SuccessAction activate node " << aNode->Name() << endl ; activatetoNode = true ; break ; } + else { + cdebug << pthread_self() << "/" << ThreadNo() + << " Successed_SuccessAction NO activate node " << aNode->Name() << endl ; + } } -// 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 ; + return 0 ; } } + toNode->UnLockDataReady() ; } } - } //PAL8517 //JR 10.02.2005 : Debug at the end of execution of a SwitchNode : @@ -2525,158 +2636,137 @@ int GraphExecutor::InNode::Successed_SuccessAction() { // BUT are not executed when Default is activated). // 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() ) { + if ( IsSwitchNode() ) { + GraphBase::InLineNode * anEndSwitchNode = GOTONode()->CoupledNode() ; + 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 ) ; + 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 ; +#endif + } } - else { + } + 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 " << Name() + << " " << Kind() << " OutGate->Value " << GetNodeOutGate()->BoolValue() + << " NO reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ; #endif - } } } - else { + +//JR 15.04.2005 Debug PAL8624 RetroConception : + 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() ; + if ( toNode->HasAllDataReady() ) { + SomeDataNodes.push_back( toNode ) ; + toNode->HasAllDataReady( false ) ; #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() << " push " + << toNode->Name() << " " << SomeDataNodes.size() << endl ; #endif + } + toNode->UnLockDataReady() ; + } } - } // 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 ) ; +//JR 15.04.2005 Debug PAL8624 RetroConception : + while ( SomeDataNodes.size() > 1 ) { + GraphExecutor::InNode *aNode = SomeDataNodes.front() ; + SomeDataNodes.pop_front() ; #if SuccessActionTrace - cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode " - << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ; -#endif - firstzeroNode = NULL ; - } - else { -#if SuccessActionTrace - cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " firsttoNode " << firsttoNode - << " firstzeroNode " << firstzeroNode << endl ; -#endif - } - - 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 ) { -#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 ( SomeDataNodes.size() ) { + firsttoNode = SomeDataNodes.front() ; + SomeDataNodes.pop_front() ; } - } - if ( firsttoNode ) { + 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; -#endif +//#if SuccessActionTrace + cdebug_out << pthread_self() << "/" << ThreadNo() + << " Successed_SuccessAction " << Name() << endl; +//#endif return 1 ; } @@ -2685,24 +2775,15 @@ 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 || @@ -2717,17 +2798,26 @@ bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) { } // 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 ; } @@ -2920,7 +3010,7 @@ void GraphExecutor::InNode::InParametersSet( bool & Err , 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() && @@ -3465,13 +3555,13 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , #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 ) ; } @@ -3479,7 +3569,7 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , #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 : //It controls that there is only one SwitchBranch activated @@ -3509,7 +3599,7 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , #if OutParametersSetTrace cdebug << " Param " ; #endif - anOutPort->Value( OutParametersList[i].Value ); + anOutPort->SetValue( OutParametersList[i].Value ); } anOutPort->PortState( PortState ) ; anOutPort->PortDone( true ) ; @@ -3529,9 +3619,10 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , #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 ; @@ -3647,16 +3738,18 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , if ( aGateOutPort->InPortsSize() && aGateOutPort->ChangeInPorts( 0 ) ) { #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 { #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 ; } @@ -3673,8 +3766,11 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , #endif long l = 0; OutParametersList[0].Value <<= l ; - aGateOutPort->Value( OutParametersList[0].Value ) ; + aGateOutPort->SetValue( OutParametersList[0].Value ) ; } +// The OutPort field of InPorts of EndSwitchNode may be updated only in branches : +// for the Default case they should not be changed (if they are changed ==> bug if we activate +// a branch after a use of the Default) if ( !OrSwitch || DefaultSwitch ) { // DefaultPort or DefaultSwitch int i ; for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { @@ -3687,7 +3783,8 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , if ( anInPort && anInPort->GetOutPort() ) { #if OutParametersSetTrace cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName() << "( " - << anInPort->PortName() << " ) linked from " << anInPort->GetOutPort()->NodeName() + << anInPort->PortName() << " , " << anInPort->Kind() << " ) linked from " + << anInPort->GetOutPort()->NodeName() << "( " << anInPort->GetOutPort()->PortName() << " ) CHANGED TO linked from " << GetChangeNodeOutPort( i )->NodeName() << "( " << GetChangeNodeOutPort( i )->PortName() << " )" << endl ; -- 2.39.2