- 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