]> AND Private Git Repository - blast.git/blobdiff - Parameters.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
added admittance computation
[blast.git] / Parameters.cpp
index 12f5b2b0e44e73d5cdeae81562323be4db7550d6..322046d562819e107c937856ef2536e2edf8ba31 100644 (file)
@@ -9,6 +9,7 @@
 #include "GroupScene.h"\r
 #include "GroupItem.h"\r
 #include "BoxItem.h"\r
 #include "GroupScene.h"\r
 #include "GroupItem.h"\r
 #include "BoxItem.h"\r
+#include "SourceItem.h"\r
 #include "InterfaceItem.h"\r
 #include "ConnectionItem.h"\r
 \r
 #include "InterfaceItem.h"\r
 #include "ConnectionItem.h"\r
 \r
@@ -232,6 +233,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     if (idUpperScene != -1) {\r
       groupWidget->setWindowTitle(groupBlock->getName());\r
       groupWidget->show();\r
     if (idUpperScene != -1) {\r
       groupWidget->setWindowTitle(groupBlock->getName());\r
       groupWidget->show();\r
+      cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl;\r
     }    \r
   }\r
   dispatcher->setSceneCounter(maxIdScene+1);\r
     }    \r
   }\r
   dispatcher->setSceneCounter(maxIdScene+1);\r
@@ -249,7 +251,29 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     GroupScene *currentScene = searchSceneById(idScene,topScene);\r
 \r
     if(currentScene == NULL) throw(Exception(PROJECTFILE_CORRUPTED));\r
     GroupScene *currentScene = searchSceneById(idScene,topScene);\r
 \r
     if(currentScene == NULL) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
+    /**********************************************************\r
+     2.1 : getting sources if it is top scene\r
+    ***********************************************************/\r
+    if (currentScene->isTopScene()) {\r
+      QDomNodeList sourceNodes = currentSceneNode.elementsByTagName("source_item");\r
+      cout << "top scene has " << sourceNodes.length() << " sources" << endl;\r
+      for(int j=0; j<sourceNodes.length(); j++) {\r
+        QDomElement currentSBNode = sourceNodes.at(j).toElement();      \r
+        SourceItem* sourceItem = new SourceItem(dispatcher,this);\r
+        try {\r
+          sourceItem->load(currentSBNode);\r
+        }\r
+        catch(Exception err) {\r
+          throw(err);\r
+        }\r
+        cout << "source item has been read, add it to the scene" << endl;\r
+        // add the block to the GroupScene\r
+        currentScene->addSourceItem(sourceItem);\r
+      } \r
+    }\r
+    /**********************************************************\r
+     2.2 : getting functional blocks\r
+    ***********************************************************/\r
     QDomNodeList functionalBlockNodes = currentSceneNode.elementsByTagName("bi_functional");\r
 \r
     for(int j=0; j<functionalBlockNodes.length(); j++) {\r
     QDomNodeList functionalBlockNodes = currentSceneNode.elementsByTagName("bi_functional");\r
 \r
     for(int j=0; j<functionalBlockNodes.length(); j++) {\r
@@ -306,7 +330,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
       // get the GroupItem already created and set at phase 1\r
       GroupItem *insideGroup = searchGroupItemById(idGroup, topScene);\r
       BoxItem* upperItem = NULL;\r
       // get the GroupItem already created and set at phase 1\r
       GroupItem *insideGroup = searchGroupItemById(idGroup, topScene);\r
       BoxItem* upperItem = NULL;\r
-      if(insideGroup == NULL) cout << "group null" << endl;\r
+      if(insideGroup == NULL) cout << "group null" << endl;      \r
       // now search within the scene which BoxItem has a childItem that is = to insideGroup\r
       QList<BoxItem *> lst = currentScene->getBoxItems();\r
       foreach(BoxItem* item, lst) {\r
       // now search within the scene which BoxItem has a childItem that is = to insideGroup\r
       QList<BoxItem *> lst = currentScene->getBoxItems();\r
       foreach(BoxItem* item, lst) {\r
@@ -342,10 +366,10 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
         double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
         if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
 \r
         double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
         if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
 \r
-        ConnectedInterface *refInter = insideGroup->searchInterfaceByName(refName)->refInter;\r
+        ConnectedInterface *refInter = insideGroup->searchInterfaceItemByName(refName)->refInter;\r
         InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, upperItem, this);\r
         ifaceItem->setId(id);\r
         InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, upperItem, this);\r
         ifaceItem->setId(id);\r
-        upperItem->addInterface(ifaceItem);\r
+        upperItem->addInterfaceItem(ifaceItem);\r
       }\r
     }\r
   }\r
       }\r
     }\r
   }\r
