#include "VTreatmentBegin.h" // Project #include "BLEScanner.h" #include "VTreatmentCreate.h" using namespace Gui; using namespace View; VTreatmentBegin::VTreatmentBegin(QObject *parent) : QObject(parent) { // incoming connect(&_BLEScanner, SIGNAL(didDisconnectFromDevice(QBluetoothDeviceInfo)), this , SLOT(onDeviceDisconnected())); connect(&_BLEScanner, SIGNAL(didConnectToDevice(QBluetoothDeviceInfo)), this , SLOT(onDeviceConnected())); connect(&_GuiController, SIGNAL(didActionReceive(HDOperationModeData)), this, SLOT(onAdjustment(HDOperationModeData))); connect(&_GuiController, SIGNAL(didAlertResponse(GuiAlertResponseData)), this, SLOT(onAdjustment(GuiAlertResponseData))); // outgoing connect(this, SIGNAL(didRequestShowAlert(GuiAlertRequestData)), &_GuiController, SLOT(doAlertRequest(GuiAlertRequestData))); connect(this, SIGNAL(didStartNewTreatment(TreatmentStartRequestData)), &_GuiController, SLOT(doAdjustment(TreatmentStartRequestData))); } /** * \brief VTreatmentBegin::doUserModifiedParameters * Manages enabling / disabling the start treatment button */ void VTreatmentBegin::doUserModifiedParameters() { continueEnabled(true); emit continueEnabledChanged(continueEnabled()); } /** * \brief VCreateTreatment::start * Called when user is ready to begin a new treatment. * Implements SRSUI 253, 695, PRS 50 */ void VTreatmentBegin::doStartTreatment() { 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 proceed with treatment using a non-Bluetooth connected Blood Pressure Cuff."); emit didRequestShowAlert(request); return; } request.title = tr("Ready for Blood Pressure Measurement"); request.description = tr("Press 'Confirm' once the blood pressure measurement has been taken."); emit didRequestShowAlert(request); } /*! * \brief VTreatmentBegin::doActionReceive * Slot called when we receive an HD operation mode update * \param messageData - (HDOperationModeData) contains the HD operation mode */ void VTreatmentBegin::onAdjustment(const HDOperationModeData &messageData) { _hdOperationMode = messageData.mOpMode; } /*! * \brief VTreatmentBegin::onDeviceConnected * Called when a BLE BP Cuff is connected */ void VTreatmentBegin::onDeviceConnected() { _bleConnected = true; } /*! * \brief VTreatmentBegin::onDeviceDisconnected * Called when a BLE BP Cuff is disconnected */ void VTreatmentBegin::onDeviceDisconnected() { _bleConnected = false; } /*! * \brief VTreatmentBegin::onAdjustment * 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() << __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; emit didStartNewTreatment(startTreatmentRequest); } }