From e5af659f87bcb199d6a5f10f09b311138351d0f3 Mon Sep 17 00:00:00 2001 From: stephane Domas Date: Mon, 8 May 2017 20:46:44 +0200 Subject: [PATCH 1/1] start modifying read/write blocks and project to take into account control ifaces --- AbstractBoxItem.cpp | 10 +- AbstractBoxItem.h | 1 + BoxItem.cpp | 36 +++++-- BoxItem.h | 1 + ConnectionItem.cpp | 9 ++ ConnectionItem.h | 35 ++++--- Dispatcher.cpp | 70 ++++++++----- Dispatcher.h | 6 +- GroupInterface.cpp | 8 +- GroupInterface.h | 2 +- GroupItem.cpp | 9 +- GroupItem.h | 1 + InterfaceItem.cpp | 160 ++--------------------------- InterfaceItem.h | 6 +- ReferenceBlock.cpp | 72 ++++++++++--- blast.creator.user | 8 +- blastconfig.xml | 11 +- block-1I1O.xml | 2 +- block-2I2O.xml | 2 +- block-2INO.xml | 2 +- lib/references/apf27-wb-master.xml | 2 +- lib/references/average-Nx3.xml | 2 +- lib/references/demux.xml | 2 +- lib/references/multadd.xml | 2 +- lib/references/references.bmf | Bin 6632 -> 6608 bytes projectfile.xsd | 8 +- 26 files changed, 221 insertions(+), 246 deletions(-) diff --git a/AbstractBoxItem.cpp b/AbstractBoxItem.cpp index a05247f..b76bf66 100644 --- a/AbstractBoxItem.cpp +++ b/AbstractBoxItem.cpp @@ -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) { diff --git a/AbstractBoxItem.h b/AbstractBoxItem.h index c061487..ed3e1ee 100644 --- a/AbstractBoxItem.h +++ b/AbstractBoxItem.h @@ -59,6 +59,7 @@ public: // others + virtual void interfaceRenamed() = 0; void addInterface(InterfaceItem* i, bool resetPosition = false); void removeInterface(InterfaceItem* i); void resetInterfacesPosition(); diff --git a/BoxItem.cpp b/BoxItem.cpp index de22f19..a107198 100644 --- a/BoxItem.cpp +++ b/BoxItem.cpp @@ -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); diff --git a/BoxItem.h b/BoxItem.h index 35a12a8..a80f9f0 100644 --- 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); diff --git a/ConnectionItem.cpp b/ConnectionItem.cpp index eaf46c2..78a3651 100644 --- a/ConnectionItem.cpp +++ b/ConnectionItem.cpp @@ -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); diff --git a/ConnectionItem.h b/ConnectionItem.h index 6370c90..c64839f 100644 --- a/ConnectionItem.h +++ b/ConnectionItem.h @@ -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 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); diff --git a/Dispatcher.cpp b/Dispatcher.cpp index b6495bb..ac0862c 100644 --- a/Dispatcher.cpp +++ b/Dispatcher.cpp @@ -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; diff --git a/Dispatcher.h b/Dispatcher.h index 61c41cb..8ffce45 100644 --- a/Dispatcher.h +++ b/Dispatcher.h @@ -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 diff --git a/GroupInterface.cpp b/GroupInterface.cpp index 1c10bff..7fc8745 100644 --- a/GroupInterface.cpp +++ b/GroupInterface.cpp @@ -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; diff --git a/GroupInterface.h b/GroupInterface.h index d487ebc..49b4957 100644 --- a/GroupInterface.h +++ b/GroupInterface.h @@ -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 diff --git a/GroupItem.cpp b/GroupItem.cpp index 679cc5e..5d84381 100644 --- a/GroupItem.cpp +++ b/GroupItem.cpp @@ -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())); diff --git a/GroupItem.h b/GroupItem.h index 137ff03..881180c 100644 --- a/GroupItem.h +++ b/GroupItem.h @@ -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); diff --git a/InterfaceItem.cpp b/InterfaceItem.cpp index 7c384d2..0047e16 100644 --- a/InterfaceItem.cpp +++ b/InterfaceItem.cpp @@ -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 { diff --git a/InterfaceItem.h b/InterfaceItem.h index ef3b58d..ff7b761 100644 --- a/InterfaceItem.h +++ b/InterfaceItem.h @@ -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; diff --git a/ReferenceBlock.cpp b/ReferenceBlock.cpp index e09b118..05fd29a 100644 --- a/ReferenceBlock.cpp +++ b/ReferenceBlock.cpp @@ -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; igetName(); - 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; igetPurpose() != 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; igetName(); - 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; igetPurpose() != 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>(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(); diff --git a/blast.creator.user b/blast.creator.user index 570664a..51f5a11 100755 --- a/blast.creator.user +++ b/blast.creator.user @@ -1,10 +1,10 @@ - + EnvironmentId - {1d077e47-e3a1-47fd-8b12-4de650e39df5} + {c8006d66-d34f-42be-ad10-d0207752286d} ProjectExplorer.Project.ActiveTarget @@ -60,12 +60,12 @@ Desktop Desktop - {451ee8a3-56ff-4aba-8a8e-3da882cc142e} + {2c9bf876-3476-44eb-8065-1f0844704dda} 0 0 0 - /localhome/sdomas/Projet/Blast/code/blast + /home/sdomas/Projet/Blast/code/blast diff --git a/blastconfig.xml b/blastconfig.xml index 43677e4..f827695 100644 --- a/blastconfig.xml +++ b/blastconfig.xml @@ -1,12 +1,15 @@ - + - - - + + + + + + diff --git a/block-1I1O.xml b/block-1I1O.xml index 32efdb5..1e05fa5 100644 --- a/block-1I1O.xml +++ b/block-1I1O.xml @@ -4,7 +4,7 @@ block-1I1O - + A testing block with 1 input, 1 output diff --git a/block-2I2O.xml b/block-2I2O.xml index 54c5460..c8bfdc5 100644 --- a/block-2I2O.xml +++ b/block-2I2O.xml @@ -4,7 +4,7 @@ block-2I2O - + A testing block with 2 inputs, 2 outputs diff --git a/block-2INO.xml b/block-2INO.xml index d654234..af3e0df 100644 --- a/block-2INO.xml +++ b/block-2INO.xml @@ -4,7 +4,7 @@ block-2INO - + A testing block with 2 inputs, N outputs diff --git a/lib/references/apf27-wb-master.xml b/lib/references/apf27-wb-master.xml index 97300cd..60a381d 100644 --- a/lib/references/apf27-wb-master.xml +++ b/lib/references/apf27-wb-master.xml @@ -4,7 +4,7 @@ wishbone master for apf27 - + This block is the wishbone master of the design, connected to the i.MX of APF27 diff --git a/lib/references/average-Nx3.xml b/lib/references/average-Nx3.xml index b103305..063ec2a 100644 --- a/lib/references/average-Nx3.xml +++ b/lib/references/average-Nx3.xml @@ -4,7 +4,7 @@ block average - + This block does an average on 3 successives units, over a sequence of N inputs diff --git a/lib/references/demux.xml b/lib/references/demux.xml index ec2e982..88d0772 100644 --- a/lib/references/demux.xml +++ b/lib/references/demux.xml @@ -4,7 +4,7 @@ block demultiplexer - + This block demux an entry presented on FPGA pins over a variable number of outputs diff --git a/lib/references/multadd.xml b/lib/references/multadd.xml index 873216e..5ba1037 100644 --- a/lib/references/multadd.xml +++ b/lib/references/multadd.xml @@ -4,7 +4,7 @@ block multiply/add - + This block multiplies 2 input values, adding the result to a third one. diff --git a/lib/references/references.bmf b/lib/references/references.bmf index 594beb02874b2614ab1f060248792d2153acc62c..66b4efeca106b928c4db56993e77f2055a2238e1 100644 GIT binary patch delta 658 zcmY*XJxhZ@49=acEmCO_Mg0LTg{tk{`-LDCT^xkEcX>ZYad2?*Pu$?@4{%Tp+ytqs zL!ESY5uMx|eUdup8$y!1+>_+V`);PDMYR4zL=7T6zHM!&Lxrdb9g?8|Rg_RjmLf_e z%Hj2C8$R2D0(c4hLTri~J`Z4xyHH>1)t~C#f6#-hY>dab0H#zz zazK~TOhy?%_uOLR+P&1y)s-LBxBh|$NaX5PKmt6S^=kznlDH4QLXJTeXAY#>l8gR= zf2fK7ZnX6=Q&ATxEQaJ!E0B@HH%O0R3jpLOS>i5)uw_6lIFO7PIRL@ebPsCBUoLdD zy7rUSr#j*aHRw>9Fw!>DYoQS|19ptN0+pGG5NqJ-%p1oMY$Or(=ceO^UG(CN8AC;qHc*ZZ?km{f+ffZ`>DfM<{ae2)2?R}vxOt@Bv3g(PI%Xl=zmFO8MD w^P9`}TK<+f86d-(T$*BnVi|==OVMr&^b8(1&xvtgLKK3j0uqD+&F;=!b_O9Nh>#|Qg=N6q+uKU8wMv^mVE%hCr&c$sdp+g@q8s(n|32X4AxdyyeaN@qOQUZ?5bQJ5=h~ccoNcDf8jWa9!^i zP8#i@+iI>Fm8n*_^q=tGR5QF{%~XkH5y>j>Oz}CiB`ZUUaQA^`sim%Y#WDDFPoNWgD8U`K&Z zWhJRTF)3i^X*C1JVHeoK(nl?Ua0MNM*|pC7Q*tLN~EEC V1G-!&$2;eW@&tHGacyN`{sGAMZu$TK diff --git a/projectfile.xsd b/projectfile.xsd index f898ca2..8fdab46 100644 --- a/projectfile.xsd +++ b/projectfile.xsd @@ -137,13 +137,7 @@ - - - - - - - + -- 2.39.5