diff --git a/main.cpp b/main.cpp index 6c9b2925..962b7d6f 100644 --- a/main.cpp +++ b/main.cpp @@ -42,6 +42,8 @@ public: }; int main() { PIEvaluator eval, eval2; + //eval.check("1-1+1"); + //piCout << eval.evaluate().real(); eval.setVariable("t", complexd(1, 2)); eval.check("(t*t*(t<8))+(72*(t>8)-8*(9-t)*(9-t)*(t>8)*(t<8.8))+(3*(t-8.8)*(t>8.8))"); PIByteArray ba = eval.save(); @@ -59,12 +61,14 @@ int main() { tm.reset(); PIEvaluator e2; - piForTimes(100) { - e2.load(ba); + e2.load(ba); + piForTimes(10000) { e2.setVariable("t", complexd(1, 2)); complexd ret = e2.evaluate(); } - us = tm.elapsed_u(); piCout << " save" << us / 100.; + us = tm.elapsed_u(); piCout << " save" << us / 10000.; + + /*A a; CONNECTU(PICout::Notifier::object(), finished, &a, pcf); diff --git a/src_io_utils/pibroadcast.cpp b/src_io_utils/pibroadcast.cpp index e73372b8..aac64a06 100644 --- a/src_io_utils/pibroadcast.cpp +++ b/src_io_utils/pibroadcast.cpp @@ -259,8 +259,10 @@ void PIBroadcast::mcastRead(uchar * data, int size) { void PIBroadcast::run() { PIVector al = PIEthernet::allAddresses(); mcast_mutex.lock(); - bool r = _reinit; + bool r = _reinit, ac = (al != prev_al); mcast_mutex.unlock(); - if (al != prev_al || r) + if (ac || r) reinit(); + if (ac) + addressesChanged(); } diff --git a/src_main/io_utils/pibroadcast.h b/src_main/io_utils/pibroadcast.h index 6fe768c9..96c8794a 100644 --- a/src_main/io_utils/pibroadcast.h +++ b/src_main/io_utils/pibroadcast.h @@ -125,6 +125,9 @@ protected: //! Called when packet received virtual void received(PIByteArray data) {} + //! Called when addresses are changed + virtual void addressesChanged() {} + private: EVENT_HANDLER2(void, mcastRead, uchar * , data, int, size); void destroyAll(); diff --git a/src_main/math/pievaluator.cpp b/src_main/math/pievaluator.cpp index 7e72bb02..8c9a081f 100755 --- a/src_main/math/pievaluator.cpp +++ b/src_main/math/pievaluator.cpp @@ -863,7 +863,7 @@ int PIEvaluator::parse(const PIString & string, int offset) { if (args.size_s() > 0) return args.back(); else return -666; } - for (int i = 0; i < PIEvaluatorTypes::operationCount; i++) { + for (int i = 0; i < PIEvaluatorTypes::oOperatorsCount; i++) { coper = operationInOrder(i); for (int j = 0; j < opers.size_s(); j++) { if (coper == PIEvaluatorTypes::oDivide || coper == PIEvaluatorTypes::oMultiply) { @@ -1016,7 +1016,7 @@ inline complexd PIEvaluator::residue(const complexd & f, const complexd & s) { inline void PIEvaluator::execFunction(const PIEvaluatorTypes::Instruction & ci) { - PIEvaluatorTypes::Function cfunc = content.function(ci.function); + const PIEvaluatorTypes::Function & cfunc(content.function(ci.function)); int oi = -ci.out - 1; complexd tmp, stmp, ttmp; //qDebug() << "function " << (int)cfunc.type; @@ -1181,13 +1181,12 @@ inline void PIEvaluator::execFunction(const PIEvaluatorTypes::Instruction & ci) inline bool PIEvaluator::execInstructions() { kvars = &(content.variables); - PIEvaluatorTypes::Instruction ci; int oi; complexd tmp; tmpvars = variables; //cout << "var count " << tmpvars.size_s() << endl; for (int i = 0; i < instructions.size_s(); i++) { - ci = instructions[i]; + const PIEvaluatorTypes::Instruction & ci(instructions[i]); oi = -ci.out - 1; //cout << value(ci.operators[0]) << operationChar(ci.operation) << value(ci.operators[1]) << ", " << oi << endl; switch (ci.operation) { @@ -1241,6 +1240,7 @@ inline bool PIEvaluator::execInstructions() { case PIEvaluatorTypes::oNone: tmpvars[oi].value = value(ci.operators[0]); break; + default: break; } } if (!instructions.isEmpty()) diff --git a/src_main/math/pievaluator.h b/src_main/math/pievaluator.h index 51b1f804..d5a12f80 100755 --- a/src_main/math/pievaluator.h +++ b/src_main/math/pievaluator.h @@ -29,12 +29,11 @@ typedef complexd (*FuncFunc)(void * , int, complexd * ); namespace PIEvaluatorTypes { - static const int operationCount = 14; enum PIP_EXPORT eType {etNumber, etOperator, etVariable, etFunction}; enum PIP_EXPORT Operation {oNone, oAdd, oSubtract, oMultiply, oDivide, oResidue, oPower, oEqual, oNotEqual, oGreater, oSmaller, oGreaterEqual, oSmallerEqual, - oAnd, oOr, oFunction + oAnd, oOr, oOperatorsCount, oFunction }; enum PIP_EXPORT BaseFunctions {bfUnknown, bfSin, bfCos, bfTg, bfCtg, bfArcsin, bfArccos, bfArctg, bfArcctg,