Index: denali.pro =================================================================== diff -u -r06d10ee1174f0947a01087554f3da3109b47aef6 -r846a9ebc350e33be4affab3cc4c136248900015d --- denali.pro (.../denali.pro) (revision 06d10ee1174f0947a01087554f3da3109b47aef6) +++ denali.pro (.../denali.pro) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -14,6 +14,8 @@ DEFINES += DISABLE_KEEP_ALIVE } +DEFINES += "\"QT_MESSAGE_PATTERN=[%{type}] (%{file}:%{line}) - %{message}\"" + # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings # depend on your compiler). Refer to the documentation for the @@ -50,7 +52,14 @@ common/HDDefs.h \ common/MsgDefs.h \ \ # Main + sources/VTreatmentBegin.h \ sources/main.h \ + sources/model/MEndTreatmentResponse.h \ + sources/model/MStartTreatmentResponse.h \ + sources/model/hd/data/MPrimingData.h \ + sources/model/mtreatmentparameters.h \ + sources/model/mtreatmentparametersresp.h \ + sources/storage/filesaver.h \ sources/model/MDGDebugText.h \ sources/model/MHDDebugText.h \ sources/storage/DriveWatcher.h \ @@ -108,12 +117,14 @@ sources/gui/guiview.h \ sources/gui/guicontroller.h \ \ # ---------- Views ---------- + sources/view/VTreatmentCreate.h \ sources/view/VEventSpy.h \ sources/view/hd/data/VHDTreatmentStatesData.h \ sources/view/vview.h \ sources/view/vpoweroff.h \ \ # ---------- Views - Alarm sources/view/valarmstatus.h \ + sources/view/VPriming.h \ \ # ---------- Views - HD - Adjustment - In-Treatment sources/view/vtreatmentadjustmentresponsebase.h \ sources/view/vtreatmentadjustmentduration.h \ @@ -157,6 +168,13 @@ \ # common \ # Main main.cpp \ + sources/VTreatmentBegin.cpp \ + sources/model/MEndTreatmentResponse.cpp \ + sources/model/MStartTreatmentResponse.cpp \ + sources/model/hd/data/MPrimingData.cpp \ + sources/model/mtreatmentparameters.cpp \ + sources/model/mtreatmentparametersresp.cpp \ + sources/storage/filesaver.cpp \ sources/model/MDGDebugText.cpp \ sources/model/MHDDebugText.cpp \ sources/storage/DriveWatcher.cpp \ @@ -211,9 +229,11 @@ sources/gui/guiview.cpp \ sources/gui/guicontroller.cpp \ \ # ---------- Views ---------- + sources/view/VTreatmentCreate.cpp \ sources/view/VEventSpy.cpp \ sources/view/hd/data/VHDTreatmentStatesData.cpp \ sources/view/vpoweroff.cpp \ + sources/view/VPriming.cpp \ \ # ---------- Views - Alarm sources/view/valarmstatus.cpp \ \ # ---------- Views - HD - Adjustment - In-Treatment @@ -251,10 +271,8 @@ sources/utility/crc.cpp \ sources/utility/format.cpp \ sources/utility/types.cpp -# sources/configuration/display.cpp \ -# sources/configuration/sound.cpp \ -# sources/storage/settings.cpp \ + RESOURCES += \ denali.qrc Index: denali.qrc =================================================================== diff -u -r4df19fe88c454bd54abcdaf983be59464c5ef5bc -r846a9ebc350e33be4affab3cc4c136248900015d --- denali.qrc (.../denali.qrc) (revision 4df19fe88c454bd54abcdaf983be59464c5ef5bc) +++ denali.qrc (.../denali.qrc) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -20,9 +20,9 @@ resources/images/ArrowRight.png resources/images/logo d Dark Transparent.png resources/images/Close.png - resources/images/alarm.svg - resources/images/bell.svg - resources/images/bell-off.svg + resources/images/alarm.png + resources/images/bell.png + resources/images/bell-off.png resources/images/Back.png resources/images/Pause.png resources/images/Resume.png @@ -56,9 +56,16 @@ sources/gui/qml/components/RangeRect.qml sources/gui/qml/components/RangeBar.qml sources/gui/qml/components/Circle.qml + sources/gui/qml/components/CircleWithText.qml sources/gui/qml/components/TimeText.qml sources/gui/qml/components/ProgressCircle.qml sources/gui/qml/components/Slider.qml + sources/gui/qml/components/SliderCreateTreatment.qml + sources/gui/qml/components/ConfirmTreatmentTable.qml + sources/gui/qml/components/ConfirmTreatmentSubTable.qml + sources/gui/qml/components/SliderDoubleCreateTreatment.qml + sources/gui/qml/components/RectSelectCreateTreatment.qml + sources/gui/qml/components/TopMenuBarCreateTreatment.qml sources/gui/qml/components/ProgressBarEx.qml sources/gui/qml/components/CloseButton.qml sources/gui/qml/components/ConfirmButton.qml @@ -69,6 +76,9 @@ sources/gui/qml/components/ImageWave.qml sources/gui/qml/components/ImageClock.qml sources/gui/qml/components/ImageLogoDDarkTransparent.qml + sources/gui/qml/components/PrimingTimer.qml + ConfirmTreatmentTableEntry.qml + ProgressLine.qml sources/gui/qml/components/DebugDataColumn.qml @@ -86,6 +96,9 @@ sources/gui/qml/pages/treatment/TreatmentHome.qml sources/gui/qml/pages/treatment/TreatmentStack.qml sources/gui/qml/pages/treatment/TreatmentCreate.qml + sources/gui/qml/pages/treatment/TreatmentBegin.qml + sources/gui/qml/pages/treatment/TreatmentConfirm.qml + sources/gui/qml/pages/treatment/TreatmentPrime.qml sources/gui/qml/pages/treatment/TreatmentStart.qml Index: sources/applicationcontroller.cpp =================================================================== diff -u -rd1907168ef46faa6de1ada400cad789f8379041f -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) +++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file applicationcontroller.cpp - * \author (last) Peter Lucia - * \date (last) 25-Jun-2020 + * \author (last) Behrouz NematiPour + * \date (last) 25-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 24-Sep-2019 * @@ -106,13 +106,19 @@ connect(&_MessageDispatcher, SIGNAL(didFailedTransmit(Sequence)), this , SLOT( onFailedTransmit(Sequence))); + // USB drive connect(&_GuiController , SIGNAL(didUSBDriveUmount()), this , SLOT( onUSBDriveUmount())); connect(&_DriveWatcher , SIGNAL(didUSBDriveMount ()), this , SLOT( onUSBDriveMount ())); connect(&_DriveWatcher , SIGNAL(didUSBDriveRemove()), this , SLOT( onUSBDriveRemove())); + // SD Card + connect(&_DriveWatcher , SIGNAL(didSDCardStateChange(bool, bool)), + this , SLOT( onSDCardStateChange(bool, bool))); + + connect(&_GuiController , SIGNAL(didExportLog()), this , SLOT( onExportLog())); @@ -242,6 +248,21 @@ // coco end /*! + * \brief ApplicationController::onSDCardStateChange + * \details This is the slot which connects to the _DriveWatcher didSDCardStateChange signal + * and notifies the other classes (GuiController) by emitting its signal didSDCardStateChange + * \param vIsReady - SdCard is Ready + * \param vIsReadOnly - SdCard is ReadOnly + */ +void ApplicationController::onSDCardStateChange(bool vIsReady, bool vIsReadOnly) +{ + // coco begin validated: This needs user interaction to plug-in SD Card + // has been tested manually + emit didSDCardStateChange(vIsReady, vIsReadOnly); +} +// coco end + +/*! * \brief ApplicationController::onExportLog * \details the slot which will be called by UI to so the log export. */ Index: sources/applicationcontroller.h =================================================================== diff -u -rd1907168ef46faa6de1ada400cad789f8379041f -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/applicationcontroller.h (.../applicationcontroller.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) +++ sources/applicationcontroller.h (.../applicationcontroller.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file applicationcontroller.h - * \author (last) Peter Lucia - * \date (last) 25-Jun-2020 + * \author (last) Behrouz NematiPour + * \date (last) 25-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 24-Sep-2019 * @@ -28,7 +28,7 @@ // define #define _ApplicationController ApplicationController::I() -// forward diclations +// forward declarations class tst_initializations; // namespace @@ -80,6 +80,8 @@ void onUSBDriveUmount(); void onUSBDriveRemove(); + void onSDCardStateChange(bool vIsReady, bool vIsReadOnly); + void onExportLog (); void onExport (); @@ -93,6 +95,8 @@ void didUSBDriveUmount(); void didUSBDriveRemove(); + void didSDCardStateChange(bool vIsReady, bool vIsReadOnly); + void didExport (); void didAdjustBloodDialysateFlows(quint32 vBloodFlow, quint32 vDialysateFlow); @@ -102,6 +106,4 @@ // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS - }; - Index: sources/canbus/messagedispatcher.cpp =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/canbus/messagedispatcher.cpp (.../messagedispatcher.cpp) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/canbus/messagedispatcher.cpp (.../messagedispatcher.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -283,6 +283,45 @@ /*! * \brief MessageDispatcher::onAdjustment + * \details This method transmits the StartTreatment request message. + * \param vData - Data model contains the start treatment request information. + * \return void + */ +void MessageDispatcher::onAdjustment(const StartTreatmentRequestData &vData) +{ + QVariantList mData; + mData += vData.request; + onActionTransmit(GuiActionType::ID_StartTreatmentReq, mData); +} + +/*! + * \brief MessageDispatcher::onAdjustment + * \details This method transmits the Confirm Treatment request message. + * \param vData - Data model contains the confirm treatment request + * \return void + */ +void MessageDispatcher::onAdjustment(const ConfirmTreatmentRequestData &vData) +{ + Q_UNUSED(vData) + QVariantList mData; + onActionTransmit(GuiActionType::ID_ConfirmTreatmentReq, mData); +} + +/*! + * \brief MessageDispatcher::onAdjustment + * \details This method transmits the End Treatment request message. + * \param vData - Data model contains the end treatment request + * \return void + */ +void MessageDispatcher::onAdjustment(const EndTreatmentRequestData &vData) +{ + Q_UNUSED(vData) + QVariantList mData; + onActionTransmit(GuiActionType::ID_EndTreatmentReq, mData); +} + + +/** * \details This method transmits the Saline Bolus Adjustment Denali message. * \param vData - Data model contains treatment Saline Bolus adjustment state. * \return void Index: sources/canbus/messageglobals.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/canbus/messageglobals.h (.../messageglobals.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/canbus/messageglobals.h (.../messageglobals.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -1,16 +1,16 @@ /*! - * + * * 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 messageglobals.h * \author (last) Behrouz NematiPour * \date (last) 20-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 06-Dec-2019 - * + * */ #pragma once @@ -74,10 +74,15 @@ {Gui::GuiActionType::ID_AlarmStatus , 4 * 4 + 2 }, // 4 parameters each 4bytes + 1 parameter 2bytes {Gui::GuiActionType::ID_AlarmTriggered , 1 * 4 }, // 1 parameter each 4bytes {Gui::GuiActionType::ID_AlarmCleared , 1 * 4 }, // 1 parameter each 4bytes - {Gui::GuiActionType::ID_AlarmSilenceReq , 5 * 4 }, // 5 parameters each 4bytes - {Gui::GuiActionType::ID_AlarmSilenceRsp , 5 * 4 }, // 5 parameters each 4bytes + {Gui::GuiActionType::ID_AlarmSilenceReq , 1 * 4 }, // 1 parameters each 4bytes // ---- + {Gui::GuiActionType::ID_StartTreatmentReq , 1 * 4 }, // 1 parameters each 4bytes + {Gui::GuiActionType::ID_StartTreatmentRsp , 2 * 4 }, // 2 parameters each 4bytes + {Gui::GuiActionType::ID_ConfirmTreatmentReq , 0 }, + {Gui::GuiActionType::ID_EndTreatmentReq , 0 }, + + // ---- {Gui::GuiActionType::ID_TreatmentRanges , 6 * 4 }, // 6 parameters each 4bytes {Gui::GuiActionType::ID_TreatmentStates , 3 * 4 }, // 3 parameters each 4bytes @@ -96,11 +101,17 @@ {Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq , 1 * 4 }, // 1 parameter each 4bytes {Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp , 8 * 4 }, // 8 parameters each 4bytes + // --- + {Gui::GuiActionType::ID_CreateTreatmentReq , 17 * 4 }, // 17 parameters, each 4 bytes + {Gui::GuiActionType::ID_CreateTreatmentRsp , 18 * 4 }, // 18 parameters, each 4 bytes + // ---- {Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq , 2 * 4 }, // 2 parameters each 4bytes {Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp , 5 * 4 }, // ---- + {Gui::GuiActionType::ID_PrimingData , 3 * 4 }, // 3 parameters each 4bytes + // ---- {Gui::GuiActionType::ID_AdjustSalineReq , 1 * 4 }, // 1 parameter each 4bytes {Gui::GuiActionType::ID_AdjustSalineRsp , 3 * 4 }, // 3 parameters each 4bytes Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -21,8 +21,10 @@ // Project #include "logger.h" #include "format.h" +#include "mtreatmentparameters.h" using namespace Can; +using namespace Model; #define DEBUG_RECEIVE_SIGNAL(vID, vMODEL) //qDebug() << vID << vMODEL; @@ -143,9 +145,9 @@ QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, eLenMessageIDDigits); QString logMessage = tr("Unhandled Message ID (HD)") + '\n' + QString("%1 # %2 %3") - .arg(int(vMessage.can_id), 3, 16, QChar('0')) - .arg(mActionIdHexString) - .arg(QString(vMessage.data.toHex('.'))); + .arg(int(vMessage.can_id), 3, 16, QChar('0')) + .arg(mActionIdHexString) + .arg(QString(vMessage.data.toHex('.'))); LOG_DEBUG(logMessage); } @@ -186,79 +188,113 @@ vPayload.clear(); int count = vData.length(); + LOG_EVENT(QString("%0").arg(vActionId)); + switch (vActionId) { // notice we are in transmit mode - case Gui::GuiActionType::ID_Acknow: // len: 0, can have zero len - break; // No data, Just registered + case Gui::GuiActionType::ID_Acknow: // len: 0, can have zero len + break; // No data, Just registered + case Gui::GuiActionType::ID_KeepAlive: // len: 255, can have any len + { + if ( count ) { // this message has a variable length + vPayload = Format::fromVariant(vData[0]); + } + LOG_EVENT(mSenderID + QString("CheckIn")); + } break; - case Gui::GuiActionType::ID_KeepAlive: // len: 255, can have any len - if ( count ) { // this message has a variable length - vPayload = Format::fromVariant(vData[0]); - } - LOG_EVENT(mSenderID + QString("CheckIn")); - break; + case Gui::GuiActionType::ID_RawData: // len: 255, can have any len + { + if ( count ) { // this message has a variable length + vPayload = Format::fromVariant(vData[0]); + } + LOG_EVENT(mSenderID + QString("RawData")); - case Gui::GuiActionType::ID_RawData: // len: 255, can have any len - if ( count ) { // this message has a variable length - vPayload = Format::fromVariant(vData[0]); - } - LOG_EVENT(mSenderID + QString("RawData")); - break; + } break; - case Gui::GuiActionType::ID_PowerOff: - if ( ! count ) { logInvalidLength(vActionId); return false; } - vPayload += Format::fromVariant(vData); - LOG_EVENT(AdjustPowerOffRequestData::toString(vData)); - break; + case Gui::GuiActionType::ID_PowerOff: + { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload += Format::fromVariant(vData); + LOG_EVENT(AdjustPowerOffRequestData::toString(vData)); - case Gui::GuiActionType::ID_AdjustBloodDialysateReq: - if ( ! count ) { logInvalidLength(vActionId); return false; } - vPayload = Format::fromVariant(vData); - LOG_EVENT(AdjustBloodDialysateRequestData::toString(vData)); - break; + } break; - case Gui::GuiActionType::ID_AdjustDurationReq: - if ( ! count ) { logInvalidLength(vActionId); return false; } - vPayload = Format::fromVariant(vData); - LOG_EVENT(AdjustDurationRequestData::toString(vData)); - break; + case Gui::GuiActionType::ID_AdjustBloodDialysateReq: + { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustBloodDialysateRequestData::toString(vData)); + } break; - case Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq: - if ( ! count ) { logInvalidLength(vActionId); return false; } - vPayload = Format::fromVariant(vData); - LOG_EVENT(AdjustUltrafiltrationStateRequestData::toString(vData)); - break; + case Gui::GuiActionType::ID_AdjustDurationReq: + { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustDurationRequestData::toString(vData)); + } break; - case Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq: - if ( ! count ) { logInvalidLength(vActionId); return false; } - vPayload = Format::fromVariant(vData); - LOG_EVENT(AdjustUltrafiltrationEditRequestData::toString(vData)); - break; + case Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq: { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustUltrafiltrationStateRequestData::toString(vData)); + } break; - case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq: - if ( ! count ) { logInvalidLength(vActionId); return false; } - vPayload = Format::fromVariant(vData); - LOG_EVENT(AdjustUltrafiltrationConfirmRequestData::toString(vData)); - break; + case Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq: { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustUltrafiltrationEditRequestData::toString(vData)); + } break; - case Gui::GuiActionType::ID_AdjustSalineReq: - if ( ! count ) { logInvalidLength(vActionId); return false; } - vPayload = Format::fromVariant(vData); - LOG_EVENT(AdjustSalineRequestData::toString(vData)); - break; + case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq: { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustUltrafiltrationConfirmRequestData::toString(vData)); + } break; - case Gui::GuiActionType::ID_AlarmSilenceReq: - if ( ! count ) { logInvalidLength(vActionId); return false; } - vPayload = Format::fromVariant(vData); - LOG_EVENT(AlarmSilenceRequestData::toString(vData)); - break; + case Gui::GuiActionType::ID_AdjustSalineReq: { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustSalineRequestData::toString(vData)); + } break; - default: - QString mActionIdHexString = Format::toHexString(vActionId); - LOG_DEBUG(mSenderID + tr("Unknown transmit Message with ID '%1'").arg(mActionIdHexString)); - ok = false; - break; + case Gui::GuiActionType::ID_AlarmSilenceReq: { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AlarmSilenceRequestData::toString(vData)); + } break; + case Gui::GuiActionType::ID_StartTreatmentReq: { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(StartTreatmentRequestData::toString(vData)); + } break; + + case Gui::GuiActionType::ID_ConfirmTreatmentReq: { + if ( count != 0 ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(ConfirmTreatmentRequestData::toString(vData)); + } break; + + case Gui::GuiActionType::ID_EndTreatmentReq: { + if ( count != 0 ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(EndTreatmentRequestData::toString(vData)); + } break; + + case Gui::GuiActionType::ID_CreateTreatmentReq: { + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + TreatmentParameters params; + params.fromVariantList(vData); + LOG_EVENT(params.toString()); + } break; + + default: { + QString mActionIdHexString = Format::toHexString(vActionId); + LOG_DEBUG(mSenderID + tr("Unknown transmit Message with ID '%1'").arg(mActionIdHexString)); + ok = false; + } break; + } return ok; } @@ -325,6 +361,7 @@ case Gui::GuiActionType::ID_TreatmentRanges : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentRanges ); break; case Gui::GuiActionType::ID_PressureOcclusion : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PressureOcclusion ); break; case Gui::GuiActionType::ID_TreatmentStates : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentStates ); break; + case Gui::GuiActionType::ID_PrimingData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PrimingData ); break; case Gui::GuiActionType::ID_Saline : ok = notify(vMessage, vData, Gui::GuiActionType::ID_Saline ); break; // ----- Events @@ -350,9 +387,13 @@ case Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp : ok = adjustUltrafiltrationEdit (vMessage, vData); break; // TODO : implement notify<>() case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp : ok = adjustUltrafiltrationConfirm (vMessage, vData); break; // TODO : implement notify<>() - // unhandled messages: these will only be logged as received message + case Gui::GuiActionType::ID_CreateTreatmentRsp : ok = createTreatmentRespData (vMessage, vData); break; + case Gui::GuiActionType::ID_StartTreatmentRsp : ok = notify (vMessage, vData, Gui::GuiActionType::ID_StartTreatmentRsp ); break; + case Gui::GuiActionType::ID_EndTreatmentRsp : ok = notify (vMessage, vData, Gui::GuiActionType::ID_EndTreatmentRsp ); break; + + // unhandles messages: these will only be logged as received message // there has nothing been defined for these messages. - default : printUnhandled (vMessage ); break; + default : printUnhandled (vMessage ); break; } return ok; @@ -585,3 +626,26 @@ return ok; } + +/*! + * \brief MessageInterpreter::createTreatmentRespData + * Checks the validity of the create treatment response data. + * \param vMessage - The message + * \param vData - the output data + * \return true if ok, false otherwise + */ +bool MessageInterpreter::createTreatmentRespData(const Message &vMessage, QVariantList &vData) { + bool ok = false; + if ( ! isType (vMessage, Gui::GuiActionType::ID_CreateTreatmentRsp) ) return ok; + if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::ID_CreateTreatmentRsp) ) return ok; + + Model::TreatmentParametersResp mData; + ok = mData.fromByteArray(vMessage.data); + LOG_DATUM(mData.toString()); + + mData.toVariantList(vData); + emit didActionReceive(mData.data()); + + return ok; + +} Index: sources/canbus/messageinterpreter.h =================================================================== diff -u -rd1907168ef46faa6de1ada400cad789f8379041f -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) +++ sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file messageinterpreter.h - * \author (last) Behrouz NemaiPour - * \date (last) 22-Jun-2020 + * \author (last) Behrouz NematiPour + * \date (last) 03-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 13-Dec-2019 * Index: sources/gui/guicontroller.cpp =================================================================== diff -u -rd1907168ef46faa6de1ada400cad789f8379041f -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/guicontroller.cpp (.../guicontroller.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) +++ sources/gui/guicontroller.cpp (.../guicontroller.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file guicontroller.cpp - * \author (last) Peter Lucia - * \date (last) 25-Jun-2020 + * \author (last) Behrouz NematiPour + * \date (last) 25-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 24-Sep-2019 * @@ -74,16 +74,23 @@ // From OS : USB Drive has been removed physically. + // USB drive connect(&_ApplicationController, SIGNAL(didUSBDriveMount ()), this , SLOT( onUSBDriveMount ())); connect(&_ApplicationController, SIGNAL(didUSBDriveRemove()), this , SLOT( onUSBDriveRemove())); + // SD card + connect(&_ApplicationController, SIGNAL(didSDCardStateChange(bool,bool)), + this , SLOT( onSDCardStateChange(bool,bool))); + + // Export connect(&_ApplicationController, SIGNAL(didExport()), this , SLOT( onExport())); + // transmission fail connect(&_ApplicationController, SIGNAL(didFailedTransmit(Sequence)), - this , SLOT(didFailedTransmit(Sequence))); + this , SLOT( onFailedTransmit(Sequence))); // ---- Signal/Slots ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS(_ApplicationController) @@ -257,6 +264,21 @@ // coco end /*! + * \brief GuiController::onSDCardStateChange + * \details emits didSDCardStateChange signal to notify other classes (GuiView) + * , the SD Card state has been changed. + * \param vIsReady - SdCard is Ready + * \param vIsReadOnly - SdCard is ReadOnly + */ +void GuiController::onSDCardStateChange(bool vIsReady, bool vIsReadOnly) +{ + // coco begin validated: This needs user interaction to plug-out the SD Card + // has been tested manually + emit didSDCardStateChange(vIsReady, vIsReadOnly); +} +// coco end + +/*! * \brief GuiController::onExport * \details The slot which will be called to notify the export is done * by emitting the didExport signal. @@ -284,10 +306,10 @@ /*! * \brief GuiController::didFailedTransmit - * Raises an HD communiation timeout alarm if communication with HD is lost. + * Raises an HD communication timeout alarm if communication with HD is lost. * \param seq - Sequence that failed to transmit */ -void GuiController::didFailedTransmit(Sequence seq) +void GuiController::onFailedTransmit(Sequence seq) { Q_UNUSED(seq); AlarmStatusData data; Index: sources/gui/guicontroller.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/guicontroller.h (.../guicontroller.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/gui/guicontroller.h (.../guicontroller.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -27,7 +27,6 @@ #define _GuiController GuiController::I() using namespace Can; - // namespace namespace Gui { @@ -90,5 +89,5 @@ // ---- Signal/Slots ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS_PUBLIC ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS -}; + }; } Index: sources/gui/guiglobals.cpp =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -54,6 +54,9 @@ #include "vtreatmentadjustmentflows.h" #include "vtreatmentadjustmentultrafiltrationedit.h" #include "vtreatmentadjustmentultrafiltrationconfirm.h" +#include "VTreatmentCreate.h" +#include "VPriming.h" +#include "VTreatmentBegin.h" #include "VTreatmentAdjustmentSaline.h" namespace Gui { @@ -88,7 +91,7 @@ void registerQmlTypes() { //using namespace View; - qmlRegisterType ("Gui.View" , 0, 1, "GuiView"); + qmlRegisterType ("Gui.View" , 0, 1, "GuiView"); qmlRegisterUncreatableType ("Gui.Actions" , 0, 1, "GuiActions" , QStringLiteral("Used only for enumerations no need to have an object")); qmlRegisterSingletonType ("Gui.VEventSpy", 0, 1, "GuiEventSpy", [](QQmlEngine *, QJSEngine *) -> QObject * { return &_VEventSpy; Index: sources/gui/guiglobals.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/guiglobals.h (.../guiglobals.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/gui/guiglobals.h (.../guiglobals.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -1,16 +1,16 @@ /*! - * + * * 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 guiglobals.h * \author (last) Behrouz NematiPour * \date (last) 25-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 28-Oct-2019 - * + * */ #pragma once @@ -51,9 +51,9 @@ * *** Exactly as it is going to be shown/used in denali messages ***\n * *** then it can be compared exactly the way it is with no conversion.***\n */ + enum GuiActionsType_Enum /* : quint16 QML doesn't support enum types */ { ID_Unknown = 0x0000, - ID_CANBusFaultCount = 0x9909, ID_RawData = 0xFFFE, @@ -81,8 +81,17 @@ ID_AlarmStatus = 0x0200, ID_AlarmTriggered = 0x0300, ID_AlarmCleared = 0x0400, + + ID_CreateTreatmentReq = 0x3500, // 53 + ID_CreateTreatmentRsp = 0x3600, // 54 + ID_StartTreatmentReq = 0x3800, // 56 + ID_StartTreatmentRsp = 0x3900, // 57 + ID_ConfirmTreatmentReq = 0x3A00, // 58 + ID_EndTreatmentReq = 0x3B00, // 59 + ID_EndTreatmentRsp = 0x3C00, // 60 + + ID_PrimingData = 0x3700, // 55 ID_AlarmSilenceReq = 0x3200, // 50 - Not implemented yet on FW side - ID_AlarmSilenceRsp = 0x0000, // Needs to be removed. ID_HDOperationModeData = 0x2500, // 37 Index: sources/gui/qml/components/NotificationBar.qml =================================================================== diff -u -rd1907168ef46faa6de1ada400cad789f8379041f -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/qml/components/NotificationBar.qml (.../NotificationBar.qml) (revision d1907168ef46faa6de1ada400cad789f8379041f) +++ sources/gui/qml/components/NotificationBar.qml (.../NotificationBar.qml) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file NotificationBar.qml - * \author (last) Peter Lucia - * \date (last) 01-Jul-2020 + * \author (last) Behrouz NemaiPour + * \date (last) 06-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 30-Mar-2020 * Index: sources/gui/qml/dialogs/NotificationDialog.qml =================================================================== diff -u -rd1907168ef46faa6de1ada400cad789f8379041f -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/qml/dialogs/NotificationDialog.qml (.../NotificationDialog.qml) (revision d1907168ef46faa6de1ada400cad789f8379041f) +++ sources/gui/qml/dialogs/NotificationDialog.qml (.../NotificationDialog.qml) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file NotificationDialog.qml - * \author (last) Peter Lucia - * \date (last) 26-Jun-2020 + * \author (last) Behrouz NematiPour + * \date (last) 20-Aug-2020 * \author (original) Peter Lucia * \date (original) 02-Jun-2020 * @@ -80,6 +80,7 @@ anchors.centerIn: _titleBar; } } + Text { id: _desc objectName: "_NotificationDialog_Description" color: Colors.textMain @@ -108,6 +109,7 @@ } } + TouchRect { id : _dismiss width: _root.width / 3; text.text: qsTr("SILENCE") Index: sources/gui/qml/globals/Variables.qml =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/qml/globals/Variables.qml (.../Variables.qml) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/gui/qml/globals/Variables.qml (.../Variables.qml) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -1,16 +1,16 @@ /*! - * + * * 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 Variables.qml * \author (last) Behrouz NematiPour * \date (last) 10-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 09-Oct-2019 - * + * */ // Qt @@ -70,16 +70,32 @@ readonly property int progressbarHandler : 35 readonly property int progressbarFluidHeight: 5 + readonly property int progressbarSmall : 5 + readonly property int progressbarSmallWidth : 600 + readonly property int progressbarRectHeight : 50 + readonly property int progressbarRectWidth : 620 readonly property int sliderTextMargin : 20 + readonly property int cTreatmentSpacing : 60 + readonly property int cTreatmentTableHeight : 800 + readonly property int cTreatmentTableWidth : applicationWidth - 50 + readonly property int cTreatmentMargin : 45 + readonly property int cTreatmentHdrHeight : 130 + readonly property int cTreatmentTblMargin : 20 + readonly property int cTreatmentSubTblHeight: 50 + readonly property int cTreatmentSubTblWidth : 500 + readonly property int notificationHeight : 50 readonly property int notificationIconSize : 36 readonly property int backIconDiameter : 17 readonly property int pauseIconDiameter : 60 + readonly property int topBarMenuHeight : 100 + readonly property int sliderCircleDiameter : 25 + readonly property int ultrafiltrationProgressbarWidth : 880 readonly property int ultrafiltrationAdjustmtenOptionWidth : 520 readonly property int ultrafiltrationAdjustmtenOptionHeight : 275 Index: sources/gui/qml/main.qml =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/qml/main.qml (.../main.qml) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/gui/qml/main.qml (.../main.qml) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -38,6 +38,7 @@ import VTreatmentAdjustmentUltrafiltrationEdit 0.1; import VTreatmentAdjustmentUltrafiltrationConfirm 0.1; +import VTreatmentCreate 0.1; import VDGDrainPump 0.1; import VDGHeaters 0.1; import VDGLoadCellReadings 0.1; @@ -47,6 +48,8 @@ import VDGReservoir 0.1; import VDGTemperatures 0.1; import VDGValvesStates 0.1; +import VPriming 0.1; +import VTreatmentBegin 0.1; // Qml imports import "qrc:/globals" @@ -125,6 +128,9 @@ VTreatmentAdjustmentUltrafiltrationState { id: vTreatmentAdjustmentUltrafiltrationState } VTreatmentAdjustmentUltrafiltrationEdit { id: vTreatmentAdjustmentUltrafiltrationEdit } VTreatmentAdjustmentUltrafiltrationConfirm { id: vTreatmentAdjustmentUltrafiltrationConfirm } + VTreatmentCreate { id: vTreatmentCreate } + VPriming { id: vPriming } + VTreatmentBegin { id: vTreatmentBegin } // ----- Follow the below Z order ----- // 1 - Screens Index: sources/gui/qml/pages/treatment/TreatmentStack.qml =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -1,24 +1,24 @@ /*! - * + * * 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 TreatmentStack.qml * \author (last) Behrouz NematiPour * \date (last) 18-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 27-Jan-2020 - * + * */ // Qt import QtQuick 2.12 // Project import Gui.Actions 0.1 -import VTreatmentRanges 0.1 +import VTreatmentRanges 0.1 import VTreatmentAdjustmentSaline 0.1 import VHDTreatmentStates 0.1 @@ -38,7 +38,7 @@ stackView.initialItem : _treatmentHome // Views - VTreatmentRanges { id: vTreatmentRanges } + VTreatmentRanges { id: vTreatmentRanges } VTreatmentAdjustmentSaline { id: vTreatmentAdjustmentSaline } VHDTreatmentStates { id: vHDTreatmentStates property bool ufPaused : ufState === GuiActions.UF_PAUSED_STATE @@ -60,7 +60,7 @@ TreatmentHome { id: _treatmentHome onTreatmentStarted : push( _treatmentStart ) - onTreatmentCreated : push( _treatmentCreate) + onTreatmentCreated : vTreatmentCreate.onSelectingParameters() } TreatmentStart { id: _treatmentStart @@ -85,9 +85,26 @@ } TreatmentCreate { id: _treatmentCreate - onBackClicked : pop() + onClickedBack : {vTreatmentCreate.onCancelSelectingParameters() } + onClickedContinue : {vTreatmentCreate.onFinishedCreate(); } } + TreatmentConfirm { id: _treatmentConfirm + onClickedBack : {vTreatmentCreate.onRequestPop() } + onClickedConfirm : {vTreatmentCreate.onFinishedConfirm(); } + } + + TreatmentPrime { id: _treatmentPrime + onClickedBack : {vTreatmentCreate.onRequestPop() } + onClickedContinue : {vTreatmentCreate.onFinishedPrime(); } + } + + TreatmentBegin { id: _treatmentBegin + onClickedBack : {vTreatmentCreate.onRequestPop() } + onClickedStart : {vTreatmentCreate.onStartTreatment(); } + } + + //// Treatment Adjustment Dialogs TreatmentAdjustmentFlow { id: _treatmentAdjustmentFlow onCloseClicked : close() @@ -212,4 +229,16 @@ } } } + + Connections { target: vTreatmentCreate + onShowCreate : { push(_treatmentCreate) } + onShowConfirm : { push(_treatmentConfirm) } + onShowPrime : { push(_treatmentPrime) } + onShowBegin : { push(_treatmentBegin) } + onPop : { pop() } + onShowTreatmentStart : { + popToItem(_treatmentHome) + push(_treatmentStart) + } + } } Index: sources/main.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/main.h (.../main.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/main.h (.../main.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -1,16 +1,16 @@ /*! - * + * * 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 main.h * \author (last) Behrouz NematiPour * \date (last) 30-Jul-2020 * \author (original) Behrouz NematiPour * \date (original) 28-Oct-2019 - * + * */ #pragma once @@ -48,14 +48,14 @@ extern bool gDisableTimeout; //--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------// -#define DEBUG_PROPERTY_CHANGED(vVARIABLE) //qDebug() << "#" << #vVARIABLE << v##vVARIABLE; +#define DEBUG_PROPERTY_CHANGED(vVARIABLE, PREFIX) // qDebug() << "#" << #vVARIABLE << PREFIX##vVARIABLE; //--------------------------------------------------------------------------------// #define PROPERTY_SLOT( vTYPE , vVARIABLE ) \ protected : \ void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ static bool init = false; \ if ( !init || _##vVARIABLE != v##vVARIABLE ) { \ - DEBUG_PROPERTY_CHANGED(vVARIABLE) \ + DEBUG_PROPERTY_CHANGED(vVARIABLE, v) \ init = true; \ _##vVARIABLE = v##vVARIABLE; \ emit vVARIABLE##Changed( _##vVARIABLE ); \ @@ -65,7 +65,7 @@ #define TRIGGER_SLOT( vTYPE , vVARIABLE ) \ protected: \ void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ - DEBUG_PROPERTY_CHANGED(vVARIABLE) \ + DEBUG_PROPERTY_CHANGED(vVARIABLE, v) \ _##vVARIABLE = v##vVARIABLE; \ emit vVARIABLE##Triggered( _##vVARIABLE ); \ } @@ -167,4 +167,63 @@ //--------------------------------------------------------------------------------// #define REGISTER_TYPE(vTYPE) \ qmlRegisterType < vTYPE > (#vTYPE, 0, 1, #vTYPE); +#define GET_VARIABLE_NAME(VARIABLE) (#VARIABLE) +#define TREATMENT_PARAMETER(TYPE, NAME, DEFVALUE, MIN, MAX, RES) \ +private: \ + TYPE _##NAME = DEFVALUE; \ + TYPE _##NAME##Min = MIN; \ + TYPE _##NAME##Max = MAX; \ + TYPE _##NAME##Res = RES; \ + bool is##NAME##Set = false; \ +protected: \ + Q_PROPERTY(TYPE NAME \ + READ get_##NAME \ + WRITE set_##NAME \ + NOTIFY NAME##Changed) \ + Q_PROPERTY(TYPE NAME##Min \ + READ NAME##Min \ + WRITE NAME##Min \ + NOTIFY NAME##MinChanged) \ + Q_PROPERTY(TYPE NAME##Max \ + READ NAME##Max \ + WRITE NAME##Max \ + NOTIFY NAME##MaxChanged) \ + Q_PROPERTY(TYPE NAME##Res \ + READ NAME##Res \ + WRITE NAME##Res \ + NOTIFY NAME##ResChanged) \ + void set_##NAME(const TYPE &p##NAME) { \ + static bool init = false; \ + if ( !init || _##NAME != p##NAME ) { \ + init = true; \ + _##NAME = p##NAME; \ + DEBUG_PROPERTY_CHANGED(NAME, _) \ + is##NAME##Set = true; \ + emit NAME##Changed(_##NAME); \ + onUserModifiedParameters(); \ + } \ + } \ + TYPE NAME##Min() const { return _##NAME##Min; } \ + void NAME##Min(const TYPE &p##NAME##Min) \ + { _##NAME##Min = p##NAME##Min; emit NAME##MinChanged(_##NAME##Min);} \ + TYPE NAME##Max() const { return _##NAME##Max; } \ + void NAME##Max(const TYPE &p##NAME##Max) \ + { _##NAME##Max = p##NAME##Max; emit NAME##MaxChanged(_##NAME##Max);} \ + TYPE NAME##Res() const { return _##NAME##Res; } \ + void NAME##Res(const TYPE &p##NAME##Res) \ + { _##NAME##Res = p##NAME##Res; emit NAME##ResChanged(_##NAME##Res);} \ + TYPE get_##NAME() const { \ + return _##NAME; \ + } \ + void reset_##NAME() { \ + _##NAME = DEFVALUE; \ + is##NAME##Set = false; \ + emit NAME##Changed(_##NAME); \ + } \ +Q_SIGNALS: \ + void NAME##Changed(const TYPE &p##NAME); \ + void NAME##MinChanged(const TYPE &p##NAME); \ + void NAME##MaxChanged(const TYPE &p##NAME); \ + void NAME##ResChanged(const TYPE &p##NAME); \ + void NAME##_ValidationFailed(const QString &reason); Index: sources/model/MModel.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/model/MModel.h (.../MModel.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/model/MModel.h (.../MModel.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -40,6 +40,9 @@ #include "MDGTemperaturesData.h" #include "MDGValvesStatesData.h" +#include "mtreatmentparameters.h" +#include "mtreatmentparametersresp.h" + #include "MHDDebugText.h" #include "MDGDebugText.h" @@ -50,6 +53,9 @@ #include "MTreatmentAdjustUltrafiltrationStateResponse.h" #include "MTreatmentAdjustUltrafiltrationEditResponse.h" #include "MTreatmentAdjustUltrafiltrationConfirmResponse.h" +#include "MPrimingData.h" +#include "MStartTreatmentResponse.h" +#include "MEndTreatmentResponse.h" #include "MTreatmentAdjustSalineResponse.h" /*! @@ -145,7 +151,14 @@ \ REGISTER_METATYPE( HDDebugTextData ) \ REGISTER_METATYPE( DGDebugTextData ) \ - /* Request */ \ + REGISTER_METATYPE( TreatmentData ) \ + REGISTER_METATYPE( PrimingData ) \ + \ + /* Request */ \ + REGISTER_METATYPE( StartTreatmentRequestData ) \ + REGISTER_METATYPE( ConfirmTreatmentRequestData ) \ + REGISTER_METATYPE( EndTreatmentRequestData ) \ + \ REGISTER_METATYPE( AdjustBloodDialysateRequestData ) \ REGISTER_METATYPE( AdjustDurationRequestData ) \ REGISTER_METATYPE( AdjustUltrafiltrationStateRequestData ) \ @@ -158,6 +171,8 @@ REGISTER_METATYPE( AdjustUltrafiltrationStateResponseData ) \ REGISTER_METATYPE( AdjustUltrafiltrationEditResponseData ) \ REGISTER_METATYPE( AdjustUltrafiltrationConfirmResponseData ) \ + REGISTER_METATYPE( StartTreatmentResponseData ) \ + REGISTER_METATYPE( EndTreatmentResponseData ) \ REGISTER_METATYPE( AdjustSalineResponseData ) //===============================================================================// @@ -188,20 +203,26 @@ \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, HDDebugTextData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, DGDebugTextData ) \ + ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, PrimingData ) \ /* Response */ \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationStateResponseData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustBloodDialysateResponseData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustDurationResponseData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationEditResponseData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationConfirmResponseData ) \ + ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, StartTreatmentResponseData ) \ + ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, EndTreatmentResponseData ) \ ACTION_RECEIVE_BRIDGE_CONNECTION(vSOURCE, AdjustSalineResponseData ) -// /* Request */ ---------------------------------------------------------// +//===============================================================================// #define ADJUST_TRANSMT_MODEL_BRIDGE_CONNECTIONS(vSOURCE) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustBloodDialysateRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustDurationRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationStateRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationEditRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustUltrafiltrationConfirmRequestData ) \ + ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, StartTreatmentRequestData ) \ + ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, ConfirmTreatmentRequestData ) \ + ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, EndTreatmentRequestData ) \ ADJUST_TRANSMT_BRIDGE_CONNECTION(vSOURCE, AdjustSalineRequestData ) //===============================================================================// #define ACTION_RECEIVE_MODEL_BRIDGE_DEFINITIONS \ @@ -231,20 +252,26 @@ \ ACTION_RECEIVE_BRIDGE_DEFINITION( HDDebugTextData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( DGDebugTextData ) \ + ACTION_RECEIVE_BRIDGE_DEFINITION( PrimingData ) \ /* Response */ \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustUltrafiltrationStateResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustBloodDialysateResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustDurationResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustUltrafiltrationEditResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustUltrafiltrationConfirmResponseData ) \ + ACTION_RECEIVE_BRIDGE_DEFINITION( StartTreatmentResponseData ) \ + ACTION_RECEIVE_BRIDGE_DEFINITION( EndTreatmentResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustSalineResponseData ) -// /* Request */ ---------------------------------------------------------// + #define ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustBloodDialysateRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustDurationRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustUltrafiltrationStateRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustUltrafiltrationEditRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustUltrafiltrationConfirmRequestData ) \ + ADJUST_TRANSMT_BRIDGE_DEFINITION( StartTreatmentRequestData ) \ + ADJUST_TRANSMT_BRIDGE_DEFINITION( ConfirmTreatmentRequestData ) \ + ADJUST_TRANSMT_BRIDGE_DEFINITION( EndTreatmentRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustSalineRequestData ) // /* Request */ ----------------------- NoEmit --------------------------// #define ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS_NOEMIT \ @@ -253,6 +280,9 @@ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustUltrafiltrationStateRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustUltrafiltrationEditRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustUltrafiltrationConfirmRequestData ) \ + ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( StartTreatmentRequestData ) \ + ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( ConfirmTreatmentRequestData ) \ + ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( EndTreatmentRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_NOEMIT( AdjustSalineRequestData ) // /* Request */ ----------------------- public --------------------------// #define ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS_PUBLIC \ @@ -261,6 +291,9 @@ ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( AdjustUltrafiltrationStateRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( AdjustUltrafiltrationEditRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( AdjustUltrafiltrationConfirmRequestData ) \ + ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( StartTreatmentRequestData ) \ + ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( ConfirmTreatmentRequestData ) \ + ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( EndTreatmentRequestData ) \ ADJUST_TRANSMT_BRIDGE_DEFINITION_PUBLIC( AdjustSalineRequestData ) //===============================================================================// #define ACTION_RECEIVE_SIGNALS \ @@ -290,12 +323,16 @@ \ ACTION_RECEIVE_SIGNAL( HDDebugTextData ) \ ACTION_RECEIVE_SIGNAL( DGDebugTextData ) \ + ACTION_RECEIVE_SIGNAL( PrimingData ) \ /* Response */ \ ACTION_RECEIVE_SIGNAL( AdjustUltrafiltrationStateResponseData ) \ ACTION_RECEIVE_SIGNAL( AdjustBloodDialysateResponseData ) \ ACTION_RECEIVE_SIGNAL( AdjustDurationResponseData ) \ ACTION_RECEIVE_SIGNAL( AdjustUltrafiltrationEditResponseData ) \ ACTION_RECEIVE_SIGNAL( AdjustUltrafiltrationConfirmResponseData ) \ + ACTION_RECEIVE_SIGNAL( TreatmentParametersRespData ) \ + ACTION_RECEIVE_SIGNAL( StartTreatmentResponseData ) \ + ACTION_RECEIVE_SIGNAL( EndTreatmentResponseData ) \ ACTION_RECEIVE_SIGNAL( AdjustSalineResponseData ) //--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------// Index: sources/model/hd/adjustment/MTreatmentAdjustRequests.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/model/hd/adjustment/MTreatmentAdjustRequests.h (.../MTreatmentAdjustRequests.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/model/hd/adjustment/MTreatmentAdjustRequests.h (.../MTreatmentAdjustRequests.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -169,6 +169,53 @@ } }; +class MStartTreatmentReq : public MModel { +public: + enum Options { + eSelectParams = 0, + eCancel = 1, + eStartTreatment = 2 + }; + Options request = eSelectParams; + // coco begin validated : Has been validated manually. + // This object is used statically for now, kept the logic for later usage. + QString toString() { + return toString({request}); + } + // coco end + static QString toString(const QVariantList &vParameters) { + return MModel::toString("StartTreatment", vParameters); + } +}; + +class MConfirmTreatmentReq : public MModel { +public: + + // coco begin validated : Has been validated manually. + // This object is used statically for now, kept the logic for later usage. + QString toString() { + return toString({}); + } + // coco end + static QString toString(const QVariantList &vParameters) { + return MModel::toString("ConfirmTreatment", vParameters); + } +}; + +class MEndTreatmentReq : public MModel { +public: + + // coco begin validated : Has been validated manually. + // This object is used statically for now, kept the logic for later usage. + QString toString() { + return toString({}); + } + // coco end + static QString toString(const QVariantList &vParameters) { + return MModel::toString("EndTreatment", vParameters); + } +}; + } typedef Model:: MAdjustPowerOffReq AdjustPowerOffRequestData; @@ -177,6 +224,8 @@ typedef Model:: MAdjustUltrafiltrationStateReq AdjustUltrafiltrationStateRequestData; typedef Model:: MAdjustUltrafiltrationEditReq AdjustUltrafiltrationEditRequestData; typedef Model::MAdjustUltrafiltrationConfirmReq AdjustUltrafiltrationConfirmRequestData; +typedef Model:: MStartTreatmentReq StartTreatmentRequestData; +typedef Model:: MConfirmTreatmentReq ConfirmTreatmentRequestData; +typedef Model:: MEndTreatmentReq EndTreatmentRequestData; typedef Model:: MAdjustSalineReq AdjustSalineRequestData; - typedef Model:: MAlarmSilenceReq AlarmSilenceRequestData; Index: sources/storage/filehandler.cpp =================================================================== diff -u -rd1907168ef46faa6de1ada400cad789f8379041f -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/storage/filehandler.cpp (.../filehandler.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) +++ sources/storage/filehandler.cpp (.../filehandler.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -7,7 +7,7 @@ * * \file filehandler.cpp * \author (last) Behrouz NematiPour - * \date (last) 22-Apr-2020 + * \date (last) 25-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 24-Sep-2019 * @@ -21,6 +21,7 @@ #include #include #include +#include // Project #include "logger.h" @@ -38,9 +39,21 @@ */ void FileHandler::errOut(const QString &vMessage) { - QString mCritical = vMessage; + static uint count; + static QString mCritical; + // coco begin validated : This has been manually test. Needs file system access to produce errors for hundred times. + if (mCritical != vMessage || !(count % 1000)) { + // coco end + count = 0; + mCritical = vMessage; QTextStream err(stderr); - err << mCritical << endl; + err << "FS" << " " + << QDate::currentDate().toString("yyyy_MM_dd") << " " + << QTime::currentTime().toString("HH:mm:ss" ) << " " + << mCritical + << endl; + } + ++count; } /*! @@ -58,11 +71,11 @@ QFile::OpenMode openMode = vAppend ? QFile::Text | QFile::Append : QFile::Text | QFile::WriteOnly; - // coco begin validated : This has been manually test. Needs filesystem access to make file the way it can't be opened for writing. + // coco begin validated : This has been manually test. Needs file system access to make file the way it can't be opened for writing. if (! file.open(openMode)) { QString msg = QString("Can't open file for write (%1).Possible corrupted file system").arg(vFileName); + // here can't use LOG_XXXX because if the folder can't be created then the log can't be written. errOut (msg); - LOG_DEBUG(msg); return false; } // coco end @@ -85,8 +98,8 @@ QFile file(vFileName); if (! file.open(QFile::Text | QFile::ReadOnly)) { QString msg = QString("Can't open file for read (%1).Possible corrupted file system").arg(vFileName); + // here can't use LOG_XXXX because if the folder can't be created then the log can't be written. errOut (msg); - LOG_DEBUG(msg); return false; } QTextStream in(&file); @@ -182,15 +195,15 @@ if (fileTime.date() <= vDateOlderThan) { if (QFile::remove(fileName)) { ++countRemoved; - LOG_DEBUG(QString("%1 File(s) %2 removed").arg(countRemoved).arg(fileName)); + errOut(QString("%1 File(s) %2 removed").arg(countRemoved).arg(fileName)); } else { - LOG_DEBUG(QString("Can't delete file : ") + fileName); + errOut(QString("Can't delete file : ") + fileName); } } } else { - LOG_DEBUG(QString("Can't get last modified date of file : ") + fileName); + errOut(QString("Can't get last modified date of file : ") + fileName); } // coco end } @@ -202,18 +215,47 @@ * \brief FileHandler::makeFolder * \details Create the folder vFolder if it doesn't exist. * \param vFolder - the folder to create - * \return true on successfull creation + * \return true on successful creation */ bool FileHandler::makeFolder(const QString &vFolder) { QDir dir(vFolder); if ( ! dir.exists(vFolder) ) { if ( ! dir.mkpath(vFolder) ) { QString msg = "Can't create folder " + vFolder; - qDebug() << msg; - LOG_DEBUG(msg); + // here can't use LOG_XXXX because if the folder can't be created then the log can't be written. + errOut(msg); return false; } } return true; } + +/*! + * \brief FileHandler::isMounted + * \param vPath - the rootPath of the device mount point + * \return true - if the given vPath is not empty and is in list of mounted devices + * if so it also has to be ready and valid. + */ +bool FileHandler::isMounted(const QString &vPath, bool *vIsReadOnly) +{ + // coco begin validated: Needed User Interaction to make the device not ready so tested manually + bool mounted = false; + // removing the extra '/' from the vPath if there is to be able to compare to the root path of the storage + QString path = vPath.trimmed(); + if (path.isEmpty()) return false; + int lastIndex = path.size() - 1; + if (path.at(lastIndex) == "/") path.remove(lastIndex, 1); + // check to see if the path in the list of mounted rootPaths + foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) { + if (storage.isValid() && storage.isReady()) { + if ( storage.rootPath() == path ) { + if (vIsReadOnly) *vIsReadOnly = storage.isReadOnly(); + mounted = true; + break; + } + } + } + return mounted; +} +// coco end Index: sources/storage/filehandler.h =================================================================== diff -u -rd1907168ef46faa6de1ada400cad789f8379041f -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/storage/filehandler.h (.../filehandler.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) +++ sources/storage/filehandler.h (.../filehandler.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -7,7 +7,7 @@ * * \file filehandler.h * \author (last) Behrouz NematiPour - * \date (last) 02-Apr-2020 + * \date (last) 25-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 24-Sep-2019 * @@ -43,6 +43,6 @@ static int copyFolder (const QString &vSource, const QString &vDestination); static int removeFiles(const QStringList &vFolders, const QStringList &vNameFilter, const QDate &vDateOlderThan); static bool makeFolder (const QString &vFolder); + static bool isMounted (const QString &vPath, bool *vIsReadOnly = nullptr); }; - } Index: sources/storage/storageglobals.cpp =================================================================== diff -u -r9551959461d534dc624f0cbcca0e6f953844fb16 -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/storage/storageglobals.cpp (.../storageglobals.cpp) (revision 9551959461d534dc624f0cbcca0e6f953844fb16) +++ sources/storage/storageglobals.cpp (.../storageglobals.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -7,7 +7,7 @@ * * \file storageglobals.cpp * \author (last) Behrouz NematiPour - * \date (last) 07-May-2020 + * \date (last) 30-Jul-2020 * \author (original) Behrouz NematiPour * \date (original) 02-Jan-2020 * Index: sources/storage/storageglobals.h =================================================================== diff -u -r9551959461d534dc624f0cbcca0e6f953844fb16 -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/storage/storageglobals.h (.../storageglobals.h) (revision 9551959461d534dc624f0cbcca0e6f953844fb16) +++ sources/storage/storageglobals.h (.../storageglobals.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -7,7 +7,7 @@ * * \file storageglobals.h * \author (last) Behrouz NematiPour - * \date (last) 07-May-2020 + * \date (last) 30-Jul-2020 * \author (original) Behrouz NematiPour * \date (original) 02-Jan-2020 * Index: sources/view/vview.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/view/vview.h (.../vview.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ sources/view/vview.h (.../vview.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -1,16 +1,16 @@ /*! - * + * * 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 vview.h * \author (last) Behrouz NematiPour * \date (last) 13-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 10-Mar-2020 - * + * */ #pragma once @@ -121,7 +121,10 @@ REGISTER_TYPE( VTreatmentAdjustmentUltrafiltrationState ) \ REGISTER_TYPE( VTreatmentAdjustmentUltrafiltrationEdit ) \ REGISTER_TYPE( VTreatmentAdjustmentUltrafiltrationConfirm ) \ - REGISTER_TYPE( VTreatmentAdjustmentSaline ) \ + REGISTER_TYPE( VTreatmentCreate ) \ + REGISTER_TYPE( VPriming ) \ + REGISTER_TYPE( VTreatmentBegin ) \ + REGISTER_TYPE( VTreatmentAdjustmentSaline ) //--------------------------------------------------------------------------------// Index: unittests/tst_messaging.cpp =================================================================== diff -u -rf3b164487b1648637f5dd9a306cb6ade763d27c9 -r846a9ebc350e33be4affab3cc4c136248900015d --- unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision f3b164487b1648637f5dd9a306cb6ade763d27c9) +++ unittests/tst_messaging.cpp (.../tst_messaging.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file tst_messaging.cpp - * \author (last) Peter Lucia - * \date (last) 06-Jul-2020 + * \author (last) Behrouz NematiPour + * \date (last) 23-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 21-Apr-2020 * @@ -781,13 +781,27 @@ } /*! - * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationConfirmReq - * \details Tests MessageInterpreter interpretMessage to handle AdjustUltrafiltrationConfirmReq message type + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustSalineReq + * \details Tests MessageInterpreter interpretMessage to handle ID_AdjustSalineReq message type * if data is empty (count==0) */ -void tst_messaging::tst_MessageInterpreter_interpretMessage_canbusFaultCountData() +void tst_messaging::tst_MessageInterpreter_interpretMessage_AdjustSalineReq() { Can::MessageInterpreter iMsg; + QByteArray payload; + // if the payload is empty the len is not valid and should return false and empty payload + QVERIFY( ! iMsg.interpretMessage(Gui::GuiActionType::ID_AdjustSalineReq, {}, payload)); + QVERIFY(payload.isEmpty()); +} + +/*! + * \brief tst_messaging::tst_MessageInterpreter_interpretMessage_CANBusFaultCount + * \details Tests MessageInterpreter interpretMessage to handle ID_CANBusFaultCount message type + * if data is empty (count==0) + */ +void tst_messaging::tst_MessageInterpreter_interpretMessage_CANBusFaultCount() +{ + Can::MessageInterpreter iMsg; Can::Message msg; msg.actionId = Gui::GuiActionType::ID_CANBusFaultCount; msg.data = {}; @@ -958,4 +972,3 @@ Can::Sequence seq = 1; dMsg.actionTransmit(Gui::GuiActionType::ID_KeepAlive, data, seq); } - Index: unittests/tst_messaging.h =================================================================== diff -u -rf3b164487b1648637f5dd9a306cb6ade763d27c9 -r846a9ebc350e33be4affab3cc4c136248900015d --- unittests/tst_messaging.h (.../tst_messaging.h) (revision f3b164487b1648637f5dd9a306cb6ade763d27c9) +++ unittests/tst_messaging.h (.../tst_messaging.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file tst_messaging.h - * \author (last) Peter Lucia - * \date (last) 06-Jul-2020 + * \author (last) Behrouz NematiPour + * \date (last) 20-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 21-Apr-2020 * @@ -92,8 +92,9 @@ void tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationStateReq(); void tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationEditReq(); void tst_MessageInterpreter_interpretMessage_AdjustUltrafiltrationConfirmReq(); + void tst_MessageInterpreter_interpretMessage_AdjustSalineReq(); - void tst_MessageInterpreter_interpretMessage_canbusFaultCountData(); + void tst_MessageInterpreter_interpretMessage_CANBusFaultCount(); void tst_MessageInterpreter_interpretMessage_String(); void tst_MessageInterpreter_interpretMessage_DG_Unhandled(); @@ -112,5 +113,3 @@ void tst_MessageDispatcher_actionTransmit(); void tst_MessageDispatcher_actionTransmit_Unknown(); }; - - Index: unittests/tst_models.cpp =================================================================== diff -u -r97fc44f948bd39ed0b4238558a16bf99f750bf5e -r846a9ebc350e33be4affab3cc4c136248900015d --- unittests/tst_models.cpp (.../tst_models.cpp) (revision 97fc44f948bd39ed0b4238558a16bf99f750bf5e) +++ unittests/tst_models.cpp (.../tst_models.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file tst_models.cpp - * \author (last) Peter Lucia - * \date (last) 07-Jul-2020 + * \author (last) Behrouz NematiPour + * \date (last) 13-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 21-Apr-2020 * @@ -38,10 +38,12 @@ #include "MTreatmentFlowsData.h" #include "MTreatmentTimeData.h" #include "MTreatmentPressureOcclusionData.h" +#include "MTreatmentSalineData.h" #include "MTreatmentAdjustUltrafiltrationStateResponse.h" #include "MTreatmentAdjustUltrafiltrationEditResponse.h" #include "MTreatmentAdjustUltrafiltrationConfirmResponse.h" +#include "MTreatmentAdjustSalineResponse.h" #include "MAlarmStatusData.h" #include "MAlarmTriggered.h" @@ -691,7 +693,7 @@ void tst_models::tst_DGLoadCellReadingsData_data () { QTest::addColumn("errorIndex"); QTest::addColumn("data"); - QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); + QTest::newRow("msg complete ") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F")); QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray()); QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray("00")); QTest::newRow("mReservoir1Prim") << 1 << QByteArray::fromHex(QByteArray("00" "01")); @@ -1548,6 +1550,53 @@ } } +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentSalineBolusData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentSalineBolusData data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentSalineBolusData_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + QTest::newRow("mTarget ") << 1 << QByteArray::fromHex(QByteArray()); + QTest::newRow("mTarget ") << 1 << QByteArray::fromHex(QByteArray("00")); + QTest::newRow("mTarget ") << 1 << QByteArray::fromHex(QByteArray("00" "01")); + QTest::newRow("mTarget ") << 1 << QByteArray::fromHex(QByteArray("00" "01" "02")); + QTest::newRow("mCumulative ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03")); + QTest::newRow("mCumulative ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04")); + QTest::newRow("mCumulative ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05")); + QTest::newRow("mCumulative ") << 2 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06")); + QTest::newRow("mDelivered ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mDelivered ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mDelivered ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mDelivered ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MTreatmentSalineBolusData test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MTreatmentSalineBolusData() { + Model::MTreatmentSaline 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.mTarget ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 2: { index = index * sizeof mData._data.mCumulative; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + case 3: { index = index * sizeof mData._data.mDelivered ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } +} + void tst_models::tst_MTreatmentParametersResp_fromVariantList() { Model::TreatmentParametersResp mData; @@ -1655,6 +1704,50 @@ } } +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MSalineBolusResponse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MSalineBolusResponse data definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MSalineBolusResponse_data () { + QTest::addColumn("errorIndex"); + QTest::addColumn("data"); + QTest::newRow("msg complete") << 0 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B")); + 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("mTarget ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07")); + QTest::newRow("mTarget ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08")); + QTest::newRow("mTarget ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09")); + QTest::newRow("mTarget ") << 3 << QByteArray::fromHex(QByteArray("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A")); +} +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MSalineBolusResponse test definition ~~~~~~~~~~~~~~~~~~~~~~~~ // +void tst_models::tst_MSalineBolusResponse() { + Model::MAdjustSalineResponse 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.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.mTarget ; QVERIFY (! mData.fromByteArray(data)); QCOMPARE( index, startIndex ); } break; + default: + QVERIFY2(false, "Incorrect Test"); + break; + } } Index: unittests/tst_models.h =================================================================== diff -u -r97fc44f948bd39ed0b4238558a16bf99f750bf5e -r846a9ebc350e33be4affab3cc4c136248900015d --- unittests/tst_models.h (.../tst_models.h) (revision 97fc44f948bd39ed0b4238558a16bf99f750bf5e) +++ unittests/tst_models.h (.../tst_models.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -6,8 +6,8 @@ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file tst_models.h - * \author (last) Peter Lucia - * \date (last) 01-Jul-2020 + * \author (last) Behrouz NematiPour + * \date (last) 20-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 21-Apr-2020 * @@ -28,7 +28,6 @@ explicit tst_models(QObject *parent = nullptr); private slots: - void tst_MTreatmentRanges_data (); void tst_MTreatmentRanges (); @@ -53,7 +52,6 @@ void tst_MAdjustUltrafiltrationConfirmResponse_data (); void tst_MAdjustUltrafiltrationConfirmResponse (); - // - Data Messages void tst_DGROPumpData_data(); void tst_DGROPumpData(); @@ -107,5 +105,10 @@ void tst_MTreatmentParametersResp_data(); void tst_MTreatmentParametersResp(); void tst_MTreatmentParametersResp_fromVariantList(); -}; + void tst_MTreatmentSalineBolusData_data(); + void tst_MTreatmentSalineBolusData(); + + void tst_MSalineBolusResponse_data(); + void tst_MSalineBolusResponse(); +}; Index: unittests/tst_views.h =================================================================== diff -u -r56e378f7504701b9e9a9dccaf205aef2fd52c58e -r846a9ebc350e33be4affab3cc4c136248900015d --- unittests/tst_views.h (.../tst_views.h) (revision 56e378f7504701b9e9a9dccaf205aef2fd52c58e) +++ unittests/tst_views.h (.../tst_views.h) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -1,16 +1,16 @@ /*! - * + * * 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 tst_views.h * \author (last) Behrouz NematiPour * \date (last) 20-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 21-Apr-2020 - * + * */ #pragma once @@ -19,16 +19,30 @@ #include // Project +#include "VTreatmentCreate.h" class tst_views : public QObject { Q_OBJECT public: 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(); void VTreatmentAdjustmentUltrafiltrationState_text(); + + void VCreateTreatment_simulate_valid_parameters(View::VTreatmentCreate &view); + void VCreateTreatment_validation(); + void VCreateTreatment_validation_ranges(); + void VCreateTreatment_save(); + void VCreateTreatment_json(); + void VCreateTreatment_save_csv(); + void VCreateTreatment_enums(); + void VCreateTreatment_fw_validation_response(); + void VCreateTreatment_init_ranges(QJsonObject &obj); + void VCreateTreatment_load_parameter_ranges(); + void VCreateTreatment_check_init(); };