static QString fctName = "FunctionalBlock::createPatterns()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
\r
cout << "create patterns for block " << qPrintable(name) << endl;\r
static QString fctName = "FunctionalBlock::createPatterns()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
\r
cout << "create patterns for block " << qPrintable(name) << endl;\r
- ok = ok & createDelta();\r
- if (ok) ok = ok & createConsumptionPattern(); \r
- if (ok) ok = ok & createProductionCounter();\r
+ try {\r
+ createDelta();\r
+ createConsumptionPattern(); \r
+ createProductionCounter();\r
+ }\r
+ catch(Exception e) {\r
+ throw(e); // rethrow e\r
+ }\r
static QString fctName = "FunctionalBlock::createDelta()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
static QString fctName = "FunctionalBlock::createDelta()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
cout << "delta for " << qPrintable(name) << " = " << qPrintable(deltaStr) << endl;\r
if (deltaStr.isEmpty()) {\r
delta = -1;\r
cout << "delta for " << qPrintable(name) << " = " << qPrintable(deltaStr) << endl;\r
if (deltaStr.isEmpty()) {\r
delta = -1;\r
- // look for parameter names\r
- bool ok = true;\r
- double result = evaluateExpression(deltaStr, &ok);\r
- if (!ok) return false;\r
- \r
+ // look for parameter names \r
+ double result = 0;\r
+ try {\r
+ result = evaluateExpression(deltaStr);\r
+ }\r
+ catch(Exception e) {\r
+ throw(e);\r
+ }\r
static QString fctName = "FunctionalBlock::createConsumptionPattern()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
\r
static QString fctName = "FunctionalBlock::createConsumptionPattern()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
\r
QHash<QString,QString> consPattern = implementation->getConsumptionPattern(); \r
\r
foreach(AbstractInterface* iface, getControlInputs()) { \r
FunctionalInterface* connIface = AI_TO_FUN(iface);\r
QString refName = connIface->getReference()->getName(); \r
if (! consPattern.contains(refName)) {\r
QHash<QString,QString> consPattern = implementation->getConsumptionPattern(); \r
\r
foreach(AbstractInterface* iface, getControlInputs()) { \r
FunctionalInterface* connIface = AI_TO_FUN(iface);\r
QString refName = connIface->getReference()->getName(); \r
if (! consPattern.contains(refName)) {\r
- QList<char>* pattern = expandPattern(consPattern.value(refName),&ok); \r
- if (!ok) return false;\r
+ QList<char>* pattern = NULL;\r
+ try {\r
+ pattern = expandPattern(consPattern.value(refName));\r
+ }\r
+ catch(Exception e) {\r
+ throw(e);\r
+ }\r
consumptionPattern.insert(connIface,pattern);\r
if (lengthCP == -1) {\r
lengthCP = pattern->size();\r
}\r
else {\r
consumptionPattern.insert(connIface,pattern);\r
if (lengthCP == -1) {\r
lengthCP = pattern->size();\r
}\r
else {\r
static QString fctName = "FunctionalBlock::createProductionPattern()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
\r
static QString fctName = "FunctionalBlock::createProductionPattern()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
\r
QHash<QString,QString> prodPattern = implementation->getProductionPattern(); \r
\r
foreach(AbstractInterface* iface, getControlOutputs()) { \r
FunctionalInterface* connIface = AI_TO_FUN(iface);\r
QString refName = connIface->getReference()->getName(); \r
if (! prodPattern.contains(refName)) {\r
QHash<QString,QString> prodPattern = implementation->getProductionPattern(); \r
\r
foreach(AbstractInterface* iface, getControlOutputs()) { \r
FunctionalInterface* connIface = AI_TO_FUN(iface);\r
QString refName = connIface->getReference()->getName(); \r
if (! prodPattern.contains(refName)) {\r
- cerr << "no production pattern for reference interface " << qPrintable(refName) << endl;\r
- return false;\r
+ throw(Exception(NO_IFACE_PP)); \r
+ }\r
+ QList<char>* pattern = NULL;\r
+ try {\r
+ pattern = expandPattern(prodPattern.value(refName));\r
+ }\r
+ catch(Exception e) {\r
+ throw(e);\r
productionPattern.insert(connIface,pattern);\r
if (lengthPP == -1) {\r
lengthPP = pattern->size();\r
}\r
else {\r
productionPattern.insert(connIface,pattern);\r
if (lengthPP == -1) {\r
lengthPP = pattern->size();\r
}\r
else {\r
static QString fctName = "FunctionalBlock::createProductionCounter()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
static QString fctName = "FunctionalBlock::createProductionCounter()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
- for(int i=0;i<3;i++) {\r
- bool okVal;\r
- double result = evaluateExpression(gen.at(i),&okVal);\r
- if (!okVal) return false;\r
+ for(int i=0;i<3;i++) { \r
+ double result = 0.0;\r
+ try {\r
+ result = evaluateExpression(gen.at(i));\r
+ }\r
+ catch(Exception e) {\r
+ throw(e);\r
+ }\r
if (i==0) start = result;\r
else if (i==1) nb = result;\r
else if (i==2) step = result;\r
if (i==0) start = result;\r
else if (i==1) nb = result;\r
else if (i==2) step = result;\r
static QString fctName = "FunctionalBlock::expandPattern()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
static QString fctName = "FunctionalBlock::expandPattern()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
-void FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset, bool *ok, QList<char>* patternOut) { \r
+void FunctionalBlock::expandPatternRecur(const QString& patternIn, int *offset, QList<char>* patternOut) throw(Exception) { \r
\r
while ((*offset < patternIn.size()) && (patternIn.at(*offset) != ')')) {\r
\r
QChar c = patternIn.at(*offset);\r
if (c == '(') {\r
*offset += 1;\r
\r
while ((*offset < patternIn.size()) && (patternIn.at(*offset) != ')')) {\r
\r
QChar c = patternIn.at(*offset);\r
if (c == '(') {\r
*offset += 1;\r
- expandPatternRecur(patternIn,offset, ok, patternOut);\r
- if (!ok) {\r
- return;\r
+ try {\r
+ expandPatternRecur(patternIn,offset, patternOut);\r
+ }\r
+ catch(Exception e) {\r
+ throw(e);\r
// repeat just the last value in currentGroup\r
char last = patternOut->last(); \r
//cout << "repeat last char " << repeat << " times : " << (int)last << endl;\r
// repeat just the last value in currentGroup\r
char last = patternOut->last(); \r
//cout << "repeat last char " << repeat << " times : " << (int)last << endl;\r
static QString fctName = "FunctionalBlock::evaluateExpression()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
static QString fctName = "FunctionalBlock::evaluateExpression()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
QHash<QString,double> vars;\r
evaluator->setExpression(expression);\r
QList<QString> varNames = evaluator->getVariableNames();\r
QHash<QString,double> vars;\r
evaluator->setExpression(expression);\r
QList<QString> varNames = evaluator->getVariableNames();\r
}\r
vars.insert(name,(double)val); \r
}\r
\r
evaluator->setVariablesValue(vars);\r
}\r
vars.insert(name,(double)val); \r
}\r
\r
evaluator->setVariablesValue(vars);\r
try {\r
result = evaluator->evaluate();\r
}\r
catch(int index) {\r
cerr << "Error at index " << index << ": " << qPrintable(evaluator->getError()) << endl;\r
try {\r
result = evaluator->evaluate();\r
}\r
catch(int index) {\r
cerr << "Error at index " << index << ": " << qPrintable(evaluator->getError()) << endl;\r
static QString fctName = "FunctionalBlock::createInputPattern())";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
static QString fctName = "FunctionalBlock::createInputPattern())";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
foreach(AbstractInterface* iface, getControlInputs()) { \r
ConnectedInterface* connIface = AI_TO_CON(iface);\r
QList<char>* out = connIface->getConnectedFrom()->getOutputPattern();\r
foreach(AbstractInterface* iface, getControlInputs()) { \r
ConnectedInterface* connIface = AI_TO_CON(iface);\r
QList<char>* out = connIface->getConnectedFrom()->getOutputPattern();\r
- if (out->size() > 0) {\r
- QList<char>* in = new QList<char>(*out);\r
- foreach(char c, *in) {\r
- cout << (int)c;\r
- }\r
- cout << endl;\r
-\r
- inputPattern.insert(connIface,in);\r
+ \r
+ QList<char>* in = new QList<char>(*out);\r
+ foreach(char c, *in) {\r
+ cout << (int)c;\r
static QString fctName = "FunctionalBlock::createAdmittance()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
static QString fctName = "FunctionalBlock::createAdmittance()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
// firstly, copy CP in AP\r
QMapIterator<AbstractInterface*,QList<char>* > iterC(consumptionPattern);\r
while (iterC.hasNext()) {\r
// firstly, copy CP in AP\r
QMapIterator<AbstractInterface*,QList<char>* > iterC(consumptionPattern);\r
while (iterC.hasNext()) {\r
static QString fctName = "FunctionalBlock::checkInputPatternCompatibility()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
static QString fctName = "FunctionalBlock::checkInputPatternCompatibility()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
while ((clock < lengthIP) && (! isValidDataGroup(inputPattern,clock))) clock++;\r
if (clock == lengthIP) {\r
cerr << "Abnormal case: end of IP has been reached without finding a valid group" << endl;\r
while ((clock < lengthIP) && (! isValidDataGroup(inputPattern,clock))) clock++;\r
if (clock == lengthIP) {\r
cerr << "Abnormal case: end of IP has been reached without finding a valid group" << endl;\r
*/\r
if (! samePatterns(inputPattern,clock,admittance,i)) {\r
cout << "AP(" << i << ") and IP(" << clock << ") are not equal" << endl;\r
*/\r
if (! samePatterns(inputPattern,clock,admittance,i)) {\r
cout << "AP(" << i << ") and IP(" << clock << ") are not equal" << endl;\r
static QString fctName = "FunctionalBlock::computeOutputPattern()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
static QString fctName = "FunctionalBlock::computeOutputPattern()";\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
// in case of inputPattern not created, do it\r
if (lengthIP <= 0) {\r
// collect the input patterns for each input \r
// in case of inputPattern not created, do it\r
if (lengthIP <= 0) {\r
// collect the input patterns for each input \r
}\r
\r
bool FunctionalBlock::samePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, const QMap<AbstractInterface*, QList<char>* >& patternDest, int destCol) {\r
}\r
\r
bool FunctionalBlock::samePatterns(const QMap<AbstractInterface*, QList<char>* >& patternSrc, int srcCol, const QMap<AbstractInterface*, QList<char>* >& patternDest, int destCol) {\r
/* NB: this method returns the number of executions that have been started\r
but not necessary completed.\r
*/\r
/* NB: this method returns the number of executions that have been started\r
but not necessary completed.\r
*/\r
int offset = 0;\r
// search for the first exec.\r
while ((offset < lengthIP) && (! isValidDataGroup(inputPattern,offset))) offset++;\r
if (offset == lengthIP) return 0;\r
int offset = 0;\r
// search for the first exec.\r
while ((offset < lengthIP) && (! isValidDataGroup(inputPattern,offset))) offset++;\r
if (offset == lengthIP) return 0;\r
int nbGroup = 0;\r
for(int i = offset;i<lengthIP;i++) {\r
if (isValidDataGroup(inputPattern,i)) nbGroup++;\r
if (nbGroup == delta+1) {\r
int nbGroup = 0;\r
for(int i = offset;i<lengthIP;i++) {\r
if (isValidDataGroup(inputPattern,i)) nbGroup++;\r
if (nbGroup == delta+1) {\r