Index: sources/bluetooth/BLEScanner.cpp =================================================================== diff -u -ra706f0bc5c65ec23de7e199d4aae158a06d07214 -r5384b4f5833568db90b988b11bbd502386d2f9b2 --- sources/bluetooth/BLEScanner.cpp (.../BLEScanner.cpp) (revision a706f0bc5c65ec23de7e199d4aae158a06d07214) +++ sources/bluetooth/BLEScanner.cpp (.../BLEScanner.cpp) (revision 5384b4f5833568db90b988b11bbd502386d2f9b2) @@ -578,8 +578,12 @@ lowEnergyController->connectToDevice(); } +/*! + * \brief BLEScanner::onRetryConnectToDevice + * Called when we retry to connect to the specific device + */ void BLEScanner::onRetryConnectToDevice() { - LOG_DEBUG("Retrying to connect to BLE device..."); + LOG_DEBUG(QString("Retrying to connect to BLE device with address %1").arg(selectedDeviceInfo.address().toString())); lowEnergyController->connectToDevice(); } Index: sources/gui/GuiGlobals.h =================================================================== diff -u -r666594860f4ea32da9a2bd362d40325b881b11f9 -r5384b4f5833568db90b988b11bbd502386d2f9b2 --- sources/gui/GuiGlobals.h (.../GuiGlobals.h) (revision 666594860f4ea32da9a2bd362d40325b881b11f9) +++ sources/gui/GuiGlobals.h (.../GuiGlobals.h) (revision 5384b4f5833568db90b988b11bbd502386d2f9b2) @@ -92,9 +92,6 @@ ID_AlarmUserAckReq = 0x3F00, // 63 ID_AlarmSilenceReq = 0x3200, // 50 - ID_AlertReq = ID_Unknown, - ID_AlertUserReq = ID_Unknown, - ID_TreatmentCreateReq = 0x3500, // 53 ID_TreatmentCreateRsp = 0x3600, // 54 ID_TreatmentStartReq = 0x3800, // 56 @@ -151,12 +148,20 @@ Timeout = 0x01, }; + enum AlertID { + ID_Alert_None = 0, + ID_Alert_BLE_Connection, + ID_Alert_BLE_Measurement_Timeout + }; + struct AlertRequest { + AlertID id; QString title; QString description; }; struct AlertResponse { + AlertID id; bool confirmed = false; }; @@ -200,6 +205,7 @@ typedef GuiActions::UF_States GuiUFStates; typedef GuiActions::Saline_Bolus_States GuiSalineStates; + typedef GuiActions::AlertID GuiAlertID; typedef GuiActions::AlertRequest GuiAlertRequestData; typedef GuiActions::AlertResponse GuiAlertResponseData; Index: sources/gui/qml/pages/treatment/TreatmentCreate.qml =================================================================== diff -u -rc3a1e077ddeba65709084f9af5dd756741db8b4f -r5384b4f5833568db90b988b11bbd502386d2f9b2 --- sources/gui/qml/pages/treatment/TreatmentCreate.qml (.../TreatmentCreate.qml) (revision c3a1e077ddeba65709084f9af5dd756741db8b4f) +++ sources/gui/qml/pages/treatment/TreatmentCreate.qml (.../TreatmentCreate.qml) (revision 5384b4f5833568db90b988b11bbd502386d2f9b2) @@ -378,9 +378,11 @@ onPressed: { _flickable.setInteractive(false) vTreatmentCreate.bloodPressureMeasureInterval = value + vVitals.doUpdateBPMeasureInterval(value) } onReleased: { vTreatmentCreate.bloodPressureMeasureInterval = value + vVitals.doUpdateBPMeasureInterval(value) _flickable.setInteractive(true) } } Index: sources/view/VAlert.cpp =================================================================== diff -u -r666594860f4ea32da9a2bd362d40325b881b11f9 -r5384b4f5833568db90b988b11bbd502386d2f9b2 --- sources/view/VAlert.cpp (.../VAlert.cpp) (revision 666594860f4ea32da9a2bd362d40325b881b11f9) +++ sources/view/VAlert.cpp (.../VAlert.cpp) (revision 5384b4f5833568db90b988b11bbd502386d2f9b2) @@ -16,7 +16,6 @@ // Project -using namespace Gui; using namespace View; VAlert::VAlert(QObject *parent) : QObject(parent) @@ -38,6 +37,7 @@ void VAlert::doAlertResponse(const bool &confirmed) { GuiAlertResponseData data; + data.id = alertID(); data.confirmed = confirmed; emit didAlertResponse(data); } @@ -49,6 +49,7 @@ */ void VAlert::onActionReceive(const GuiAlertRequestData &request) { + alertID(request.id); title(request.title); description(request.description); didRequestShowAlert(); Index: sources/view/VAlert.h =================================================================== diff -u -r666594860f4ea32da9a2bd362d40325b881b11f9 -r5384b4f5833568db90b988b11bbd502386d2f9b2 --- sources/view/VAlert.h (.../VAlert.h) (revision 666594860f4ea32da9a2bd362d40325b881b11f9) +++ sources/view/VAlert.h (.../VAlert.h) (revision 5384b4f5833568db90b988b11bbd502386d2f9b2) @@ -21,7 +21,7 @@ #include "main.h" #include "GuiController.h" -using namespace Model; +using namespace Gui; // forward declarations class tst_views; @@ -44,8 +44,9 @@ explicit VAlert(QObject *parent = NULL); private: - PROPERTY(QString , title, "") - PROPERTY(QString , description, "") + PROPERTY(QString , title, "") + PROPERTY(QString , description, "") + PROPERTY(GuiAlertID , alertID, GuiAlertID::ID_Alert_None) signals: void didRequestShowAlert(); Index: sources/view/VTreatmentBegin.cpp =================================================================== diff -u -r3a238930f8d939800512c9a786e96f15b35a2001 -r5384b4f5833568db90b988b11bbd502386d2f9b2 --- sources/view/VTreatmentBegin.cpp (.../VTreatmentBegin.cpp) (revision 3a238930f8d939800512c9a786e96f15b35a2001) +++ sources/view/VTreatmentBegin.cpp (.../VTreatmentBegin.cpp) (revision 5384b4f5833568db90b988b11bbd502386d2f9b2) @@ -46,13 +46,14 @@ * Implements SRSUI 253, 695, PRS 50 */ void VTreatmentBegin::doStartTreatment() { - qDebug() << "Requesting to start a treatment..."; + LOG_DEBUG("Requesting to start a treatment..."); GuiAlertRequestData request; + request.id = GuiAlertID::ID_Alert_BLE_Connection; if (!_bleConnected) { request.title = tr("The Blood Pressure Cuff is Not Connected"); - request.description = tr("Press 'Confirm' to continue treatment without taking vitals."); + request.description = tr("Press 'Confirm' to proceed with treatment using a non-Bluetooth connected Blood Pressure Cuff."); emit didRequestShowAlert(request); return; } @@ -93,13 +94,17 @@ /*! * \brief VTreatmentBegin::onAdjustment - * Called when the user has responded to the blood pressure prompt - * \param messageData - (AlertUserRequestData) the message data + * Called when the user has responded to the blood pressure conection alert + * \param messageData - (GuiAlertResponseData) the message data */ void VTreatmentBegin::onAdjustment(const GuiAlertResponseData &messageData) { - qDebug() << "Blood Pressure Prompt response: " << messageData.confirmed; + qDebug() << __FUNCTION__ << messageData.id; + if (messageData.id != GuiAlertID::ID_Alert_BLE_Connection) + return; + LOG_DEBUG(QString("Blood Pressure Prompt response: %1").arg(messageData.confirmed)); + if (messageData.confirmed) { startTreatmentRequest.request = TreatmentStartRequestData::eStartTreatment; Index: sources/view/VTreatmentCreate.cpp =================================================================== diff -u -r666594860f4ea32da9a2bd362d40325b881b11f9 -r5384b4f5833568db90b988b11bbd502386d2f9b2 --- sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision 666594860f4ea32da9a2bd362d40325b881b11f9) +++ sources/view/VTreatmentCreate.cpp (.../VTreatmentCreate.cpp) (revision 5384b4f5833568db90b988b11bbd502386d2f9b2) @@ -328,7 +328,7 @@ emit fwValidationFailed(enumToString(static_cast(data.requestValid))); } - qDebug() << "fw validation success = " << success; + LOG_DEBUG(QString("FW Validation Success? %1").arg(success)); if (success) { @@ -347,7 +347,9 @@ */ void VTreatmentCreate::doActionReceive(const TreatmentStartResponseData &messageData) { - qDebug() << "Received response after start treatment request: " << messageData.startTreatmentResponse; + LOG_DEBUG(QString("Received response after start treatment request: %1, Reason: %2") + .arg(messageData.startTreatmentResponse) + .arg(messageData.startTreatmentRejectReason)); if (messageData.startTreatmentResponse != 1) return; @@ -365,7 +367,7 @@ */ void VTreatmentCreate::goToNextPage(bool forward) { - qDebug() << __FUNCTION__ << pageToShow; + LOG_DEBUG(QString("Create treatment: go to page #%1").arg(pageToShow)); switch (pageToShow) { @@ -435,9 +437,8 @@ * application controller will save the data to disk. */ void VTreatmentCreate::doFinishedConfirm() { - qDebug() << "Finished create treatment confirm..."; + LOG_DEBUG(QString("Finished create treatment confirm...")); - QJsonObject obj { {"bloodFlowRate", QString::number(treatmentData.bloodFlowRate)}, {"dialysateFlowRate", QString::number(treatmentData.dialysateFlowRate)}, Index: sources/view/VVitals.cpp =================================================================== diff -u -r666594860f4ea32da9a2bd362d40325b881b11f9 -r5384b4f5833568db90b988b11bbd502386d2f9b2 --- sources/view/VVitals.cpp (.../VVitals.cpp) (revision 666594860f4ea32da9a2bd362d40325b881b11f9) +++ sources/view/VVitals.cpp (.../VVitals.cpp) (revision 5384b4f5833568db90b988b11bbd502386d2f9b2) @@ -3,19 +3,65 @@ // Project #include "VVitals.h" +#include "Logger.h" +#include "MainTimer.h" - using namespace View; +using namespace Gui; VVitals::VVitals(QObject *parent) : QObject(parent) { // incoming connect(&_BLEScanner, SIGNAL(didReceiveBPMeasurement(BLEMeasurementData)), this, SLOT(onReceiveBPMeasurement(BLEMeasurementData))); + + connect(&_GuiController, SIGNAL(didActionReceive(HDOperationModeData)), + this, SLOT(onHDOperationModeUpdate(HDOperationModeData))); + + connect(&_MainTimer, SIGNAL(didTimeout()), + this, SLOT(onTimeout())); + + connect(&_GuiController, SIGNAL(didAlertResponse(GuiAlertResponseData)), + this, SLOT(onReceiveAlertResponse(GuiAlertResponseData))); + + connect(&_GuiController, SIGNAL(didActionReceive(TreatmentStartResponseData)), + this, SLOT(onActionReceive(TreatmentStartResponseData))); + // outgoing + connect(this, SIGNAL(didRequestShowAlert(GuiAlertRequestData)), + &_GuiController, SLOT(doAlertRequest(GuiAlertRequestData))); } /*! + * \brief VVitals::doUpdateBPMeasureInterval + * Updates the blood pressure and hr measurement interval during a treatment + * Called whenever a new treatment parameters request is issued + * \param msgID - (QVariantList) the treatment parameters request + * \param request - (QVariantList) the treatment parameters request + */ +void VVitals::doUpdateBPMeasureInterval(const quint32 &intervalMinutes) +{ + LOG_DEBUG(QString("Updated BP/HR measurement notify interval to %1 minutes").arg(intervalMinutes)); + bloodPressureMeasureIntervalMinutes(intervalMinutes); +} + +/*! + * \brief VVitals::doManualBPMeasureEntry + * Called when a user manually enters the bp measurement data + * \param systolic - systolic blood pressure value + * \param diastolic - diastolic blood pressure value + * \param pulse_rate - pulse rate in beats per minute + */ +void VVitals::doManualBPMeasureEntry(const quint32 &systolic, const quint32 &diastolic, const quint32 &pulse_rate) +{ + BLEMeasurementData measurement; + measurement.systolic = systolic; + measurement.diastolic = diastolic; + measurement.pulse_rate = pulse_rate; + onReceiveBPMeasurement(measurement); +} + +/*! * \brief VVitals::onReceiveBPMeasurement * Private slot that is called when we recieve a blood pressure measurement * \param measurement - (BLEScanner::bp_measurement) the blood pressure measurement @@ -26,3 +72,66 @@ bloodPressureSystolic (measurement.systolic); pulseBPM (measurement.pulse_rate); } + +/*! + * \brief VVitals::onHDOperationModeUpdate + * When we receive an HD operation mode update + * \param hdOpMode - the HD operation mode + */ +void VVitals::onHDOperationModeUpdate(HDOperationModeData hdOpMode) +{ + if (hdOpMode.mOpMode != GuiHDOpModes::MODE_TREA) + _inTreatmentMode = false; + else + _inTreatmentMode = true; +} + +/*! + * \brief VVitals::onTimeout + * Notifies the user to take a measurement + */ +void VVitals::onTimeout() +{ + if (_inTreatmentMode && + _lastNotification.secsTo(QDateTime::currentDateTime()) >= bloodPressureMeasureIntervalMinutes()*60) // PRS 94 + { + GuiAlertRequestData request; + LOG_DEBUG("Notify user to take a measurement"); + request.id = GuiAlertID::ID_Alert_BLE_Measurement_Timeout; + request.title = tr("Please take vitals"); + request.description = tr("Press 'Confirm' once you have finished measuring your blood pressure and heart rate."); + emit didRequestShowAlert(request); + _lastNotification = QDateTime::currentDateTime(); + + } else { + int secondsRemaining = bloodPressureMeasureIntervalMinutes()*60 - _lastNotification.secsTo(QDateTime::currentDateTime()); + LOG_DEBUG(QString("There are %1 seconds until next bp/hr measurement request notification").arg(secondsRemaining)); + } +} + +/*! + * \brief VVitals::onReceiveAlertResponse + * Called when we receive an alert response + * \param response - the alert response + */ +void VVitals::onReceiveAlertResponse(GuiAlertResponseData response) +{ + if (response.id != GuiAlertID::ID_Alert_BLE_Measurement_Timeout) + return; + + LOG_DEBUG(QString("User confirmed alert? %1").arg(response.confirmed)); +} + +/*! + * \brief VVitals::onActionReceive + * Called when a treatment start request response is received + * Sets the last take vitals notification time to the start of treatment + * \param response - (TreatmentStartResponseData) the response data + */ +void VVitals::onActionReceive(const TreatmentStartResponseData &response) +{ + if (response.startTreatmentResponse != 1) + return; + + _lastNotification = QDateTime::currentDateTime(); +} Index: sources/view/VVitals.h =================================================================== diff -u -r666594860f4ea32da9a2bd362d40325b881b11f9 -r5384b4f5833568db90b988b11bbd502386d2f9b2 --- sources/view/VVitals.h (.../VVitals.h) (revision 666594860f4ea32da9a2bd362d40325b881b11f9) +++ sources/view/VVitals.h (.../VVitals.h) (revision 5384b4f5833568db90b988b11bbd502386d2f9b2) @@ -3,10 +3,12 @@ // Qt #include +#include // Project #include "BLEScanner.h" #include "main.h" +#include "GuiController.h" #define UNSET 9999 @@ -19,7 +21,6 @@ * \brief The VVitals class * \details View for handling BP/HR data * - * */ class VVitals : public QObject { @@ -33,12 +34,26 @@ explicit VVitals(QObject *parent = nullptr); protected: - PROPERTY(quint32, bloodPressureSystolic, UNSET) - PROPERTY(quint32, bloodPressureDiastolic, UNSET) - PROPERTY(quint32, pulseBPM, UNSET) - + PROPERTY(quint32, bloodPressureSystolic, UNSET) + PROPERTY(quint32, bloodPressureDiastolic, UNSET) + PROPERTY(quint32, pulseBPM, UNSET) + PROPERTY(quint32, bloodPressureMeasureIntervalMinutes, UNSET) +public slots: + void doUpdateBPMeasureInterval(const quint32 &intervalMinutes); + void doManualBPMeasureEntry(const quint32 &systolic, const quint32 &diastolic, const quint32 &pulse_rate); +signals: + void didRequestShowAlert(GuiAlertRequestData); private slots: void onReceiveBPMeasurement(BLEMeasurementData measurement); + void onReceiveAlertResponse(GuiAlertResponseData response); + void onActionReceive(const TreatmentStartResponseData &response); + void onHDOperationModeUpdate(HDOperationModeData hdOpMode); + void onTimeout(); + +private: + bool _inTreatmentMode = false; + bool _enterManually = false; + QDateTime _lastNotification; }; } #endif // VVITALS_H