]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/GraphBase/DataFlowBase_ComputingNode.cxx
Salome HOME
SMH: 3.0.0 preparation = merged version (POLYWORK + RTVDEBUG01) + adopation for new GUI
[modules/superv.git] / src / GraphBase / DataFlowBase_ComputingNode.cxx
index 8b1d3e7c67cd466075f5da5d2f4411277dc657f7..5978f0931a424a3cecfe9eda89ff6796f0c57117 100644 (file)
@@ -589,7 +589,8 @@ void GraphBase::ComputingNode::SetMacroDatas( GraphBase::Graph * aGraph ,
     cdebug << "                 " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
            << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
     if ( anOutPort->IsDataConnected() ) {
-      aGraphOfMacroGraph->AddInputData( Name() , anInPort->PortName() , *(anOutPort->Value()) ) ;
+//JR 30.03.2005      aGraphOfMacroGraph->AddInputData( Name() , anInPort->PortName() , *(anOutPort->Value()) ) ;
+      aGraphOfMacroGraph->AddInputData( Name() , anInPort->PortName() , anOutPort->Value() ) ;
       anOutPort->PortStatus( ExternConnected ) ;
     }
   }
@@ -685,15 +686,15 @@ GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( c
 
 bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode ,
                                          GraphBase::EndOfLoopNode * anEndLoopNode ) const {
-  cdebug_in << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
+  cdebug_in << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
             << anEndLoopNode->Name() << ") LinkedNodesSize "
             << LinkedNodesSize() << endl;
 
   int i ;
   if ( LinkedNodesSize() == 0 && !IsDataFlowNode() && !IsDataStreamNode() ) {
-    cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name()
+    cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name()
                << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
-               << LinkedNodesSize() << " false" << endl;
+               << LinkedNodesSize() << " WARNING false" << endl;
     return false ;
   }
 // We check that all nodes linked to that node go to the end of LoopNode :
@@ -702,14 +703,14 @@ bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode ,
     cdebug << i << ". " << Name() << " Linked to " << aNode->Name() << endl ;
     if ( !aNode->IsEndLoopNode() || aNode != anEndLoopNode ) {
       if ( !aNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
-        cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name()
+        cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name()
                    << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
-                   << LinkedNodesSize() << " false" << endl;
+                   << LinkedNodesSize() << " WARNING false" << endl;
         return false ;
       }
     }
   }
-  cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
+  cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
              << anEndLoopNode->Name() << ") LinkedNodesSize "
              << LinkedNodesSize() << " true" << endl;
   return true ;
@@ -717,15 +718,15 @@ bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode ,
 
 bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode ,
                                             GraphBase::EndOfLoopNode * anEndLoopNode ) const {
-  cdebug_in << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
+  cdebug_in << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
             << anEndLoopNode->Name() << ") LinkedFromNodesSize "
             << LinkedFromNodesSize() << endl;
 
   int i ;
   if ( LinkedFromNodesSize() == 0 ) {
-    cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name()
+    cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name()
                << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
-               << LinkedFromNodesSize() << " false" << endl;
+               << LinkedFromNodesSize() << " WARNING false" << endl;
     return false ;
   }
 // We have to check that all nodes linked from that node go to the beginning of LoopNode : 
@@ -734,19 +735,128 @@ bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode ,
     cdebug << i << ". " << Name() << " Linked from " << aNode->Name() << endl ;
     if ( !aNode->IsLoopNode() || aNode != aLoopNode ) {
       if ( !aNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
-        cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name()
+        cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name()
                    << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
-                   << LinkedFromNodesSize() << " false" << endl;
+                   << LinkedFromNodesSize() << " WARNING false" << endl;
         return false ;
       }
     }
   }
-  cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
+  cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
              << anEndLoopNode->Name() << ") LinkedFromNodesSize "
              << LinkedFromNodesSize() << " true" << endl;
   return true ;
 }
 
