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

Private GIT Repository
start modifying read/write blocks and project to take into account control ifaces
authorstephane Domas <stephane.domas@univ-fcomte.fr>
Mon, 8 May 2017 18:46:44 +0000 (20:46 +0200)
committerstephane Domas <stephane.domas@univ-fcomte.fr>
Mon, 8 May 2017 18:46:44 +0000 (20:46 +0200)
26 files changed:
AbstractBoxItem.cpp
AbstractBoxItem.h
BoxItem.cpp
BoxItem.h
ConnectionItem.cpp
ConnectionItem.h
Dispatcher.cpp
Dispatcher.h
GroupInterface.cpp
GroupInterface.h
GroupItem.cpp
GroupItem.h
InterfaceItem.cpp
InterfaceItem.h
ReferenceBlock.cpp
blast.creator.user
blastconfig.xml
block-1I1O.xml
block-2I2O.xml
block-2INO.xml
lib/references/apf27-wb-master.xml
lib/references/average-Nx3.xml
lib/references/demux.xml
lib/references/multadd.xml
lib/references/references.bmf
projectfile.xsd

index a05247f0ffbc0ce8d627d91c65218b3955e51e4e..b76bf667b798e2190e7c9af53a0ffd596758fa18 100644 (file)
@@ -128,7 +128,11 @@ void AbstractBoxItem::initInterfaces() {
   int orientation = Parameters::West;
 
   foreach(AbstractInterface *inter, refBlock->getInterfaces()){
-    
+   
+    /* NB: create InterfaceItem for every interfaces, even if they do not have a graphical representation
+       It will allow to save them in the XML project file and thus to create their equivalent
+       in the graph while the file is loaded.      
+    */
     InterfaceItem *item;
     if(inter->getDirection() == AbstractInterface::Input){
       orientation = Parameters::West;
@@ -138,8 +142,8 @@ void AbstractBoxItem::initInterfaces() {
       orientation = Parameters::North;
     }
     item = new InterfaceItem(0.0 , orientation, (ConnectedInterface *)inter, this, params);
-    interfaces.append(item);    
-  }  
+    interfaces.append(item);        
+  }
 }
 
 InterfaceItem* AbstractBoxItem::searchInterfaceByName(QString name) {
index c061487af5f42781da17de45ab80916cf4a49bc5..ed3e1ee74060ae0f0c696304d5068ae900cc220a 100644 (file)
@@ -59,6 +59,7 @@ public:
 
   // others
 
+  virtual void interfaceRenamed() = 0;
   void addInterface(InterfaceItem* i, bool resetPosition = false);
   void removeInterface(InterfaceItem* i);
   void resetInterfacesPosition();
index de22f19ce472c4ca8c651e23fe233f5fcb9a13c9..a107198654913fdc6badc66bc19ed9b13f784d47 100644 (file)
@@ -207,6 +207,13 @@ bool BoxItem::updateGeometry(ChangeType type) {
   return false;
 }
 
+void BoxItem::interfaceRenamed() {
+  if (updateGeometry(InterfaceMove)) {
+    //cout << "must recompute group item geometry" << endl;
+    (getScene()->getGroupItem())->updateShape();
+  }  
+}
+
 void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
 
   if(params->editState == Parameters::EditBlockMove) {
@@ -282,7 +289,7 @@ void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
     moveInterfaceTo(event->pos());
     // recompute the geometry of the block
     if (updateGeometry(InterfaceMove)) {
-      cout << "must recompute group item geometry" << endl;
+      //cout << "must recompute group item geometry" << endl;
       (getScene()->getGroupItem())->updateShape();
     }
     // update connection from/to the selected interface
@@ -577,7 +584,7 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
 
   if (selectedAction == removeAction) {
     if(ifaceItem != NULL) {
-     dispatcher->removeBlockInterface(ifaceItem);
+     dispatcher->removeFunctionalInterface(ifaceItem);
     }
     else {
       dispatcher->removeBlock(this);
@@ -648,7 +655,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
   int dimY = dimensionStr.at(1).toInt(&ok);
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
-
+  
   ReferenceBlock *referenceMd5 = NULL;
   ReferenceBlock *referenceXml = NULL;
   ReferenceBlock *reference = NULL;
@@ -667,6 +674,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
   else {
     reference = referenceMd5;
   }
+  
   GroupBlock* parentGroupBlock = AB_TO_GRP(((GroupItem *)parentItem())->getRefBlock());
   FunctionalBlock* functionalBlock = params->getGraph()->addFunctionalBlock(parentGroupBlock, reference);
   /* NB: addFunctionalBlock creates all interfaces from the reference, which is annoying when
@@ -695,9 +703,9 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
     blockParam = functionalBlock->getParameterFromName(name);
     if (blockParam == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
     blockParam->setValue(value);
-  }
+  }  
 
-  // recreate all interface because of some may have a multiplicity>1 with several examplars
+  // recreate all (non-control) interfaces because of some may have a multiplicity>1 with several examplars
   functionalBlock->removeAllInterfaces();
   QDomNodeList interfaceNodes = funcElement.elementsByTagName("bif_iface");
   // setting interfaces (user name, and for multiplicity>1 may be create some new ones)
@@ -712,10 +720,26 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
     if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));
 
     ReferenceInterface* refInter = AI_TO_REF(reference->getIfaceFromName(refName));
+    cout << "creating iface from reference named " << qPrintable(refName) << endl;
     FunctionalInterface *functionalInterface = new FunctionalInterface(functionalBlock,refInter);
     functionalInterface->setName(name);
     functionalBlock->addInterface(functionalInterface);
+    
+    // searching for control interface
+    QString ctlRefName = refName+"_ctl";
+    ReferenceInterface* ctlRefIface = AI_TO_REF(reference->getIfaceFromName(ctlRefName));
+    
+    if (ctlRefIface != NULL) {
+      cout << "found a control iface:" << qPrintable(ctlRefName) << endl;
+      FunctionalInterface *ctlIface = new FunctionalInterface(functionalBlock,ctlRefIface);      
+      if (! ctlIface->setAssociatedIface(functionalInterface)) {
+        throw(Exception(PROJECTFILE_CORRUPTED));
+      }      
+      ctlIface->setName(name+"_ctl");
+      functionalBlock->addInterface(ctlIface);
+    }    
   }
+  
   // creating InterfaceItem
   initInterfaces();
   // setting them with saved values
@@ -752,7 +776,7 @@ void BoxItem::save(QXmlStreamWriter &writer) {
     writer.writeAttribute("ref_xml", ((FunctionalBlock*)refBlock)->getReferenceXmlFile());
     writer.writeAttribute("ref_md5", ((FunctionalBlock*)refBlock)->getReferenceHashMd5());
     writer.writeAttribute("name",refBlock->getName());
-    QString attrPos = QString::number(pos().x()).append(",").append(QString::number(pos().y()));
+    QString attrPos = QString::number((int)(pos().x())).append(",").append(QString::number((int)(pos().y())));
     writer.writeAttribute("position",attrPos);
     QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
     writer.writeAttribute("dimension",attrDim);
index 35a12a84cf71900a6dc58c85e66684748656b0e7..a80f9f03078fae6dd0c3e1cefe5cd27a626d8126 100644 (file)
--- a/BoxItem.h
+++ b/BoxItem.h
@@ -46,6 +46,7 @@ public:
   bool isBoxItem();
 
   // others
+  void interfaceRenamed();
   void moveTo(QPointF dest);
   void loadFunctional(QDomElement funcElement) throw(Exception);
   void save(QXmlStreamWriter& writer);
index eaf46c22482f751fd926dae6b02dd068f0fc60ec..78a3651dea989cac1ff8f34033bf296f3f213899 100644 (file)
@@ -84,6 +84,13 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1,
   setFlag(ItemSendsGeometryChanges);
   setCursor(Qt::PointingHandCursor);
   setZValue(0);
+  
+  if (fromInterfaceItem->refInter->getPurpose() == AbstractInterface::Data) {
+    visible = true;
+  }
+  else {
+    visible = false;
+  }
 
   setPath();
 }
@@ -133,6 +140,8 @@ void ConnectionItem::paint(QPainter *painter,
                            const QStyleOptionGraphicsItem *option,
                            QWidget *widget) {
 
+  if (!visible) return;
+  
   painter->setPen(Qt::blue);
   if(selected){
     painter->setPen(Qt::red);
index 6370c90d31ec3b6ed62effbae538d9e6d703baab..c64839f0c69cf0628a7ee01731aab0d9139c50bf 100644 (file)
@@ -51,17 +51,24 @@ public:
   QPainterPath shape() const;
 
   void prepareChange();
-
+  
+  // getters
   inline GroupScene* getScene() { return (GroupScene*)(scene()); }
   inline InterfaceItem* getToInterfaceItem(){ return toInterfaceItem; }
-  inline void setToInterfaceItem(InterfaceItem *iface){ toInterfaceItem = iface; }
   inline InterfaceItem* getFromInterfaceItem(){ return fromInterfaceItem; }
-  inline void setFromInterfaceItem(InterfaceItem* iface){ fromInterfaceItem = iface; }
   inline int getId(){ return id; }
+  
+  // setters
+  inline void setToInterfaceItem(InterfaceItem *iface){ toInterfaceItem = iface; }  
+  inline void setFromInterfaceItem(InterfaceItem* iface){ fromInterfaceItem = iface; }  
   inline void setId(int id){ this->id = id; }
-  inline bool isSelected() { return selected; }
   void setSelected(bool selected);
-
+  inline void setVisible(bool state) { visible = state; }
+  
+  // testers
+  inline bool isSelected() { return selected; }
+  
+  // others
   void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
 
   /*!
@@ -87,7 +94,14 @@ protected:
   void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
 
 private:
-
+  void computeEsse(int orientationFrom);
+  void computeStaircase(int orientationFrom);
+  void computeHookSmallEnd(int orientationFrom, int orientationTo);
+  void computeHookSmallStart(int orientationFrom, int orientationTo);
+  void computeOpenRect(int orientationFrom, int orientationTo);
+  void computeElle(int orientationFrom);
+  void computeCorner(int orientationFrom);
+  
   QPointF pointFrom;
   QPointF pointTo;
   QList<QPointF> interPoints;
@@ -106,13 +120,8 @@ private:
   bool selected;
   int id;
   int marginConn;
-  void computeEsse(int orientationFrom);
-  void computeStaircase(int orientationFrom);
-  void computeHookSmallEnd(int orientationFrom, int orientationTo);
-  void computeHookSmallStart(int orientationFrom, int orientationTo);
-  void computeOpenRect(int orientationFrom, int orientationTo);
-  void computeElle(int orientationFrom);
-  void computeCorner(int orientationFrom);
+  
+  bool visible;
 
   friend QDataStream &operator << (QDataStream &out, ConnectionItem &c);
   friend QDataStream &operator >> (QDataStream &in, ConnectionItem &c);
index b6495bb4b536cb03706dc9acdb108b1f27958506..ac0862ca64a60e8508b411643a8c3b08f3e0b49a 100644 (file)
@@ -224,28 +224,40 @@ void Dispatcher::renameInterface(InterfaceItem *item) {
   cout << "call to " << qPrintable(fctName) << endl;
 #endif
 
-  bool ok;
-  QString text = QInputDialog::getText(NULL, "Rename an interface",
+  bool ok = false;
+  QString text = "";
+  while (!ok) {
+    text = QInputDialog::getText(NULL, "Rename an interface",
                                        "New name:", QLineEdit::Normal,
                                        item->refInter->getName(), &ok);
-
-  /* CAUTION: when renaming an interface item, there are two cases :
-     - it refers to a functional block interface (fbi): the fbi keeps its name
-     and the new name is given to item
-     - it refers to a group block interface (gbi) : both gbi and item store the new name
-
-   */
-  if(ok && !text.isEmpty() && text.length() < 30) {
-    if (item->refInter->getOwner()->isGroupBlock()) {
-      item->refInter->setName(text);
+   
+    if (!ok) return;
+    
+    if (text == item->refInter->getName()) return;
+    
+    if( (text.isEmpty()) || (text.length() > 30)) {
+      QMessageBox::warning(NULL,"Error in given name",
+                           "the interface name must be shorter than 30 characters, cannot be empty",
+                           QMessageBox::Ok);
+      ok = false;
+    }
+    else {
+      AbstractInterface* iface = item->refInter->getOwner()->getIfaceFromName(text);
+      if (iface != NULL) {
+        QMessageBox::warning(NULL,"Error in given name",
+                             "the name provided is similar to that of another interface",
+                             QMessageBox::Ok);
+        ok = false;
+      }
     }
   }
-  else {
-    QMessageBox::warning(NULL,"Error in given name",
-                         "the interface name must be shorter than 30 characters and can't be empty!",
-                         QMessageBox::Ok);
-    renameInterface(item);
+  item->refInter->setName(text);
+  AbstractInterface* assoIface = item->refInter->getAssociatedIface();
+  if (assoIface != NULL) {
+    assoIface->setName(text+"_ctl");
   }
+  item->updateName(text);
+  item->getOwner()->interfaceRenamed();  
 }
 
 void Dispatcher::duplicateBlock(BoxItem *item){
@@ -284,16 +296,26 @@ void Dispatcher::duplicateInterface(InterfaceItem *item) {
   if(! refB->isFunctionalBlock()) return;
 
   FunctionalInterface* iface = (FunctionalInterface*)refI;
-  AbstractInterface *otherRef = iface->clone();
-  if (otherRef == NULL) {
+  AbstractInterface *cloneIface = iface->clone();
+  if (cloneIface == NULL) {
     QMessageBox::warning(NULL,"Error while cloning an interface","the interface cannot be cloned because its maximum multiplicity is reached", QMessageBox::Ok);
     return;
   }
 
-  refB->addInterface(otherRef);
+  refB->addInterface(cloneIface);
 
-  InterfaceItem *otherIface = new InterfaceItem(item->getPosition(),item->getOrientation(),(ConnectedInterface*)otherRef,item->getOwner(),params);
-  item->getOwner()->addInterface(otherIface,true);
+  InterfaceItem *cloneIfaceItem = new InterfaceItem(item->getPosition(),item->getOrientation(),(ConnectedInterface*)cloneIface,item->getOwner(),params);
+  item->getOwner()->addInterface(cloneIfaceItem,true);
+  
+  // creating control interface if needed
+  if (refI->getAssociatedIface() != NULL) {
+    QString ctlName = cloneIface->getName()+"_ctl";
+    ReferenceInterface* ctlIface = new ReferenceInterface(refB,ctlName,"boolean","1",cloneIface->getDirection(), AbstractInterface::Control, 1);
+    refB->addInterface(ctlIface);
+    if (! ctlIface->setAssociatedIface(cloneIface)) {
+      cerr << "Abnormal case while cloning an interface and creating its associated control interface" << endl;
+    }
+  }
 }
 
 
@@ -814,7 +836,7 @@ void Dispatcher::connectInterToGroup(InterfaceItem *item){
   GroupItem *parentItem = item->getOwner()->getScene()->getGroupItem();
 
   // creating/adding the group interface in the graph model
-  GroupInterface *groupInter = new GroupInterface(parentBlock,refInter->getName()+"_group",refInter->getDirection());
+  GroupInterface *groupInter = new GroupInterface(parentBlock,refInter->getName()+"_group",refInter->getDirection(),refInter->getPurpose());
   groupInter->setType(refInter->getType());
   groupInter->setWidth(refInter->getWidth());
   groupInter->setPurpose(refInter->getPurpose());
@@ -956,7 +978,7 @@ void Dispatcher::disconnectInterFromGroup(InterfaceItem *item) {
 #endif
 
 }
-void Dispatcher::removeBlockInterface(InterfaceItem *item) {
+void Dispatcher::removeFunctionalInterface(InterfaceItem *item) {
   static QString fctName = "Dispatcher::removeBlockInterface()";
 #ifdef DEBUG_FCTNAME
   cout << "call to " << qPrintable(fctName) << endl;
index 61c41cb6cf1a6f84df00e44753e1d11972347c33..8ffce457a598e488e5a284f13407b1e66882f9f6 100644 (file)
@@ -90,14 +90,14 @@ public slots:
    */
   void disconnectInterFromGroup(InterfaceItem* item);
   /*!
-   * \brief removeBlockInterface
+   * \brief removeFunctionalInterface
    * \param item item is always owned by a BoxItem
    *
    * This method is called only when the user right clicks on an InterfaceItem (that belongs
-   * to a BoxItem and has a multiplicity > 1) and chooses remove in the contextual menu.
+   * to a BoxItem that represents a functional block and has a multiplicity > 1) and chooses remove in the contextual menu.
    * Thus, parameter item is always owned by a BoxItem
    */
-  void removeBlockInterface(InterfaceItem* item);
+  void removeFunctionalInterface(InterfaceItem* item);
   /*!
    * \brief removeGroupInterface
    * \param item item is always owned by a GroupItem
index 1c10bffba03f2b4eeeddd8c8f3ff35f233dce163..7fc8745e032e9ea82adac25b985bd0e8f9a29bb6 100644 (file)
@@ -2,7 +2,7 @@
 #include "FunctionalInterface.h"
 #include "GroupBlock.h"
 
-GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction) throw(Exception) : ConnectedInterface(_owner,_name,"expression","",_direction,AbstractInterface::Data) {
+GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,"expression","",_direction,_purpose) {
   if (! _owner->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));
 
   connectedFrom = NULL;
@@ -13,10 +13,8 @@ bool GroupInterface::isGroupInterface() {
 }
 
 AbstractInterface *GroupInterface::clone() {
-    GroupInterface *inter = new GroupInterface(owner,name,direction);
-    inter->setWidth(width);
-    inter->setDirection(direction);
-    inter->setPurpose(purpose);    
+    GroupInterface *inter = new GroupInterface(owner,name,direction, purpose);
+    inter->setWidth(width);    
     inter->connectFrom(NULL);
 
     return inter;
index d487ebce4a7be3a35f9857d49cbb56884243b83d..49b4957eacfee2f42c5c204e2c401c153b0e2d44 100644 (file)
@@ -34,7 +34,7 @@ using namespace Qt;
 class GroupInterface : public ConnectedInterface {
 
 public :
-  GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction) throw (Exception);
+  GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw (Exception);
 
   // getters
 
index 679cc5e7498310cf06767cc0e9469dc4462a1ae5..5d843811941a6bbd3334858beab637d8f6ac5232 100644 (file)
@@ -266,6 +266,11 @@ bool GroupItem::updateGeometry(ChangeType type) {
   return false;
 }
 
+void GroupItem::interfaceRenamed() {
+  updateGeometry(InterfaceMove);     
+}
+
+
 void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
 
   if(params->editState == Parameters::EditGroupMove) {
@@ -647,7 +652,7 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) {
     double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
 
-    GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction);
+    GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction,AbstractInterface::Data);
 
     InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupInterface,this,params);
     interfaceItem->setId(id);
@@ -669,7 +674,7 @@ void GroupItem::save(QXmlStreamWriter &writer) {
   if(parentItem != NULL){
     attrUpperItem = QString::number(parentItem->getId());
   }
-  QString attrPos = QString::number(pos().x()).append(",").append(QString::number(pos().y()));
+  QString attrPos = QString::number((int)(pos().x())).append(",").append(QString::number((int)(pos().y())));
   QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
 
 
index 137ff03f4723c5b07d1ec6816c270f363da5b288..881180ccc17f00bd0dca72edb5f71502b6f2e2fe 100644 (file)
@@ -47,6 +47,7 @@ public:
   bool isGroupItem();
 
   // others  
+  void interfaceRenamed();
   void updateShape();
   void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);  
   void load(QDomElement groupElement) throw(Exception);
index 7c384d286709e06039ea3d6f909e9dc8f7828df7..0047e16f5a810aef7e76f06d88f251e40cf15953 100644 (file)
@@ -45,6 +45,14 @@ QString InterfaceItem::getName() {
   return refInter->getName();
 }
 
+void InterfaceItem::updateName(QString name) {  
+  QFontMetrics fmName(params->defaultIfaceFont);
+  nameWidth = fmName.width(refInter->getName());
+  nameHeight = fmName.height();
+  updatePosition();
+}
+
+
 /* boundingRect() : give the bounding rect in the blockitem coord. system */
 QRectF InterfaceItem::boundingRect() const {
 
@@ -227,157 +235,7 @@ int InterfaceItem::getIntOrientation(QString str) {
 }
 
 
-/* connectWith() :
-  - modify all necessary attributes in the model to create a connection
-  between current InterfaceItem and iface. Note that the source and destination
-  are deduced from the direction (In, Out) and the type of the owner (funcitonal, group)
-
-  CAUTION: No security checks are done. This method must be called only if canConnectWith has been called and returned true.
-
-  NOTE : conditions so that this InterfaceItem can be connected with inter.
-     (i.e. current one can connect to inter OR inter can connect to current)
-
-     Here are all the possible combinations, depending on the type of the
-     block/item and direction of the interface, which are :
-     GI/GB : a GroupItem referencing a GroupBlock (single solution for GI)
-     BI/FB : a BlockItem referencing a FunctionalBlock
-     BI/GB : a BlockItem referencing a GroupBlock
-
-     For GI/GB:
-     - Input can connect with BI/FB or BI/GB Input
-     - Output can connect with BI/FB or BI/GB Output
-
-     For BI/FB:
-     - Input can connect with:
-         GI/GB Input
-         BI/FB Output
-         BI/GB Output
-     - Output can connect with:
-         GI/GB Output
-         BI/FB Input
-         BI/GB Input
-
-     For BI/GB:
-     - Input can connect with:
-         GI/GB Input
-         BI/FB Output
-         BI/GB Output
-     - Output can connect with:
-         GI/GB Output
-         BI/FB Input
-         BI/GB Input
-
-    And whatever the case an InOut can only connect with an InOut
-    We note that:
-       - the IG does not allow the connect a GI/GB interface to an
-       interface of another GI/GB, thus the case is not considered above.
-       - BI/FB and BI/GB are the same.
-       - the cases where direction are the same only occur when
-       the 2 items are of different type (GI and BI)
-       - the cases where directions are different only occur when
-       the 2 are of both BlockItem
-
-*/
-bool InterfaceItem::connectWith(InterfaceItem *iface) {
-  ConnectedInterface* interThis = refInter; // the reference of this
-  ConnectedInterface* interOther = iface->refInter; // the reference of the other
-  ConnectedInterface* src = NULL, *dest = NULL;
-
-  if(interThis->getDirection() == AbstractInterface::InOut && interOther->getDirection() == AbstractInterface::InOut){
-    /* NOTE: InOut interfaces have both directions and thus are
-       connected from inter1 to inter2 AND inter2 to inter1
-       Another effect is that a InOut can be connected to/from a single
-       InOut.
-    */
-    if((interThis->getConnectedFrom() == NULL) && (interOther->getConnectedFrom() == NULL)) {
-
-      interOther->connectFrom(interThis);
-      interOther->getConnectedTo().append(interThis);
-      interThis->connectFrom(interOther);
-      interThis->getConnectedTo().append(interOther);
-
-      cout << "connecting 2 InOut"<< endl;
-      return true;
-    }
-    return false;
-  }
-  else if (interThis->getDirection() == interOther->getDirection()) {
-
-    // cannot connect  GI to GI or 2 BI of the same direction.
-    if ((getOwner()->isGroupItem()) && (iface->getOwner()->isGroupItem())) return false;
-    if ((getOwner()->isBoxItem()) && (iface->getOwner()->isBoxItem())) return false;
-
-    if (interThis->getDirection() == AbstractInterface::Input) { // both are inputs
-      cout << "connecting GI to BI" << endl;
-      if(getOwner()->isGroupItem()) {
-        src = interThis;
-        dest = interOther;
-      }
-      else {
-        src = interOther;
-        dest = interThis;
-      }
-    }
-    else { // both are outputs
-      cout << "connecting BO to GO" << endl;
-      if(getOwner()->isGroupItem()){
-        src = interOther;
-        dest = interThis;
-      }
-      else {
-        src = interThis;
-        dest = interOther;
-      }
-    }
-  }
-  else {
-    if ((getOwner()->isGroupItem()) || (iface->getOwner()->isGroupItem())) return false;
-
-    cout << "connecting BO to BI" << endl;
-    if(interOther->getDirection() == AbstractInterface::Output) {
-      src = interOther;
-      dest = interThis;
-    }
-    else {
-      src = interThis;
-      dest = interOther;
-    }
-  }
-
-  if(dest != NULL && src != NULL){
-    // cannot overrive existing connectionFrom
-    if(dest->getConnectedFrom() == NULL) {
-      dest->connectFrom(src);
-      src->connectTo(dest);
-      return true;
-    }
-    else {
-      return false;
-    }
-  }
-  return false;
-}
-
-void InterfaceItem::unconnectTo(InterfaceItem *iface)
-{
-  if(iface->refInter->getConnectedFrom() == refInter){
-    iface->refInter->connectFrom(NULL);
-  }
-  if(iface->refInter->getConnectedTo().contains(refInter)){
-    cout << "abnormal case while removing iface conn from " << qPrintable(refInter->getName()) << " to " << qPrintable(iface->refInter->getName()) << endl;
-    iface->refInter->removeConnectedTo(refInter);
-  }
-  if(refInter->getConnectedFrom() == iface->refInter) {
-    cout << "abnormal case while removing iface conn from " << qPrintable(refInter->getName()) << " to " << qPrintable(iface->refInter->getName()) << endl;
-    refInter->connectFrom(NULL);
-  }
-  if(refInter->getConnectedTo().contains(iface->refInter)){
-    refInter->removeConnectedTo(iface->refInter);
-  }
-}
-
-void InterfaceItem::updatePosition()
-{
+void InterfaceItem::updatePosition() {
   if(orientation == Parameters::North || orientation == Parameters::South){
     position = positionRatio * owner->getWidth();
   } else {
index ef3b58d4c6ab4e41193fcff04bca65900a7b58ef..ff7b76121513d25c93b62f05ed2640d940d19e39 100644 (file)
@@ -49,11 +49,9 @@ public:
 
   // others
   void addConnectionItem(ConnectionItem* item);
-  void removeConnectionItem(ConnectionItem* item);
-  bool canConnectWith(InterfaceItem* iface);
-  bool connectWith(InterfaceItem* iface);
-  void unconnectTo(InterfaceItem *iface);
+  void removeConnectionItem(ConnectionItem* item);  
   void updatePosition();
+  void updateName(QString name);
 
   AbstractBoxItem* owner;
   ConnectedInterface* refInter;
index e09b1188c0dcb8c30b753d23f24a66fae9862bb2..05fd29a785e921fbf1f42fa1ae6869ca1249ef99 100644 (file)
@@ -256,6 +256,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     if (!inter->setAssociatedIface(dataIface)) {
       throw (Exception(BLOCKFILE_CORRUPTED));      
     }
+    cout << "created a control input named " << qPrintable(inter->getName()) << endl;
     inputs.append(inter);
   }
   QDomElement eltOutputs = eltInputs.nextSiblingElement("outputs");
@@ -287,6 +288,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     if (!inter->setAssociatedIface(dataIface)) {
       throw (Exception(BLOCKFILE_CORRUPTED));      
     }
+    cout << "created a control output named " << qPrintable(inter->getName()) << endl;
     outputs.append(inter);
   }
 
@@ -376,22 +378,50 @@ QDataStream& operator<<(QDataStream &out, const ReferenceBlock &b) {
   }
 
   toWrite << b.inputs.size();
+  // firstly write control ifaces
   for(int i=0; i<b.inputs.size(); i++){
     ReferenceInterface *iface = (ReferenceInterface *)(b.inputs.at(i));
-    toWrite << iface->getName();
-    toWrite << iface->getWidth();
-    toWrite << iface->getPurpose();
-    toWrite << iface->getDirection();    
-    toWrite << iface->getMultiplicity();
+    if (iface->getPurpose() == AbstractInterface::Control) {
+      toWrite << iface->getName();
+      toWrite << iface->getWidth();
+      toWrite << iface->getPurpose();
+      toWrite << iface->getDirection();    
+      toWrite << iface->getMultiplicity();
+    }
+  }
+  // secondly, write other ifaces
+  for(int i=0; i<b.inputs.size(); i++){
+    ReferenceInterface *iface = (ReferenceInterface *)(b.inputs.at(i));
+    if (iface->getPurpose() != AbstractInterface::Control) {
+      toWrite << iface->getName();
+      toWrite << iface->getWidth();
+      toWrite << iface->getPurpose();
+      toWrite << iface->getDirection();    
+      toWrite << iface->getMultiplicity();
+    }
   }
   toWrite << b.outputs.size();
+  // firstly write control ifaces
   for(int i=0; i<b.outputs.size(); i++){
     ReferenceInterface *iface = (ReferenceInterface *)(b.outputs.at(i));
-    toWrite << iface->getName();
-    toWrite << iface->getWidth();
-    toWrite << iface->getPurpose();
-    toWrite << iface->getDirection();    
-    toWrite << iface->getMultiplicity();
+    if (iface->getPurpose() == AbstractInterface::Control) {
+      toWrite << iface->getName();
+      toWrite << iface->getWidth();
+      toWrite << iface->getPurpose();
+      toWrite << iface->getDirection();    
+      toWrite << iface->getMultiplicity();
+    }
+  }
+  // secondly, write other ifaces
+  for(int i=0; i<b.outputs.size(); i++){
+    ReferenceInterface *iface = (ReferenceInterface *)(b.outputs.at(i));
+    if (iface->getPurpose() != AbstractInterface::Control) {
+      toWrite << iface->getName();
+      toWrite << iface->getWidth();
+      toWrite << iface->getPurpose();
+      toWrite << iface->getDirection();    
+      toWrite << iface->getMultiplicity();
+    }
   }
   toWrite << b.bidirs.size();
   for(int i=0; i<b.bidirs.size(); i++){
@@ -474,12 +504,21 @@ QDataStream& operator>>(QDataStream &in, ReferenceBlock &b) {
     in >> txt;
     iface->setWidth(txt);
     in >> val;
-    iface->setPurpose(val);
+    iface->setPurpose(val);    
     in >> val;
     iface->setDirection(val);    
     in >> val;
     iface->setMultiplicity(val);
     b.inputs.append(iface);
+    if (iface->getPurpose() == AbstractInterface::Data) {
+      QString ctlRefName = iface->getName()+"_ctl";
+      ReferenceInterface* ctlRefIface = AI_TO_REF(b.getIfaceFromName(ctlRefName));      
+      if (ctlRefIface != NULL) {        
+        if (! ctlRefIface->setAssociatedIface(iface)) {
+          cerr << "Abnormal case while reading a reference block in library" << endl;
+        }      
+      }        
+    }    
   }
 
   b.outputs.clear();
@@ -491,12 +530,21 @@ QDataStream& operator>>(QDataStream &in, ReferenceBlock &b) {
     in >> txt;
     iface->setWidth(txt);
     in >> val;
-    iface->setPurpose(val);
+    iface->setPurpose(val);    
     in >> val;
     iface->setDirection(val);
     in >> val;   
     iface->setMultiplicity(val);
     b.outputs.append(iface);
+    if (iface->getPurpose() == AbstractInterface::Data) {
+      QString ctlRefName = iface->getName()+"_ctl";      
+      ReferenceInterface* ctlRefIface = AI_TO_REF(b.getIfaceFromName(ctlRefName));      
+      if (ctlRefIface != NULL) {        
+        if (! ctlRefIface->setAssociatedIface(iface)) {
+          cerr << "Abnormal case while reading a reference block in library" << endl;
+        }      
+      }        
+    }    
   }
 
   b.bidirs.clear();
index 570664a3f6b566f7a8ebd808e8c21c0f3400779f..51f5a11003127ff8adaf38bc5e87e4b28ef67021 100755 (executable)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 3.2.1, 2017-05-05T14:29:41. -->
+<!-- Written by QtCreator 3.2.1, 2017-05-08T20:46:10. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
-  <value type="QByteArray">{1d077e47-e3a1-47fd-8b12-4de650e39df5}</value>
+  <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</value>
  </data>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
   <valuemap type="QVariantMap">
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{451ee8a3-56ff-4aba-8a8e-3da882cc142e}</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{2c9bf876-3476-44eb-8065-1f0844704dda}</value>
    <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
-    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/localhome/sdomas/Projet/Blast/code/blast</value>
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/sdomas/Projet/Blast/code/blast</value>
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
       <valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
index 43677e4ce972a421bc1fba7354b76df609c8a467..f827695ee8a3d418ef9c2156520a19d188fd0323 100644 (file)
@@ -1,12 +1,15 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
 <config>
-  <categories nb="6">
+  <categories nb="9">
     <category name="root" id="0" parent="-1"/>
     <category name="math" id="1" parent="0"/>
     <category name="trigonemetric" id="2" parent="1"/>
-    <category name="multadd" id="3" parent="1"/>
-    <category name="dsp" id="4" parent="0"/>
-    <category name="user" id="5" parent="0"/>
+    <category name="arithmetics" id="3" parent="1"/>
+    <category name="filters" id="4" parent="0"/>
+    <category name="wishbone" id="5" parent="0"/>
+    <category name="sources" id="6" parent="0"/>
+    <category name="scopes" id="7" parent="0"/>
+    <category name="user" id="8" parent="0"/>    
   </categories>
 
   <references nb="2" lib_file="/home/sdomas/Projet/Blast/code/blast/lib/references/references.bmf" >
index 32efdb59c97383c5bcf88901aa73815f9946e828..1e05fa5625d6740b3b8332ecc6c858e491124964 100644 (file)
@@ -4,7 +4,7 @@
     <name>
       block-1I1O
     </name>
-    <category ids="1,4" />  
+    <category ids="8" />  
     <description>
       <brief>
        A testing block with 1 input, 1 output
index 54c546065d90cd2fc5c7d38aeb5d89d9a6d47f4a..c8bfdc579bf1dc7ca9879d243256ab2aff9328e6 100644 (file)
@@ -4,7 +4,7 @@
     <name>
       block-2I2O
     </name>
-    <category ids="1,4" />  
+    <category ids="8" />  
     <description>
       <brief>
        A testing block with 2 inputs, 2 outputs
index d6542344a629b52b150cb4a603aea21328d44d38..af3e0dfa16bd51c1441d7bdaad8076ec3579de62 100644 (file)
@@ -4,7 +4,7 @@
     <name>
       block-2INO
     </name>
-    <category ids="1,4" />  
+    <category ids="8" />  
     <description>
       <brief>
        A testing block with 2 inputs, N outputs
index 97300cd2ab46eef1c5e38b27521872d3b1538808..60a381d21d9a0faee8439de524b25477a792450b 100644 (file)
@@ -4,7 +4,7 @@
     <name>
       wishbone master for apf27
     </name>
-    <category ids="1,4" />  
+    <category ids="5" />  
     <description>
       <brief>
        This block is the wishbone master of the design, connected to the i.MX of APF27
index b10330539b5af9277d093e00185c8a6f1b0a82f8..063ec2a3cb20f116dc244df413e945388b780b7f 100644 (file)
@@ -4,7 +4,7 @@
     <name>\r
       block average\r
     </name>\r
-    <category ids="1,4" />  \r
+    <category ids="4" />  \r
     <description>\r
       <brief>\r
        This block does an average on 3 successives units, over a sequence of N inputs\r
index ec2e982d7ad6d321e16a28eee91312d717fedc1c..88d07725788aeffb65b677d57165d7d6ee85be82 100644 (file)
@@ -4,7 +4,7 @@
     <name>\r
       block demultiplexer\r
     </name>\r
-    <category ids="1,4" />  \r
+    <category ids="1,5" />  \r
     <description>\r
       <brief>\r
        This block demux an entry presented on FPGA pins over a variable number of outputs\r
index 873216eb1e790241a12d94a72e6691279019c17c..5ba103753dc5ae0b3f1b40b4ec5073c6edd1184b 100644 (file)
@@ -4,7 +4,7 @@
     <name>\r
       block multiply/add\r
     </name>\r
-    <category ids="1,4" />  \r
+    <category ids="3" />  \r
     <description>\r
       <brief>\r
        This block multiplies 2 input values, adding the result to a third one.\r
index 594beb02874b2614ab1f060248792d2153acc62c..66b4efeca106b928c4db56993e77f2055a2238e1 100644 (file)
Binary files a/lib/references/references.bmf and b/lib/references/references.bmf differ
index f898ca2be21de07820c2f449ab421f72b552ee2b..8fdab46ca82a675ecc0f801542c79d57c90468fa 100644 (file)
        </xs:simpleType>
     </xs:attribute>
 
-    <xs:attribute name="value">
-       <xs:simpleType>
-           <xs:restriction base="xs:nonNegativeInteger">
-               <xs:minInclusive value="0"/>
-           </xs:restriction>
-       </xs:simpleType>
-    </xs:attribute>
+    <xs:attribute name="value" type="xs:string"/>
 
     <xs:attribute name="from">
        <xs:simpleType>