1 #include "FunctionalBlock.h"
\r
2 #include "ReferenceBlock.h"
\r
3 #include "GroupBlock.h"
\r
4 #include "AbstractInterface.h"
\r
5 #include "FunctionalInterface.h"
\r
6 #include "ReferenceInterface.h"
\r
7 #include "BlockParameter.h"
\r
10 FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference) throw(Exception) : AbstractBlock() {
\r
11 //if (! _reference->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
\r
12 //if (! _group->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));
\r
13 reference = _reference;
\r
15 name = reference->getName();
\r
19 void FunctionalBlock::parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock *> *blocksToConfigure) {
\r
21 checkedBlocks->append(this);
\r
23 foreach(BlockParameter* param, params){
\r
24 if(param->isUserParameter() && !param->isValueSet()){
\r
25 if(!blocksToConfigure->contains(param->getOwner())){
\r
26 blocksToConfigure->append(param->getOwner());
\r
30 foreach(AbstractInterface *inter, outputs){
\r
31 foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){
\r
32 if(!checkedBlocks->contains(connectedInter->getOwner())){
\r
33 connectedInter->getOwner()->parametersValidation(checkedBlocks, blocksToConfigure);
\r
40 bool FunctionalBlock::isFunctionalBlock() {
\r
44 void FunctionalBlock::populate() {
\r
47 AbstractInterface* inter;
\r
49 // create parameters from reference block
\r
50 QList<BlockParameter*> lstParam = reference->getParameters();
\r
51 for(i=0;i<lstParam.size();i++) {
\r
52 p = lstParam.at(i)->clone();
\r
56 // create interfaces from reference block
\r
57 QList<AbstractInterface *> lstRef = reference->getInterfaces();
\r
58 // store relation between functional and reference
\r
59 QHash<AbstractInterface *, AbstractInterface *> hashIface;
\r
60 for(i=0;i<lstRef.size();i++) {
\r
62 inter = new FunctionalInterface(this, AI_TO_REF(lstRef.at(i)));
\r
64 catch(Exception e) {
\r
65 cerr << "Abnormal case: " << qPrintable(e.getDefaultMessage()) << endl << "Aborting execution." << endl;
\r
68 hashIface.insert(lstRef.at(i),inter);
\r
70 addInterface(inter);
\r
73 AbstractInterface* funCtlIface = NULL;
\r
74 AbstractInterface* funDataIface = NULL;
\r
76 for(i=0;i<lstRef.size();i++) {
\r
77 AbstractInterface* refIface = lstRef.at(i);
\r
78 if (refIface->getPurpose() == AbstractInterface::Control) {
\r
79 funCtlIface = hashIface.value(refIface);
\r
80 funDataIface = hashIface.value(refIface->getAssociatedIface());
\r
81 if (! funCtlIface->setAssociatedIface(funDataIface)) {
\r
82 cerr << "Abnormal case when associating a control interface to data" << endl << "Aborting execution." << endl;
\r
90 QString FunctionalBlock::getReferenceXmlFile() {
\r
91 return ((ReferenceBlock *)reference)->getXmlFile();
\r
94 QString FunctionalBlock::getReferenceHashMd5()
\r
96 return ((ReferenceBlock *)reference)->getHashMd5();
\r