X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/df84660fd98b39737692d57b68c8b2c2d34af0f1..4cf57e6db08da791233d75237f62e74bc88dd427:/Parameters.cpp?ds=inline diff --git a/Parameters.cpp b/Parameters.cpp index 322046d..d3a8dd4 100644 --- a/Parameters.cpp +++ b/Parameters.cpp @@ -24,6 +24,10 @@ #include "Exception.h" #include "BlocksToConfigureWidget.h" +#include "BlockParameterGeneric.h" + +#include "DelayInputModifier.h" + Parameters::Parameters() { categoryTree = NULL; arrowWidth = 5; @@ -81,6 +85,48 @@ ReferenceBlock* Parameters::getReferenceBlock(int idCategory, int idBlock) { return ref; } +void Parameters::createDelayBlock() { + delayRef = new ReferenceBlock("no.xml"); + delayRef->addCategory(100); + delayRef->setName("delay"); + + BlockCategory* cat = categoryTree->searchCategory(100); + cat->blocks.append(delayRef); + + AbstractInterface* interIn = new ReferenceInterface(delayRef,"data_in",AbstractInterface::Input, AbstractInterface::Data, "expression","$in_width"); + delayRef->addInterface(interIn); + AbstractInterface* interInCtl = new ReferenceInterface(delayRef,"data_in_enb",AbstractInterface::Input, AbstractInterface::Control, "boolean","1"); + delayRef->addInterface(interInCtl); + interInCtl->setAssociatedIface(interIn); + AbstractInterface* interOut = new ReferenceInterface(delayRef,"data_out",AbstractInterface::Output, AbstractInterface::Data, "expression","$in_width"); + delayRef->addInterface(interOut); + AbstractInterface* interOutCtl = new ReferenceInterface(delayRef,"data_out_enb",AbstractInterface::Output, AbstractInterface::Control, "boolean","1"); + delayRef->addInterface(interOutCtl); + interOutCtl->setAssociatedIface(interOut); + BlockParameter* param1 = new BlockParameterGeneric(delayRef,"in_width","natural","8"); + BlockParameter* param2 = new BlockParameterGeneric(delayRef,"dly_length","natural","1"); + delayRef->addParameter(param1); + delayRef->addParameter(param2); + delayImpl = new BlockImplementation("no.xml"); + delayImpl->setDelta("1"); + QHash consPattern; + consPattern.insert("data_in_enb","1"); + delayImpl->setConsumptionPattern(consPattern); + QHash prodPattern; + prodPattern.insert("data_out_enb","O{$dly_length}1"); + delayImpl->setProductionPattern(prodPattern); + delayImpl->setProductionCounter("1"); + delayRef->addImplementation(delayImpl); + delayImpl->setReference(delayRef); + if (! delayImpl->checkPatterns()) { + cout << "Delay block creation: failure" << endl; + } + else { + cout << "Delay block creation: success" << endl; + } + +} + void Parameters::validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception) { @@ -398,6 +444,38 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { } cout << "connections loaded and created succefully!" << endl; + QDomNodeList modifierNodes = root.elementsByTagName("modifier"); + + for(int i=0; irefInter->setInputModifier(mod); + + } else { + cout << "interfaces not found, modifiers setup canceled!" << endl; + } + } + cout << "modifiers loaded and created succefully!" << endl; + return topGroup; } @@ -539,7 +617,7 @@ void Parameters::loadReferencesFromXml() throw(Exception) { QString line = in.readLine(); line = in.readLine(); - if (!line.contains("")) { + if (!line.contains(" + + QList lstIfaceItem; + // search for modifiers + foreach(ConnectionItem* item, allConnections) { + InterfaceItem* fromIfaceItem = item->getFromInterfaceItem(); + AbstractInputModifier* mod = fromIfaceItem->refInter->getInputModifier(); + if (mod != NULL) { + if (!lstIfaceItem.contains(fromIfaceItem)) lstIfaceItem.append(fromIfaceItem); + } + InterfaceItem* toIfaceItem = item->getToInterfaceItem(); + mod = toIfaceItem->refInter->getInputModifier(); + if (mod != NULL) { + if (!lstIfaceItem.contains(toIfaceItem)) lstIfaceItem.append(toIfaceItem); + } + } + // write input modifiers + writer.writeStartElement("modifiers"); + foreach(InterfaceItem* item, lstIfaceItem) { + AbstractInputModifier* mod = item->refInter->getInputModifier(); + if (mod != NULL) { + writer.writeStartElement("modifier"); + writer.writeAttribute("id", QString::number(item->getId())); + writer.writeAttribute("type",mod->getTypeStr()); + writer.writeAttribute("params", mod->getParametersStr()); + writer.writeEndElement(); + } + } + + writer.writeEndElement(); // writer.writeEndElement(); //getBoxItems()){ + if(item->getRefBlock() == block) { + return item; + } + } + + BoxItem* item = NULL; + foreach(GroupScene *s, scene->getChildrenScene()) { + item = searchFunctionalBlockRecur(block,s); + if (item != NULL) return item; + } + return NULL; +} + InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) { foreach(InterfaceItem *item, scene->getGroupItem()->getInterfaces()){