Index: sources/canbus/messageacknowmodel.cpp =================================================================== diff -u -r93d7ff58cd6fd2fea5d00587ee712a637fc941bf -r634824d6fce314971aa236e508024bd154562c9d --- sources/canbus/messageacknowmodel.cpp (.../messageacknowmodel.cpp) (revision 93d7ff58cd6fd2fea5d00587ee712a637fc941bf) +++ sources/canbus/messageacknowmodel.cpp (.../messageacknowmodel.cpp) (revision 634824d6fce314971aa236e508024bd154562c9d) @@ -161,8 +161,10 @@ */ void MessageAcknowModel::onAcknowReceive(Sequence vSequence) { - _acknowList[vSequence]->deleteLater(); - _acknowList.remove(vSequence); + if (_acknowList.contains(vSequence)) { + _acknowList[vSequence]->deleteLater(); + _acknowList.remove(vSequence); + } } /*! Index: sources/gui/qml/pages/treatment/sections/TreatmentUltrafiltration.qml =================================================================== diff -u -r95c671ab7037af055db551456a719ff67bf10262 -r634824d6fce314971aa236e508024bd154562c9d --- sources/gui/qml/pages/treatment/sections/TreatmentUltrafiltration.qml (.../TreatmentUltrafiltration.qml) (revision 95c671ab7037af055db551456a719ff67bf10262) +++ sources/gui/qml/pages/treatment/sections/TreatmentUltrafiltration.qml (.../TreatmentUltrafiltration.qml) (revision 634824d6fce314971aa236e508024bd154562c9d) @@ -40,11 +40,10 @@ title : qsTr("ULTRAFILTRATION VOLUME") + " " + qsTr("(mL)") Connections { target: vTreatmentAdjustmentsResponse - onAdjustmentDurationTriggered: { - } + onAdjustmentDurationTriggered: { } onUltrafiltrationChanged: { // As a reminder for later use - // console.debug("@",vTreatmentAdjustmentsResponse.ultrafiltration) + console.debug("@",vTreatmentAdjustmentsResponse.ultrafiltration) } } Index: sources/main.h =================================================================== diff -u -r95c671ab7037af055db551456a719ff67bf10262 -r634824d6fce314971aa236e508024bd154562c9d --- sources/main.h (.../main.h) (revision 95c671ab7037af055db551456a719ff67bf10262) +++ sources/main.h (.../main.h) (revision 634824d6fce314971aa236e508024bd154562c9d) @@ -51,38 +51,47 @@ //--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------// #define DEBUG_PROPERTY_CHANGED(vVARIABLE) //qDebug() << "#" << #vVARIABLE << v##vVARIABLE; -#define PROPERTY_BASE(vTYPE , vVARIABLE , vDEFVALUE, vALWAYSEMIT, vSIGNAL) \ - Q_PROPERTY(vTYPE vVARIABLE \ - READ vVARIABLE \ - WRITE vVARIABLE \ - NOTIFY vVARIABLE##vSIGNAL) \ - Q_SIGNALS: \ - void vVARIABLE##vSIGNAL \ - ( const vTYPE & v##vVARIABLE ); \ - private: \ - vTYPE _##vVARIABLE = vDEFVALUE; \ - vTYPE vVARIABLE () const { \ - return _##vVARIABLE ; \ - } \ - void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ - static bool init = false; \ - if ( vALWAYSEMIT \ - || ! init \ - || _##vVARIABLE != v##vVARIABLE ) { \ - DEBUG_PROPERTY_CHANGED(vVARIABLE) \ - init = true; \ - _##vVARIABLE = v##vVARIABLE; \ - emit vVARIABLE##vSIGNAL( _##vVARIABLE ); \ - } \ +//--------------------------------------------------------------------------------// +#define PROPERTY_SLOT( vTYPE , vVARIABLE ) \ + void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ + static bool init = false; \ + if ( !init || _##vVARIABLE != v##vVARIABLE ) { \ + DEBUG_PROPERTY_CHANGED(vVARIABLE) \ + init = true; \ + _##vVARIABLE = v##vVARIABLE; \ + emit vVARIABLE##Changed( _##vVARIABLE ); \ + } \ } //--------------------------------------------------------------------------------// -#define PROPERTY( vTYPE , vVARIABLE , vDEFVALUE ) \ - PROPERTY_BASE(vTYPE , vVARIABLE , vDEFVALUE, false, Changed ) +#define TRIGGER_SLOT( vTYPE , vVARIABLE ) \ + void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ + DEBUG_PROPERTY_CHANGED(vVARIABLE) \ + _##vVARIABLE = v##vVARIABLE; \ + emit vVARIABLE##Triggered( _##vVARIABLE ); \ + } //--------------------------------------------------------------------------------// -#define TRIGGER( vTYPE , vVARIABLE, vDEFVALUE ) \ - PROPERTY_BASE(vTYPE , vVARIABLE , vDEFVALUE, true , Triggered ) +#define PROPERTY_BASE(vTYPE , vVARIABLE , vDEFVALUE, vSIGNAL) \ + Q_PROPERTY( vTYPE vVARIABLE \ + READ vVARIABLE \ + WRITE vVARIABLE \ + NOTIFY vVARIABLE##vSIGNAL) \ + Q_SIGNALS: \ + void vVARIABLE##vSIGNAL( const vTYPE & v##vVARIABLE ); \ + private: \ + vTYPE _##vVARIABLE = vDEFVALUE; \ + vTYPE vVARIABLE () const { \ + return _##vVARIABLE ; \ + } //--------------------------------------------------------------------------------// +#define PROPERTY( vTYPE , vVARIABLE , vDEFVALUE ) \ + PROPERTY_BASE( vTYPE , vVARIABLE , vDEFVALUE , Changed ) \ + PROPERTY_SLOT( vTYPE , vVARIABLE) //--------------------------------------------------------------------------------// +#define TRIGGER( vTYPE , vVARIABLE , vDEFVALUE ) \ + PROPERTY_BASE( vTYPE , vVARIABLE , vDEFVALUE , Triggered) \ + TRIGGER_SLOT( vTYPE , vVARIABLE) +//--------------------------------------------------------------------------------// +//--------------------------------------------------------------------------------// #define ACTION_METHOD_BRIDGE_CONNECTION(vMETHOD, vSOURCE, vTYPE) \ connect(&vSOURCE, SIGNAL(did##vMETHOD(const vTYPE &)), \ this , SLOT( on##vMETHOD(const vTYPE &))); Index: unittests/tst_acknow.cpp =================================================================== diff -u -r805119c460b4a266d6401c8705f4427e7fbe270f -r634824d6fce314971aa236e508024bd154562c9d --- unittests/tst_acknow.cpp (.../tst_acknow.cpp) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) +++ unittests/tst_acknow.cpp (.../tst_acknow.cpp) (revision 634824d6fce314971aa236e508024bd154562c9d) @@ -126,6 +126,21 @@ _MessageDispatcher._needsAcknow.removeOne(Gui::GuiActionType::KeepAlive); } +/*! + * \brief tst_acknow::tst_AcknowModel_onAcknowReceive_Incorrect + * \details Tries to remove a seq from acknow model which we don't expect + * (there was no message send with this seq which required qcknow) + * and the seq should not exists before and after removal + * this is a test for qt hash test used for acknow model + * \param vSequence + */ +void tst_acknow::tst_AcknowModel_onAcknowReceive_Incorrect() +{ + QVERIFY( ! _MessageAcknowModel._acknowList.contains(9999)); + _MessageAcknowModel.onAcknowReceive(9999); + QVERIFY( ! _MessageAcknowModel._acknowList.contains(9999)); +} + void tst_acknow::cleanupTestCase() { _CanInterface.quitDevice(); Index: unittests/tst_acknow.h =================================================================== diff -u -r805119c460b4a266d6401c8705f4427e7fbe270f -r634824d6fce314971aa236e508024bd154562c9d --- unittests/tst_acknow.h (.../tst_acknow.h) (revision 805119c460b4a266d6401c8705f4427e7fbe270f) +++ unittests/tst_acknow.h (.../tst_acknow.h) (revision 634824d6fce314971aa236e508024bd154562c9d) @@ -45,6 +45,8 @@ void tst_AcknowModel_Transmit_Normal(); void tst_AcknowModel_Transmit_Acknow(); + void tst_AcknowModel_onAcknowReceive_Incorrect(); + void cleanupTestCase(); void onFrameTransmit (Can_Id vCan_Id , const QByteArray &vPayload); Index: unittests/tst_messaging.cpp =================================================================== diff -u -rd07ec81c7002ed2ac60c1dfc3101fb820e88211c -r634824d6fce314971aa236e508024bd154562c9d --- unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision d07ec81c7002ed2ac60c1dfc3101fb820e88211c) +++ unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision 634824d6fce314971aa236e508024bd154562c9d) @@ -293,6 +293,26 @@ QVERIFY( ! iMsg.adjustBloodDialysateData(msg, list)); } +void tst_messaging::tst_MessageInterpreter_adjustDurationData_isType() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::Unknown; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.adjustDurationData(msg, list)); +} + +void tst_messaging::tst_MessageInterpreter_adjustDurationData_payloadLen() +{ + Can::MessageInterpreter iMsg; + Can::Message msg; + msg.actionId = Gui::GuiActionType::AdjustDurationRsp; + msg.data = {}; + QVariantList list; + QVERIFY( ! iMsg.adjustDurationData(msg, list)); +} + void tst_messaging::tst_MessageInterpreter_treatmentRangesData_isType() { Can::MessageInterpreter iMsg; @@ -329,6 +349,14 @@ QVERIFY(payload.isEmpty()); } +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustDurationReq() +{ + Can::MessageInterpreter iMsg; + QByteArray payload; + QVERIFY(iMsg.interpretMessage(Gui::GuiActionType::AdjustDurationReq, {}, payload)); + QVERIFY(payload.isEmpty()); +} + void tst_messaging::tst_MessageBuilder_addActionId() { Can::MessageBuilder bMsg; Index: unittests/tst_messaging.h =================================================================== diff -u -r5626bf604947efe5a80c9ca51802aab1a70a6939 -r634824d6fce314971aa236e508024bd154562c9d --- unittests/tst_messaging.h (.../tst_messaging.h) (revision 5626bf604947efe5a80c9ca51802aab1a70a6939) +++ unittests/tst_messaging.h (.../tst_messaging.h) (revision 634824d6fce314971aa236e508024bd154562c9d) @@ -60,11 +60,15 @@ void tst_MessageInterpreter_adjustBloodDialysateData_isType(); void tst_MessageInterpreter_adjustBloodDialysateData_payloadLen(); + void tst_MessageInterpreter_adjustDurationData_isType(); + void tst_MessageInterpreter_adjustDurationData_payloadLen(); + void tst_MessageInterpreter_treatmentRangesData_isType(); void tst_MessageInterpreter_treatmentRangesData_payloadLen(); void tst_MessageInterpreter_interpretMessage_String(); void tst_MessageInterpreter_interpretMessage_AdjustBloodDialysateReq(); + void tst_MessageInterpreter_interpretMessage_AdjustDurationReq(); void tst_MessageBuilder_addActionId(); void tst_MessageBuilder_addData_shorterLen(); Index: unittests/tst_models.cpp =================================================================== diff -u -rd3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d -r634824d6fce314971aa236e508024bd154562c9d --- unittests/tst_models.cpp (.../tst_models.cpp) (revision d3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision 634824d6fce314971aa236e508024bd154562c9d) @@ -17,6 +17,7 @@ // Project #include "mtreatmentadjustblooddialysateresponse.h" +#include "mtreatmentadjustdurationresponse.h" #include "mtreatmentranges.h" // #define CONSOLEOUT @@ -140,3 +141,52 @@ } +void tst_models::tst_MAdjustDurationResponse_data () +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg compelete ")<< 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mAccepted ")<< 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mReason ")<< 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mDuration ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mDuration ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mDuration ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mDuration ")<< 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); + QTest::newRow("mUltrafiltration")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mUltrafiltration")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C")); + QTest::newRow("mUltrafiltration")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D")); + QTest::newRow("mUltrafiltration")<< 4 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E")); +} + +void tst_models::tst_MAdjustDurationResponse () +{ + Model::MAdjustDurationResponse mData; + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + +#ifdef CONSOLEOUT + qDebug() << index << errorIndex << startIndex << ok << data ; +#endif + + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 1: { index = index * sizeof mData._data.mAccepted ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mDuration ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 4: { index = index * sizeof mData._data.mUFVolume ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} Index: unittests/tst_models.h =================================================================== diff -u -rd3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d -r634824d6fce314971aa236e508024bd154562c9d --- unittests/tst_models.h (.../tst_models.h) (revision d3f916066c2d10c10fffa91fd8a7e5ac6dd86c7d) +++ unittests/tst_models.h (.../tst_models.h) (revision 634824d6fce314971aa236e508024bd154562c9d) @@ -31,6 +31,9 @@ void tst_MAdjustBloodDialysateResponse_data (); void tst_MAdjustBloodDialysateResponse (); + void tst_MAdjustDurationResponse_data (); + void tst_MAdjustDurationResponse (); + void tst_MTreatmentRanges_data (); void tst_MTreatmentRanges ();