@@ -367,7 +391,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);\r
 \r
     if(iface1 != NULL && iface2 != NULL){\r
     InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);\r
 \r
     if(iface1 != NULL && iface2 != NULL){\r
-      dispatcher->createConnectionItem(iface1,iface2);\r
+      dispatcher->createConnection(iface1,iface2);\r
     } else {\r
       cout << "interfaces not found, connect canceled!" << endl;\r
     }\r
     } else {\r
       cout << "interfaces not found, connect canceled!" << endl;\r
     }\r
@@ -683,6 +707,12 @@ void Parameters::loadImplementationsFromXml() throw(Exception) {
       QString refXml = implRoot.attribute("ref_name","none");\r
       QString refMd5 = implRoot.attribute("ref_md5","none");\r
       BlockImplementation* impl = new BlockImplementation(fileName,refXml,refMd5);\r
       QString refXml = implRoot.attribute("ref_name","none");\r
       QString refMd5 = implRoot.attribute("ref_md5","none");\r
       BlockImplementation* impl = new BlockImplementation(fileName,refXml,refMd5);\r
+      try {\r
+        impl->loadPatterns(implRoot);\r
+      }\r
+      catch(int err) {\r
+        throw(err);\r
+      }\r
       availableImplementations.append(impl);\r
 \r
       ReferenceBlock* ref = NULL;\r
       availableImplementations.append(impl);\r
 \r
       ReferenceBlock* ref = NULL;\r
@@ -694,9 +724,12 @@ void Parameters::loadImplementationsFromXml() throw(Exception) {
       }\r
       if (ref == NULL) {\r
         cout << "Cannot find a reference block for impl :" << qPrintable(fileName) << endl;\r
       }\r
       if (ref == NULL) {\r
         cout << "Cannot find a reference block for impl :" << qPrintable(fileName) << endl;\r
-      }\r
-      ref->addImplementation(impl);\r
-      impl->setReference(ref);\r
+      }      \r
+      else {          \r
+        ref->addImplementation(impl);\r
+        impl->setReference(ref);\r
+        if (! impl->checkPatterns()) throw(Exception(IMPLFILE_CORRUPTED));\r
+      }      \r
       cout << "OK" << endl;\r
     }\r
   }\r
       cout << "OK" << endl;\r
     }\r
   }\r
@@ -741,8 +774,11 @@ void Parameters::loadImplementationsFromLib() throw(Exception) {
     if (ref == NULL) {\r
       cout << "Cannot find a reference block for impl :" << qPrintable(impl->getXmlFile()) << endl;\r
     }\r
     if (ref == NULL) {\r
       cout << "Cannot find a reference block for impl :" << qPrintable(impl->getXmlFile()) << endl;\r
     }\r
-    ref->addImplementation(impl);\r
-    impl->setReference(ref);\r
+    else {          \r
+      ref->addImplementation(impl);\r
+      impl->setReference(ref);\r
+      if (! impl->checkPatterns()) throw(Exception(IMPLFILE_CORRUPTED));\r
+    }\r
   }\r
   libFile.close();\r
 }\r
   }\r
   libFile.close();\r
 }\r
@@ -1010,6 +1046,15 @@ InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) {
       return item;\r
     }\r
   }\r
       return item;\r
     }\r
   }\r
+  if (scene->isTopScene()) {\r
+    foreach(SourceItem *block, scene->getSourceItems()){\r
+      foreach(InterfaceItem *item, block->getInterfaces()){\r
+        if(item->getId() == id){\r
+          return item;\r
+        }\r
+      }\r
+    } \r
+  }\r
   foreach(BoxItem *block, scene->getBoxItems()){\r
     foreach(InterfaceItem *item, block->getInterfaces()){\r
       if(item->getId() == id){\r
   foreach(BoxItem *block, scene->getBoxItems()){\r
     foreach(InterfaceItem *item, block->getInterfaces()){\r
       if(item->getId() == id){\r