+void GraphBase::ComputingNode::SetMacroPorts( GraphBase::Graph * aGraph ) {
+ cdebug_in << "GraphBase::ComputingNode::SetMacroPorts fill ports of MacroNode" << endl;
+ int i ;
+ for ( i = 0 ; i < aGraph->GetNodeInPortsSize() ; i++ ) {
+ const GraphBase::InPort * anInPort = aGraph->GetNodeInPort( i ) ;
+ cdebug << "SetMacroPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
+ << " " << anInPort->Kind() << endl ;
+ GraphBase::InPort * aNewInPort ;
+ if ( anInPort->IsDataStream() ) {
+ aNewInPort = AddInDataStreamPort( anInPort->PortName() , StringToDataStreamType( anInPort->PortType() ) ,
+ anInPort->Dependency() , anInPort->Kind() ) ;
+ }
+ else if ( anInPort->IsParam() || anInPort->IsInLine() ) {
+ aNewInPort = AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() ) ;
+ }
+ }
+ for ( i = 0 ; i < aGraph->GetNodeOutPortsSize() ; i++ ) {
+ const GraphBase::OutPort * anOutPort = aGraph->GetNodeOutPort( i ) ;
+ cdebug << "SetMacroPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
+ << " " << anOutPort->Kind() << endl ;
+ if ( anOutPort->IsDataStream() ) {
+ AddOutDataStreamPort( anOutPort->PortName() , StringToDataStreamType( anOutPort->PortType() ) ,
+ anOutPort->Dependency() , anOutPort->Kind() ) ;
+ }
+ else if ( anOutPort->IsParam() || anOutPort->IsInLine() ) {
+ AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() ) ;
+ }
+ }
+ cdebug_out << "GraphBase::ComputingNode::SetMacroPorts" << endl;
+}
+
+void GraphBase::ComputingNode::UpdateMacroPorts( GraphBase::Graph * aGraph ) {
+ cdebug_in << "GraphBase::ComputingNode::UpdateMacroPorts fill ports of MacroNode from "
+ << aGraph->Name() << " InPorts(" << aGraph->GetNodeInPortsSize() << ") OutPorts("
+ << aGraph->GetNodeInPortsSize() << ") to MacroNode " << Name() << " InPorts(" << GetNodeInPortsSize()
+ << ") OutPorts(" << GetNodeInPortsSize() << ")" << endl;
+ cdebug << Name() << " : " << *GetService() << endl ;
+ cdebug << aGraph->Name() << " : " << *aGraph->GetService() << endl ;
+ int i ;
+// Loop over InPorts of MacroNode ; if it does not exist in the MacroGraph ===> DelInPort in the MacroNode
+ for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
+ GraphBase::InPort * anInPort = aGraph->GetChangeInPort( GetNodeInPort( i )->PortName() ) ;
+ if ( anInPort && !anInPort->IsGate() && !GetNodeInPort( i )->IsGate() ) {
+ if ( strcmp( GetNodeInPort( i )->PortType() , anInPort->PortType() ) ) {
+ cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType()
+ << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ;
+ cdebug << " <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
+ << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ;
+ GetChangeNodeInPort( i )->PortType( (char * ) anInPort->PortType() ) ;
+ }
+ if ( GetNodeInPort( i )->Kind() != anInPort->Kind() ) {
+ cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType()
+ << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ;
+ cdebug << " <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
+ << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ;
+ GetChangeNodeInPort( i )->Kind( anInPort->Kind() ) ;
+ }
+ if ( GetNodeInPort( i )->Dependency() != anInPort->Dependency() ) {
+ cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType()
+ << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ;
+ cdebug << " <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
+ << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ;
+ GetChangeNodeInPort( i )->Dependency( anInPort->Dependency() ) ;
+ }
+ }
+ else if ( !GetNodeInPort( i )->IsGate() ) {
+ cdebug << "UpdateMacroPorts DelInPort In" << i << " " << GetNodeInPort( i )->PortName() << " "
+ << GetNodeInPort( i )->PortType() << " " << GetNodeInPort( i )->Kind() << endl ;
+ DelInPort( GetNodeInPort( i )->PortName() ) ;
+ i--; // mkr : fix for bug PAL8004
+ }
+ }
+ int index ;
+// Loop over InPorts of the MacroGraph : if it does not exist in the MacroNode ==> AddInPort in the MacroNode
+ for ( index = 0 ; index < aGraph->GetNodeInPortsSize() ; index++ ) {
+ GraphBase::InPort * anInPort = aGraph->GetChangeNodeInPort( index ) ;
+ GraphBase::InPort * aMacroInPort = GetChangeInPort( anInPort->PortName() ) ;
+ if ( !anInPort->IsGate() &&
+ strcmp( GetChangeNodeInPort( index )->PortName() , anInPort->PortName() ) ) {
+ cdebug << "UpdateMacroPorts Add/MoveInPort In" << index << " " << anInPort->PortName() << " "
+ << anInPort->PortType() << " " << anInPort->Kind() << endl ;
+ if ( aMacroInPort ) {
+ MoveInPort( anInPort->PortName() , index ) ;
+ }
+ else {
+ AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() , index ) ;
+ }
+ }
+ }
+// Loop over OutPorts of MacroNode ; if it does not exist in the MacroGraph ===> DelOutPort in the MacroNode
+ for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+ GraphBase::OutPort * anOutPort = aGraph->GetChangeOutPort( GetNodeOutPort( i )->PortName() ) ;
+ if ( anOutPort && !anOutPort->IsGate() && !GetNodeOutPort( i )->IsGate() ) {
+ if ( strcmp( GetNodeOutPort( i )->PortType() , anOutPort->PortType() ) ) {
+ cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType()
+ << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ;
+ cdebug << " <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
+ << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ;
+ GetChangeNodeOutPort( i )->PortType( (char * ) anOutPort->PortType() ) ;
+ }
+ if ( GetNodeOutPort( i )->Kind() != anOutPort->Kind() ) {
+ cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType()
+ << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ;
+ cdebug << " <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
+ << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ;
+ GetChangeNodeOutPort( i )->Kind( anOutPort->Kind() ) ;
+ }
+ if ( GetNodeOutPort( i )->Dependency() != anOutPort->Dependency() ) {
+ cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType()
+ << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ;
+ cdebug << " <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
+ << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ;
+ GetChangeNodeOutPort( i )->Dependency( anOutPort->Dependency() ) ;
+ }
+ }
+ else if ( !GetNodeOutPort( i )->IsGate() ) {
+ cdebug << "UpdateMacroPorts DelOutPort Out" << i << " " << GetNodeOutPort( i )->PortName() << " "
+ << GetNodeOutPort( i )->PortType() << " " << GetNodeOutPort( i )->Kind() << endl ;
+ DelOutPort( GetNodeOutPort( i )->PortName() ) ;
+ }
+ }
+// Loop over OutPorts of the MacroGraph : if it does not exist in the MacroNode ==> AddOutPort in the MacroNode
+ for ( index = 0 ; index < aGraph->GetNodeOutPortsSize() ; index++ ) {
+ GraphBase::OutPort * anOutPort = aGraph->GetChangeNodeOutPort( index ) ;
+ GraphBase::OutPort * aMacroOutPort = GetChangeOutPort( anOutPort->PortName() ) ;
+ if ( !anOutPort->IsGate() && strcmp( GetNodeOutPort( index )->PortName() , anOutPort->PortName() ) ) {
+ cdebug << "UpdateMacroPorts Add/MoveOutPort Out" << index << " " << anOutPort->PortName() << " "
+ << anOutPort->PortType() << " " << anOutPort->Kind() << endl ;
+ if ( aMacroOutPort ) {
+ MoveOutPort( anOutPort->PortName() , index ) ;
+ }
+ else {
+ AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() , index ) ;
+ }
+ }
+ }
+ bool ErrPort = false ;
+ if ( aGraph->GetNodeInPortsSize() != GetNodeInPortsSize() ||
+ aGraph->GetNodeOutPortsSize() != GetNodeOutPortsSize() ) {
+ ErrPort = true ;
+ }
+ for ( i = 0 ; i < aGraph->GetNodeInPortsSize() && i < GetNodeInPortsSize() ; i++ ) {
+ if ( !strcmp( aGraph->GetNodeInPort( i )->PortName() , GetNodeInPort( i )->PortName() ) ) {
+ ErrPort = true ;
+ }
+ }
+ for ( i = 0 ; i < aGraph->GetNodeOutPortsSize() && i < GetNodeOutPortsSize() ; i++ ) {
+ if ( !strcmp( aGraph->GetNodeOutPort( i )->PortName() , GetNodeOutPort( i )->PortName() ) ) {
+ ErrPort = true ;
+ }
+ }
+ if ( ErrPort ) {
+ for ( i = 0 ; i < aGraph->GetNodeInPortsSize() || i < GetNodeInPortsSize() ; i++ ) {
+ if ( i < aGraph->GetNodeInPortsSize() && i < GetNodeInPortsSize() ) {
+ cdebug << "ComputingNode::UpdateMacroPorts In" << i << " " << aGraph->GetNodeInPort( i )->PortName()
+ << " " << GetNodeInPort( i )->PortName() << endl ;
+ }
+ else if ( i >= GetNodeInPortsSize() ) {
+ cdebug << "ComputingNode::UpdateMacroPorts In" << i << " " << aGraph->GetNodeInPort( i )->PortName()
+ << endl ;
+ }
+ else {
+ cdebug << "ComputingNode::UpdateMacroPorts In" << i << " " << GetNodeInPort( i )->PortName()
+ << endl ;
+ }
+ }
+ for ( i = 0 ; i < aGraph->GetNodeOutPortsSize() || i < GetNodeOutPortsSize() ; i++ ) {
+ if ( i < aGraph->GetNodeOutPortsSize() && i < GetNodeOutPortsSize() ) {
+ cdebug << "ComputingNode::UpdateMacroPorts Out" << i << " " << aGraph->GetNodeOutPort( i )->PortName()
+ << " != " << GetNodeOutPort( i )->PortName() << endl ;
+ }
+ else if ( i >= GetNodeOutPortsSize() ) {
+ cdebug << "ComputingNode::UpdateMacroPorts Out" << i << " " << aGraph->GetNodeOutPort( i )->PortName()
+ << endl ;
+ }
+ else {
+ cdebug << "ComputingNode::UpdateMacroPorts Out" << i << " " << GetNodeOutPort( i )->PortName()
+ << endl ;
+ }
+ }
+ }
+ cdebug_out << "GraphBase::ComputingNode::UpdateMacroPorts"
+ << aGraph->Name() << " InPorts(" << aGraph->GetNodeInPortsSize() << ") OutPorts("
+ << aGraph->GetNodeOutPortsSize() << ") to MacroNode " << Name() << " InPorts("
+ << GetNodeInPortsSize() << ") OutPorts(" << GetNodeOutPortsSize() << ")" << endl;
+}
+
+void GraphBase::ComputingNode::SetMacroDatas( GraphBase::Graph * aGraph ,
+ GraphBase::Graph * aGraphOfMacroGraph ) {
+ cdebug_in << "GraphBase::ComputingNode::SetMacroDatas fill inputs of MacroNode" << endl;
+ int i ;
+ for ( i = 0 ; i < aGraph->GetNodeInPortsSize() ; i++ ) {
+ const GraphBase::InPort * anInPort = aGraph->GetNodeInPort( i ) ;
+ GraphBase::OutPort * anOutPort = aGraph->GetChangeNodeInDataNodePort(i) ;
+ cdebug << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
+ << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
+ if ( anOutPort->IsDataConnected() ) {
+//JR 30.03.2005 aGraphOfMacroGraph->AddInputData( Name() , anInPort->PortName() , *(anOutPort->Value()) ) ;
+ aGraphOfMacroGraph->AddInputData( Name() , anInPort->PortName() , anOutPort->Value() ) ;
+ anOutPort->PortStatus( ExternConnected ) ;
+ }
+ }
+ cdebug_out << "GraphBase::ComputingNode::SetMacroDatas" << endl;
+}
+
+void GraphBase::ComputingNode::DelInPort( const char * InputParameterName ) {
+//PAL9122
+//JR 07.06.2005 Debug : LinkedNodes and LinkedFromNode must be updated
+// LinkedInPortsNumber and LinkedFromInPortsNumber must be updated
+ cdebug_in << "ComputingNode::DelInPort " << Name() << "( " << InputParameterName << " )"
+ << endl;
+ bool RetVal = true ;
+ if ( !IsEndSwitchNode() ) {
+ GraphBase::InPort * anInPort = GetChangeInPort( InputParameterName ) ;
+ cdebug << "ComputingNode::DelInPort InPort " << Name() << "( "
+ << anInPort->PortName() << " ) " << anInPort->PortStatus() << " <-- " ;
+ GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
+ if ( anOutPort && !( IsEndLoopNode() && anInPort->IsLoop() ) ) {
+ cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
+ << anOutPort->PortStatus() ;
+ }
+ cdebug << endl ;
+ if ( !anInPort->IsNotConnected() ) {
+ GraphBase::ComputingNode * FromNode = NULL ;
+ RetVal = true ;
+ if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
+ cdebug << " Data/Extern ignored" << endl ;
+ }
+ else {
+ FromNode = GraphOfNode()->GetChangeGraphNode( anOutPort->NodeName() ) ;
+ }
+ if ( FromNode ) {
+ cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize "
+ << FromNode->LinkedNodesSize() << " and " << Name()
+ << " LinkedFromNodesSize " << LinkedFromNodesSize() << endl ;
+ if ( !FromNode->IsGOTONode() &&
+ !( FromNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
+ if ( anInPort->IsDataStream() ) {
+ RetVal = FromNode->RemoveStreamLinkedNode( this ) ;
+ }
+ else {
+ RetVal = FromNode->RemoveLinkedNode( this ) ;
+ }
+ if ( !RetVal ) {
+ cdebug << "ComputingNode::DelInPort anOutPort->RemoveLinkedNode Error RetVal "
+ << RetVal << endl ;
+ }
+ }
+ }
+ }
+ }
+//We have an EndSwitchNode :
+ else {
+ int i ;
+ for ( i = LinkedFromNodesSize() - 1 ; i >= 0 ; i-- ) {
+ GraphBase::ComputingNode * aLinkedFromNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ;
+ cdebug << aLinkedFromNode->Name() << " linked to " << Name() << endl ;
+ int j ;
+ for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) {
+ GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ;
+ cdebug << "ComputingNode::DelInPort OutPort" << j << ". Remove " << anOutPort->InPortsSize()
+ << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << ") "
+ << anOutPort->PortStatus() << " :" << endl ;
+ int k ;
+//Process concerned OutPorts of LinkedFromNodes of that EndSwitchNode
+ for ( k = anOutPort->InPortsSize() - 1 ; k >= 0 ; k-- ) {
+ GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
+ if ( !strcmp( anInPort->NodeName() , Name() ) &&
+ !strcmp( anInPort->PortName() , InputParameterName ) ) {
+// InPort of the EndSwitchNode
+ cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( "
+ << anInPort->PortName() << ") "
+ << anInPort->PortStatus() << endl ;
+ anInPort->RemoveOutPort() ;
+ if ( anOutPort->IsDataStream() ) {
+ aLinkedFromNode->RemoveStreamLinkedNode( this ) ;
+ }
+ else {
+// false ==> No error for aNode->LinkedFromNode()
+ RetVal = aLinkedFromNode->RemoveLinkedNode( this , false ) ;
+ if ( !RetVal ) {
+ cdebug << "ComputingNode::DelInPort aLinkedFromNode->RemoveLinkedNode Error RetVal "
+ << RetVal << endl ;
+ break ;
+ }
+ }
+// Remove the InPort of the EndSwitchNode from that OutPort
+ RetVal = anOutPort->RemoveInPort( anInPort ) ;
+ if ( !RetVal ) {
+ cdebug << "ComputingNode::DelInPort anOutPort->RemoveInPort( anInPort ) Error RetVal "
+ << RetVal << endl ;
+ break ;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
+ cdebug_out << "ComputingNode::DelInPort " << Name() << "( " << InputParameterName << " )"
+ << endl;
+}
+void GraphBase::ComputingNode::DelOutPort( const char * OutputParameterName ) {
+//PAL9122
+//JR 07.06.2005 Debug : LinkedNodes and LinkedFromNode must be updated
+// LinkedInPortsNumber and LinkedFromInPortsNumber must be updated
+ cdebug_in << "ComputingNode::DelOutPort " << Name() << "( " << OutputParameterName << " )"
+ << endl;
+ bool RetVal = true ;
+ GraphBase::OutPort * anOutPort = GetChangeOutPort( OutputParameterName ) ;
+ cdebug << "ComputingNode::DelOutPort OutPort " << " InPortof OutPort : "
+ << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
+ << anOutPort->PortStatus() << " :" << endl ;
+ int j ;
+ for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
+ GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
+ GraphBase::ComputingNode * ToNode = NULL ;
+ cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( "
+ << anInPort->PortName() << ") " << anInPort->PortStatus() ;
+ if ( anInPort->IsExternConnected() ) {
+ cdebug << " ExternConnected ignored" << endl ;
+ }
+ else {
+ cdebug << endl ;
+ ToNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ;
+ }
+ if ( ToNode ) {
+ RetVal = anInPort->RemoveOutPort() ;
+// JR 04.02.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
+// PAL7990
+ if ( !RetVal ) {
+ cdebug << "ComputingNode::DelOutPort anOutPort->RemoveOutPort Error RetVal " << RetVal
+ << endl ;
+ break ;
+ }
+ if ( ( IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
+ ( IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
+ }
+ else if ( anOutPort->IsDataStream() ) {
+ RetVal = RemoveStreamLinkedNode( ToNode ) ;
+ }
+ else {
+ RetVal = RemoveLinkedNode( ToNode ) ;
+ }
+ if ( !RetVal ) {
+ cdebug << "ComputingNode::DelOutPort anOutPort->RemoveLinkedNode Error RetVal " << RetVal
+ << endl ;
+ break ;
+ }
+ if ( ToNode->IsEndSwitchNode() ) {
+ int i ;
+ int done = false ;
+ for ( i = 0 ; i < ToNode->LinkedFromNodesSize() ; i++ ) {
+ GraphBase::StreamNode * fromNode = ToNode->LinkedFromNodes( i ) ;
+// Not the node that we are deleting ... :
+ if ( strcmp( fromNode->Name() , Name() ) ) {
+ 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 ) {
+ if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
+// Restore an OutPort in the InPort
+ anInPort->ChangeOutPort( fromOutPort ) ;
+ cdebug << "ComputingNode::DelOutPort reestablish " << fromOutPort->NodeName() << "( "
+ << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
+ << ToNode->Name() << "( " << anInPort->PortName() << " )"
+ << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
+ done = true ;
+ break ;
+ }
+ }
+ }
+ if ( done ) {
+ break ;
+ }
+ }
+ if ( done ) {
+ break ;
+ }
+ }
+ }
+ }
+ }
+ }
+ if ( !RetVal ) {
+ cdebug << "Error RetVal " << RetVal << endl ;
+ }
+
+ GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
+ cdebug_out << "ComputingNode::DelOutPort " << Name() << "( " << OutputParameterName << " )"
+ << endl;
+}
+