+bool GraphBase::ComputingNode::InitBranchOfSwitchDone(bool AllInit ,
+                                                      GraphBase::EndOfSwitchNode * anEndSwitchNode ) {
+  bool sts = BranchOfSwitchDone( false ) ;
+  if ( !sts && !AllInit && anEndSwitchNode != this ) {
+// Common Node in branchs :
+    cdebug << Name() << "->ComputingNode::InitBranchOfSwitchDone WARNING false"
+           << endl ;
+    return 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 ;
+      }
+    }
+  }
+  return true ;
+}
+
+bool GraphBase::ComputingNode::CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwitchNode ) {
+  cdebug_in << Name() << "->ComputingNode::CheckSwitch( "
+            << anEndSwitchNode->Name() << " ) " << Kind() << endl;
+  if ( anEndSwitchNode == this ) {
+  }
+// if it is a SwitchNode, continue the check at the corresponding EndSwitchNode
+  else if ( IsSwitchNode() ) {
+    GraphBase::EndOfSwitchNode * anOtherEndSwitchNode ;
+    anOtherEndSwitchNode = (GraphBase::EndOfSwitchNode * ) ((GraphBase::SwitchNode * ) this)->CoupledNode() ;
+    cdebug << Name() << "->ComputingNode::CheckSwitch will Check "
+           << anOtherEndSwitchNode->Name() << endl ;
+    if ( !anOtherEndSwitchNode->CheckSwitch( anEndSwitchNode ) ) {
+      cdebug_out << Name() << "->ComputingNode::CheckSwitch "
+                 << anOtherEndSwitchNode->Name() << " WARNING false" << endl;
+      return false ;
+    }
+  }
+  else {
+    int i ;
+    for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+      GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
+      if ( !anOutPort->IsDataStream() ) {
+        int j ;
+        for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
+          GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
+          if ( !anInPort->IsDataStream() ) {
+            GraphBase::ComputingNode * aNode ;
+            aNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ;
+            GraphBase::LoopNode * aLoopNode = NULL ;
+            GraphBase::EndOfLoopNode * aEndLoopNode = NULL ;
+            if ( IsLoopNode() ) {
+              aEndLoopNode = (GraphBase::EndOfLoopNode * ) ((GraphBase::LoopNode * ) this)->CoupledNode() ;
+              cdebug << Name() << "->ComputingNode::CheckSwitch LoopNode " << Name() << " coupled to "
+                     << aEndLoopNode << " " << aEndLoopNode->Name() << " aNode " << aNode << endl ;
+            }
+            else if ( IsEndLoopNode() ) {
+              aLoopNode = (GraphBase::LoopNode * ) ((GraphBase::EndOfLoopNode * ) this)->CoupledNode() ;
+              cdebug << Name() << "->ComputingNode::CheckSwitch EndLoopNode " << Name()
+                     << " coupled to "
+                     << aLoopNode << " " << aLoopNode->Name() << " aNode " << aNode << endl ;
+            }
+            if ( aNode == NULL ) {
+              cdebug << Name() << "->ComputingNode::CheckSwitch ignore "
+                     << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
+            }
+            else if ( aNode == anEndSwitchNode ) {
+              ((GraphBase::EndOfSwitchNode * ) aNode)->DecrEndSwitchInPortLinked( anInPort ) ;
+            }
+            else if ( aNode->BranchOfSwitchDone() ) {
+              cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
+                     << anInPort->NodeName() << "( " << anInPort->PortName() << " ) : already checked"
+                     << endl ;
+            }
+            else if ( IsLoopNode() && aNode == aEndLoopNode ) {
+              cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
+                     << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
+            }
+            else if ( IsEndLoopNode() && aNode == aLoopNode ) {
+              cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
+                     << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
+            }
+            else if ( aNode->IsGOTONode() ) {
+              cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
+                     << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
+              anEndSwitchNode->SetSwitchWithGOTO() ;
+            }
+            else {
+              cdebug << Name() << "->ComputingNode::CheckSwitch will Check "
+                     << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
+              if ( !aNode->CheckSwitch( anEndSwitchNode ) ) {
+                cdebug_out << Name() << "->ComputingNode::CheckSwitch "
+                         << anEndSwitchNode->Name() << " WARNING false" << endl;
+                return false ;
+             }
+//            aNode->BranchOfSwitchDone( true ) ;
+            }
+          }
+        }
+      }
+    }
+  }
+  BranchOfSwitchDone( true ) ;
+  cdebug_out << Name() << "->ComputingNode::CheckSwitch BranchOfSwitchDone == true "
+             << anEndSwitchNode->Name() << " true" << endl;
+  return true ;
+}
+
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <unistd.h>
@@ -1207,6 +1317,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
                                        const ListOfFuncName FuncNames ,
                                        const ListOfPythonFunctions PythonFunctions ,
                                        int XCoordinate , int YCoordinate ) const {
+  cdebug_in << "ComputingNode::SavePY " << Name() << endl ;
   // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
   if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
@@ -1215,7 +1326,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
       f << "    " << Name() << ".SetCoupled( '"
         << ((GraphBase::GOTONode * ) this)->CoupledNodeName() << "' )" << endl ;
     }
- }
 }
   else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
     f << "    " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
     long Timeout ;
@@ -1312,6 +1423,8 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
 //      strcpy( EndName , "End" ) ;
 //      strcat( EndName , Name() ) ;
       char * EndName = aCoupledNode->Name() ;
+      cdebug << "ComputingNode::SavePY Node " << Name() << " EndName " << EndName
+             << endl ;
       if ( IsLoopNode() ) {
         int i ;
         SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
@@ -1499,7 +1612,11 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
          }
         }
       }
-      delete [] EndName ;
+      cdebug << "ComputingNode::SavePY Node " << Name() << " EndName " << EndName
+             << endl ;
+// PAL8507
+//JR 24.02.2005 Debug !!!... : I should not delete myself : what a stupid thing !
+//      delete [] EndName ;
     }
   }
 
@@ -1627,6 +1744,9 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
     }
   }
 
+  cdebug_out << "ComputingNode::SavePY " ;
+  NodeInfo( *_fdebug ) ;
+  cdebug << endl ;
   return true ;
 }