bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
const char* NewNodeName ) {
- cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ")" << endl;
+ cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ") "
+ << endl;
int i ;
bool RetVal = false ;
+//#if 0
+ GraphBase::ComputingNode * anOldNode = GetChangeGraphNode( OldNodeName ) ;
+ for ( i = 0 ; i < anOldNode->LinkedNodesSize() ; i++ ) {
+ cdebug << "LinkedNode " << i << " " << anOldNode->LinkedNodes( i )->Name() << endl ;
+ }
+//#endif
if ( !strcmp( OldNodeName , NewNodeName ) ) {
RetVal = true ;
}
SetGraphNodeIndex( NewNodeName , index ) ;
GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
+// Update 'ToNode's Map from 'aNode'
+ cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize "
+ << aNode->LinkedNodesSize() << endl ;
+ for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
+ GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ;
+ ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ;
+ }
+// Update 'FomNode's Map to 'aNode'
+// Inports 'anInPort' of 'aNode'
for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
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 " ;
if ( anOutPort ) {
cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
}
else {
+// Node 'FromNode' of 'anOutPort'
GraphBase::ComputingNode * FromNode ;
if ( strcmp( anOutPort->NodeName() , Name() ) ) {
FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
else {
FromNode = this ;
}
+// Rename in _MapOfLinkedFromNodes of 'FromNode'
cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
if ( anInPort->IsDataStream() ) {
FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
}
bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
- cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << LinkedNodesSize() << " LinkedNodes :"
- << endl;
+ cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << endl;
int i ;
bool RetVal = false ;
int index = GetGraphNodeIndex( aNodeName ) ;
GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
- for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
- cdebug << " " << i << ". " << LinkedNodes( i ) << endl ;
- }
if ( aNode ) {
- cdebug << "Graph::RemoveNode " << aNode->GetNodeInPortsSize() << " InPorts " << aNode->GetNodeOutPortsSize()
- << " OutPorts" << endl ;
- if ( aNode->GetNodeInPortsSize() ) {
- for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
- GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
- cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") "
- << anInPort->PortStatus() << " <-- " ;
- GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
- if ( anOutPort ) {
- cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ;
- }
- cdebug << endl ;
- if ( !anInPort->IsNotConnected() ) {
- RetVal = true ;
- if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
- cdebug << " Data/Extern" << endl ;
- }
+ cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
+ << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
+ << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
+ << " LinkedFromNodes IsEndSwitchNode " << aNode->IsEndSwitchNode() << endl ;
+ for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
+ cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
+ << aNode->LinkedNodes( i )->Name() << endl ;
+ }
+ if ( !aNode->IsEndLoopNode() ) { // The LoopNode is already deleted
+ for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
+ cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
+ << aNode->LinkedFromNodes( i )->Name() << endl ;
+ }
+ }
+ if ( !aNode->IsEndSwitchNode() ) {
+ if ( aNode->GetNodeInPortsSize() ) {
+ for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
+ GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
+ cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") "
+ << anInPort->PortStatus() << " <-- " ;
+ GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
+ if ( anOutPort && !( aNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
+ cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ;
+ }
+ cdebug << endl ;
+ if ( !anInPort->IsNotConnected() ) {
+ RetVal = true ;
+ if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
+ cdebug << " Data/Extern" << endl ;
+ }
+ else {
+ GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
+ cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize "
+ << FromNode->LinkedNodesSize() << " and " << aNode->Name()
+ << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
+ // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120.
+// JR 05.01.05 : IsOneOfGOTO is not ok : I shall check the bug 7120 with IsGOTONode
+// if ( !FromNode->IsOneOfGOTONodes() ) {
+// if ( !FromNode->IsGOTONode() ) {
+ if ( !FromNode->IsGOTONode() &&
+ !( FromNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
+ if ( anInPort->IsDataStream() ) {
+ RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
+ }
+ else {
+ RetVal = FromNode->RemoveLinkedNode( aNode ) ;
+ }
+ if ( !RetVal ) {
+ cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
+ break ;
+ }
+ }
+ }
+ RetVal = anOutPort->RemoveInPort( anInPort ) ;
+ if ( !RetVal ) {
+ cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
+ break ;
+ }
+ }
else {
- GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
- // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120.
- if ( !FromNode->IsOneOfGOTONodes() ) {
- if ( anInPort->IsDataStream() ) {
- RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
+ RetVal = true ;
+ }
+ }
+ }
+ else {
+ RetVal = true ;
+ }
+ }
+ else {
+// Special case of EndSwitchNodes : each Input port must be multi-connected.
+// There is one link for each branch of the switch
+// But in GraphBase::InPort there is only one field GraphBase::OutPort *
+// At execution time there is no problem because only one branch of the switch
+// may be executed and the Executor set the right OutPort in the field
+// GraphBase::OutPort * of each InPort of the EndSwitchNode
+// But here we must remove that node EndSwitch from the LinkedNodes field of
+// terminal nodes of all branches.
+// And also in the OutPorts of that terminal nodes of branches we must remove
+// references to InPorts of the EndSwitchNode.
+
+// Explore LinkedFromnodes of the EndSwitchNode :
+ for ( i = aNode->LinkedFromNodesSize() - 1 ; i >= 0 ; i-- ) {
+ GraphBase::ComputingNode * aLinkedFromNode = (GraphBase::ComputingNode * ) aNode->LinkedFromNodes( i ) ;
+ cdebug << aLinkedFromNode->Name() << " linked to " << aNode->Name() << endl ;
+ int j ;
+ for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) {
+ GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ;
+ cdebug << "OutPort" << j << ". Remove " << anOutPort->InPortsSize()
+ << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << ") "
+ << anOutPort->PortStatus() << " :" << endl ;
+ int k ;
+ for ( k = anOutPort->InPortsSize() - 1 ; k >= 0 ; k-- ) {
+ GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
+ if ( strcmp( anInPort->NodeName() , aNode->Name() ) == NULL ) {
+// InPort of the EndSwitchNode
+ cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( "
+ << anInPort->PortName() << ") "
+ << anInPort->PortStatus() << endl ;
+ anInPort->RemoveOutPort() ;
+ if ( anOutPort->IsDataStream() ) {
+ aLinkedFromNode->RemoveStreamLinkedNode( aNode ) ;
}
else {
- RetVal = FromNode->RemoveLinkedNode( aNode ) ;
+// false ==> No error for aNode->LinkedFromNode()
+ RetVal = aLinkedFromNode->RemoveLinkedNode( aNode , false ) ;
+ if ( !RetVal ) {
+ cdebug << "aLinkedFromNode->RemoveLinkedNode Error RetVal " << RetVal << endl ;
+ break ;
+ }
}
+// Remove the InPort of the EndSwitchNode from that OutPort
+ RetVal = anOutPort->RemoveInPort( anInPort ) ;
if ( !RetVal ) {
- cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
+ cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
break ;
}
}
}
- RetVal = anOutPort->RemoveInPort( anInPort ) ;
- if ( !RetVal ) {
- cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
- break ;
- }
- }
- else {
- RetVal = true ;
- }
+ }
}
}
- else {
- RetVal = true ;
- }
+
if ( RetVal ) {
for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
break ;
}
- RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ;
+ RetVal = anOutPort->RemoveInPort( anInPort ) ;
if ( !RetVal ) {
cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
break ;
}
}
}
- if ( RetVal ) {
+ cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
+ << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
+ << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
+ << " LinkedFromNodes " << endl ;
+ for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
+ cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
+ << aNode->LinkedNodes( i )->Name() << endl ;
+ }
+ for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
+ cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
+ << aNode->LinkedFromNodes( i )->Name() << endl ;
+ }
+// Delete of aNode from the Graph :
+// The LoopNode is needed by the delete of the EndLoopNode. So the LoopNode will be deleted
+// when the EndLoopNode is deleted. It is the same for SwitchNode & EndSwitchNode
+ if ( RetVal && !aNode->IsLoopNode() && !aNode->IsSwitchNode() ) {
+ GraphBase::InLineNode * theCoupledNode = NULL ;
+ char * theCoupledNodeName = NULL ;
+ int CoupledIndex = -1 ;
+ if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) {
+ theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
+ theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ;
+ CoupledIndex = GetGraphNodeIndex( theCoupledNode->Name() ) ;
+ }
delete aNode ;
_GraphNodesSize -= 1 ;
for ( i = index ; i < _GraphNodesSize ; i++ ) {
- SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ;
_GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
+ SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
}
_GraphNodes.resize( _GraphNodesSize+1 ) ;
_MapOfGraphNodes.erase( aNodeName ) ;
+// Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode :
+ if ( theCoupledNode ) {
+ delete theCoupledNode ;
+ _GraphNodesSize -= 1 ;
+ for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) {
+ _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
+ SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
+ }
+ _GraphNodes.resize( _GraphNodesSize+1 ) ;
+ _MapOfGraphNodes.erase( theCoupledNodeName ) ;
+ }
RetVal = true ;
}
}
GraphBase::InPort *toPort = NULL ;
if ( fromNode ) {
- fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
+ // asv : 29.12.04 : as I understand, replacement of "InitLoop" by "DoLoop" was
+ // done by JR in order to keep old graphs and batch test scripts working after change
+ // of special Loop's port name from "InitLoop" to "DoLoop". I suppose, it is not
+ // needed, all old graphs and tests must be changed to use "DoLoop" name for addressing
+ // this port.. It we don't do it, ANY port with "InitLoop" name will be replaced by "DoLoop"
+ // and it can cause unexpected bugs in future... So I comment out the replacement code.
+ //if ( strcmp( FromServiceParameterName , "InitLoop" ) ) {
+//JR 12.01.05 : Yes the test is not good ; now I test that PortName only in LoopNodes ==>
+// + old graphs will runs normally (it is not possible to ask CEA to edit their graphs)
+// + in old graphs "InitLoop" and "DoLoop" were reserved parameter names (but not controlled)
+// + in new graphs, I have added a control at port creation of that names : they are refused
+ if ( !(fromNode->IsLoopNode() && strcmp( FromServiceParameterName , "InitLoop" ) == 0 ) ) {
+ fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
+ }
+ else {
+ fromPort = fromNode->GetChangeOutPort( "DoLoop" ) ;
+ }
if ( !fromPort ) {
cdebug << "ERROR AddLink fromPort " << FromServiceParameterName << " FromNode("
<< FromNodeName << ") not found." << endl ;
cdebug << "ERROR AddLink FromNode " << FromNodeName << " not found." << endl ;
}
if ( toNode ) {
- toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
+ // see comment above
+// if ( strcmp( ToServiceParameterName , "InitLoop" ) ) {
+ if ( !(toNode->IsLoopNode() && strcmp( ToServiceParameterName , "InitLoop" ) == 0 ) ) {
+ toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
+ }
+ else {
+ toPort = toNode->GetChangeInPort( "DoLoop" ) ;
+ }
if ( !toPort ) {
cdebug << "ERROR AddLink toPort " << ToServiceParameterName << " ToNode("
<< ToNodeName << ") not found." << endl ;
toPort->Kind( SUPERV::EndSwitchParameter ) ;
}
}
+// JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate
+ else if ( fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) {
+ cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ;
+ cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
+ return false ;
+ }
else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
cdebug << "!fromPort->AddLink Error." << endl ;
cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
if ( anInPort && ( anInPort->IsPortConnected() ||
anInPort->IsDataConnected() ||
anInPort->IsExternConnected() ) ) {
- GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
- RetVal = anOutPort->RemoveInPort( anInPort ) ; // ==> :
-// anInPort->RemoveOutPort() ;
- const char * FromNodeName = anOutPort->NodeName() ;
+// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The OutPort may be an other one !!!
GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
+ GraphBase::OutPort * anOutPort = NULL ;
+ if ( toNode->IsEndSwitchNode() ) {
+ anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
+ RetVal = anOutPort->RemoveInPort( anInPort ) ;
+ }
+ else {
+ anOutPort = anInPort->GetOutPort() ;
+ RetVal = anOutPort->RemoveInPort( anInPort ) ;
+ }
+// anInPort->RemoveOutPort() ; // Already done in RemoveInPort
+// const char * FromNodeName = anOutPort->NodeName() ;
if ( RetVal ) {
if ( fromNode ) {
if ( anInPort->IsDataStream() ) {
if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
anOutPort->Kind( SUPERV::InLineParameter ) ;
}
+// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be linked !!!
+ if ( toNode->IsEndSwitchNode() ) {
+ int i ;
+ int done = false ;
+ for ( i = 0 ; i < toNode->LinkedFromNodesSize() ; i++ ) {
+ GraphBase::StreamNode * fromNode = toNode->LinkedFromNodes( i ) ;
+ int j ;
+ for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
+ GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
+ int k ;
+ for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
+ if ( strcmp( toNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
+// Restore an OutPort in the InPort
+ anInPort->ChangeOutPort( fromOutPort ) ;
+ cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( "
+ << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
+ << toNode->Name() << "( " << anInPort->PortName() << " )" << endl;
+ done = true ;
+ break ;
+ }
+ }
+ if ( done ) {
+ break ;
+ }
+ }
+ if ( done ) {
+ break ;
+ }
+ }
+ }
}
}
}
return true ;
}
+bool GraphBase::Graph::ValidLoops() const {
+ cdebug_in << "GraphBase::Graph::ValidLoops" << endl;
+
+ int i ;
+ GraphBase::ComputingNode * aNode ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ aNode = GraphNodes( i ) ;
+ if ( aNode->IsLoopNode() ) {
+ 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 ;
+ }
+ else if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
+ cdebug_out << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name()
+ << endl;
+ return false ;
+ }
+ }
+ }
+ cdebug_out << "GraphBase::Graph::ValidLoops true" << endl;
+ return true ;
+}
+
// Controle de la coherence des noeuds de calcul
// Enregistrement dans la liste des noeuds "tete" de graphe
anOutPort = anInPort->GetOutPort() ;
if ( anOutPort ) {
aRet = anOutPort->Value() ;
- cdebug << "OutPort value " << anOutPort->NodeName() << "("
+ cdebug << "Graph::PortInData OutPort value " << anOutPort->NodeName() << "("
<< anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
<< "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
}
else {
- cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
+ cdebug << "Graph::PortInData GraphBase::Graph::PortInData " << ToNodeName << " "
<< ToServiceParameterName << " ERROR no OutPort" << endl ;
}
}
if ( CORBA::is_nil( objComponent ) ) {
cdebug_out << aThread
<< " StartComponent cannot FindOrLoad " << aComputerContainer
- << " " << ComponentName << endl;
+ << " " << ComponentName << " ERROR" << endl;
return 0 ;
}
else {
if ( CORBA::is_nil( myContainer ) ) {
cdebug_out << aThread
<< " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
- << aComputerContainer << "' ) Container does not exist"
+ << aComputerContainer << "' ) Container does not exist ERROR"
<< endl ;
return 0 ;
}
}
- cdebug_out << aThread << " GraphBase::Graph::StartComponent" << endl;
+ cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;
return RetVal ;
}