Index: denali.pro =================================================================== diff -u -rc241fc1d31be3e4958582dff94de8189f5bbba67 -r0d59385f134f65a19dace1e2b46eb2631924396e --- denali.pro (.../denali.pro) (revision c241fc1d31be3e4958582dff94de8189f5bbba67) +++ denali.pro (.../denali.pro) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -57,7 +57,7 @@ sources/model/MStartTreatmentResponse.h \ sources/model/hd/data/MPrimingData.h \ sources/model/MTreatmentParametersResp.h \ - sources/storage/filesaver.h \ + sources/storage/FileSaver.h \ sources/model/MDGDebugText.h \ sources/model/MHDDebugText.h \ sources/storage/DriveWatcher.h \ @@ -263,7 +263,7 @@ sources/storage/FileHandler.cpp \ sources/storage/Logger.cpp \ sources/storage/DriveWatcher.cpp \ - sources/storage/filesaver.cpp \ + sources/storage/FileSaver.cpp \ \ # Utility sources/utility/crc.cpp \ sources/utility/format.cpp \ Index: denali.pro.user =================================================================== diff -u -r321e667cd58da515845f2173d5e1a59082823455 -r0d59385f134f65a19dace1e2b46eb2631924396e --- denali.pro.user (.../denali.pro.user) (revision 321e667cd58da515845f2173d5e1a59082823455) +++ denali.pro.user (.../denali.pro.user) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -1,6 +1,6 @@ - + EnvironmentId Index: sources/VTreatmentBegin.h =================================================================== diff -u -r321e667cd58da515845f2173d5e1a59082823455 -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/VTreatmentBegin.h (.../VTreatmentBegin.h) (revision 321e667cd58da515845f2173d5e1a59082823455) +++ sources/VTreatmentBegin.h (.../VTreatmentBegin.h) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -7,12 +7,18 @@ // Project #include "main.h" +// forward declarations +class tst_views; + namespace View { class VTreatmentBegin : public QObject { Q_OBJECT + // friends + friend class ::tst_views; + public: explicit VTreatmentBegin(QObject *parent = nullptr); Index: sources/canbus/MessageInterpreter.h =================================================================== diff -u -rd9f8e4e8356bd081f84dc08c4d65d727c0ee707f -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/canbus/MessageInterpreter.h (.../MessageInterpreter.h) (revision d9f8e4e8356bd081f84dc08c4d65d727c0ee707f) +++ sources/canbus/MessageInterpreter.h (.../MessageInterpreter.h) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -24,6 +24,7 @@ // forward declaration class tst_messaging; class tst_logging; +class tst_canbus; namespace Can { @@ -47,6 +48,7 @@ // friend friend class ::tst_messaging; friend class ::tst_logging; + friend class ::tst_canbus; bool isType (const Message &vMessage, Gui::GuiActionType vType) const; bool isPayloadLenValid (const Message &vMessage, Gui::GuiActionType vType) const; Index: sources/gui/GuiGlobals.h =================================================================== diff -u -rc241fc1d31be3e4958582dff94de8189f5bbba67 -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/gui/GuiGlobals.h (.../GuiGlobals.h) (revision c241fc1d31be3e4958582dff94de8189f5bbba67) +++ sources/gui/GuiGlobals.h (.../GuiGlobals.h) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -100,7 +100,7 @@ ID_EndTreatmentReq = 0x3B00, // 59 ID_EndTreatmentRsp = 0x3C00, // 60 - ID_PrimingData = 0x3700, // 55 + ID_PrimingData = 0x4300, // 67 ID_HDOperationModeData = 0x2500, // 37 Index: sources/gui/qml/components/TopMenuBarCreateTreatment.qml =================================================================== diff -u -rb61d8a3e01fef66eee8095c9cddf835d9bb32b66 -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/gui/qml/components/TopMenuBarCreateTreatment.qml (.../TopMenuBarCreateTreatment.qml) (revision b61d8a3e01fef66eee8095c9cddf835d9bb32b66) +++ sources/gui/qml/components/TopMenuBarCreateTreatment.qml (.../TopMenuBarCreateTreatment.qml) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -30,6 +30,7 @@ signal clickedBack() BackButton { id : _backButton + objectName: "_backButton" width: parent.width / 10 anchors.verticalCenter: parent.verticalCenter anchors.top: parent.top Index: sources/gui/qml/pages/treatment/TreatmentBegin.qml =================================================================== diff -u -rb62ab443e75b76a91e35aca6ba2efd84e7199602 -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/gui/qml/pages/treatment/TreatmentBegin.qml (.../TreatmentBegin.qml) (revision b62ab443e75b76a91e35aca6ba2efd84e7199602) +++ sources/gui/qml/pages/treatment/TreatmentBegin.qml (.../TreatmentBegin.qml) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -90,7 +90,7 @@ sliderObjectName: objectName + "Slider" selectedValueObjectName: objectName + "Value" text: "Ultrafiltration Volume" - units: qsTr(" mL") + units: qsTr("mL") min: vTreatmentBegin.ufVolumeMin max: vTreatmentBegin.ufVolumeMax step: vTreatmentBegin.ufVolumeRes Index: sources/storage/FileSaver.cpp =================================================================== diff -u --- sources/storage/FileSaver.cpp (revision 0) +++ sources/storage/FileSaver.cpp (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -0,0 +1,55 @@ +/*! + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file filesaver.cpp + * \author (last) Peter Lucia + * \date (last) 15-Oct-2020 + * \author (original) Peter Lucia + * \date (original) 03-Aug-2020 + * + */ +#include "FileSaver.h" + + +// Qt +#include +#include + +// Project +#include "FileHandler.h" + + +using namespace Storage; + +FileSaver::FileSaver(QObject *parent) : QObject(parent) +{ + connect(&_futureWatcher, SIGNAL(finished()), + this , SLOT(onFileSaved())); +} + +/** + * @brief FileSaver::concurrentSave + * @param filename (QString) contains the path to the file to be written to + * @param content (QString) the content to write to the file + * @param append (bool) if True, append the content. Otherwise, overwrite it + */ +void FileSaver::onConcurrentSave(const QString &filename, const QString &content, bool append) +{ + QFuture future = QtConcurrent::run(&FileHandler::write, filename, content, append); + _futureWatcher.setFuture(future); +} + +/** + * @brief FileSaver::onFileSaved + * Emits when the file save operation is complete and true if the save was successful, false otherwise + */ +void FileSaver::onFileSaved() +{ + // coco begin validated: Has been validated manually + emit fileSaved(_futureWatcher.result()); +} +// coco end Index: sources/storage/FileSaver.h =================================================================== diff -u --- sources/storage/FileSaver.h (revision 0) +++ sources/storage/FileSaver.h (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -0,0 +1,50 @@ +/*! + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file filesaver.h + * \author (last) Peter Lucia + * \date (last) 14-Oct-2020 + * \author (original) Peter Lucia + * \date (original) 03-Aug-2020 + * + */ +#ifndef FILESAVER_H +#define FILESAVER_H + +// Qt +#include +#include + +// Project +#include "main.h" + +// Define +#define _FileSaver FileSaver::I() + +namespace Storage { + +class FileSaver : public QObject +{ + Q_OBJECT + +SINGLETON(FileSaver) + +private: + QFutureWatcher _futureWatcher; + +signals: + void fileSaved(bool result); + +public slots: + void onConcurrentSave(const QString &filename, const QString &content, bool append); + +private slots: + void onFileSaved(); +}; +} + +#endif // FILESAVER_H Fisheye: Tag 0d59385f134f65a19dace1e2b46eb2631924396e refers to a dead (removed) revision in file `sources/storage/filesaver.cpp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0d59385f134f65a19dace1e2b46eb2631924396e refers to a dead (removed) revision in file `sources/storage/filesaver.h'. Fisheye: No comparison available. Pass `N' to diff? Index: sources/view/VPriming.h =================================================================== diff -u -r9cef897469b01673d2ac04fc73510fc96382caf3 -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/view/VPriming.h (.../VPriming.h) (revision 9cef897469b01673d2ac04fc73510fc96382caf3) +++ sources/view/VPriming.h (.../VPriming.h) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -20,12 +20,18 @@ // Project #include "MPrimingData.h" +// forward declarations +class tst_views; namespace View { class VPriming : public QObject { Q_OBJECT + + // friends + friend class::tst_views; + public: VPriming(QObject *parent = NULL); Index: sources/view/VTreatmentCreate.cpp =================================================================== diff -u -rb62ab443e75b76a91e35aca6ba2efd84e7199602 -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision b62ab443e75b76a91e35aca6ba2efd84e7199602) +++ sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -456,6 +456,8 @@ {"rinsebackFlowRate", QString::number(treatmentData.rinsebackFlowRate)} }; + QString treatmentParameters = QJsonDocument(obj).toJson(QJsonDocument::Indented); + LOG_EVENT(QString("Create Treatment Confirm: %1").arg(treatmentParameters)); if (saveTreatmentProfile()) saveNewTreatment(obj); Index: sources/view/VTreatmentCreate.h =================================================================== diff -u -r321e667cd58da515845f2173d5e1a59082823455 -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/view/VTreatmentCreate.h (.../VTreatmentCreate.h) (revision 321e667cd58da515845f2173d5e1a59082823455) +++ sources/view/VTreatmentCreate.h (.../VTreatmentCreate.h) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -13,7 +13,7 @@ #include "MTreatmentParametersResp.h" #include "GuiController.h" #include "StorageGlobals.h" -#include "filesaver.h" +#include "FileSaver.h" // forward diclations class tst_views; @@ -69,9 +69,9 @@ TREATMENT_PARAMETER(quint32, heparinStopTime, 0, 0, 480, 10 ) // min TREATMENT_PARAMETER(quint32, salineBolusVolume, 100, 100, 300, 100) // mL - TREATMENT_PARAMETER(quint32, acidConcentrate, UNSET, 0, 3, 1) - TREATMENT_PARAMETER(quint32, bicarbonateConcentrate, UNSET, 0, 1, 1) - TREATMENT_PARAMETER(quint32, dialyzerType, UNSET, 0, 3, 1) + TREATMENT_PARAMETER(quint32, acidConcentrate, UNSET, 0, 2, 1) + TREATMENT_PARAMETER(quint32, bicarbonateConcentrate, UNSET, 0, 0, 1) + TREATMENT_PARAMETER(quint32, dialyzerType, UNSET, 0, 2, 1) TREATMENT_PARAMETER(qreal, dialysateTemp, 37, 35, 38, 0.5) // Celsius TREATMENT_PARAMETER(qint32, arterialPressureLimitLow, -300, -300, 200, 10) // mmHg Index: sources/view/hd/alarm/VAlarmStatus.cpp =================================================================== diff -u -rb61d8a3e01fef66eee8095c9cddf835d9bb32b66 -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/view/hd/alarm/VAlarmStatus.cpp (.../VAlarmStatus.cpp) (revision b61d8a3e01fef66eee8095c9cddf835d9bb32b66) +++ sources/view/hd/alarm/VAlarmStatus.cpp (.../VAlarmStatus.cpp) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -32,6 +32,9 @@ connect(this, SIGNAL(requestAlarmSilence(AlarmSilenceRequestData)), &_GuiController, SLOT(doAdjustment(AlarmSilenceRequestData))); + + connect(this, SIGNAL(didRequestEndTreatment(EndTreatmentRequestData)), + &_GuiController, SLOT(doAdjustment(EndTreatmentRequestData))); } void VAlarmStatus::onActionReceive(const AlarmStatusData &vData) @@ -153,3 +156,20 @@ emit requestAlarmSilence(data); onSetMinimize(true); } + +/*! + * \brief VAlarmStatus::onRequestEndTreatment + * When an alarm showing an end treatment request is issued, + * if the user decides to end the treatment, this slot will be called + * + * Note that this may have to be moved to another class depending on + * the direction of the alarm design and dialogues. + */ +void VAlarmStatus::doRequestEndTreatment() +{ + // coco begin validated: This has been validated manually as the end treatment request has not yet been implemented in QML + EndTreatmentRequestData endTreatmentRequest; + emit didRequestEndTreatment(endTreatmentRequest); +} +// coco end + Index: sources/view/hd/alarm/VAlarmStatus.h =================================================================== diff -u -rb61d8a3e01fef66eee8095c9cddf835d9bb32b66 -r0d59385f134f65a19dace1e2b46eb2631924396e --- sources/view/hd/alarm/VAlarmStatus.h (.../VAlarmStatus.h) (revision b61d8a3e01fef66eee8095c9cddf835d9bb32b66) +++ sources/view/hd/alarm/VAlarmStatus.h (.../VAlarmStatus.h) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -26,6 +26,9 @@ #include "GuiController.h" #include "format.h" +// forward declarations +class tst_views; + using namespace Can; // namespace using namespace Gui; @@ -41,6 +44,10 @@ class VAlarmStatus : public QObject { Q_OBJECT + + // friends + friend class ::tst_views; + public: VAlarmStatus(QObject *parent = NULL); @@ -76,6 +83,7 @@ void requestActionTransmit(GuiActionType vAction, const QVariantList &vData); void requestAlarmAcknowledge(AlarmAcknowledgeRequestData); void requestAlarmSilence(AlarmSilenceRequestData); + void didRequestEndTreatment(EndTreatmentRequestData); private: QString alarmPriorityText (GuiAlarmPriority vEnum); @@ -90,5 +98,6 @@ void onRequestOkay(GuiAlarmID alarmID); void onRequestSilence(); void onSetMinimize(bool minimize); + void doRequestEndTreatment(); }; } Index: unittests/tst_canbus.cpp =================================================================== diff -u -r64d87d540594252e8039ab2595016d98f1e3cc28 -r0d59385f134f65a19dace1e2b46eb2631924396e --- unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision 64d87d540594252e8039ab2595016d98f1e3cc28) +++ unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -364,3 +364,49 @@ } } } + +void tst_canbus::tst_MAlarmAcknowledgeRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_AlarmUserAckReq, vData, payload)); +} + +void tst_canbus::tst_MStartTreatmentRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_StartTreatmentReq, vData, payload)); +} + +void tst_canbus::tst_MConfirmTreatmentRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_ConfirmTreatmentReq, vData, payload)); +} + +void tst_canbus::tst_MEndTreatmentRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + Message msg; + msg.actionId = Gui::GuiActions::ID_EndTreatmentReq; + + QVERIFY(interpreter.interpretMessage(Gui::GuiActions::ID_EndTreatmentReq, vData, payload)); + QVERIFY(!interpreter.interpretMessage_HD(msg,vData)); + vData.append(0); + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_EndTreatmentReq, vData, payload)); +} + +void tst_canbus::tst_MAdjustmentTreatmentParametersRequest() +{ + MessageInterpreter interpreter; + QVariantList vData; + QByteArray payload; + QVERIFY(!interpreter.interpretMessage(Gui::GuiActions::ID_CreateTreatmentReq, vData, payload)); +} Index: unittests/tst_canbus.h =================================================================== diff -u -r64d87d540594252e8039ab2595016d98f1e3cc28 -r0d59385f134f65a19dace1e2b46eb2631924396e --- unittests/tst_canbus.h (.../tst_canbus.h) (revision 64d87d540594252e8039ab2595016d98f1e3cc28) +++ unittests/tst_canbus.h (.../tst_canbus.h) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -47,8 +47,14 @@ void tst_FrameInterface_ReInit(); + void tst_MAlarmAcknowledgeRequest(); + void tst_MStartTreatmentRequest(); + void tst_MConfirmTreatmentRequest(); + void tst_MEndTreatmentRequest(); + void tst_MAdjustmentTreatmentParametersRequest(); + // NOTE : PLEASE DON'T CHANGE THE ORDER - // THE SEQUENCES HAS BEEN HARD CODED IN THE MESSAGES. + // THE SEQUENCES HAVE BEEN HARD CODED IN THE MESSAGES. void tst_FrameInterface_ActionTransmit_KeepAlive(); void tst_FrameInterface_TransmitFrame_LongerData(); void tst_FrameInterface_ActionTransmit_PowerOff_Accepted(); Index: unittests/tst_models.cpp =================================================================== diff -u -rd9f8e4e8356bd081f84dc08c4d65d727c0ee707f -r0d59385f134f65a19dace1e2b46eb2631924396e --- unittests/tst_models.cpp (.../tst_models.cpp) (revision d9f8e4e8356bd081f84dc08c4d65d727c0ee707f) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -51,6 +51,7 @@ #include "MAlarmCleared.h" #include "MTreatmentParametersResp.h" +#include "MStartTreatmentResponse.h" #include "MEndTreatmentResponse.h" // #define CONSOLEOUT @@ -1643,7 +1644,48 @@ } } +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MStartTreatmentResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MStartTreatmentResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MStartTreatmentResponse_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("startTreatmentResponse ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("startTreatmentResponse ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("startTreatmentResponse ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("startTreatmentResponse ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("startTreatmentRejectReason") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("startTreatmentRejectReason") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("startTreatmentRejectReason") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("startTreatmentRejectReason") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MStartTreatmentResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MStartTreatmentResponse() { + Model::MStartTreatmentResponse 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 << 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.startTreatmentResponse ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.startTreatmentRejectReason ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MEndTreatmentResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MEndTreatmentResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // void tst_models::tst_MEndTreatmentResponse_data () { Index: unittests/tst_models.h =================================================================== diff -u -rd9f8e4e8356bd081f84dc08c4d65d727c0ee707f -r0d59385f134f65a19dace1e2b46eb2631924396e --- unittests/tst_models.h (.../tst_models.h) (revision d9f8e4e8356bd081f84dc08c4d65d727c0ee707f) +++ unittests/tst_models.h (.../tst_models.h) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -31,6 +31,12 @@ void tst_MTreatmentRanges_data (); void tst_MTreatmentRanges (); + // Treatment Start / Stop + void tst_MStartTreatmentResponse_data(); + void tst_MStartTreatmentResponse(); + void tst_MEndTreatmentResponse_data(); + void tst_MEndTreatmentResponse(); + // - Treatment Adjustments // -- Treatment Duration @@ -111,7 +117,4 @@ void tst_MSalineBolusResponse_data(); void tst_MSalineBolusResponse(); - - void tst_MEndTreatmentResponse_data(); - void tst_MEndTreatmentResponse(); }; Index: unittests/tst_views.cpp =================================================================== diff -u -rb62ab443e75b76a91e35aca6ba2efd84e7199602 -r0d59385f134f65a19dace1e2b46eb2631924396e --- unittests/tst_views.cpp (.../tst_views.cpp) (revision b62ab443e75b76a91e35aca6ba2efd84e7199602) +++ unittests/tst_views.cpp (.../tst_views.cpp) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -20,6 +20,9 @@ #include "VTreatmentAdjustmentResponseBase.h" #include "VTreatmentAdjustmentUltrafiltrationState.h" #include "FileHandler.h" +#include "VTreatmentBegin.h" +#include "VPriming.h" +#include "VAlarmStatus.h" tst_views::tst_views(QObject *parent) : QObject(parent) { } @@ -83,10 +86,10 @@ if (i != 4) view.heparinBolusVolume(view.heparinBolusVolumeMax()); if (i != 5) view.heparinStopTime(view.heparinStopTimeMax()); if (i != 6) view.salineBolusVolume(view.salineBolusVolumeMax()); - if (i != 7) view.acidConcentrate(0); - if (i != 8) view.bicarbonateConcentrate(0); + if (i != 7) view.acidConcentrate(view.acidConcentrateMax()); + if (i != 8) view.bicarbonateConcentrate(view.bicarbonateConcentrateMax()); - if (i != 9) view.dialyzerType(0); + if (i != 9) view.dialyzerType(view.dialyzerTypeMax()); if (i != 10) view.dialysateTemp(view.dialysateTempMax()); if (i != 11) view.arterialPressureLimitLow(view.arterialPressureLimitLowMin()); if (i != 12) view.arterialPressureLimitHigh(view.arterialPressureLimitHighMax()); @@ -125,10 +128,10 @@ QCOMPARE(view.heparinBolusVolume(),view.heparinBolusVolumeMax()); QCOMPARE(view.heparinStopTime(),view.heparinStopTimeMax()); QCOMPARE(view.salineBolusVolume(), view.salineBolusVolumeMax()); - QCOMPARE(view.acidConcentrate(), quint32(0)); - QCOMPARE(view.bicarbonateConcentrate(), quint32(0)); + QCOMPARE(view.acidConcentrate(), view.acidConcentrateMax()); + QCOMPARE(view.bicarbonateConcentrate(), view.bicarbonateConcentrateMax()); - QCOMPARE(view.dialyzerType(), quint32(0)); + QCOMPARE(view.dialyzerType(), view.dialyzerTypeMax()); QCOMPARE(view.dialysateTemp(), view.dialysateTempMax()); QCOMPARE(view.arterialPressureLimitLow(),view.arterialPressureLimitLowMin()); QCOMPARE(view.arterialPressureLimitHigh(), view.arterialPressureLimitHighMax()); @@ -160,11 +163,11 @@ view.heparinBolusVolume(view.heparinBolusVolumeMax()); view.heparinStopTime(view.heparinStopTimeMax()); - view.salineBolusVolume(0); - view.acidConcentrate(0); - view.bicarbonateConcentrate(0); + view.salineBolusVolume(view.salineBolusVolumeMax()); + view.acidConcentrate(view.acidConcentrateMax()); + view.bicarbonateConcentrate(view.bicarbonateConcentrateMax()); - view.dialyzerType(0); + view.dialyzerType(view.dialyzerTypeMax()); view.dialysateTemp(view.dialysateTempMax()); view.arterialPressureLimitLow(view.arterialPressureLimitLowMin()); view.arterialPressureLimitHigh(view.arterialPressureLimitHighMax()); @@ -173,7 +176,6 @@ view.bloodPressureMeasureInterval(view.bloodPressureMeasureIntervalMax()); view.rinsebackFlowRate(view.rinsebackFlowRateMax()); - } /*! @@ -238,6 +240,27 @@ { View::VTreatmentCreate view; + // check resolutions + QCOMPARE(view.bloodFlowRateRes(), quint32(25)); + QCOMPARE(view.dialysateFlowRateRes(), quint32(50 )); + QCOMPARE(view.durationRes(), quint32(15 )); + QCOMPARE(view.heparinDispensingRateRes(), qreal(0.1)); + QCOMPARE(view.heparinBolusVolumeRes(), qreal(0.1)); + QCOMPARE(view.heparinStopTimeRes(), quint32(10 )); + QCOMPARE(view.salineBolusVolumeRes(), quint32(100)); + + QCOMPARE(view.acidConcentrateRes(), quint32(1)); + QCOMPARE(view.bicarbonateConcentrateRes(), quint32(1)); + QCOMPARE(view.dialyzerTypeRes(), quint32(1)); + + QCOMPARE(view.dialysateTempRes(), qreal(0.5)); + QCOMPARE(view.arterialPressureLimitLowRes(), qint32(10)); + QCOMPARE(view.arterialPressureLimitHighRes(), qint32(10)); + QCOMPARE(view.venousPressureLimitLowRes(), qint32(10)); + QCOMPARE(view.venousPressureLimitHighRes(), qint32(10)); + QCOMPARE(view.bloodPressureMeasureIntervalRes(), quint32(5)); + QCOMPARE(view.rinsebackFlowRateRes(), quint32(25)); + // adjust quint32 minimums view.bloodFlowRateMin(1); view.dialysateFlowRateMin(1); @@ -338,7 +361,6 @@ QCOMPARE(view.validate(view.treatmentData), false); view.doFinishedCreate(); } - } void tst_views::VCreateTreatment_check_init() @@ -734,15 +756,55 @@ _FileSaver.onConcurrentSave(path, document.toJson(), false); - QThread::msleep(500); + int elapsedSeconds = 0; + QDateTime startTime = QDateTime::currentDateTime(); + while (view.loadTreatmentParameterRanges(path) != obj) + elapsedSeconds += startTime.secsTo(QDateTime::currentDateTime()); QJsonObject readObj = view.loadTreatmentParameterRanges(path); QCOMPARE(obj, readObj); + QVERIFY(elapsedSeconds < 2); readObj = view.loadTreatmentParameterRanges(QString("/tmp/wrong_path_%0.json") .arg(QDateTime::currentDateTime().toString(datetimeFormat))); QVERIFY(obj != readObj); } +void tst_views::VTreatmentBegin_continue() +{ + View::VTreatmentBegin view; + view.continueEnabled(false); + QCOMPARE(view.continueEnabled(), false); + view.doUserModifiedParameters(); + QCOMPARE(view.continueEnabled(), true); +} + +void tst_views::VTreatmentPriming_properties() +{ + View::VPriming view; + PrimingData primingData; + primingData.currentState = View::VPriming::PRIMING_COMPLETE+1; + + view.checkingInstallationComplete(true); + QCOMPARE(view.checkingInstallationComplete(), true); + view.creatingDialysateComplete(true); + QCOMPARE(view.creatingDialysateComplete(), true); + view.primingLinesComplete(true); + QCOMPARE(view.primingLinesComplete(), true); + view.primingComplete(true); + QCOMPARE(view.primingComplete(), true); + view.continueEnabled(true); + QCOMPARE(view.continueEnabled(), true); + view.onActionReceive(primingData); + QCOMPARE(view.currentState(), (quint32)View::VPriming::PRIMING_COMPLETE+1); + view.primingLinesComplete(false); + QVERIFY(!view.primingLinesComplete()); + view.secondsRemaining(quint32(10)); + QCOMPARE(view.secondsRemaining(), quint32(10)); + view.secondsTotal(quint32(50)); + QCOMPARE(view.secondsTotal(), quint32(50)); + view.continueEnabled(false); + QCOMPARE(view.continueEnabled(), false); +} Index: unittests/tst_views.h =================================================================== diff -u -r0583a63307936f09e184dfe16acca25f9e3fd81c -r0d59385f134f65a19dace1e2b46eb2631924396e --- unittests/tst_views.h (.../tst_views.h) (revision 0583a63307936f09e184dfe16acca25f9e3fd81c) +++ unittests/tst_views.h (.../tst_views.h) (revision 0d59385f134f65a19dace1e2b46eb2631924396e) @@ -47,4 +47,7 @@ void VCreateTreatment_fw_validation_response(); void VCreateTreatment_load_parameter_ranges(); void VCreateTreatment_check_init(); + + void VTreatmentBegin_continue(); + void VTreatmentPriming_properties(); };