+bool FunctionalBlock::createPatterns() {\r
+ evaluator = new ArithmeticEvaluator();\r
+ bool ok = true;\r
+ ok = ok & createDelta();\r
+ if (ok) ok = ok & createConsumptionPattern();\r
+ if (ok) ok = ok & createProductionCounter();\r
+ if (ok) ok = ok & createProductionPattern();\r
+ delete evaluator;\r
+ return ok;\r
+}\r
+\r
+bool FunctionalBlock::createDelta() {\r
+ QString delta = implementation->getDelta();\r
+ cout << "delta for " << qPrintable(name) << " = " << qPrintable(delta) << endl;\r
+ \r
+ // look for parameter names\r
+ QHash<QString,double> vars;\r
+ QRegularExpression re("[$][a-zA-Z0-9_]+");\r
+ QRegularExpressionMatchIterator matcher = re.globalMatch(delta);\r
+ while(matcher.hasNext()) {\r
+ QRegularExpressionMatch m = matcher.next();\r
+ QString var = m.captured(0);\r
+ cout << qPrintable(var) << endl;\r
+ vars.insert(var,0.0); \r
+ }\r
+ QHashIterator<QString,double> iterV(vars);\r
+ while (iterV.hasNext()) {\r
+ iterV.next();\r
+ QString var = iterV.key();\r
+ QString paramName = var.remove(0,1);\r
+ BlockParameter* param = reference->getParameterFromName(paramName);\r
+ cout << "param = " << qPrintable(param->getStringValue()) << endl;\r
+ if (param == NULL) {\r
+ cerr << "found an unknown parameter in delta"<< endl;\r
+ return false;\r
+ }\r
+ bool ok;\r
+ int val = param->getIntValue(&ok);\r
+ vars.insert(var,(double)val);\r
+ }\r
+ cout << "set expr " << endl;\r
+ evaluator->setExpression(delta);\r
+ cout << "set vars " << endl;\r
+ evaluator->setVariablesValue(vars);\r
+ double result = evaluator->evaluate();\r
+ cout << "delta = " << result << endl;\r
+ \r
+ return true;\r
+}\r
+\r
+bool FunctionalBlock::createConsumptionPattern() {\r
+ return true;\r
+}\r
+\r
+bool FunctionalBlock::createProductionPattern() {\r
+ return true;\r
+}\r
+\r
+bool FunctionalBlock::createProductionCounter() {\r
+ return true;\r
+}\r
+\r
+bool FunctionalBlock::computeOutputPattern(int nbExec) {\r