#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 "Exception.h"\r
#include "BlocksToConfigureWidget.h"\r
\r
+#include "BlockParameterGeneric.h"\r
+\r
+#include "DelayInputModifier.h"\r
+\r
Parameters::Parameters() {\r
categoryTree = NULL;\r
arrowWidth = 5;\r
\r
unsaveModif = false;\r
isRstClkShown = false;\r
+ \r
+ validityExtension = "_enb";\r
\r
- projectPath = QDir::currentPath();\r
+ projectPath = "";\r
+ projectName = "";\r
+ projectFile = "";\r
}\r
\r
Parameters::~Parameters() {\r
BlockCategory* blockCat = categoryTree->searchCategory(idCategory);\r
\r
if (blockCat == NULL) return NULL;\r
- ReferenceBlock* ref = blockCat->getBlock(idBlock);\r
+ ReferenceBlock* ref = blockCat->getBlockById(idBlock);\r
return ref;\r
}\r
\r
+ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) {\r
\r
-FunctionalBlock* Parameters::duplicateFunctionalBlock(FunctionalBlock *block) {\r
+ BlockCategory* blockCat = categoryTree->searchCategory(100);\r
+ if (blockCat == NULL) return NULL;\r
+ ReferenceBlock* ref = blockCat->getBlockByName(blockName);\r
+ return ref;\r
+}\r
\r
- ReferenceBlock* ref = block->getReference();\r
- GroupBlock* group = AB_TO_GRP(block->getParent());\r
+void Parameters::createDelayBlock() {\r
+ delayRef = new ReferenceBlock("no.xml");\r
+ delayRef->addCategory(100);\r
+ delayRef->setName("delay");\r
+\r
+ BlockCategory* cat = categoryTree->searchCategory(100);\r
+ cat->blocks.append(delayRef);\r
+\r
+ AbstractInterface* interIn = new ReferenceInterface(delayRef,"data_in",AbstractInterface::Input, AbstractInterface::Data, "expression","$in_width");\r
+ delayRef->addInterface(interIn);\r
+ AbstractInterface* interInCtl = new ReferenceInterface(delayRef,"data_in_enb",AbstractInterface::Input, AbstractInterface::Control, "boolean","1");\r
+ delayRef->addInterface(interInCtl);\r
+ interInCtl->setAssociatedIface(interIn);\r
+ AbstractInterface* interOut = new ReferenceInterface(delayRef,"data_out",AbstractInterface::Output, AbstractInterface::Data, "expression","$in_width");\r
+ delayRef->addInterface(interOut);\r
+ AbstractInterface* interOutCtl = new ReferenceInterface(delayRef,"data_out_enb",AbstractInterface::Output, AbstractInterface::Control, "boolean","1");\r
+ delayRef->addInterface(interOutCtl);\r
+ interOutCtl->setAssociatedIface(interOut);\r
+ BlockParameter* param1 = new BlockParameterGeneric(delayRef,"in_width","natural","8");\r
+ BlockParameter* param2 = new BlockParameterGeneric(delayRef,"dly_length","natural","1");\r
+ delayRef->addParameter(param1);\r
+ delayRef->addParameter(param2);\r
+ delayImpl = new BlockImplementation("no.xml");\r
+ delayImpl->setDelta("1");\r
+ QHash<QString,QString> consPattern;\r
+ consPattern.insert("data_in_enb","1");\r
+ delayImpl->setConsumptionPattern(consPattern);\r
+ QHash<QString,QString> prodPattern;\r
+ prodPattern.insert("data_out_enb","O{$dly_length}1");\r
+ delayImpl->setProductionPattern(prodPattern);\r
+ delayImpl->setProductionCounter("1");\r
+ delayRef->addImplementation(delayImpl);\r
+ delayImpl->setReference(delayRef);\r
+ if (! delayImpl->checkPatterns()) {\r
+ cout << "Delay block creation: failure" << endl;\r
+ }\r
+ else {\r
+ cout << "Delay block creation: success" << endl;\r
+ }\r
\r
- // adding to the graph\r
- FunctionalBlock* newBlock = graph->addFunctionalBlock(group,ref);\r
- return newBlock;\r
}\r
\r
+\r
+\r
void Parameters::validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception) {\r
// opening configFile\r
QFile xmlFile(xmlFileName);\r
return root;\r
}\r
\r
-void Parameters::loadProject(QDomElement root) {\r
-\r
-#ifdef DEBUG_INCLFUN\r
+GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {\r
\r
bool ok = false;\r
GroupWidget* groupWidget = NULL;\r
GroupItem *groupItem = NULL;\r
GroupBlock *groupBlock = NULL;\r
\r
+ GroupWidget* topGroup = NULL;\r
+\r
+ QString path = root.attribute("project_path","none");\r
+ if (path != "none") {\r
+ QDir dir(path);\r
+ if (dir.exists()) {\r
+ projectPath = path;\r
+\r
+ }\r
+ cout << "project path set to " << qPrintable(projectPath) << endl;\r
+ }\r
/**********************************************************\r
1 : getting scene and creating associated group widgets\r
***********************************************************/\r
QDomNodeList scenesNodes = root.elementsByTagName("scene");\r
\r
+ int maxIdScene = -1;\r
for(int i=0; i<scenesNodes.length(); i++) {\r
QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
int idScene = currentSceneNode.attribute("id","none").toInt(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ if (idScene > maxIdScene) maxIdScene = idScene;\r
int idUpperScene = currentSceneNode.attribute("upper_scene","none").toInt(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
if (idUpperScene == -1) {\r
- dispatcher->createTopScene();\r
+ topGroup = dispatcher->createTopScene();\r
topScene->setId(idScene);\r
- groupItem = topScene->getGroupItem();\r
- groupBlock = AB_TO_GRP(groupItem->getRefBlock());\r
+ groupItem = topScene->getGroupItem(); \r
cout << "top group added to scene n°" << idScene << endl;\r
}\r
else {\r
- GroupScene* scene = searchSceneById(idUpperScene, topScene);\r
- GroupWidget* parent = scene->getGroupWindow();\r
- groupWidget = dispatcher->createChildScene(parent);\r
- groupItem = groupWidget->getScene()->getGroupItem();\r
- groupBlock = AB_TO_GRP(groupItem->getRefBlock());\r
+ cout << "trying to create scene n°" << idScene << " with upper scene n°" <<idUpperScene << endl;\r
+ GroupScene* upperScene = searchSceneById(idUpperScene, topScene);\r
+ groupWidget = dispatcher->addNewEmptyGroup(upperScene,false);\r
+ groupWidget->getScene()->setId(idScene);\r
+ groupItem = groupWidget->getScene()->getGroupItem(); \r
}\r
+ groupBlock = AB_TO_GRP(groupItem->getRefBlock());\r
/**********************************************************\r
- 1.1 : getting the group item\r
+ 1.1 : getting the group item of each scene\r
***********************************************************/\r
QDomElement groupItemNode = currentSceneNode.firstChildElement("group_item");\r
-\r
- int id = groupItemNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString name = groupItemNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QStringList positionStr = groupItemNode.attribute("position","none").split(",");\r
- if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int posX = positionStr.at(0).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int posY = positionStr.at(1).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QStringList dimensionStr = groupItemNode.attribute("dimension","none").split(",");\r
- if(dimensionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int dimX = dimensionStr.at(0).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int dimY = dimensionStr.at(1).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- groupItem->setId(id);\r
- groupItem->setPos(posX,posY);\r
- groupItem->setDimension(dimX,dimY);\r
- groupBlock->setName(name);\r
+ try {\r
+ groupItem->load(groupItemNode);\r
+ }\r
+ catch(Exception err) {\r
+ throw(err);\r
+ }\r
\r
if (idUpperScene != -1) {\r
groupWidget->setWindowTitle(groupBlock->getName());\r
groupWidget->show();\r
- }\r
- cout << "group info : \n-id : " << id << "\n-pos : " << posX << ", " << posY << "\n-dim : " << dimX << ", " << dimY << "\n-name : " << name.toStdString() << endl;\r
-\r
- QDomNodeList interfaces = groupItemNode.elementsByTagName("group_iface");\r
- for(int j=0; j<interfaces.length(); j++){\r
- QDomElement currentInterfaceNode = interfaces.at(j).toElement();\r
-\r
- int id = currentInterfaceNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString name = currentInterfaceNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString levelStr = currentInterfaceNode.attribute("level","none");\r
- int level = AbstractInterface::getIntLevel(levelStr);\r
- if(level == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString directionStr = currentInterfaceNode.attribute("direction","none");\r
- int direction = AbstractInterface::getIntDirection(directionStr);\r
- if(direction == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString orientationStr = currentInterfaceNode.attribute("orientation","none");\r
- int orientation = InterfaceItem::getIntOrientation(orientationStr);\r
- if(orientation == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction,level);\r
-\r
- InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupInterface,groupItem,this);\r
- interfaceItem->setId(id);\r
-\r
- groupBlock->addInterface(groupInterface);\r
- groupItem->addInterface(interfaceItem);\r
- cout << "interface add to " << groupBlock->getName().toStdString() << endl;\r
- }\r
+ cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl;\r
+ } \r
}\r
-\r
+ dispatcher->setSceneCounter(maxIdScene+1);\r
cout << "groupItems loaded and windows created succefully!" << endl;\r
\r
+ /**********************************************************\r
+ 2 : getting the functional blocks of each scene\r
+ ***********************************************************/\r
\r
for(int i=0; i<scenesNodes.length(); i++){\r
QDomElement currentSceneNode = scenesNodes.at(i).toElement();\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
- QDomElement currentFBNode = functionalBlockNodes.at(j).toElement();\r
-\r
- int id = currentFBNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString refXml = currentFBNode.attribute("ref_xml","none");\r
- if(refXml == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString refMd5 = currentFBNode.attribute("ref_md5","none");\r
- if(refMd5 == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- cout << "ref md5 : " << refMd5.toStdString() << "\nref xml : " << refXml.toStdString() << endl;\r
-\r
- QString name = currentFBNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QStringList positionStr = currentFBNode.attribute("position","none").split(",");\r
- if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int posX = positionStr.at(0).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int posY = positionStr.at(1).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QStringList dimensionStr = currentFBNode.attribute("dimension","none").split(",");\r
- if(dimensionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int dimX = dimensionStr.at(0).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int dimY = dimensionStr.at(1).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- AbstractBlock *reference;\r
- /*if(refMd5 != "none"){\r
- cout << "md5" << endl;\r
- reference = searchBlockByMd5(refMd5);\r
- }\r
- else */if(refXml != "none"){\r
- cout << "xml" << endl;\r
- reference = searchBlockByXml(refXml);\r
- }\r
- else {\r
- throw(Exception(PROJECTFILE_CORRUPTED));\r
- }\r
-\r
- FunctionalBlock *functionalBlock = new FunctionalBlock(currentScene->getGroupItem()->getRefBlock(),reference);\r
- functionalBlock->setName(name);\r
-\r
- ((GroupBlock*)currentScene->getGroupItem()->getRefBlock())->addBlock(functionalBlock);\r
-\r
-\r
- BlockItem *blockItem = new BlockItem(currentScene->getGroupItem(),functionalBlock,dispatcher,this);\r
- blockItem->setPos(posX,posY);\r
- blockItem->setDimension(dimX,dimY);\r
- blockItem->setId(id);\r
- ((GroupItem*)currentScene->getGroupItem())->addBlockItem(blockItem);\r
- currentScene->addItem(blockItem);\r
- currentScene->addBlockItem(blockItem);\r
-\r
- QDomNodeList blockParamNodes = currentFBNode.elementsByTagName("bif_parameter");\r
-\r
- for(int i=0; i<blockParamNodes.length(); i++){\r
- QDomElement currentBlockParamNode = blockParamNodes.at(i).toElement();\r
-\r
- QString name = currentBlockParamNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString value = currentBlockParamNode.attribute("value","none");\r
- if(value == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString context = currentBlockParamNode.attribute("context","none");\r
- if(context == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString type = currentBlockParamNode.attribute("type","none");\r
- if(type == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-\r
- BlockParameter *blockParam = new BlockParameter;\r
- blockParam->setName(name);\r
- blockParam->setValue(value);\r
- blockParam->setType(type);\r
- if(context == "constant") blockParam->setContext(BlockParameter::Constant);\r
- if(context == "user") blockParam->setContext(BlockParameter::User);\r
- if(context == "generic") blockParam->setContext(BlockParameter::Generic);\r
- if(context == "wb") blockParam->setContext(BlockParameter::Wishbone);\r
- if(context == "port") blockParam->setContext(BlockParameter::Port);\r
-\r
- functionalBlock->addParameter(blockParam);\r
+ for(int j=0; j<functionalBlockNodes.length(); j++) {\r
+ QDomElement currentFBNode = functionalBlockNodes.at(j).toElement(); \r
+ BoxItem* funcItem = new BoxItem(dispatcher,this, currentScene->getGroupItem());\r
+ try {\r
+ funcItem->loadFunctional(currentFBNode);\r
}\r
-\r
-\r
- QDomNodeList interfaceNodes = currentFBNode.elementsByTagName("bif_iface");\r
-\r
- for(int i=0; i<interfaceNodes.length(); i++){\r
-\r
- QDomElement currentInterfaceNode = interfaceNodes.at(i).toElement();\r
-\r
- int id = currentInterfaceNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString name = currentInterfaceNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString refName = currentInterfaceNode.attribute("ref_name","none");\r
- if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString orientationStr = currentInterfaceNode.attribute("orientation","none");\r
- int orientation = InterfaceItem::getIntOrientation(orientationStr);\r
- if(orientation == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- ReferenceInterface *refInter = (ReferenceInterface*)reference->getIfaceFromName(refName);\r
- FunctionalInterface *functionalInterface = new FunctionalInterface(functionalBlock,refInter);\r
- functionalBlock->addInterface(functionalInterface);\r
- functionalInterface->setName(refName);\r
-\r
- InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,functionalInterface,blockItem,this);\r
- interfaceItem->setId(id);\r
- interfaceItem->setName(name);\r
-\r
- blockItem->addInterface(interfaceItem);\r
-\r
+ catch(Exception err) {\r
+ throw(err);\r
}\r
+ // add the block to the GroupScene\r
+ currentScene->addBoxItem(funcItem);\r
}\r
}\r
- cout << "functionalBlocks loaded and created succefully!" << endl;\r
+ cout << "functional blocks loaded and created succefully!" << endl;\r
\r
+ /**********************************************************\r
+ 3 : set the BoxItem that represents a GroupItem in a child scene\r
+ ***********************************************************/\r
\r
for(int i=0; i<scenesNodes.length(); i++){\r
QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
int dimY = dimensionStr.at(1).toInt(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
-\r
+ // get the GroupItem already created and set at phase 1\r
GroupItem *insideGroup = searchGroupItemById(idGroup, topScene);\r
- if(insideGroup == NULL) cout << "group null" << endl;\r
- BlockItem *blockItem = new BlockItem(insideGroup->getRefBlock(), dispatcher, this);\r
- blockItem->setChildGroupItem(insideGroup);\r
- blockItem->setId(id);\r
- blockItem->setPos(posX,posY);\r
- blockItem->setDimension(dimX,dimY);\r
+ BoxItem* upperItem = NULL;\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
+ if (item->getChildGroupItem() == insideGroup) {\r
+ upperItem = item;\r
+ break;\r
+ }\r
+ }\r
+ if (upperItem == NULL) {\r
+ throw(Exception(PROJECTFILE_CORRUPTED));\r
+ }\r
\r
- ((GroupItem*)currentScene->getGroupItem())->addBlockItem(blockItem);\r
- currentScene->addItem(blockItem);\r
- currentScene->addBlockItem(blockItem);\r
+ upperItem->setId(id);\r
+ upperItem->setPos(posX,posY);\r
+ upperItem->setDimension(dimX,dimY);\r
\r
+ // set interfaces of this BoxItem\r
QDomNodeList interfaceNodes = currentBiGroup.elementsByTagName("big_iface");\r
\r
for(int k=0; k<interfaceNodes.length(); k++){\r
double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
- GroupInterface *refInter = (GroupInterface*)insideGroup->searchInterfaceByName(refName)->refInter;\r
- InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, blockItem, this);\r
+ ConnectedInterface *refInter = insideGroup->searchInterfaceItemByName(refName)->refInter;\r
+ InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, upperItem, this);\r
ifaceItem->setId(id);\r
- blockItem->addInterface(ifaceItem);\r
+ upperItem->addInterfaceItem(ifaceItem);\r
}\r
}\r
}\r
cout << "blockItems \"group\" loaded and created succefully!" << endl;\r
\r
-\r
- for(int i=0; i<scenesNodes.length(); i++){\r
- QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
-\r
- QDomElement groupItemNode = currentSceneNode.firstChildElement("group_item");\r
-\r
- int id = groupItemNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int idUpperItem = groupItemNode.attribute("upper_item","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- BlockItem *currentItem = searchBlockItemById(id,topScene);\r
- GroupItem *upperItem = searchGroupItemById(idUpperItem, topScene);\r
-\r
- if(currentItem != NULL && upperItem != NULL){\r
- currentItem->setUpperItem(upperItem);\r
- }\r
- }\r
-\r
QDomNodeList connectionNodes = root.elementsByTagName("connection");\r
\r
for(int i=0; i<connectionNodes.length(); i++){\r
InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);\r
\r
if(iface1 != NULL && iface2 != NULL){\r
- dispatcher->connect(iface1,iface2);\r
+ dispatcher->createConnection(iface1,iface2);\r
} else {\r
cout << "interfaces not found, connect canceled!" << endl;\r
}\r
}\r
+ cout << "connections loaded and created succefully!" << endl;\r
\r
-#endif\r
+ QDomNodeList modifierNodes = root.elementsByTagName("modifier");\r
+\r
+ for(int i=0; i<modifierNodes.length(); i++){\r
+ QDomElement currentModifierNode = modifierNodes.at(i).toElement();\r
+\r
+ int id = currentModifierNode.attribute("id","none").toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+\r
+ QString typeStr = currentModifierNode.attribute("type","none");\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ QString paramsStr = currentModifierNode.attribute("params","none");\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+\r
+ /* NB: just adding delays for now. To be cont'd */\r
+ InterfaceItem *iface = searchInterfaceItemById(id,topScene);\r
+\r
+ if ((iface == NULL ) || (iface->refInter == NULL) || (iface->refInter->getAssociatedIface() == NULL)) {\r
+ cout << "modified interface not found, modifiers setup canceled!" << endl;\r
+ }\r
+ else {\r
+ ConnectedInterface* connIface = AI_TO_CON(iface->refInter->getAssociatedIface());\r
+\r
+ AbstractInputModifier* mod = NULL;\r
+ if (typeStr == "delay") {\r
+ int delay = paramsStr.toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ mod = new DelayInputModifier(connIface, delay);\r
+ connIface->setInputModifier(mod);\r
+ }\r
+ }\r
+ }\r
+\r
+ cout << "modifiers loaded and created succefully!" << endl;\r
+\r
+ return topGroup;\r
}\r
\r
void Parameters::loadBlastConfiguration(QString confFile) throw(Exception) {\r
QString line = in.readLine();\r
line = in.readLine();\r
\r
- if (!line.contains("<block>")) {\r
+ if (!line.contains("<block")) {\r
blockXML.close();\r
continue;\r
}\r
\r
blockXML.close();\r
try {\r
- validateXmlFile(fileName,"block.xsd",Reference);\r
+ validateXmlFile(fileName,"reference.xsd",Reference);\r
}\r
catch(Exception err) {\r
throw(err);\r
implXML.close();\r
cout << "OK" << endl;\r
cout << "reading " << qPrintable(fileName) << " content ...";\r
- /*\r
+\r
try {\r
- validateXmlFile(fileName,"block.xsd",Implementation);\r
+ validateXmlFile(fileName,"implementation.xsd",Implementation);\r
}\r
catch(Exception e) {\r
throw(e);\r
}\r
- */\r
+\r
// reading in into QDomDocument\r
QDomDocument document ("FileXML");\r
if (!implXML.open(QIODevice::ReadOnly)) {\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
}\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
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
\r
void Parameters::updateToolbar() {\r
- int nb = currentScene->getBlockItems().length();\r
+ int nb = currentScene->getBoxItems().length();\r
for(int i = 0; i<nb; i++){\r
- if(currentScene->getBlockItems().at(i)->isSelected()){\r
+ if(currentScene->getBoxItems().at(i)->isSelected()){\r
currentScene->getGroupWidget()->enableGroupButton(true);\r
return;\r
}\r
}\r
\r
writer.writeEndElement(); //</connections>\r
+\r
+ QList<InterfaceItem *> lstIfaceItem;\r
+ // search for modifiers\r
+ foreach(ConnectionItem* item, allConnections) {\r
+ InterfaceItem* fromIfaceItem = item->getFromInterfaceItem();\r
+ AbstractInputModifier* mod = fromIfaceItem->refInter->getInputModifier();\r
+ if (mod != NULL) {\r
+ if (!lstIfaceItem.contains(fromIfaceItem)) lstIfaceItem.append(fromIfaceItem);\r
+ }\r
+ InterfaceItem* toIfaceItem = item->getToInterfaceItem();\r
+ mod = toIfaceItem->refInter->getInputModifier();\r
+ if (mod != NULL) {\r
+ if (!lstIfaceItem.contains(toIfaceItem)) lstIfaceItem.append(toIfaceItem);\r
+ }\r
+ }\r
+ // write input modifiers\r
+ writer.writeStartElement("modifiers");\r
+ foreach(InterfaceItem* item, lstIfaceItem) {\r
+ AbstractInputModifier* mod = item->refInter->getInputModifier();\r
+ if (mod != NULL) {\r
+ writer.writeStartElement("modifier");\r
+ writer.writeAttribute("id", QString::number(item->getId()));\r
+ writer.writeAttribute("type",mod->getTypeStr());\r
+ writer.writeAttribute("params", mod->getParametersStr());\r
+ writer.writeEndElement();\r
+ }\r
+ }\r
+\r
+ writer.writeEndElement(); //</modifiers>\r
writer.writeEndElement(); //</blast_project\r
\r
writer.writeEndDocument();\r
_inArrow.lineTo(arrowLineLength+arrowWidth,-arrowHeight/2);\r
_inArrow.lineTo(arrowLineLength+arrowWidth,arrowHeight/2);\r
_inArrow.lineTo(arrowLineLength,0);\r
- _inArrow.closeSubpath();\r
- inArrow = _inArrow;\r
+ //_inArrow.closeSubpath();\r
+ dataArrowIn = _inArrow;\r
+\r
+ QPainterPath _inArrowC;\r
+ _inArrowC.lineTo(arrowLineLength,0);\r
+ _inArrowC.addEllipse(arrowLineLength,-arrowHeight/2,arrowHeight-1,arrowHeight-1);\r
+ clkrstArrow = _inArrowC;\r
\r
QPainterPath _outArrow;\r
_outArrow.lineTo(arrowLineLength,0);\r
_outArrow.lineTo(arrowLineLength+arrowWidth,0);\r
_outArrow.lineTo(arrowLineLength,arrowHeight/2);\r
_outArrow.lineTo(arrowLineLength,0);\r
- _outArrow.closeSubpath();\r
- outArrow = _outArrow;\r
+ //_outArrow.closeSubpath();\r
+ dataArrowOut = _outArrow;\r
\r
}\r
\r
\r
BoxItem* Parameters::searchBlockItemById(int id, GroupScene *scene) {\r
\r
- foreach(BoxItem *item, scene->getBlockItems()){\r
+ foreach(BoxItem *item, scene->getBoxItems()){\r
if(item->getId() == id){\r
return item;\r
}\r
return NULL;\r
}\r
\r
+BoxItem* Parameters::searchFunctionalBlock(AbstractBlock* block) {\r
+\r
+ return searchFunctionalBlockRecur(block,topScene);\r
+}\r
+\r
+BoxItem* Parameters::searchFunctionalBlockRecur(AbstractBlock* block, GroupScene* scene) {\r
+\r
+ foreach(BoxItem *item, scene->getBoxItems()){\r
+ if(item->getRefBlock() == block) {\r
+ return item;\r
+ }\r
+ }\r
+\r
+ BoxItem* item = NULL;\r
+ foreach(GroupScene *s, scene->getChildrenScene()) {\r
+ item = searchFunctionalBlockRecur(block,s);\r
+ if (item != NULL) return item;\r
+ }\r
+ return NULL;\r
+}\r
+\r
InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) {\r
\r
foreach(InterfaceItem *item, scene->getGroupItem()->getInterfaces()){\r
return item;\r
}\r
}\r
- foreach(BoxItem *block, scene->getBlockItems()){\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
return item;\r
}\r
return NULL;\r
}\r
+\r
+QString Parameters::normalizeName(const QString &name) {\r
+ QString s = name;\r
+ s.replace(QRegularExpression("[^a-zA-Z0-9_]"),"_");\r
+ s.replace(QRegularExpression("[_]+"),"_");\r
+ return s;\r
+}\r