From cb76eaeab5b10d96883a8a26536354685f10e8e5 Mon Sep 17 00:00:00 2001 From: rahuel Date: Fri, 8 Jul 2005 13:00:16 +0000 Subject: [PATCH] End of developpement/test of Switch Python Nodes --- src/GraphBase/DataFlowBase_ComputingNode.cxx | 73 ++-- src/GraphBase/DataFlowBase_ComputingNode.hxx | 16 +- src/GraphBase/DataFlowBase_DataNode.cxx | 50 ++- .../DataFlowBase_EndOfSwitchNode.cxx | 102 +++-- .../DataFlowBase_EndOfSwitchNode.hxx | 13 +- src/GraphBase/DataFlowBase_Graph.cxx | 246 ++++++++--- src/GraphBase/DataFlowBase_Graph.hxx | 8 +- src/GraphBase/DataFlowBase_OutPort.cxx | 2 +- src/GraphBase/DataFlowBase_SwitchNode.cxx | 280 ++++++++---- src/GraphBase/DataFlowBase_XmlHandler.cxx | 19 +- src/GraphEditor/DataFlowEditor_DataFlow.hxx | 3 +- src/GraphEditor/DataFlowEditor_DataFlow.lxx | 24 +- src/GraphEditor/DataFlowEditor_OutNode.cxx | 137 ++++-- src/GraphEditor/DataFlowEditor_OutNode.hxx | 13 +- .../DataFlowExecutor_FiniteStateMachine.cxx | 12 +- .../DataFlowExecutor_FiniteStateMachine.hxx | 3 +- src/GraphExecutor/DataFlowExecutor_InNode.cxx | 95 ++-- src/GraphExecutor/DataFlowExecutor_InNode.hxx | 5 +- .../DataFlowExecutor_InNodeThreads.cxx | 404 ++++++++++++++---- .../DataFlowExecutor_OutNode.cxx | 71 ++- .../DataFlowExecutor_OutNode.hxx | 8 + src/Supervision/CNode_Impl.cxx | 8 +- src/Supervision/Graph_Impl.cxx | 15 + src/Supervision/Graph_Impl.hxx | 2 + src/Supervision/Port_Impl.cxx | 2 +- src/Supervision/SuperV.py | 2 + 26 files changed, 1178 insertions(+), 435 deletions(-) diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx index aca8d70..54139b0 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.cxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -869,17 +869,20 @@ GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( c } -bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode , - GraphBase::EndOfLoopNode * anEndLoopNode ) const { +bool GraphBase::ComputingNode::CheckLoop( GraphBase::LoopNode * aLoopNode , + GraphBase::EndOfLoopNode * anEndLoopNode , + string & anErrorMessage ) const { cdebug_in << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedNodesSize " << LinkedNodesSize() << endl; int i ; if ( LinkedNodesSize() == 0 && !IsDataFlowNode() && !IsDataStreamNode() ) { + anErrorMessage = anErrorMessage + string( "The node " ) + string( Name() ) + + string( " has no linked Nodes. Loop not valid\n" ) ; cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedNodesSize " - << LinkedNodesSize() << " WARNING false" << endl; + << LinkedNodesSize() << " ERROR false" << endl; return false ; } // We check that all nodes linked to that node go to the end of LoopNode : @@ -887,10 +890,10 @@ bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode , GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ; cdebug << i << ". " << Name() << " Linked to " << aNode->Name() << endl ; if ( !aNode->IsEndLoopNode() || aNode != anEndLoopNode ) { - if ( !aNode->CheckLoop( aLoopNode , anEndLoopNode ) ) { + if ( !aNode->CheckLoop( aLoopNode , anEndLoopNode , anErrorMessage) ) { cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedNodesSize " - << LinkedNodesSize() << " WARNING false" << endl; + << LinkedNodesSize() << " ERROR false" << endl; return false ; } } @@ -902,16 +905,19 @@ bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode , } bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode , - GraphBase::EndOfLoopNode * anEndLoopNode ) const { + GraphBase::EndOfLoopNode * anEndLoopNode , + string & anErrorMessage ) const { cdebug_in << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize " << LinkedFromNodesSize() << endl; int i ; if ( LinkedFromNodesSize() == 0 ) { + anErrorMessage = anErrorMessage + string( "The node " ) + string( Name() ) + + string( " has no reversed linked Nodes. Loop not valid\n" ) ; cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize " - << LinkedFromNodesSize() << " WARNING false" << endl; + << LinkedFromNodesSize() << " ERROR false" << endl; return false ; } // We have to check that all nodes linked from that node go to the beginning of LoopNode : @@ -919,10 +925,10 @@ bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode , GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ; cdebug << i << ". " << Name() << " Linked from " << aNode->Name() << endl ; if ( !aNode->IsLoopNode() || aNode != aLoopNode ) { - if ( !aNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) { + if ( !aNode->CheckEndLoop( aLoopNode , anEndLoopNode , anErrorMessage ) ) { cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize " - << LinkedFromNodesSize() << " WARNING false" << endl; + << LinkedFromNodesSize() << " ERROR false" << endl; return false ; } } @@ -933,29 +939,35 @@ bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode , return true ; } -bool GraphBase::ComputingNode::InitBranchOfSwitchDone(bool AllInit , - GraphBase::EndOfSwitchNode * anEndSwitchNode ) { +bool GraphBase::ComputingNode::InitBranchOfSwitchDone( bool AllInit , + GraphBase::EndOfSwitchNode * anEndSwitchNode , + string & anErrorMessage ) { + bool RetVal = true ; bool sts = BranchOfSwitchDone( false ) ; if ( !sts && !AllInit && anEndSwitchNode != this ) { // Common Node in branchs : - cdebug << Name() << "->ComputingNode::InitBranchOfSwitchDone WARNING false" + anErrorMessage = anErrorMessage + string( "Common Node between some SwitchBranches : " ) + + string( Name() ) + string("\n" ) ; + cdebug << Name() << "->ComputingNode::InitBranchOfSwitchDone ERROR false" << endl ; - return false ; + RetVal = false ; } int i ; if ( !IsGOTONode() && anEndSwitchNode != this ) { for ( i = 0 ; i < LinkedNodesSize() ; i++ ) { GraphBase::ComputingNode * aNode ; aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ; - if ( !aNode->InitBranchOfSwitchDone( AllInit , anEndSwitchNode ) ) { - return false ; + if ( !aNode->InitBranchOfSwitchDone( AllInit , anEndSwitchNode , anErrorMessage ) ) { + RetVal = false ; } } } - return true ; + return RetVal ; } -bool GraphBase::ComputingNode::CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwitchNode ) { +bool GraphBase::ComputingNode::CheckSwitch( GraphBase::EndOfSwitchNode * anEndSwitchNode , + string & anErrorMessage ) { + bool RetVal = true ; cdebug_in << Name() << "->ComputingNode::CheckSwitch( " << anEndSwitchNode->Name() << " ) " << Kind() << endl; if ( anEndSwitchNode == this ) { @@ -966,10 +978,10 @@ bool GraphBase::ComputingNode::CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwi anOtherEndSwitchNode = (GraphBase::EndOfSwitchNode * ) ((GraphBase::SwitchNode * ) this)->CoupledNode() ; cdebug << Name() << "->ComputingNode::CheckSwitch will Check " << anOtherEndSwitchNode->Name() << endl ; - if ( !anOtherEndSwitchNode->CheckSwitch( anEndSwitchNode ) ) { + if ( !anOtherEndSwitchNode->CheckSwitch( anEndSwitchNode , anErrorMessage ) ) { cdebug_out << Name() << "->ComputingNode::CheckSwitch " - << anOtherEndSwitchNode->Name() << " WARNING false" << endl; - return false ; + << anOtherEndSwitchNode->Name() << " ERROR false" << endl; + RetVal = false ; } } else { @@ -1001,7 +1013,10 @@ bool GraphBase::ComputingNode::CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwi << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ; } else if ( aNode == anEndSwitchNode ) { - ((GraphBase::EndOfSwitchNode * ) aNode)->DecrEndSwitchInPortLinked( anInPort ) ; + if ( !((GraphBase::EndOfSwitchNode * ) aNode)->DecrEndSwitchInPortLinked( anInPort , + anErrorMessage ) ) { + RetVal = false ; + } } else if ( aNode->BranchOfSwitchDone() ) { cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check " @@ -1024,10 +1039,10 @@ bool GraphBase::ComputingNode::CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwi else { cdebug << Name() << "->ComputingNode::CheckSwitch will Check " << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ; - if ( !aNode->CheckSwitch( anEndSwitchNode ) ) { + if ( !aNode->CheckSwitch( anEndSwitchNode , anErrorMessage ) ) { cdebug_out << Name() << "->ComputingNode::CheckSwitch " - << anEndSwitchNode->Name() << " WARNING false" << endl; - return false ; + << anEndSwitchNode->Name() << " ERROR false" << endl; + RetVal = false ; } // aNode->BranchOfSwitchDone( true ) ; } @@ -1036,10 +1051,12 @@ bool GraphBase::ComputingNode::CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwi } } } - BranchOfSwitchDone( true ) ; - cdebug_out << Name() << "->ComputingNode::CheckSwitch BranchOfSwitchDone == true " - << anEndSwitchNode->Name() << " true" << endl; - return true ; + if ( RetVal ) { + BranchOfSwitchDone( true ) ; + } + cdebug_out << Name() << "->ComputingNode::CheckSwitch " + << anEndSwitchNode->Name() << " RetVal " << RetVal << endl; + return RetVal ; } #include diff --git a/src/GraphBase/DataFlowBase_ComputingNode.hxx b/src/GraphBase/DataFlowBase_ComputingNode.hxx index d0b3069..76b84f4 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.hxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.hxx @@ -272,12 +272,16 @@ namespace GraphBase { } return false ; } ; - bool CheckLoop(GraphBase::LoopNode * aLoopNode , - GraphBase::EndOfLoopNode * anEndLoopNode ) const ; - bool CheckEndLoop(GraphBase::LoopNode * aLoopNode , - GraphBase::EndOfLoopNode * anEndLoopNode ) const ; - bool InitBranchOfSwitchDone( bool AllInit , GraphBase::EndOfSwitchNode * anEndSwitchNode ) ; - bool CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwitchNode ) ; + bool CheckLoop( GraphBase::LoopNode * aLoopNode , + GraphBase::EndOfLoopNode * anEndLoopNode , + string & anErrorMessage ) const ; + bool CheckEndLoop( GraphBase::LoopNode * aLoopNode , + GraphBase::EndOfLoopNode * anEndLoopNode , + string & anErrorMessage ) const ; + bool InitBranchOfSwitchDone( bool AllInit , GraphBase::EndOfSwitchNode * anEndSwitchNode , + string & anErrorMessage ) ; + bool CheckSwitch( GraphBase::EndOfSwitchNode * anEndSwitchNode , + string & anErrorMessage ) ; // const GraphBase::ListOfParameters * GetListOfParameters() const ; diff --git a/src/GraphBase/DataFlowBase_DataNode.cxx b/src/GraphBase/DataFlowBase_DataNode.cxx index 64a4bbf..1b0a191 100644 --- a/src/GraphBase/DataFlowBase_DataNode.cxx +++ b/src/GraphBase/DataFlowBase_DataNode.cxx @@ -28,6 +28,7 @@ using namespace std; #include "DataFlowBase_DataNode.hxx" +#include "DataFlowBase_Graph.hxx" GraphBase::DataNode::DataNode() : GOTONode() { @@ -101,42 +102,69 @@ int GraphBase::DataNode::CheckDataServerNodes() const { int i , ierr = 0 ; for ( i = 0 ; i < _DataFlowDataPorts->GetNodeOutPortsSize() ; i++ ) { -// Not a BUG : Reversed Service of the graph +// Not a BUG : Reversed Service of the graph : OutPort of the Graph give input values to nodes const GraphBase::OutPort * anOutPort = _DataFlowDataPorts->GetNodeOutPort(i) ; // if ( !anOutPort->IsGate() && !anOutPort->IsDataStream() && !anOutPort->IsDataConnected() ) { if ( !anOutPort->IsGate() && !anOutPort->IsDataConnected() ) { if ( anOutPort->IsExternConnected() && GraphMacroLevel() != 0 ) { - cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() << " " + cdebug << "Base::DataNode::CheckDataServerNodes InPort " << anOutPort->PortName() << " " + << anOutPort->PortType() << " " << anOutPort->PortStatus() << " of DataFlow " << Name() << " is ExternConnected. GraphMacroLevel " << GraphMacroLevel() << endl ; } else { - cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() << " " - << anOutPort->PortStatus() << " of DataFlow " << Name() << " has NO Data. GraphMacroLevel " - << GraphMacroLevel() << endl ; - ierr++ ; + cdebug << "Base::DataNode::CheckDataServerNodes InPort " << anOutPort->PortName() << " " + << anOutPort->PortType() << " " << anOutPort->PortStatus() << " of DataFlow " << Name() + << " has NO Data. GraphMacroLevel " << GraphMacroLevel() << " InPortsSize " + << anOutPort->InPortsSize() << " corresponding to :" + << endl ; + int i ; + for ( i = 0 ; i < anOutPort->InPortsSize() ; i++ ) { + cdebug << " " << anOutPort->InPorts( i )->NodeName() << "( " + << anOutPort->InPorts( i )->PortName() << " ) " << endl ; + } + if ( anOutPort->InPortsSize() == 1 && + GraphOfNode()->GetGraphNode( anOutPort->InPorts( 0 )->NodeName() )->IsEndSwitchNode() ) { + cdebug << "Base::DataNode::CheckDataServerNodes InPort " << anOutPort->PortName() + << " is connected to an EndSwitchNode. Input Data is controlled by ValidSwitchs." + << endl ; + } + else { + ostringstream astr ; + astr << anOutPort->PortStatus() ; + string anErrorMessage = string( "InPort " ) + string( anOutPort->NodeName() ) + + string( "( " ) + string( anOutPort->PortName() ) + string( " ) " ) + + astr.str() + string( " has NO Input Data.\n" ) ; + GraphOfNode()->SetMessages( anErrorMessage ) ; + ierr++ ; + } } } else { - cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() << " " - << anOutPort->PortStatus() << " of DataFlow " << Name() << " has Data : " + cdebug << "Base::DataNode::CheckDataServerNodes InPort " << anOutPort->PortName() << " " + << anOutPort->PortType() << " " + << anOutPort->PortStatus() << " of DataFlow " << Name() << " has Data or IsGate" << endl ; } } for ( i = 0 ; i < _DataFlowDataPorts->GetNodeInPortsSize() ; i++ ) { if ( _DataFlowDataPorts->GetNodeInPort(i)->IsPortConnected() ) { - cdebug << "OutPort " << _DataFlowDataPorts->GetNodeInPort(i)->PortName() + cdebug << "Base::DataNode::CheckDataServerNodes OutPort " + << _DataFlowDataPorts->GetNodeInPort(i)->PortName() << " of DataFlow " << Name() << " is Connected" << endl ; } else { - cdebug << "OutPort " << _DataFlowDataPorts->GetNodeInPort(i)->PortName() + cdebug << "Base::DataNode::CheckDataServerNodes OutPort " + << _DataFlowDataPorts->GetNodeInPort(i)->PortName() << " of DataFlow " << Name() << " is NOT Connected" << endl ; } } if ( ierr ) { - cdebug << "In the DataFlow " << Name() << " " << ierr << " Some Input Data is missing" << endl ; + GraphOfNode()->SetMessages( "Some Input Data are missing.\n" ) ; + cdebug << "Base::DataNode::CheckDataServerNodes In the DataFlow " << Name() << " " << ierr + << " Some Input Data are missing" << endl ; } cdebug_out << "GraphBase::DataNode::CheckDataServerNodes ierr " << ierr << endl; diff --git a/src/GraphBase/DataFlowBase_EndOfSwitchNode.cxx b/src/GraphBase/DataFlowBase_EndOfSwitchNode.cxx index 867cafd..d60ace2 100644 --- a/src/GraphBase/DataFlowBase_EndOfSwitchNode.cxx +++ b/src/GraphBase/DataFlowBase_EndOfSwitchNode.cxx @@ -74,49 +74,91 @@ GraphBase::EndOfSwitchNode::~EndOfSwitchNode() { // delete [] _Comment; } -bool GraphBase::EndOfSwitchNode::DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort ) { +void GraphBase::EndOfSwitchNode::InitEndSwitchInPortLinked() { // without StreamInPorts + cdebug << "Base::EndOfSwitchNode::InitEndSwitchInPortLinked of " << Name() << endl ; +//JR 06.07.2005 : the InGatePort(Default) must also be counted (enhancement) ... +// _EndSwitchInPortLinkedNumber = GetNodeInPortsSize() - DataStreamInPortsNumber() - 1 ; + _EndSwitchInPortLinkedNumber = GetNodeInPortsSize() - DataStreamInPortsNumber() ; + _SwitchWithGOTO = false ; + int i ; +//JR 06.07.2005 : the InGatePort must also be counted (enhancement) ... +// for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) { + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + GetChangeNodeInPort( i )->BranchOfSwitchLinked( false ) ; + } +} + +bool GraphBase::EndOfSwitchNode::DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort , + string & anErrorMessage ) { bool RetVal = true ; -// if ( !anInPort->BranchOfSwitchLinked() ) { - RetVal = anInPort->BranchOfSwitchLinked( true ) ; //JR 16.02.2005 : except for DefaultPort - if ( !anInPort->IsGate() ) { - _EndSwitchInPortLinkedNumber -= 1 ; +//JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ... +// if ( !anInPort->IsGate() ) { + if ( !anInPort->BranchOfSwitchLinked( true ) ) { + cdebug << Name() << "->DecrEndSwitchInPortLinked ERROR " << anInPort->NodeName() << "( " + << anInPort->PortName() << " ) was already linked in that branch." << endl ; + anErrorMessage = anErrorMessage + string( Name() ) + string( " The port " ) + + string( anInPort->NodeName() ) + string( "( " ) + + string( anInPort->PortName() ) + + string( " ) was already linked in that branch.\n" ) ; + RetVal = false ; } - cdebug << Name() - << "->EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber " - << _EndSwitchInPortLinkedNumber << " InPort '" << anInPort->PortName() << "' of " - << anInPort->NodeName() << " RetVal " << RetVal << endl ; -// } -// else { -// cdebug << "EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber " -// << _EndSwitchInPortLinkedNumber << " InPort " << anInPort->PortName() -// << " already done RetVal " << RetVal << endl ; + _EndSwitchInPortLinkedNumber -= 1 ; // } + cdebug << Name() + << "->EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber " + << _EndSwitchInPortLinkedNumber << " InPort '" << anInPort->PortName() << "' of " + << anInPort->NodeName() << " RetVal " << RetVal << endl ; return RetVal ; } -bool GraphBase::EndOfSwitchNode::CheckEndSwitchInPortsLinked() { +bool GraphBase::EndOfSwitchNode::CheckEndSwitchInPortsLinked( string & anErrorMessage ) { + bool RetVal = true ; + bool DefaultNotLinked = false ; +// Check that all inports of the EndSwitchNode are reachable in that branch(es) + int i ; +//JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ... +// for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) { + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ; + if ( !anInPort->IsDataStream() && !anInPort->BranchOfSwitchLinked() ) { + cdebug << Name() << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked " + << anInPort->PortName() << " have no link in that branch" + << " SwitchWithGOTO() " << SwitchWithGOTO() << endl ; + if ( !SwitchWithGOTO() ) { + anErrorMessage = anErrorMessage + string( Name() ) + string( "( " ) + + string( anInPort->PortName() ) + + string( " ) has no link from that branch.\n" ) ; + if ( anInPort->IsGate() ) { + DefaultNotLinked = true ; + } + else { + RetVal = false ; // that InPort is not linked + } + } + } + } // Check that all inports of the EndSwitchNode will have a value only once if ( _EndSwitchInPortLinkedNumber != 0 ) { cdebug << Name() << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked EndSwitchInPortLinkedNumber " - << _EndSwitchInPortLinkedNumber << endl ; + << _EndSwitchInPortLinkedNumber << " SwitchWithGOTO() " << SwitchWithGOTO() + << " DefaultNotLinked " << DefaultNotLinked << endl ; if ( !SwitchWithGOTO() ) { - return false ; // Some InPort is not linked - } - } -// Check that all inports of the EndSwitchNode are reachable in that branch(es) - int i ; - for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) { - if ( !GetChangeNodeInPort( i )->IsDataStream() && - !GetChangeNodeInPort( i )->BranchOfSwitchLinked() ) { - cdebug << Name() << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked " - << GetNodeInPort( i )->PortName() << " have no link in that branch" - << endl ; - if ( !SwitchWithGOTO() ) { - return false ; // that InPort is not linked + if ( RetVal && _EndSwitchInPortLinkedNumber == 1 && DefaultNotLinked ) { + } + else { + if ( _EndSwitchInPortLinkedNumber > 0 ) { + anErrorMessage = anErrorMessage + string( Name() ) + + string( " has some InPort(s) not linked.\n" ) ; + } + else { + anErrorMessage = anErrorMessage + string( Name() ) + + string( " has some InPort(s) multiply linked.\n" ) ; + } + RetVal = false ; // Some InPort is not linked or multiply linked } } } - return true ; // Ok : all InPorts are linked + return RetVal ; } diff --git a/src/GraphBase/DataFlowBase_EndOfSwitchNode.hxx b/src/GraphBase/DataFlowBase_EndOfSwitchNode.hxx index 93e2599..c6ac446 100644 --- a/src/GraphBase/DataFlowBase_EndOfSwitchNode.hxx +++ b/src/GraphBase/DataFlowBase_EndOfSwitchNode.hxx @@ -44,19 +44,14 @@ namespace GraphBase { ofstream * Graph_fdebug = NULL ) ; virtual ~EndOfSwitchNode() ; - void InitEndSwitchInPortLinked() { // without StreamInPorts and Default - _EndSwitchInPortLinkedNumber = GetNodeInPortsSize() - DataStreamInPortsNumber() - 1 ; - _SwitchWithGOTO = false ; - int i ; - for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) { - GetChangeNodeInPort( i )->BranchOfSwitchLinked( false ) ; - } } ; - bool DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort ) ; + void InitEndSwitchInPortLinked() ; + bool DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort , + string & anErrorMessage ) ; void SetSwitchWithGOTO() { _SwitchWithGOTO = true ; } ; bool SwitchWithGOTO() { return _SwitchWithGOTO ; } ; - bool CheckEndSwitchInPortsLinked() ; + bool CheckEndSwitchInPortsLinked( string & anErrorMessage ) ; }; diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx index 29b0716..d461fad 100644 --- a/src/GraphBase/DataFlowBase_Graph.cxx +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -35,6 +35,7 @@ GraphBase::Graph::Graph() : DataNode() { cdebug << "GraphBase::Graph::Graph" << endl ; _GraphNodesSize = 0 ; + GraphOfNode( this ) ; } GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , @@ -49,6 +50,7 @@ GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ; cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ") GraphNodesSize() " << GraphNodesSize() << endl ; _GraphNodesSize = 0 ; + GraphOfNode( this ) ; } GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , @@ -73,6 +75,7 @@ GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) { _Orb = CORBA::ORB::_duplicate( ORB ) ; _GraphNodesSize = 0 ; + GraphOfNode( this ) ; Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ; cdebug_in << "GraphBase::Graph::Graph" << endl ; DataService( ORB , DataFlowService , Graph_prof_debug , Graph_fdebug ) ; @@ -557,7 +560,7 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ") " << endl; int i ; - bool RetVal = false ; + bool RetVal = true ; //#if 0 GraphBase::ComputingNode * anOldNode = GetChangeGraphNode( OldNodeName ) ; for ( i = 0 ; i < anOldNode->LinkedNodesSize() ; i++ ) { @@ -565,28 +568,29 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , } //#endif if ( !strcmp( OldNodeName , NewNodeName ) ) { - RetVal = true ; } else if ( strcmp( Name() , OldNodeName ) ) { int index = GetGraphNodeIndex( OldNodeName ) ; int newindex = GetGraphNodeIndex( NewNodeName ) ; if ( index >= 0 && index < _GraphNodesSize && ( newindex < 0 || newindex > _GraphNodesSize ) ) { + DelGraphNodeIndex( _GraphNodes[ index ]->Name() ) ; _GraphNodes[ index ]->Name( NewNodeName ) ; - _MapOfGraphNodes.erase( OldNodeName ) ; - SetGraphNodeIndex( NewNodeName , index ) ; +//JR 29.06.2005 Debug ??? +// SetGraphNodeIndex( NewNodeName , index ) ; + SetGraphNodeIndex( _GraphNodes[ index ]->Name() , index ) ; GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ; // Update 'ToNode's Map from 'aNode' - cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize : " + cdebug << "Graph::ReNameNode " << aNode->Name() << "/" << OldNodeName << " LinkedNodesSize : " << aNode->LinkedNodesSize() << endl ; for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) { GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ; ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ; } // Rename in _MapOfLinkedNodes of 'FromNode' - cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedFromNodesSize : " - << aNode->LinkedFromNodesSize() << endl ; + cdebug << "Graph::ReNameNode " << aNode->Name() << "/" << OldNodeName + << " LinkedFromNodesSize : " << aNode->LinkedFromNodesSize() << endl ; for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) { GraphBase::StreamNode * FromNode = aNode->LinkedFromNodes( i ) ; if ( FromNode->GetLinkedNodeIndex( OldNodeName ) >= 0 ) { @@ -601,14 +605,16 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ; // OutPort 'anOutPort' linked to 'anInPort' GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; - cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ; + cdebug << i << ". " << aNode->Name() << "/" << OldNodeName + << " GraphBase::Graph::ReNameNode of LinkedNode : from " ; if ( anOutPort ) { - cdebug << anOutPort->NodeName() ; + cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )" ; } else { cdebug << "without link" ; } - cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName ; + cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName + << " OldNodeName " << OldNodeName ; if ( !anInPort->IsNotConnected() ) { if ( anOutPort->IsDataConnected() ) { cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ; @@ -623,27 +629,15 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , FromNode = this ; } cdebug << " fromConnected " << anOutPort->NodeName() << endl ; -#if 0 -//JR 26.01.2005 : a same node may be renamed severeal times. So this is done above -// Rename in _MapOfLinkedFromNodes of 'FromNode' - if ( anInPort->IsDataStream() ) { - FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ; - } - else { - FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ; - } -#endif } char* OldNodePortName = new char[ strlen( OldNodeName ) + strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ; char* NewNodePortName = new char[ strlen( NewNodeName ) + strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ; strcpy( OldNodePortName , OldNodeName ) ; -// strcat( OldNodePortName , "\\" ) ; strcat( OldNodePortName , "__" ) ; strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ; strcpy( NewNodePortName , NewNodeName ) ; -// strcat( NewNodePortName , "\\" ) ; strcat( NewNodePortName , "__" ) ; strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ; RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ; @@ -654,10 +648,8 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , } else { cdebug << " not connected" << endl ; - RetVal = true ; } } - RetVal = true ; // PAL8508 //JR 02.02.2005 DEBUG : ReName in the CoupledNode was missing if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() || @@ -678,13 +670,29 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , } } else { - cdebug << "ERROR Node not found" << endl ; + cdebug << "ERROR Node not found or conflicting NodeName" << endl ; + RetVal = false ; } } else { - RetVal = Name( NewNodeName ) ; + cdebug << "ReNameNode with same name." << endl ; +// RetVal = Name( NewNodeName ) ; } +#if 1 + cdebug << "Graph::ReNameNode " << _GraphNodesSize << " known nodes" << endl; + for ( i = 0 ; i < _GraphNodesSize ; i++ ) { + cdebug << "Node" << i << _GraphNodes[ i ]->Name() << endl ; + } + map< string , int >::iterator aMapOfGraphNodesIterator ; + i = 0 ; + for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ; + aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) { + cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> " + << aMapOfGraphNodesIterator->second << " - 1" << endl ; + } +#endif + cdebug_out << "GraphBase::Graph::ReNameNode RetVal " << RetVal << endl; return RetVal ; } @@ -1142,17 +1150,25 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , << fromPort->PortName() << " " << fromPort->PortStatus() << ") " << fromPort->Kind() << " ---> " << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus() << ") " << toPort->Kind() << " )" << endl; + ostringstream LinkStrError ; + LinkStrError << "Creation of link from " << fromNode->Name() << "( " + << fromPort->PortName() << " " << fromPort->PortStatus() << " " << fromPort->Kind() + << " ) ---> " << toNode->Name() << "( " << toPort->PortName() << " " + << toPort->PortStatus() << " " << toPort->Kind() << " ) :\n" ; if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) { if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort() - cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "(" - << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ; + cdebug_out << "GraphBase::Graph::AddLink in OutPort ( " << fromNode->Name() << "(" + << fromPort->PortName() << " " << fromPort->PortStatus() + << ") RemoveInPort ERROR InPortsSize " << fromPort->InPortsSize() << endl ; return false ; } } if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) { if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort() - cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "(" - << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ; + cdebug_out << "GraphBase::Graph::AddLink in InPort connected to the OutPort ( " + << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus() + << ") RemoveInPort ERROR InPortsSize " << toPort->GetOutPort()->InPortsSize() + << endl ; return false ; } } @@ -1168,8 +1184,18 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() && !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() && toPort->GetOutPort() ) { - if ( !strcmp( toPort->GetOutPort()->NodePortName() , +//JR Debug 15.06.2005 : the case of multiple links to EndSwitchNode was missing : + if ( toNode->IsEndSwitchNode() && fromPort->GetInPort( toPort ) == toPort ) { + LinkStrError << "Link already exists.\n" ; + SetMessages( LinkStrError.str() ) ; + cdebug << "Link already exists" << endl ; + cdebug_out << "GraphBase::Graph::AddLink 1" << endl; + return true ; + } + else if ( !strcmp( toPort->GetOutPort()->NodePortName() , fromPort->NodePortName() ) ) { + LinkStrError << "Link already exists.\n" ; + SetMessages( LinkStrError.str() ) ; cdebug << "Link already exists" << endl ; cdebug_out << "GraphBase::Graph::AddLink 1" << endl; return true ; @@ -1210,12 +1236,27 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , return false ; } } +//JR 15.06.2005 : disabled : GraphSwitchBranchGates ... +// else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() && !toPort->IsGate() ) { +// cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode toPort(NotGate)Error." +// << endl ; +// LinkStrError << "Link from SwitchNode to EndSwitchNode is not allowed.\n" ; +// SetMessages( LinkStrError.str() ) ; +// cdebug << "Graph::AddLink ERROR Link from SwitchNode to EndSwitchNode is not allowed." +// << endl ; +// cdebug_out << "GraphBase::Graph::AddLink 0" << endl; +// return false ; +// } +//JR 15.06.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default) //PAL8511 //JR Debug 15.02.2005 : Not multiple links in that case except if toPort is the DefaultPort - else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() && !toPort->IsGate() ) { - cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode toPort(NotGate)Error." + else if ( fromNode->IsSwitchNode() && fromPort->IsGate() && + !toNode->IsEndSwitchNode() ) { + LinkStrError << "Link from SwitchNode(Default) is allowed only to EndSwitchNode(Default).\n" ; + SetMessages( LinkStrError.str() ) ; + cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error." << endl ; - cdebug_out << "GraphBase::Graph::AddLink" << endl; + cdebug_out << "GraphBase::Graph::AddLink 0" << endl; return false ; } } @@ -1223,13 +1264,23 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , //JR 24.03.2005 : No Link between OutPort of SwitchNode to InPort of EndSwitchNode except if // they have the same name for a special case : // Switch with no branch ==> Default is applied always : GraphSyrControl example +//JR 22.06.2005 : Enhancement of the behaviour : +// For the DefaultBranch, if we have same PortsNames, Values are automatically +// transmitted +// But for the DefaultBranch, if we have NOT same PortsNames, we may create links. +// Look at GraphSyrControlAve* ... +#if 0 else if ( fromNode->IsSwitchNode() && !fromPort->IsGate() && toNode->IsEndSwitchNode() && !toPort->IsGate() && strcmp( fromPort->PortName() , toPort->PortName() ) ) { - cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode with different PortNames Error." << endl ; + LinkStrError << "Link from SwitchNode to EndSwitchNode with different PortNames is not allowed.\n" ; + SetMessages( LinkStrError.str() ) ; + cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode with different PortNames Error." + << endl ; cdebug_out << "GraphBase::Graph::AddLink" << endl; return false ; } +#endif else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) { if ( !RemoveLink( fromNode->Name() , fromPort->PortName() , fromPort->ChangeInPorts(0)->NodeName() , @@ -1252,6 +1303,8 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , // JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate if ( !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() && fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) { + LinkStrError << "Link from SwitchNode Port linked to a Gate may be connected only to Gates.\n" ; + SetMessages( LinkStrError.str() ) ; cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ; cdebug_out << "GraphBase::Graph::AddLink 0" << endl; return false ; @@ -1263,6 +1316,18 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , !( ( fromPort->IsGate() && toPort->IsGate() ) || ( !fromPort->IsGate() ) ) ) { // ( !fromPort->IsGate() && !toPort->IsGate() ) ) ) { + LinkStrError << "Link from SwitchNode to EndSwitchNode : different kinds of ports not allowed.\n" ; + SetMessages( LinkStrError.str() ) ; + cdebug << "Link ERROR from SwitchNode to EndSwitchNode : different kinds of ports not allowed." + << endl ; + cdebug_out << "GraphBase::Graph::AddLink 0" << endl; + return false ; + } +//JR 15.06.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default) + else if ( fromNode->IsSwitchNode() && fromPort->IsGate() && + !toNode->IsEndSwitchNode() ) { + LinkStrError << "Link from SwitchNode(Default) is allowed only to EndSwitchNode(Default).\n" ; + SetMessages( LinkStrError.str() ) ; cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error." << endl ; cdebug_out << "GraphBase::Graph::AddLink 0" << endl; @@ -1292,7 +1357,10 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , cdebug_out << "GraphBase::Graph::AddLink 0" << endl; return false ; } - else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) { + else if ( !fromNode->IsSwitchNode() && + ( fromPort->IsParam() || fromPort->IsInLine() ) && toPort->IsGate() ) { + LinkStrError << "Link from OutPort to a Gate is not allowed.\n" ; + SetMessages( LinkStrError.str() ) ; cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ; cdebug_out << "GraphBase::Graph::AddLink 0" << endl; return false ; @@ -1544,6 +1612,7 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName , } int i ; + cdebug << endl << "Graph::AddInputData ListOfInOutPorts of the Graph : " << endl ; for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) { cdebug << "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ; } @@ -1793,6 +1862,23 @@ void GraphBase::Graph::SetGraphPorts() { cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl; } +string GraphBase::Graph::Messages() { +// cdebug_in << "Graph::Messages" << endl ; +// cdebug_out << "Graph::Messages" << endl ; + return ( CORBA::string_dup( _Messages.c_str() ) ) ; +} + +void GraphBase::Graph::ReSetMessages() { + cdebug << "Graph::ReSetMessages" << endl ; + _Messages = string( "" ) ; +} + +void GraphBase::Graph::SetMessages( string anErrorMessage ) { + cdebug_in << "Graph::SetMessages" << endl ; + _Messages = _Messages + anErrorMessage + string( "\n" ) ; + cdebug_out << "Graph::SetMessages :" << endl << _Messages << endl ; +} + bool GraphBase::Graph::CreateService() { cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl; bool RetVal = true ; @@ -2103,7 +2189,9 @@ bool GraphBase::Graph::CreateService() { } //JR PAL8914 : InPorts of EndLoopNodes may not be in the Service of the Graph // else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) { - else if ( !anInPort->IsGate() && anInPort->IsNotConnected() && !aToNode->IsEndLoopNode() ) { + else if ( !anInPort->IsGate() && + ( anInPort->IsNotConnected() || anInPort->IsExternConnected() ) && + !aToNode->IsEndLoopNode() ) { if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) { cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ; @@ -2114,6 +2202,10 @@ bool GraphBase::Graph::CreateService() { << anInPort->PortStatus() << " --> AddInLink" << endl ; } } + else { + cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") " + << anInPort->PortStatus() << " --> NO AddInputData/AddInLink" << endl ; + } } for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) { GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ; @@ -2141,6 +2233,10 @@ bool GraphBase::Graph::CreateService() { ListPorts( *_Graph_fdebug , 0 ) ; #endif + if ( !RetVal ) { + SetMessages( "Fail to create the Service of the graph.\n" ) ; + } + cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl; return RetVal ; } @@ -2361,7 +2457,8 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph // will wait for data(s) from node(s) not executed or not executing for ever if ( !NewSorted ) { - cdebug << "Loop detected level " << _LevelsNumber << endl ; + SetMessages( "That graph is cyclic.\n" ) ; + cdebug << "ERROR Loop detected at level " << _LevelsNumber << endl ; return false ; // Loop in the Graph } // cdebug << "Bilan level " << _LevelsNumber << " : " << endl ; @@ -2424,7 +2521,8 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { // cdebug << "No Parallel Execution Nodes detected." << endl ; } if ( AllSortedNodes != GraphNodesSize() ) { - cdebug << "Loop detected level " << _LevelsNumber << endl ; + SetMessages( "That graph is cyclic.\n" ) ; + cdebug << "ERROR Loop detected at level " << _LevelsNumber << endl ; return false ; // Loop in the Graph } @@ -2662,7 +2760,7 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { bool GraphBase::Graph::ValidLoops() const { cdebug_in << "GraphBase::Graph::ValidLoops" << endl; - + bool RetVal = true ; int i ; GraphBase::ComputingNode * aNode ; for ( i = 0 ; i < GraphNodesSize() ; i++ ) { @@ -2671,25 +2769,32 @@ bool GraphBase::Graph::ValidLoops() const { GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ; GraphBase::EndOfLoopNode * anEndLoopNode ; anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ; - if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode ) ) { - cdebug_out << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name() - << endl; - return false ; + string anErrorMessage = string( "CheckLoop " ) + string( aLoopNode->Name() ) + + string( " --> " ) + string( anEndLoopNode->Name() ) + + string( " :\n" ) ; + if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode , anErrorMessage ) ) { + ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ; + cdebug << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name() + << endl; + RetVal = false ; } - else if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) { - cdebug_out << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name() - << endl; - return false ; + anErrorMessage = string( "CheckEndLoop " ) + string( aLoopNode->Name() ) + + string( " --> " ) + string( anEndLoopNode->Name() ) + string( " :\n" ) ; + if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode , anErrorMessage ) ) { + ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ; + cdebug << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name() + << endl; + RetVal = false ; } } } - cdebug_out << "GraphBase::Graph::ValidLoops true" << endl; - return true ; + cdebug_out << "GraphBase::Graph::ValidLoops RetVal " << RetVal << endl; + return RetVal ; } bool GraphBase::Graph::ValidSwitchs() const { cdebug_in << "GraphBase::Graph::ValidSwitchs" << endl; - + bool RetVal = true ; int i ; GraphBase::ComputingNode * aNode ; for ( i = 0 ; i < GraphNodesSize() ; i++ ) { @@ -2697,14 +2802,14 @@ bool GraphBase::Graph::ValidSwitchs() const { if ( aNode->IsSwitchNode() ) { GraphBase::SwitchNode * aSwitchNode = (GraphBase::SwitchNode * ) aNode ; if ( !aSwitchNode->CheckSwitch() ) { - cdebug_out << "GraphBase::Graph::ValidSwitchs false aSwitchNode " << aSwitchNode->Name() - << endl; - return false ; + cdebug << "GraphBase::Graph::ValidSwitchs false aSwitchNode " << aSwitchNode->Name() + << endl; + RetVal = false ; } } } - cdebug_out << "GraphBase::Graph::ValidSwitchs true" << endl; - return true ; + cdebug_out << "GraphBase::Graph::ValidSwitchs RetVal " << RetVal << endl; + return RetVal ; } // Controle de la coherence des noeuds de calcul @@ -2737,6 +2842,10 @@ bool GraphBase::Graph::ComputingNodes() const { // cdebug << "Le port d'entree " << iP->PortName() // << " du noeud de calcul " << aNode->Name() << " du graphe " // << Name() << " n'est pas connecte "<< endl; +// string anErrorMessage = string( "That graph have InPort not connected " ) + +// string( iP->NodeName() ) + +// string( "( " ) + string( iP->PortName() ) + string( " )\n" ) ; +// ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ; RetVal = false ; }; @@ -2754,6 +2863,10 @@ bool GraphBase::Graph::ComputingNodes() const { // cdebug << "Le port de sortie " << iP->PortName() // << " du noeud de calcul " << aNode->Name() << " du graphe " // << Name() << " n'est pas connecte "<< endl; +// string anErrorMessage = string( "That graph have OutPort not connected " ) + +// string( iP->NodeName() ) + +// string( "( " ) + string( iP->PortName() ) + string( " )\n" ) ; +// ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ; RetVal = false ; } }; @@ -3126,15 +3239,20 @@ bool GraphBase::Graph::StartComponent(const int aThread , << " GraphBase::Graph::StartComponent " << aComputerContainer << " " << ComponentName << endl; bool RetVal = true ; - + objComponent = Engines::Component::_nil() ; SALOME_LifeCycleCORBA LCC( NamingService() ) ; - objComponent = LCC.FindOrLoad_Component( aComputerContainer , - ComponentName ); + try { + objComponent = LCC.FindOrLoad_Component( aComputerContainer , + ComponentName ); + } + catch (...) { + RetVal = 0 ; + } if ( CORBA::is_nil( objComponent ) ) { cdebug_out << aThread << " StartComponent cannot FindOrLoad " << aComputerContainer << " " << ComponentName << " ERROR" << endl; - return 0 ; + RetVal = 0 ; } /* asv : 24.01.05 : FindContainer() method does not exist any more. FindOrLoad_Component() starts the container for us. If it fails to start the container, then it @@ -3151,6 +3269,12 @@ bool GraphBase::Graph::StartComponent(const int aThread , } } */ - cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl; + if ( !RetVal ) { + string anErrorMessage = string( "Error while FindOrLoad_Component " ) + + string( ComponentName ) + string( " in Container " ) + + string( aComputerContainer ) ; + SetMessages( anErrorMessage ) ; + } + cdebug_out << aThread << " GraphBase::Graph::StartComponent RetVal " << RetVal << endl; return RetVal ; } diff --git a/src/GraphBase/DataFlowBase_Graph.hxx b/src/GraphBase/DataFlowBase_Graph.hxx index c941f6d..886eb21 100644 --- a/src/GraphBase/DataFlowBase_Graph.hxx +++ b/src/GraphBase/DataFlowBase_Graph.hxx @@ -90,6 +90,8 @@ namespace GraphBase { // int _SubStreamGraphsSize ; // vector > _SubStreamGraphs ; + string _Messages ; + bool AddLink( GraphBase::ComputingNode *fromNode , GraphBase::OutPort *fromPort , GraphBase::ComputingNode *toNode , @@ -168,7 +170,7 @@ namespace GraphBase { << index << " Node " << (void *) _GraphNodes[ index ] << " '" << _GraphNodes[ index ]->Name() << "' MapOfGraphNodessize " << GetGraphNodeSize() << endl ; -#if 0 +#if 1 cdebug << "Graph::SetGraphNodeIndex " << _GraphNodesSize << " known nodes" << endl; int i ; for ( i = 0 ; i < _GraphNodesSize ; i++ ) { @@ -330,6 +332,10 @@ namespace GraphBase { void SetGraphPorts() ; + string Messages() ; + void ReSetMessages() ; + void SetMessages( string anErrorMessage ) ; + bool CreateService() ; bool InLineServices() ; diff --git a/src/GraphBase/DataFlowBase_OutPort.cxx b/src/GraphBase/DataFlowBase_OutPort.cxx index 455c640..0aa4499 100644 --- a/src/GraphBase/DataFlowBase_OutPort.cxx +++ b/src/GraphBase/DataFlowBase_OutPort.cxx @@ -158,7 +158,7 @@ bool GraphBase::OutPort::ReNameInPort( const char* OldNodePortName , const char* NewNodePortName ) { int index = _MapOfInPorts[ OldNodePortName ] ; if ( index <= 0 || index > _InPortsSize ) { - cdebug << "GraphBase::OutPort::ReNameInPort Error " << OldNodePortName + cdebug << "GraphBase::OutPort::ReNameInPort Error in Node " << NodeName() << " " << OldNodePortName << " --> " << NewNodePortName << " index " << index << endl ; return false ; } diff --git a/src/GraphBase/DataFlowBase_SwitchNode.cxx b/src/GraphBase/DataFlowBase_SwitchNode.cxx index ada6a21..4586720 100644 --- a/src/GraphBase/DataFlowBase_SwitchNode.cxx +++ b/src/GraphBase/DataFlowBase_SwitchNode.cxx @@ -82,6 +82,10 @@ bool GraphBase::SwitchNode::CheckSwitch() const { << anEndSwitchNode->Name() << endl; int i ; + string anErrorMessage = string( "SwitchCheck of " ) + string( Name() ) + " --> " + + string( anEndSwitchNode->Name() ) + string( " :\n" ) ; + bool RetVal = true ; + //All nodes between Switch and EndSwitch will have _BranchOfSwitchDone to false //When we have to execute such a node in a switchbranch, if _BranchOfSwitchDone is true we have // an error ; else we set _BranchOfSwitchDone to true @@ -94,7 +98,7 @@ bool GraphBase::SwitchNode::CheckSwitch() const { GraphBase::ComputingNode * aNode ; aNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ; if ( aNode && aNode != anEndSwitchNode ) { - aNode->InitBranchOfSwitchDone( true , anEndSwitchNode ) ; + aNode->InitBranchOfSwitchDone( true , anEndSwitchNode , anErrorMessage ) ; } } } @@ -106,9 +110,13 @@ bool GraphBase::SwitchNode::CheckSwitch() const { GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ; if ( anOutPort->IsSwitch() || anOutPort->IsGate() ) { // We have a branch of the switch + anErrorMessage = anErrorMessage + string( "Branch " ) + string( Name() ) + string( "( " ) + + string( anOutPort->PortName() ) + string( " ) :\n" ) ; cdebug << endl << Name() << "->SwitchNode::CheckSwitch OutPort " << anOutPort->PortName() << " " << anOutPort->PortStatus() << " " << anOutPort->Kind() - << " SWITCHBRANCH" << endl ; + << " SWITCHBRANCH" << endl + << "====================================================================================" + << endl ; //JR 11.02.2005 : if Default is not connected and if Default is true at execution time, the SwitchNode // execution will be aborted @@ -130,17 +138,17 @@ bool GraphBase::SwitchNode::CheckSwitch() const { if ( anOutPort->IsGate() || EndSwitchNode_Default ) { if ( anOutPort->InPortsSize() == 0 ) { // DefaultPort of the SwitchNode is not connected - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " OutPort " << anOutPort->PortName() << " " - << anOutPort->InPortsSize() << " InPortsSize EndSwitch(Default) " - << anEndSwitchNode->GetNodeInGate()->PortStatus() << "WARNING" << endl; + cdebug << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " OutPort " << anOutPort->PortName() << " " + << anOutPort->InPortsSize() << " InPortsSize EndSwitch(Default) " + << anEndSwitchNode->GetNodeInGate()->PortStatus() << "WARNING" << endl; } else { // But the DefaultPort of the EndSwitchNode is connected : so there is a branch going to // that DefaultPort - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " OutPort " << anOutPort->PortName() << " " - << " " << anOutPort->PortStatus() << " " << anOutPort->InPortsSize() << " InPortsSize " + cdebug << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " OutPort " << anOutPort->PortName() << " " + << " " << anOutPort->PortStatus() << " " << anOutPort->InPortsSize() << " InPortsSize " << endl ; DefaultConnected = true ; @@ -151,10 +159,15 @@ bool GraphBase::SwitchNode::CheckSwitch() const { GraphBase::ComputingNode * aNode ; aNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ; if ( aNode != anEndSwitchNode ) { - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " for OutPort " << anOutPort->PortName() - << " linked to " << aNode->Name() << " WARNING false" << endl; - return false ; + anErrorMessage = anErrorMessage + string( Name() ) + "( " + + string( anOutPort->PortName() ) + + string( " ) should not be linked to " ) + + string( aNode->Name() ) + string( "( " ) + + string( anInPort->PortName() ) + string ( " )\n" ) ; + cdebug << "1. " << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " for OutPort " << anOutPort->PortName() + << " linked to " << aNode->Name() << " ERROR false" << endl; + RetVal = false ; } cdebug << endl << Name() << " Check of " << anOutPort->PortName() << " switch port branch" << " to EndSwitchNode" << endl ; @@ -162,37 +175,66 @@ bool GraphBase::SwitchNode::CheckSwitch() const { int k ; for ( k = 0 ; k < GetNodeOutPortsSize() ; k++ ) { GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( k ) ; +//JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ... +// But it is done in EndSwitchNode::CheckEndSwitchInPortsLinked if ( !anOutPort->IsGate() ) { - GraphBase::InPort * anInPort ; + GraphBase::InPort * anInPort = NULL ; +//JR 22.06.2005 : Enhancement of the behaviour : +// For the DefaultBranch, if we have same PortsNames, Values are automatically +// transmitted +// But for the DefaultBranch, if we have NOT same PortsNames, we may create links. +// Look at GraphSyrControlAve* ... + int kk ; +//JR 22.06.2005 : At first look at OutPorts linked to InPorts of the EndSwitchNode with +// different PortsNames : + for ( kk = 0 ; kk < anOutPort->InPortsSize() ; kk++ ) { + anInPort = anOutPort->ChangeInPorts( kk ) ; + if ( GraphOfNode()->GetGraphNode( anInPort->NodeName() ) == anEndSwitchNode ) { + if ( !anEndSwitchNode->GetChangeInPort( anOutPort->PortName() ) ) { + if ( anInPort && !anEndSwitchNode->DecrEndSwitchInPortLinked( anInPort , + anErrorMessage ) ) { + cdebug << "2. " << Name() << "->SwitchNode::CheckSwitch EndSwitchNode : " + << anEndSwitchNode->Name() << " to port " << anInPort->PortName() + << " from port " << Name() << "( " << anOutPort->PortName() + << " ) ERROR false" << endl; + RetVal = false ; + } + } + } + } +//Get an InPort of the EndSwitchNode with the same name as that OutPort of the SwitchNode anInPort = anEndSwitchNode->GetChangeInPort( anOutPort->PortName() ) ; - if ( anInPort && !anEndSwitchNode->DecrEndSwitchInPortLinked( anInPort ) ) { - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " for port " << anInPort->PortName() - << " WARNING false" << endl; - return false ; + if ( anInPort && !anEndSwitchNode->DecrEndSwitchInPortLinked( anInPort , + anErrorMessage ) ) { + cdebug << "3. " << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " for port " << anInPort->PortName() + << " ERROR false" << endl; + RetVal = false ; } else { - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " OutPort " << anOutPort->PortName() - << " " << anOutPort->PortStatus() << " " << anOutPort->Kind() - << " not in EndSwitchNode : IGNORED" - << endl; + cdebug << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " OutPort " << anOutPort->PortName() + << " " << anOutPort->PortStatus() << " " << anOutPort->Kind() + << " not in EndSwitchNode : IGNORED" + << endl; } +//JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ... +// But it is done in EndSwitchNode::CheckEndSwitchInPortsLinked } else { - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " OutPort " << anOutPort->PortName() - << " " << anOutPort->PortStatus() << " " << anOutPort->Kind() - << " SwitchPort or Gate : IGNORED" - << endl; + cdebug << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " OutPort " << anOutPort->PortName() + << " " << anOutPort->PortStatus() << " " << anOutPort->Kind() + << " SwitchPort or Gate : IGNORED" + << endl; } } // Check that all InPorts of the EndSwitchNode have a value : - if ( !anEndSwitchNode->CheckEndSwitchInPortsLinked() ) { - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " " << aNode->Name() - << " WARNING false" << endl; - return false ; + if ( !anEndSwitchNode->CheckEndSwitchInPortsLinked( anErrorMessage ) ) { + cdebug << "4. " << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " " << aNode->Name() + << " ERROR false" << endl; + RetVal = false ; } } } @@ -208,10 +250,12 @@ bool GraphBase::SwitchNode::CheckSwitch() const { GraphBase::ComputingNode * aNode ; aNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ; if ( aNode && aNode != anEndSwitchNode ) { - if ( !aNode->InitBranchOfSwitchDone( false , anEndSwitchNode ) ) { - cdebug << Name() << "->ComputingNode::InitBranchOfSwitchDone WARNING false" + if ( !aNode->InitBranchOfSwitchDone( false , anEndSwitchNode , anErrorMessage ) ) { + anErrorMessage = anErrorMessage + string( Name() ) + + string( " Node(s) are common to two or more branchs of switch.\n" ) ; + cdebug << "5. " << Name() << "->ComputingNode::InitBranchOfSwitchDone ERROR false" << " Node common to two or more branchs of switch" << endl ; - return false ; + RetVal = false ; } } } @@ -221,57 +265,102 @@ bool GraphBase::SwitchNode::CheckSwitch() const { // At first all of not SwitchPort should have to be done also : // Not Switch Branches (Gate not connected to a switch port of a SwitchNode) : // They are always executed except if we execute the DefaultBranch ... - cdebug << "1. " << Name() << "->SwitchNode::CheckSwitch at first NOT_SWITCH_BRANCH_OUTPORT FOR " - << anOutPort->PortName() - << " " << anOutPort->PortStatus() << " " << anOutPort->Kind() << endl ; + + cdebug << "1. " << Name() << "->SwitchNode::CheckSwitch at first NOTSWITCHBRANCH_OUTPORT FOR " + << anOutPort->PortName() << " " << anOutPort->PortStatus() << " " << anOutPort->Kind() + << " :" << endl ; for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) { GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( j ) ; + cdebug << Name() << "->SwitchNode::CheckSwitch for OutPort" << j << " " + << anOutPort->PortName() << " " << anOutPort->PortStatus() << " " << anOutPort->Kind() + << " InPortsSize " << anOutPort->InPortsSize() << endl ; if ( !anOutPort->IsSwitch() && !anOutPort->IsGate() ) { - int k ; - for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) { - GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ; - GraphBase::ComputingNode * aNode ; - aNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ; - if ( aNode ) { - const GraphBase::InPort * anInGatePort = aNode->GetNodeInGate() ; - cdebug << Name() << "->SwitchNode::CheckSwitch InPort" << k << ". " - << anInPort->PortName() << " of " << aNode->Name() << " :" << endl ; +//JR 23.06.2005 : implicit connection with same PortsNames was missing in SwitchNodeBranches : + if ( anOutPort->IsExternConnected() ) { + GraphBase::InPort * anInPort ; + anInPort = anEndSwitchNode->GetChangeInPort( anOutPort->PortName() ) ; + if ( anInPort ) { + anErrorMessage = anErrorMessage + string( "Implicit NotSwitchBranch " ) + + string( Name() ) + string( "( " ) + string( anOutPort->PortName() ) + + string( " ) --> " ) + string( anEndSwitchNode->Name() ) + + string( "( " ) + string( anInPort->PortName() ) + string( " ).\n" ) ; + if ( !anEndSwitchNode->DecrEndSwitchInPortLinked( anInPort , + anErrorMessage ) ) { + cdebug << "6. " << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " for port " << anInPort->PortName() + << " ERROR false" << endl; + RetVal = false ; + } + cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" + << anOutPort->PortName() << "' " << anOutPort->Kind() + << " NOT switch port Branch to EndSwitchNode " + << anEndSwitchNode->Name() << " is done" << endl ; + } + else { + cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" + << anOutPort->PortName() << "' " << anOutPort->Kind() + << " NOT switch port does not exist in EndSwitchNode. Ignoed " << endl ; + } + } + else { + int k ; + for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) { + GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ; + GraphBase::ComputingNode * aNode ; + aNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ; + if ( aNode ) { + const GraphBase::InPort * anInGatePort = aNode->GetNodeInGate() ; + cdebug << Name() << "->SwitchNode::CheckSwitch InPort" << k << ". " + << anInPort->PortName() << " of " << aNode->Name() << " :" << endl ; // Direct Connexion to the EndSwitchNode : always executed (except for DefaultBranch) - if ( aNode == anEndSwitchNode ) { - if ( !anEndSwitchNode->DecrEndSwitchInPortLinked( anInPort ) ) { - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " for port " << anInPort->PortName() - << " WARNING false" << endl; - return false ; - } - cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" - << anOutPort->PortName() << "' " << anOutPort->Kind() - << " NOT switch port Branch to EndSwitchNode " - << aNode->Name() << " is done" << endl ; - } + if ( aNode == anEndSwitchNode ) { + anErrorMessage = anErrorMessage + string( "NotSwitchBranch " ) + string( Name() ) + + string( "( " ) + string( anOutPort->PortName() ) + + string( " ) --> " ) + string( aNode->Name() ) + + string( "( " ) + string( anInPort->PortName() ) + + string( " ).\n" ) ; + if ( !anEndSwitchNode->DecrEndSwitchInPortLinked( anInPort , + anErrorMessage ) ) { + cdebug << "7. " << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " for port " << anInPort->PortName() + << " ERROR false" << endl; + RetVal = false ; + } + cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" + << anOutPort->PortName() << "' " << anOutPort->Kind() + << " NOT switch port Branch to EndSwitchNode " + << aNode->Name() << " is done" << endl ; + } // Check that InGate is not linked from a SwitchPort or a GatePort of the SwitchNode : - else if ( !anInGatePort->GetOutPort() ) { - cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" - << anOutPort->PortName() << "' " << anOutPort->Kind() - << " NOT switch port Branch to node " - << aNode->Name() << " will be done" << endl ; - if ( !aNode->CheckSwitch( anEndSwitchNode ) ) { - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " " << aNode->Name() - << " WARNING false" << endl; - return false ; + else if ( !anInGatePort->GetOutPort() ) { + cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" + << anOutPort->PortName() << "' " << anOutPort->Kind() + << " NOT switch port Branch to node " + << aNode->Name() << " will be done" << endl ; + anErrorMessage = anErrorMessage + string( "NotSwitchBranch " ) + string( Name() ) + + string( "( " ) + string( anOutPort->PortName() ) + + string( " ) --> " ) + string( aNode->Name() ) + + string( "( " ) + string( anInPort->PortName() ) + + string( " ).\n" ) ; + if ( !aNode->CheckSwitch( anEndSwitchNode , anErrorMessage ) ) { + cdebug << "8. " << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " " << aNode->Name() + << " ERROR false" << endl; + RetVal = false ; + } + cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" + << anOutPort->PortName() << "' " << anOutPort->Kind() + << " NOT switch port Branch to node " + << aNode->Name() << " is done" << endl ; } - cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" - << anOutPort->PortName() << "' " << anOutPort->Kind() - << " NOT switch port Branch to node " - << aNode->Name() << " is done" << endl ; + else { + cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" + << anOutPort->PortName() << "' " << anOutPort->Kind() + << " NOT switch port Branch to node " + << aNode->Name() << " has InGate connected IGNORED for that branch" + << endl ; + } } - else { - cdebug << Name() << "->SwitchNode::CheckSwitch Check of '" - << anOutPort->PortName() << "' " << anOutPort->Kind() - << " NOT switch port Branch to node " - << aNode->Name() << " has InGate connected IGNORED for that branch" << endl ; - } } } } @@ -298,20 +387,20 @@ bool GraphBase::SwitchNode::CheckSwitch() const { cdebug << Name() << " Check of " << anOutPort->PortName() << " switch port Branch to node " << aNode->Name() << endl ; - if ( !aNode->CheckSwitch( anEndSwitchNode ) ) { - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " " << aNode->Name() << " WARNING false" - << endl; - return false ; + if ( !aNode->CheckSwitch( anEndSwitchNode , anErrorMessage ) ) { + cdebug << "9. " << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " " << aNode->Name() << " ERROR false" + << endl; + RetVal = false ; } } } // Check that all InPorts of the EndSwitchNode have a value : - if ( !anEndSwitchNode->CheckEndSwitchInPortsLinked() ) { - cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " CheckEndSwitchInPortsLinked WARNING false" - << endl; - return false ; + if ( !anEndSwitchNode->CheckEndSwitchInPortsLinked( anErrorMessage ) ) { + cdebug << "10. " << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " + << anEndSwitchNode->Name() << " CheckEndSwitchInPortsLinked ERROR false" + << endl; + RetVal = false ; } else { cdebug << Name() << "->SwitchNode::CheckSwitch OutPort " << anOutPort->PortName() @@ -326,8 +415,13 @@ bool GraphBase::SwitchNode::CheckSwitch() const { << " IGNORED" << endl ; } } + + if ( !RetVal ) { + GraphOfNode()->SetMessages( anErrorMessage ) ; + } + cdebug_out << Name() << "->SwitchNode::CheckSwitch EndSwitchNode " - << anEndSwitchNode->Name() << " true" << endl; - return true ; + << anEndSwitchNode->Name() << " RetVal " << RetVal << endl; + return RetVal ; } diff --git a/src/GraphBase/DataFlowBase_XmlHandler.cxx b/src/GraphBase/DataFlowBase_XmlHandler.cxx index 068dc83..a6e6a91 100644 --- a/src/GraphBase/DataFlowBase_XmlHandler.cxx +++ b/src/GraphBase/DataFlowBase_XmlHandler.cxx @@ -759,8 +759,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, if ( fieldvalue[depth] == NULLSTRING ) return returnfalse( this , "depth4-4" , qName ) ; if ( !strcmp( fieldvalue[depth].c_str() , "?" ) ) { -// aLink.aLinkValue.Value = fieldvalue[depth].c_str() ; - aLink.aLinkValue = CORBA::Any() ; // ??? + aLink.aLinkValue <<= "" ; } else { switch ( aLink.aLinkValue.type()->kind() ) { @@ -971,7 +970,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, fieldvalue[depth] = NULLSTRING ; #if TRACE //cout << "InDataStreamParameter.inParameter-dependency " << anInDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]" - << step[depth] << endl ; + // << step[depth] << endl ; #endif // step[depth]++ ; // step[depth] = 4 ; @@ -984,7 +983,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, fieldvalue[depth] = NULLSTRING ; #if TRACE //cout << "InDataStreamParameter.inParameter-schema " << anInDataStreamParameter.theKindOfSchema << " step[" << depth << "]" - << step[depth] << endl ; + // << step[depth] << endl ; #endif // step[depth]++ ; // step[depth] = 4 ; @@ -997,7 +996,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, fieldvalue[depth] = NULLSTRING ; #if TRACE //cout << "InDataStreamParameter.inParameter-interpolation " << anInDataStreamParameter.theKindOfInterpolation << " step[" << depth << "]" - << step[depth] << endl ; + // << step[depth] << endl ; #endif // step[depth]++ ; // step[depth] = 4 ; @@ -1012,7 +1011,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, step[depth] = 4 ; #if TRACE //cout << "InDataStreamParameter.inParameter-extrapolation " << anInDataStreamParameter.theKindOfExtrapolation << " step[" << depth << "]" - << step[depth] << endl ; + // << step[depth] << endl ; #endif break ; } @@ -1029,7 +1028,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, step[depth] = 7 ; #if TRACE //cout << "OutDataStreamParameter.outParameter-type " << anOutDataStreamParameter.theDataStreamParameter.Parametertype << " step[" << depth << "]" - << step[depth] << endl ; + // << step[depth] << endl ; #endif } else @@ -1048,7 +1047,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, fieldvalue[depth] = NULLSTRING ; #if TRACE //cout << "OutDataStreamParameter.outParameter-name " << anOutDataStreamParameter.theDataStreamParameter.Parametername << " step[" << depth << "]" - << step[depth] << endl ; + // << step[depth] << endl ; #endif // step[depth]++ ; // step[depth] = 6 ; @@ -1060,7 +1059,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, fieldvalue[depth] = NULLSTRING ; #if TRACE //cout << "OutDataStreamParameter.outParameter-dependency " << anOutDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]" - << step[depth] << endl ; + // << step[depth] << endl ; #endif // step[depth]++ ; // step[depth] = 6 ; @@ -1074,7 +1073,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, step[depth] = 6 ; #if TRACE //cout << "OutDataStreamParameter.outParameter-values " << anOutDataStreamParameter.theNumberOfValues << " step[" << depth << "]" - << step[depth] << endl ; + // << step[depth] << endl ; #endif } else diff --git a/src/GraphEditor/DataFlowEditor_DataFlow.hxx b/src/GraphEditor/DataFlowEditor_DataFlow.hxx index b2931a7..bbe2312 100644 --- a/src/GraphEditor/DataFlowEditor_DataFlow.hxx +++ b/src/GraphEditor/DataFlowEditor_DataFlow.hxx @@ -212,7 +212,8 @@ namespace GraphEditor { const CORBA::Any GetOutData( const char * FromNodeName , const char * FromParameterName ) ; - bool IsValid(bool kLoopSwitch = true ) ; +// bool IsValid(bool kLoopSwitch = true ) ; + bool IsValid() ; bool IsExecutable() ; void Executing() ; // asv : removed a bool parameter, use Editing() to set _Executing = false diff --git a/src/GraphEditor/DataFlowEditor_DataFlow.lxx b/src/GraphEditor/DataFlowEditor_DataFlow.lxx index d69cc14..d73dd00 100644 --- a/src/GraphEditor/DataFlowEditor_DataFlow.lxx +++ b/src/GraphEditor/DataFlowEditor_DataFlow.lxx @@ -33,6 +33,8 @@ inline void GraphEditor::DataFlow::ReadOnly() { _ReadOnly = true ; } +//JR 07.07.2005 : old code from the first prototype +#if 0 inline char * GraphEditor::DataFlow::DataFlowInfo() { ostringstream s; IsValid() ; @@ -56,6 +58,7 @@ inline char * GraphEditor::DataFlow::NodeInfo( const char * aNodeName ) { s << aNodeName << " not found" << ends ; return CORBA::string_dup( s.str().c_str() ); } +#endif inline bool GraphEditor::DataFlow::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) { if ( _ReadOnly ) @@ -424,8 +427,10 @@ inline const CORBA::Any GraphEditor::DataFlow::GetOutData( //JR Optional parameter kLoopSwitch (default = true) : //In some cases we do not need to check the validity of loops and switchs -inline bool GraphEditor::DataFlow::IsValid(bool kLoopSwitch ) { - return GraphEditor::OutNode::IsValid( kLoopSwitch ) ; +//inline bool GraphEditor::DataFlow::IsValid(bool kLoopSwitch ) { +inline bool GraphEditor::DataFlow::IsValid() { +// return GraphEditor::OutNode::IsValid( kLoopSwitch ) ; + return GraphEditor::OutNode::IsValid() ; } inline bool GraphEditor::DataFlow::IsExecutable() { @@ -470,35 +475,40 @@ inline bool GraphEditor::DataFlow::IsReadOnly() { } inline long GraphEditor::DataFlow::LevelMax() { - if ( !IsValid( false ) ) { +// if ( !IsValid( false ) ) { + if ( !IsExecutable() ) { return 0 ; } return Graph()->LevelMax() ; } inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) { - if ( !IsValid( false ) ) { +// if ( !IsValid( false ) ) { + if ( !IsExecutable() ) { return ((SUPERV::ListOfStrings * ) NULL ) ; } return Graph()->LevelNodes( aLevel ) ; } inline long GraphEditor::DataFlow::ThreadsMax() { - if ( !IsValid() ) { +// if ( !IsValid() ) { + if ( !IsExecutable() ) { return 0 ; } return Graph()->ThreadsMax() ; } inline long GraphEditor::DataFlow::SubGraphsNumber() { - if ( !IsValid() ) { +// if ( !IsValid() ) { + if ( !IsExecutable() ) { return 0 ; } return Graph()->SubGraphsNumber() ; } inline long GraphEditor::DataFlow::SubStreamGraphsNumber() { - if ( !IsValid() ) { +// if ( !IsValid() ) { + if ( !IsExecutable() ) { return 0 ; } return StreamGraph()->SubStreamGraphsNumber() ; diff --git a/src/GraphEditor/DataFlowEditor_OutNode.cxx b/src/GraphEditor/DataFlowEditor_OutNode.cxx index 49890ac..9c02f21 100644 --- a/src/GraphEditor/DataFlowEditor_OutNode.cxx +++ b/src/GraphEditor/DataFlowEditor_OutNode.cxx @@ -207,7 +207,7 @@ bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) { RetVal = LoadDatas( aMapOfNodes , (*aDataFlow).Datas ) ; } cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize() - << " RetVal " << RetVal << endl; + << " _Valid " << _Valid << " _Executable " << _Executable << " RetVal " << RetVal << endl; return RetVal ; } @@ -953,16 +953,19 @@ bool GraphEditor::OutNode::UnValid() { //JR Optional parameter kLoopSwitch (default = true) : //In some cases we do not need to check the validity of loops and switchs -bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) { - if ( _Valid ) - return true ; - +//JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method +//bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) { +bool GraphEditor::OutNode::Valid() { + bool RetVal = true ; cdebug_in << "GraphEditor::OutNode::Valid" << endl; +// if ( _Valid ) +// return true ; + _Executable = false ; if ( !Graph()->CreateService() ) { - cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl; - return false ; + cdebug << "GraphEditor::OutNode::Valid ERROR _Valid " << _Valid << endl; + RetVal = false ; } if ( Graph()->GraphMacroLevel() != 0 ) { @@ -980,10 +983,12 @@ bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) { Graph()->CoupledNode()->GraphEditor()->UnValid() ; } +//JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method +#if 0 int SubStreamGraphsNumber = 0 ; if ( !Graph()->Sort( SubStreamGraphsNumber ) ) { cdebug_out << "This DataFlow is not valid." << endl ; - return false ; + RetVal = false ; } if ( Graph()->IsDataStreamNode() ) { StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ; @@ -994,50 +999,79 @@ bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) { if ( kLoopSwitch ) { if ( !Graph()->ValidLoops() ) { cdebug_out << "This DataFlow have not valid Loops." << endl ; - return false ; + RetVal = false ; } if ( !Graph()->ValidSwitchs() ) { cdebug_out << "This DataFlow have not valid Switchs." << endl ; - return false ; + RetVal = false ; } } -// CreateService() ; - Graph()->ComputingNodes() ; +#endif - if ( kLoopSwitch ) { + if ( RetVal ) { _Valid = true ; } - cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl; - return true ; + cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << " RetVal " << RetVal << endl; + return RetVal ; } bool GraphEditor::OutNode::Executable() { cdebug_in << "GraphEditor::OutNode::Executable" << endl; + bool RetVal = true ; bool NewLink ; // LinkLoopNodes manage input values of LoopNodes and EndLoopNodes if ( Graph()->LinkLoopNodes( NewLink ) ) { if ( NewLink ) { _Valid = false ; + RetVal = false ; } } else { - cdebug << "This DataFlow is not executable." << endl ; + cdebug << "Editor::OutNode::Executable This DataFlow is not executable(LinkLoopNodes)." << endl ; _Executable = false ; + RetVal = false ; } if ( !IsValid() ) { Valid() ; } if ( !IsValid() ) { - return false ; + RetVal = false ; + } + +//JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method + int SubStreamGraphsNumber = 0 ; + if ( !Graph()->Sort( SubStreamGraphsNumber ) ) { + cdebug << "Editor::OutNode::Executable This DataFlow is not valid(Sort)." << endl ; + RetVal = false ; + } + if ( Graph()->IsDataStreamNode() ) { + StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ; } + + Graph()->InLineServices() ; + +// if ( kLoopSwitch ) { + if ( !Graph()->ValidLoops() ) { + cdebug << "Editor::OutNode::Executable This DataFlow have not valid Loops(ValidLoops)." << endl ; + RetVal = false ; + } + if ( !Graph()->ValidSwitchs() ) { + cdebug << "Editor::OutNode::Executable This DataFlow have not valid Switchs(ValidSwitchs)." << endl ; + RetVal = false ; + } +// } + + Graph()->ComputingNodes() ; + if ( Graph()->DataServerNodes() ) _Executable = true ; else { - cdebug << "This DataFlow is not executable." << endl ; + cdebug << "Editor::OutNode::Executable This DataFlow is not executable(DataServerNodes)." << endl ; _Executable = false ; + RetVal = false ; } if ( _Executable && Graph()->IsDataStreamNode() ) { @@ -1047,10 +1081,12 @@ bool GraphEditor::OutNode::Executable() { // asv : 13.12.04 : introducing check for compatibility of linked ports' types. if ( !IsLinksCompatible() ) { _Executable = false; + RetVal = false ; } - cdebug_out << "GraphEditor::OutNode::Executable " << _Executable << endl; - return _Executable ; + cdebug_out << "GraphEditor::OutNode::Executable _Executable " << _Executable << " RetVal " << RetVal + << endl; + return RetVal ; } //JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetInData( @@ -1146,12 +1182,23 @@ bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & lin // f << Tabs << " " << retstr << "" << endl ; QDomElement value = Graph.createElement( "value" ) ; //PAL9133 Debug JR : accept void strings - QDomCDATASection aCDATA = Graph.createCDATASection( retstr ) ; + QDomCDATASection aCDATA ; + int i ; + for ( i = 0 ; i < (int ) strlen( retstr ) ; i++ ) { + if ( retstr[ i ] != ' ' ) { + break ; + } + } + if ( i == (int ) strlen( retstr ) ) { + aCDATA = Graph.createCDATASection( "?" ) ; + } + else { + aCDATA = Graph.createCDATASection( retstr ) ; + } // aField = Graph.createTextNode( retstr ) ; - aField = Graph.createCDATASection( retstr ) ; - datavalue.appendChild( aCDATA ) ; + datavalue.appendChild( value ) ; // datavalue.appendChild( value ) ; - value.appendChild( aField ) ; + value.appendChild( aCDATA ) ; // MESSAGE( "ToString( string ) " << retstr ); break ; } @@ -1728,23 +1775,45 @@ bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) { * Returns true if all are compatible. */ bool GraphEditor::OutNode::IsLinksCompatible() { + cdebug_in << "Editor::OutNode::IsLinksCompatible()" << endl ; + bool RetVal = true; + bool b ; const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ; - bool b = true; - for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) { + cdebug_in << "Editor::OutNode::IsLinksCompatible() " << Links->size() << " Links" << endl ; +// for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) { + for ( int i = 0 ; i < (int ) Links->size() ; i++ ) { GraphBase::SLink aLink = (*Links)[i]; GraphBase::ComputingNode* anOutNode = Graph()->GetChangeGraphNode( aLink.FromNodeName.c_str() ); GraphBase::ComputingNode* anInNode = Graph()->GetChangeGraphNode( aLink.ToNodeName.c_str() ); const GraphBase::OutPort* anOutPort = anOutNode->GetOutPort( aLink.FromServiceParameterName.c_str() ); const GraphBase::InPort* anInPort = anInNode->GetInPort( aLink.ToServiceParameterName.c_str() ); b = IsCompatible( anOutPort->PortType(), anInPort->PortType() ); - cdebug << "GraphEditor::OutNode::IsLinksCompatible: "< "<PortType() + << " ) --> " << aLink.ToNodeName <<"( " << aLink.ToServiceParameterName << " " + << anInPort->PortType() << " ) = " << (b ? "OK" : "Not compatible (ERROR)") << endl; + if ( !b ) { + RetVal = false ; + MESSAGE( "Graph structure ERROR: type of port \"" << aLink.FromServiceParameterName + << "\" of node \"" << aLink.FromNodeName + << "\" is not compatible with type of linked port \"" + << aLink.ToServiceParameterName << "\" of node \"" << aLink.ToNodeName<<"\"" ) ; + ostringstream aTypeOutPortstr ; + aTypeOutPortstr << anOutPort->PortType() ; + ostringstream aTypeInPortstr ; + aTypeInPortstr << anInPort->PortType() ; + string anErrorMessage = string( "PortTypes of " ) + string( aLink.FromNodeName ) + + string( "( " ) + aLink.FromServiceParameterName + + string( " ) " ) + aTypeOutPortstr.str() + string( " and " ) + + string( aLink.ToNodeName ) + string( "( " ) + + string( aLink.ToServiceParameterName ) + + string( " ) " ) + aTypeInPortstr.str() + + string( " are not compatibles.\n" ) ; + Graph()->SetMessages( anErrorMessage ) ; + } + } + cdebug_out << "Editor::OutNode::IsLinksCompatible() RetVal " << RetVal << endl ; + return RetVal ; } static const char* gSimpleTypes[] = diff --git a/src/GraphEditor/DataFlowEditor_OutNode.hxx b/src/GraphEditor/DataFlowEditor_OutNode.hxx index cf560f0..ab2af30 100644 --- a/src/GraphEditor/DataFlowEditor_OutNode.hxx +++ b/src/GraphEditor/DataFlowEditor_OutNode.hxx @@ -50,7 +50,8 @@ namespace GraphEditor { CORBA::ORB_ptr _Orb; - bool Valid(bool kLoopSwitch = true ) ; +// bool Valid(bool kLoopSwitch = true ) ; + bool Valid() ; bool Executable() ; bool LoadNodes( map< string , int > & aMapOfNodes , @@ -278,15 +279,19 @@ namespace GraphEditor { const int index , long &X , long &Y ) ; - bool IsValid(bool kLoopSwitch = true ) { +// bool IsValid(bool kLoopSwitch = true ) { + bool IsValid( ) { if ( !_Valid ) - Valid( kLoopSwitch ) ; +// Valid( kLoopSwitch ) ; + Valid() ; return _Valid ; } ; bool IsNotValid() const { return !_Valid ; } ; bool UnValid() ; bool IsExecutable() { + cdebug_in << "Editor::OutNode::IsExecutable() " << " _Valid " << _Valid + << " _Executable " << _Executable << endl; if ( !_Valid ) Valid() ; if ( _Valid ) { @@ -295,6 +300,8 @@ namespace GraphEditor { } else _Executable = false ; + cdebug_out << "Editor::OutNode::IsExecutable() " << " _Valid " << _Valid + << " _Executable " << _Executable << endl ; return _Executable ; } ; bool IsNotExecutable() const { return !_Executable ; } ; diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx index 5b79d6b..76a22d5 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx @@ -229,7 +229,8 @@ GraphExecutor::FiniteStateMachine::FiniteStateMachine() { _ActionName[ Executing_StopAction ] = "Executing_StopAction" ; _ActionName[ Executing_SuccessAction ] = "Executing_SuccessAction" ; - _ActionName[ Executing_ErrorAction ] = "Executing_ErrorAction" ; +// _ActionName[ Executing_ErrorAction ] = "Executing_ErrorAction" ; + _ActionName[ Errored_ExecutingAction ] = "Errored_ExecutingAction" ; _ActionName[ Successed_SuccessAction ] = "Successed_SuccessAction" ; _ActionName[ Errored_ErrorAction ] = "Errored_ErrorAction" ; @@ -358,13 +359,16 @@ GraphExecutor::FiniteStateMachine::FiniteStateMachine() { //JR 24.03.2005 : Debug for PAL8176 : abort of GOTONode // ErrorEvent _TransitionTable[ SuccessedState ][ ErrorEvent ] = ErroredExecutingState ; - _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction; +// _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction; + _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Errored_ExecutingAction; // ErrorEvent _TransitionTable[ ExecutingState ][ ErrorEvent ] = ErroredExecutingState ; - _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction; +// _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction; + _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Errored_ExecutingAction; // SuspendedExecutingState : NO ResumeEvent 13-03-2003 _TransitionTable[ SuspendedExecutingState ][ ErrorEvent ] = ErroredExecutingState ; - _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction; +// _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction; + _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Errored_ExecutingAction; // DONE-CONTROL : // SuccessedExecutingState - SuccessEvent diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx index d79e0e4..12c71e7 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx @@ -144,7 +144,8 @@ namespace GraphExecutor { Executing_KillAction , Executing_StopAction , Executing_SuccessAction , - Executing_ErrorAction , +// Executing_ErrorAction , + Errored_ExecutingAction , Successed_SuccessAction , Errored_ErrorAction , Successed_SuspendAction , diff --git a/src/GraphExecutor/DataFlowExecutor_InNode.cxx b/src/GraphExecutor/DataFlowExecutor_InNode.cxx index 70aa2eb..8788224 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNode.cxx @@ -1371,7 +1371,9 @@ void GraphExecutor::InNode::InitialState() GetChangeNodeOutPort(i)->PortState( SUPERV::ReadyState ) ; GetChangeNodeOutPort(i)->PortDone( true ) ; } - else if ( i != 0 || !IsGOTONode() ) { +//JR Debug 01.07.2005 : +// else if ( i != 0 || !IsGOTONode() ) { + else { GetChangeNodeOutPort(i)->PortState( SUPERV::WaitingState ) ; GetChangeNodeOutPort(i)->PortDone( false ) ; } @@ -1379,7 +1381,8 @@ void GraphExecutor::InNode::InitialState() int InPortsCount = GetNodeInPortsSize() ; for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { - const GraphBase::InPort * anInPort = GetNodeInPort(i) ; + GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ; + anInPort->PortState( SUPERV::WaitingState ) ; GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; if ( IsHeadNode() && IsLoopNode() && anInPort->IsLoop() ) { anOutPort->PortStatus( DataConnected ); @@ -1517,67 +1520,105 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) { cdebug_in << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " WithErr " << WithErr << " PyFuncRunned() " << PyFuncRunned() << endl; bool Err = false ; + bool OneErr ; if ( !PyFuncRunned() && IsOneOfInLineNodes() ) { if ( IsLoopNode() ) { PyObject * PyRunMethod = InLineNode()->PyRunMethod() ; PyObject * PyMoreMethod = NULL ; PyObject * PyNextMethod = NULL ; if ( PyRunMethod ) { + OneErr = false ; } else { PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() , InLineNode()->PythonFunction() , - Err ) ; + OneErr ) ; InLineNode()->PyRunMethod( PyRunMethod ) ; } - if ( !Err ) { - PyMoreMethod = LoopNode()->PyMoreMethod() ; - if ( PyMoreMethod ) { - } - else { - PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() , - LoopNode()->MorePythonFunction() , - Err ) ; - LoopNode()->PyMoreMethod( PyMoreMethod ) ; - } + Err = Err || OneErr ; + if ( OneErr && WithErr ) { + string anErrorMessage = string( "Error while declaring the Python function " ) + + string( LoopNode()->PyFuncName() ) + string( " in Node " ) + + string( Name() ) ; + _OutNode->Graph()->SetMessages( anErrorMessage ) ; } - if ( !Err ) { - PyNextMethod = LoopNode()->PyNextMethod() ; - if ( PyNextMethod ) { - } - else { - PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() , - LoopNode()->NextPythonFunction() , - Err ) ; - LoopNode()->PyNextMethod( PyNextMethod ) ; - } + PyMoreMethod = LoopNode()->PyMoreMethod() ; + if ( PyMoreMethod ) { + OneErr = false ; + } + else { + PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() , + LoopNode()->MorePythonFunction() , + OneErr ) ; + LoopNode()->PyMoreMethod( PyMoreMethod ) ; + } + Err = Err || OneErr ; + if ( OneErr && WithErr ) { + string anErrorMessage = string( "Error while declaring the Python function " ) + + string( LoopNode()->PyMoreName() ) + string( " in Node " ) + + string( Name() ) ; + _OutNode->Graph()->SetMessages( anErrorMessage ) ; + } + PyNextMethod = LoopNode()->PyNextMethod() ; + if ( PyNextMethod ) { + OneErr = false ; + } + else { + PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() , + LoopNode()->NextPythonFunction() , + OneErr ) ; + LoopNode()->PyNextMethod( PyNextMethod ) ; + } + Err = Err || OneErr ; + if ( OneErr && WithErr ) { + string anErrorMessage = string( "Error while declaring the Python function " ) + + string( LoopNode()->PyNextName() ) + string( " in Node " ) + + string( Name() ) ; + _OutNode->Graph()->SetMessages( anErrorMessage ) ; } - cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod(Init) " << PyRunMethod - << " PyMoreMethod " << PyMoreMethod << " PyNextMethod " << PyNextMethod << endl; + cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod(Init) " + << PyRunMethod << " PyMoreMethod " << PyMoreMethod << " PyNextMethod " << PyNextMethod + << endl; } else if ( IsInLineNode() || IsSwitchNode() ) { PyObject * PyRunMethod = InLineNode()->PyRunMethod() ; if ( PyRunMethod ) { + OneErr = false ; } else { PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() , InLineNode()->PythonFunction() , - Err ) ; + OneErr ) ; InLineNode()->PyRunMethod( PyRunMethod ) ; } + Err = Err || OneErr ; + if ( OneErr && WithErr ) { + string anErrorMessage = string( "Error while declaring the Python function " ) + + string( InLineNode()->PyFuncName() ) + string( " in Node " ) + + string( Name() ) ; + _OutNode->Graph()->SetMessages( anErrorMessage ) ; + } cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl; } else if ( ( IsEndLoopNode() || IsEndSwitchNode() || IsGOTONode() ) && (*InLineNode()->PythonFunction()).length() ) { PyObject * PyRunMethod = InLineNode()->PyRunMethod() ; if ( PyRunMethod ) { + OneErr = false ; } else { PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() , InLineNode()->PythonFunction() , - Err ) ; + OneErr ) ; InLineNode()->PyRunMethod( PyRunMethod ) ; } + Err = Err || OneErr ; + if ( OneErr && WithErr ) { + string anErrorMessage = string( "Error while declaring the Python function " ) + + string( InLineNode()->PyFuncName() ) + string( " in Node " ) + + string( Name() ) ; + _OutNode->Graph()->SetMessages( anErrorMessage ) ; + } cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl; } } diff --git a/src/GraphExecutor/DataFlowExecutor_InNode.hxx b/src/GraphExecutor/DataFlowExecutor_InNode.hxx index 3986ceb..bd5af50 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_InNode.hxx @@ -462,7 +462,8 @@ namespace GraphExecutor { int Executing_KillAction() ; int Executing_StopAction() ; int Executing_SuccessAction() ; - int Executing_ErrorAction() ; +// int Executing_ErrorAction() ; + int Errored_ExecutingAction() ; int Successed_SuccessAction() ; bool SendSomeDataReady( char * FromNodeName ) ; int Errored_ErrorAction() ; @@ -487,6 +488,8 @@ namespace GraphExecutor { bool OutParametersSet( bool Err , SUPERV::GraphState PortState , int nOutParams , ServicesAnyData * OutParametersList ) ; + void SetOutPortsOfInportsOfEndSwitch( GraphBase::OutPort * anOutPort , + const char * anEndSwitchNodeName ) ; void coutbegin() ; void coutexit() ; diff --git a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx index 75e7d77..b69a61a 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx @@ -70,7 +70,7 @@ static void UpperCase(std::string& rstr) #endif } -#define SendEventTrace 1 +#define SendEventTrace 0 int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) { _CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ; @@ -120,7 +120,16 @@ int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) { << " _RewindStack " << _RewindStack << endl ; #endif - int sts = executeAction() ; + int sts = true ; + if ( _OutNode->IsNodeAborted() ) { +#if SendEventTrace + cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name() + << " will exit : a node was aborted ..." << endl ; +#endif + } + else { + sts = executeAction() ; + } #if SendEventTrace cdebug_out << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name() @@ -133,7 +142,7 @@ int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) { } -#define ActionsTrace 1 +#define ActionsTrace 0 // ReadyAction - RunningAction - DoneAction - SuspendedAction : // for StateWait( ReadyW - RunningW - DoneW - SuspendedW ) void GraphExecutor::InNode::ReadyAction() { @@ -783,8 +792,8 @@ int GraphExecutor::InNode::ExecuteAction() { sts = Executing_SuccessAction() ; break ; } - case GraphExecutor::Executing_ErrorAction : { - sts = Executing_ErrorAction() ; + case GraphExecutor::Errored_ExecutingAction : { + sts = Errored_ExecutingAction() ; break ; } case GraphExecutor::Successed_SuccessAction : { @@ -868,7 +877,7 @@ int GraphExecutor::InNode::VoidAction() { return 1; } -#define SomeDataReadyActionTrace 1 +#define SomeDataReadyActionTrace 0 int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { #if SomeDataReadyActionTrace cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name() @@ -906,7 +915,7 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { } } else { -//JR 20.04.2005 : SomeDataReady is FROM the SwitchNode +//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 @@ -934,6 +943,11 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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 ; + } } } @@ -946,17 +960,34 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ; GraphBase::OutPort * anOutPort ; if ( SwitchDefault && !anInPort->IsDataStream() ) { -//Set the field OutPort of that InPort of the EndSwitchNode to the corresponding OutPort +//Get or Set the field OutPort of that InPort of the EndSwitchNode to the corresponding OutPort // of the SwitchNode - anOutPort = CoupledNode()->GetChangeOutPort( anInPort->PortName() ) ; + anOutPort = anInPort->GetOutPort() ; + 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 ; + cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " + << anInPort->PortName() << " already setted to OutPort " << anOutPort->NodeName() + << "( " << anOutPort->PortName() << " )" << endl ; #endif - anInPort->ChangeOutPort( anOutPort ) ; + } + 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() ; @@ -984,7 +1015,7 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { } // 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 ; @@ -1199,7 +1230,7 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { } -#define TraceDataReadyAction 1 +#define TraceDataReadyAction 0 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() { //JR 15.04.2005 Debug PAL8624 RetroConception : // CreateNewThreadIf( false ) ; @@ -1323,7 +1354,7 @@ int GraphExecutor::InNode::DataReady_StopAction() { #include -#define TraceDataReady_ExecuteAction 1 +#define TraceDataReady_ExecuteAction 0 int GraphExecutor::InNode::DataReady_ExecuteAction() { #if TraceDataReady_ExecuteAction @@ -1484,9 +1515,13 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { InLineNode()->PyFuncName() , &InParametersList[1] , ServiceInParameter().length() , &OutParametersList[1] , ServiceOutParameter().length() ) ; - if ( !StsPyDynInvoke ) { - RemovePyDynInvoke( InLineNode()->PyFuncName() ) ; - } + 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 { @@ -1513,6 +1548,10 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { &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 ; @@ -1622,6 +1661,10 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { &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() ) ; } } @@ -1654,6 +1697,10 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { &InParametersList[0] , ServiceInParameter().length() , &OutParametersList[0] , 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() ) ; } } @@ -1670,6 +1717,10 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { &InParametersList[0] , ServiceInParameter().length() , &OutParametersList[0] , 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() ) ; } } @@ -1686,6 +1737,10 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { &InParametersList[0] , ServiceInParameter().length() , &OutParametersList[0] , 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() ) ; } } @@ -1701,6 +1756,10 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { &InParametersList[0] , ServiceInParameter().length() + 1 , &OutParametersList[0] , 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() ) ; } } @@ -1735,6 +1794,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { //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 { @@ -1772,6 +1834,12 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { << " Value(long) " << OutParametersList[argout0 + i ].Name.c_str() << endl ; break ; + case CORBA::tk_float : + cdebug << "ArgOut->In" << argin0 + i << " : " + << InParametersList[ argin0 + i].Name.c_str() + << " Value(float) " + << OutParametersList[argout0 + i].Name.c_str() << endl ; + break ; case CORBA::tk_double : cdebug << "ArgOut->In" << argin0 + i << " : " << InParametersList[argin0 + i].Name.c_str() @@ -1796,6 +1864,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } 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 ; @@ -1803,6 +1874,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } 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 ; @@ -1820,6 +1894,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { _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 @@ -1852,6 +1929,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { 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; } @@ -1887,6 +1967,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } 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 ; @@ -2095,11 +2178,13 @@ int GraphExecutor::InNode::Executing_SuccessAction() { 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 : { @@ -2128,12 +2213,12 @@ int GraphExecutor::InNode::Executing_ErrorAction() { } 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 ; } @@ -2257,7 +2342,7 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { } } -#define SuccessActionTrace 1 +#define SuccessActionTrace 0 //JR Step B int GraphExecutor::InNode::Successed_SuccessAction() { #if SuccessActionTrace @@ -2328,6 +2413,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode " << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ; #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() ; @@ -2410,6 +2496,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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() ) { @@ -2463,15 +2551,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } } +//Loop of LinkedNodes for SendSomeDataReady : 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 do not activate Nodes within Switch -// We activate directly the EnSwitch -// BUT the NotSwitchBranch(es) are NOT activated : -// bool IgnoreForDefaultSwitch = false ; GraphBase::ComputingNode * aComputingNode ; aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ; toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ; @@ -2497,15 +2578,10 @@ int GraphExecutor::InNode::Successed_SuccessAction() { GateOutPort->PortDone( true ) ; } } + //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 ) { @@ -2514,13 +2590,6 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } } //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++ ) { @@ -2569,9 +2638,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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 : if ( IgnoreForDefaultSwitch ) { //We have to activate Default to EndSwitchNode @@ -2620,24 +2688,30 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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). -// 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() ; +//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 ( !GetNodeOutGate()->BoolValue() && anEndSwitchNode->GetNodeInGate()->GetOutPort() && !anEndSwitchNode->GetNodeInGate()->GetOutPort()->BoolValue() ) { #if SuccessActionTrace @@ -2680,12 +2754,13 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } //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() ; + toNode->LockDataReady() ; // Only ONE Node may send AllDataReadyEvent to an other node if ( toNode->HasAllDataReady() ) { SomeDataNodes.push_back( toNode ) ; toNode->HasAllDataReady( false ) ; @@ -2700,8 +2775,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } // 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 //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() ; @@ -2718,11 +2793,11 @@ int GraphExecutor::InNode::Successed_SuccessAction() { res = aNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute } +//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() @@ -2751,7 +2826,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { << " " << Automaton()->StateName( firsttoNode->State() ) << endl ; #endif //JR 15.04.2005 Debug PAL8624 RetroConception : -//No creation of thread and with LockDataReady an other node in an other thread cannot be +//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 } @@ -2770,7 +2845,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { return 1 ; } -#define SendSomeDataReadyTrace 1 +#define SendSomeDataReadyTrace 0 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) { bool RetVal = false ; if ( IsDataFlowNode() ) { @@ -2824,6 +2899,9 @@ bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) { int GraphExecutor::InNode::Errored_ErrorAction() { cdebug << ThreadNo() << " Errored_ErrorAction " << Name() << " will pthread_exit" << endl; + + _OutNode->NodeAborted( Name() ) ; + DoneAction() ; return 1 ; } @@ -2855,6 +2933,9 @@ int GraphExecutor::InNode::Errored_SuspendAction() { << _OutNode->SuspendedThreads() << endl; _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent , GraphExecutor::SuspendedErroredState ) ; + + _OutNode->NodeAborted( Name() ) ; + DoneAction() ; GraphExecutor::InNode * aReStartNode = SuspendAction() ; cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name() @@ -2883,6 +2964,9 @@ int GraphExecutor::InNode::SuspendedErrored_ResumeAction() { // ResumeAction() ; _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent , GraphExecutor::ResumedErroredState ) ; + + _OutNode->NodeAborted( Name() ) ; + SendEvent( ResumedErroredEvent ) ; return 1 ; } @@ -2899,6 +2983,9 @@ int GraphExecutor::InNode::Errored_KillAction() { KillAction() ; _OutNode->PushEvent( this , GraphExecutor::KilledEvent , GraphExecutor::KilledErroredState ) ; + + _OutNode->NodeAborted( Name() ) ; + cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl; return 1 ; } @@ -2915,6 +3002,9 @@ int GraphExecutor::InNode::Errored_StopAction() { StopAction() ; _OutNode->PushEvent( this , GraphExecutor::StoppedEvent , GraphExecutor::StoppedErroredState ) ; + + _OutNode->NodeAborted( Name() ) ; + cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl; return 1 ; } @@ -2985,7 +3075,7 @@ int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() { return 1 ; } -#define InParametersSetTrace 1 +#define InParametersSetTrace 0 void GraphExecutor::InNode::InParametersSet( bool & Err , int nInParams , ServicesAnyData * InParametersList ) { @@ -3431,7 +3521,7 @@ void GraphExecutor::InNode::InOutParametersSet( int nOutParams , } } -#define OutParametersSetTrace 1 +#define OutParametersSetTrace 0 bool GraphExecutor::InNode::OutParametersSet( bool Err , SUPERV::GraphState PortState , int nOutParams , @@ -3571,12 +3661,17 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , #endif 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 ; } @@ -3728,14 +3823,23 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , } #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" @@ -3746,6 +3850,10 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , 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" @@ -3755,7 +3863,7 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , } } //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 ) { @@ -3768,30 +3876,98 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , OutParametersList[0].Value <<= l ; 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 + 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() << " , " << anInPort->Kind() << " ) linked from " - << anInPort->GetOutPort()->NodeName() - << "( " << anInPort->GetOutPort()->PortName() << " ) CHANGED TO linked from " - << GetChangeNodeOutPort( i )->NodeName() << "( " - << GetChangeNodeOutPort( i )->PortName() << " )" << endl ; -#endif - anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ; - } + 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( 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() ) ; + } + } + } + } + } } } } @@ -3801,3 +3977,61 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , #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 +} diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx index 92c4f32..0518ce3 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx @@ -50,6 +50,7 @@ GraphExecutor::OutNode::OutNode() { _Valid = false ; _Executable = false ; _Done = false ; + _NodeAborted = false ; _Threads = 0 ; _ControlState = SUPERV::VoidState ; _State = GraphExecutor::UnKnownState ; @@ -90,6 +91,7 @@ GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, _Valid = false ; _Executable = false ; _Done = false ; + _NodeAborted = false ; _Threads = 0 ; _ControlState = SUPERV::VoidState ; _State = GraphExecutor::UnKnownState ; @@ -152,6 +154,7 @@ GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, _Valid = false ; _Executable = false ; _Done = false ; + _NodeAborted = false ; _Threads = 0 ; _ControlState = SUPERV::VoidState ; _State = GraphExecutor::UnKnownState ; @@ -195,7 +198,7 @@ bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph * aDataFlow ) if ( RetVal ) { IsValid() ; RetVal = LoadDatas( (*aDataFlow).Datas ) ; - IsExecutable() ; +// IsExecutable() ; if ( !RetVal) { cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadDatas Error." << endl ; @@ -440,7 +443,8 @@ GraphExecutor::InNode *GraphExecutor::OutNode::AddNode( bool GraphExecutor::OutNode::Valid() { cdebug_in << "GraphExecutor::OutNode::Valid" << endl; - + bool RetVal = true ; + Graph()->ReSetMessages() ; // ==> Only one set of errors messages ... if ( _Valid ) return true ; @@ -448,12 +452,12 @@ bool GraphExecutor::OutNode::Valid() { if ( !Graph()->CreateService() ) { cdebug_out << "This DataFlow has invalid type(s)." << endl ; - return false ; + RetVal = false ; } int SubStreamGraphsNumber = 0 ; if ( !Graph()->Sort( SubStreamGraphsNumber ) ) { cdebug_out << "This DataFlow is not valid." << endl ; - return false ; + RetVal = false ; } if ( Graph()->IsDataStreamNode() ) { StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ; @@ -462,35 +466,40 @@ bool GraphExecutor::OutNode::Valid() { if ( !Graph()->ValidLoops() ) { cdebug_out << "This DataFlow have not valid Loops." << endl ; - return false ; + RetVal = false ; } if ( !Graph()->ValidSwitchs() ) { cdebug_out << "This DataFlow have not valid Switchs." << endl ; - return false ; + RetVal = false ; } // CreateService() ; Graph()->ComputingNodes() ; - - _Valid = true ; + if ( RetVal ) { + _Valid = true ; + } - cdebug_out << "GraphExecutor::OutNode::Valid " << _Valid << endl; - return _Valid ; + cdebug_out << "GraphExecutor::OutNode::Valid " << _Valid << " RetVal " << RetVal << endl; + return RetVal ; } - bool GraphExecutor::OutNode::Executable() { - cdebug_in << "GraphExecutor::OutNode::Executable" << endl; - if ( !IsValid() ) - return false ; + bool RetVal = true ; + if ( !IsValid() ) { + RetVal = false ; + } - if ( Graph()->DataServerNodes() ) - _Executable = true ; + if ( Graph()->DataServerNodes() ) { + if ( RetVal ) { + _Executable = true ; + } + } else { cdebug << "This DataFlow is not executable." << endl ; _Executable = false ; + RetVal = false ; } cdebug_out << "GraphExecutor::OutNode::Executable " << _Executable << endl; @@ -542,7 +551,7 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { Done( true ) ; cdebug_out << "GraphExecutor::OutNode::Run InitPythonFunctions ERROR " << anInNode->Name() << endl ; - return false ; + RetVal = false ; } } } @@ -697,6 +706,19 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { //JR 24.03.2005 debug : State and done flags were missing State( GraphExecutor::ErroredState ) ; Done( true ) ; +//JR 17.06.2005 debug call to executed was missing ===> +// _GraphExecutingNumber field of FiniteStateMachine was not decremented ===> +// register of python functions was de-activated ==> +// two graphs execution with two different python functions with the same name +// give aborted state for the second one +//Example : GraphLoopSwitchOfSwitchNOTValid, GraphLoopSwitchs and GraphLoopSwitchsBranches + if ( IsDone() ) { + cdebug << " ==> theAutomaton->Executed() " << endl ; + theAutomaton->Executed() ; + } + else { + cdebug << " NO theAutomaton->Executed() " << endl ; + } cdebug_out << "GraphExecutor::OutNode::Run Not Executable ERROR " << endl ; return false ; } @@ -722,7 +744,9 @@ void GraphExecutor::OutNode::CheckAllDone() { if ( InNodeState != GraphExecutor::SuccessedState && InNodeState != GraphExecutor::ErroredState && InNodeState != GraphExecutor::DataWaitingState ) { - AllDone = false ; + if ( !IsNodeAborted() ) { + AllDone = false ; + } } if ( InNodeState != GraphExecutor::SuccessedState && InNodeState != GraphExecutor::DataWaitingState && @@ -762,7 +786,9 @@ void GraphExecutor::OutNode::CheckAllDone() { aState == SUPERV::SuspendDoneState || aState == SUPERV::SuspendErroredState || aState == SUPERV::SuspendState ) { - alivenodes += 1 ; + if ( !IsNodeAborted() ) { + alivenodes += 1 ; + } } aNode->SuspendedAction() ; aNode->DoneAction() ; @@ -906,9 +932,16 @@ void GraphExecutor::OutNode::ExitThread( pthread_t ThreadNumber ) { } if ( _Threads == 0 && _SuspendedThreads == 0 ) { CheckAllDone() ; + cdebug << pthread_self() << " ExitThread( " << ThreadNumber << " ) " << _Threads + << " running threads " << _SuspendedThreads << " suspended threads IsDone() " + << IsDone() ; if ( IsDone() ) { + cdebug << " ==> theAutomaton->Executed() " << endl ; theAutomaton->Executed() ; } + else { + cdebug << " NO theAutomaton->Executed() " << endl ; + } } } void GraphExecutor::OutNode::JoinedWait() { diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx index 1c8eff8..4746eaf 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx @@ -53,6 +53,7 @@ namespace GraphExecutor { GraphExecutor::AutomatonState _State ; SUPERV::ControlState _ControlState ; bool _Done ; + bool _NodeAborted ; // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL //Engines_Container_i * _SuperVisionContainer ; @@ -226,6 +227,13 @@ namespace GraphExecutor { bool Kill() ; bool Stop() ; + void NodeAborted( const char * aNodeName ) { + string aMsg = string( "The node " ) + string( aNodeName ) + " was aborted." ; + Graph()->SetMessages( aMsg.c_str() ) ; + _NodeAborted = true ; } ; + bool IsNodeAborted() { + return _NodeAborted ; } ; + bool IsWaiting() ; bool IsReady() ; bool IsRunning() ; diff --git a/src/Supervision/CNode_Impl.cxx b/src/Supervision/CNode_Impl.cxx index 0f1dd57..f41cccf 100644 --- a/src/Supervision/CNode_Impl.cxx +++ b/src/Supervision/CNode_Impl.cxx @@ -254,8 +254,12 @@ bool CNode_Impl::SetName( const char * aDataFlowName ) { bool RetVal = false ; if ( DataFlowEditor()->IsEditing() ) { if ( _IsNode ) { - RetVal = DataFlowEditor()->ReNameNode( DataFlowNode()->Name() , - aDataFlowName ) ; +//JR 29.06.2005 debug : + char * OldNodeName = my_strdup( DataFlowNode()->Name() ) ; +// RetVal = DataFlowEditor()->ReNameNode( DataFlowNode()->Name() , + RetVal = DataFlowEditor()->ReNameNode( OldNodeName , + aDataFlowName ) ; + delete [] OldNodeName ; } else { // RetVal = DataFlowEditor()->Graph()->Name( aDataFlowName ) ; diff --git a/src/Supervision/Graph_Impl.cxx b/src/Supervision/Graph_Impl.cxx index abeac2f..627b614 100644 --- a/src/Supervision/Graph_Impl.cxx +++ b/src/Supervision/Graph_Impl.cxx @@ -1655,6 +1655,20 @@ Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer return Engines::Component::_duplicate( objComponent ) ; } +char * Graph_Impl::Messages() { + beginService( "Graph_Impl::Messages" ); + string Messages ; + MESSAGE( "Graph_Impl::Messages IsEditing " << DataFlowEditor()->IsEditing() ) ; + Messages = DataFlowEditor()->Graph()->Messages() ; + DataFlowEditor()->Graph()->ReSetMessages() ; + if ( DataFlowExecutor() ) { + Messages += DataFlowExecutor()->Graph()->Messages() ; + DataFlowExecutor()->Graph()->ReSetMessages() ; + } + endService( "Graph_Impl::Messages" ); + return ( CORBA::string_dup( Messages.c_str() ) ) ; +} + bool Graph_Impl::IsValid() { // beginService( "Graph_Impl::IsValid" ); bool RetVal = false ; @@ -1781,6 +1795,7 @@ bool Graph_Impl::Begin() { perror("pthread_mutex_lock _MutexExecutorWait") ; exit( 0 ) ; } + DataFlowEditor()->Graph()->ReSetMessages() ; // ==> Only one set of errors messages ... if ( DataFlowExecutor() ) { MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" ) Editing(); // just in case it was not called before by GUI.. diff --git a/src/Supervision/Graph_Impl.hxx b/src/Supervision/Graph_Impl.hxx index 3469f05..84dfe64 100644 --- a/src/Supervision/Graph_Impl.hxx +++ b/src/Supervision/Graph_Impl.hxx @@ -167,6 +167,8 @@ class Graph_Impl : public POA_SUPERV::Graph , virtual Engines::Component_ptr ComponentRef( const char * aComputerContainer , const char * aComponentName ) ; + virtual char * Messages() ; + virtual bool IsValid() ; virtual bool IsExecutable() ; diff --git a/src/Supervision/Port_Impl.cxx b/src/Supervision/Port_Impl.cxx index 21953c6..2e0c7e5 100644 --- a/src/Supervision/Port_Impl.cxx +++ b/src/Supervision/Port_Impl.cxx @@ -113,7 +113,7 @@ void Port_Impl::destroy() { bool destroyed = false ; if ( _DataFlowNode->IsOneOfInLineNodes() ) { if ( _InputPort ) { - GraphBase::InPort * anInPort = (GraphBase::InPort * ) _DataFlowPort ; +// GraphBase::InPort * anInPort = (GraphBase::InPort * ) _DataFlowPort ; // if ( anInPort->GetOutPort() ) { // anInPort->GetOutPort()->RemoveInPort( anInPort ) ; // } diff --git a/src/Supervision/SuperV.py b/src/Supervision/SuperV.py index 7b7acbd..17d37b0 100644 --- a/src/Supervision/SuperV.py +++ b/src/Supervision/SuperV.py @@ -869,6 +869,8 @@ class Graph(GNode): return self.G.Import( anXmlFileName ) def Export( self , anXmlFileName ): return self.G.Export( anXmlFileName ) + def Messages( self ) : + return self.G.Messages() def IsReadOnly( self ) : return self.G.IsReadOnly() def ComponentRef( self , aFactoryServer , aComponent ) : -- 2.39.2