Index: sources/model/mtreatmentparameters.cpp =================================================================== diff -u -r772d48b0ccaa0d25b6ed48bba3a4b29dc73c5c16 -rc838ade760d18fe2b391ea2e90bc04de0d4aa1eb --- sources/model/mtreatmentparameters.cpp (.../mtreatmentparameters.cpp) (revision 772d48b0ccaa0d25b6ed48bba3a4b29dc73c5c16) +++ sources/model/mtreatmentparameters.cpp (.../mtreatmentparameters.cpp) (revision c838ade760d18fe2b391ea2e90bc04de0d4aa1eb) @@ -28,9 +28,10 @@ TreatmentParameters::Data TreatmentParameters::fromVariantList(const QVariantList &list) { Data data; - if (list.length() != 18) + if (list.length() != 17) { - qDebug() << "Invalid QVariant List in " << __FUNCTION__; + qDebug() << "Invalid QVariant List found in " << __FUNCTION__; + qDebug() << list; return data; } data.bloodFlowRate = list[0].toUInt(); Index: sources/view/VCreateTreatment.h =================================================================== diff -u -r9551959461d534dc624f0cbcca0e6f953844fb16 -rc838ade760d18fe2b391ea2e90bc04de0d4aa1eb --- sources/view/VCreateTreatment.h (.../VCreateTreatment.h) (revision 9551959461d534dc624f0cbcca0e6f953844fb16) +++ sources/view/VCreateTreatment.h (.../VCreateTreatment.h) (revision c838ade760d18fe2b391ea2e90bc04de0d4aa1eb) @@ -47,10 +47,10 @@ TREATMENT_PARAMETER(quint32, bicarbonateConcentrate, 9999) // lookup idx TREATMENT_PARAMETER(quint32, dialyzerType, 9999) // lookup idx TREATMENT_PARAMETER(quint32, dialysateTemp, 35) // Celsius - TREATMENT_PARAMETER(quint32, arterialPressureLimitLow, 0) // mmHg - TREATMENT_PARAMETER(quint32, arterialPressureLimitHigh, 0) // mmHg - TREATMENT_PARAMETER(quint32, venousPressureLimitLow, 0) // mmHg - TREATMENT_PARAMETER(quint32, venousPressureLimitHigh, 0) // mmHg + TREATMENT_PARAMETER(qint32, arterialPressureLimitLow, 0) // mmHg + TREATMENT_PARAMETER(qint32, arterialPressureLimitHigh, 0) // mmHg + TREATMENT_PARAMETER(qint32, venousPressureLimitLow, 0) // mmHg + TREATMENT_PARAMETER(qint32, venousPressureLimitHigh, 0) // mmHg TREATMENT_PARAMETER(quint32, bloodPressureMeasureInterval, 0) // minutes TREATMENT_PARAMETER(quint32, rinsebackFlowRate, 50) // mL/min Index: unittests/tst_models.cpp =================================================================== diff -u -rbf645acccabb7b5a84801620c4f7fa0b0e6878e0 -rc838ade760d18fe2b391ea2e90bc04de0d4aa1eb --- unittests/tst_models.cpp (.../tst_models.cpp) (revision bf645acccabb7b5a84801620c4f7fa0b0e6878e0) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision c838ade760d18fe2b391ea2e90bc04de0d4aa1eb) @@ -47,6 +47,9 @@ #include "MAlarmTriggered.h" #include "MAlarmCleared.h" +#include "mtreatmentparameters.h" +#include "mtreatmentparametersresp.h" + // #define CONSOLEOUT /*! @@ -1247,8 +1250,8 @@ } QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(0)), tr("")); - QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(-1)), tr("Alarm Not Recognized.")); - QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(599)), tr("Alarm Not Recognized.")); + QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(-1)), tr("ALARM_ID_UNDEFINED [-1]")); + QCOMPARE(Model::MAlarmStatus::toText(Gui::GuiAlarmID(599)), tr("ALARM_ID_UNDEFINED [599]")); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1376,3 +1379,78 @@ break; } } + +void tst_models::tst_MTreatmentParametersResp_data() +{ + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" + "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" + "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" + "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("requestValid") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("bloodFlowRate") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("dialysateFlowRate") << 1 << QByteArray::fromHex(QByteArray("00" "00")); + QTest::newRow("duration") << 1 << QByteArray::fromHex(QByteArray("00" "00" "00")); + QTest::newRow("heparinDispensingRate") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "00")); + QTest::newRow("heparinBolusVolume") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00")); + QTest::newRow("heparinStopTime") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00")); + QTest::newRow("salineBolus") << 2 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("acidConcentrate") << 3 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("bicarbonateConcentrate") << 3 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("dialyzerType") << 3 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("dialysateTemp") << 3 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("arterialPressureLimitLow") << 4 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("arterialPressureLimitHigh") << 4 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("venousPressureLimitLow") << 4 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("venousPressureLimitHigh") << 4 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("bloodPressureMeasureInterval") << 5 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); + QTest::newRow("rinsebackFlowRate") << 5 << QByteArray::fromHex(QByteArray("00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00")); +} + + +void tst_models::tst_MTreatmentParametersResp() +{ + Model::TreatmentParametersResp mData; + + + QFETCH(int , errorIndex ); + QFETCH(QByteArray, data ); + + int startIndex = 0; + int index = errorIndex - 1; + bool ok = mData.fromByteArray(data, &startIndex); + + Q_UNUSED(ok) +#ifdef CONSOLEOUT + qDebug() << "index: " << index << "\n" + << "errorIndex: " << errorIndex << "\n" + << "startIndex: " << startIndex << "\n" + << "ok: " << ok << "\n" + << "data: " << data; +#endif + switch (errorIndex) { + case 0: { index = 0 ; QVERIFY ( mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 1: { index = index * sizeof mData._data.requestValid ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 2: { index = index * sizeof mData._data.bloodFlowRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 3: { index = index * sizeof mData._data.dialysateFlowRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 4: { index = index * sizeof mData._data.duration ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 5: { index = index * sizeof mData._data.heparinDispensingRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 6: { index = index * sizeof mData._data.heparinBolusVolume ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 7: { index = index * sizeof mData._data.heparinStopTime ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 8: { index = index * sizeof mData._data.salineBolus ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 9: { index = index * sizeof mData._data.acidConcentrate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 10: { index = index * sizeof mData._data.bicarbonateConcentrate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 11: { index = index * sizeof mData._data.dialyzerType ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 12: { index = index * sizeof mData._data.dialysateTemp ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 13: { index = index * sizeof mData._data.arterialPressureLimitLow ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 14: { index = index * sizeof mData._data.arterialPressureLimitHigh ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 15: { index = index * sizeof mData._data.venousPressureLimitLow ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 16: { index = index * sizeof mData._data.venousPressureLimitHigh ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 17: { index = index * sizeof mData._data.bloodPressureMeasureInterval; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + case 18: { index = index * sizeof mData._data.rinsebackFlowRate ; QVERIFY ( !mData.fromByteArray(data)); QCOMPARE(index, startIndex); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} Index: unittests/tst_models.h =================================================================== diff -u -rbf645acccabb7b5a84801620c4f7fa0b0e6878e0 -rc838ade760d18fe2b391ea2e90bc04de0d4aa1eb --- unittests/tst_models.h (.../tst_models.h) (revision bf645acccabb7b5a84801620c4f7fa0b0e6878e0) +++ unittests/tst_models.h (.../tst_models.h) (revision c838ade760d18fe2b391ea2e90bc04de0d4aa1eb) @@ -101,5 +101,9 @@ void tst_MAlarmCleared_data(); void tst_MAlarmCleared(); + + // Treatment Parameters + void tst_MTreatmentParametersResp_data(); + void tst_MTreatmentParametersResp(); }; Index: unittests/tst_views.cpp =================================================================== diff -u -r772d48b0ccaa0d25b6ed48bba3a4b29dc73c5c16 -rc838ade760d18fe2b391ea2e90bc04de0d4aa1eb --- unittests/tst_views.cpp (.../tst_views.cpp) (revision 772d48b0ccaa0d25b6ed48bba3a4b29dc73c5c16) +++ unittests/tst_views.cpp (.../tst_views.cpp) (revision c838ade760d18fe2b391ea2e90bc04de0d4aa1eb) @@ -117,6 +117,29 @@ QCOMPARE(view.isbloodPressureMeasureIntervalSet, true); QCOMPARE(view.isrinsebackFlowRateSet, true); QCOMPARE(view.validate(view.treatmentData), true); + + // check getters + QCOMPARE(view.get_bloodFlowRate(), view.bloodFlowRateMax()); + QCOMPARE(view.get_dialysateFlowRate(), view.dialysateFlowRateMax()); + QCOMPARE(view.get_duration(), view.durationMax()); + QCOMPARE(view.get_heparinDispensingRate(),view.heparinDispensingRateMax()); + + QCOMPARE(view.get_heparinBolusVolume(),view.heparinBolusVolumeMax()); + QCOMPARE(view.get_heparinStopTime(),view.heparinStopTimeMax()); + QCOMPARE(view.get_salineBolusVolume(), quint32(0)); + QCOMPARE(view.get_acidConcentrate(), quint32(0)); + QCOMPARE(view.get_bicarbonateConcentrate(), quint32(0)); + + QCOMPARE(view.get_dialyzerType(), quint32(0)); + QCOMPARE(view.get_dialysateTemp(), view.dialysateTempMax()); + QCOMPARE(view.get_arterialPressureLimitLow(),view.arterialPressureLimitLowMin()); + QCOMPARE(view.get_arterialPressureLimitHigh(), view.arterialPressureLimitHighMax()); + QCOMPARE(view.get_venousPressureLimitLow(), view.venousPressureLimitLowMin()); + QCOMPARE(view.get_venousPressureLimitHigh(), view.venousPressureLimitHighMax()); + + QCOMPARE(view.get_bloodPressureMeasureInterval(), view.bloodPressureMeasureIntervalMax()); + QCOMPARE(view.get_rinsebackFlowRate(), view.rinsebackFlowRateMax()); + view.onFinishedCreate(); } else { Index: unittests/tst_views.h =================================================================== diff -u -r9551959461d534dc624f0cbcca0e6f953844fb16 -rc838ade760d18fe2b391ea2e90bc04de0d4aa1eb --- unittests/tst_views.h (.../tst_views.h) (revision 9551959461d534dc624f0cbcca0e6f953844fb16) +++ unittests/tst_views.h (.../tst_views.h) (revision c838ade760d18fe2b391ea2e90bc04de0d4aa1eb) @@ -28,7 +28,6 @@ explicit tst_views(QObject *parent = nullptr); private: QString datetimeFormat = "MM.dd.yyyy_HH.mm.ss"; - private slots: void VTreatmentAdjustmentsResponse_text_NoReason(); void VTreatmentAdjustmentsResponse_text_WAReason();