Index: sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp =================================================================== diff -u -rab7ffd27ecea1277d8645a8b62ff48c0cb3f6ff4 -raa8f2c87c14c68d1fda6da2540d47144990a596c --- sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp (.../VCommonAdjustmentVitals.cpp) (revision ab7ffd27ecea1277d8645a8b62ff48c0cb3f6ff4) +++ sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp (.../VCommonAdjustmentVitals.cpp) (revision aa8f2c87c14c68d1fda6da2540d47144990a596c) @@ -20,6 +20,7 @@ // Project #include "GuiController.h" #include "TreatmentLog.h" +#include "BluetoothInterface.h" VIEW_DEF_CLASS_ADJUSTMENT(VTreatmentVitals) @@ -28,14 +29,12 @@ * \details All the class signal/slot connections are defined here. */ void View::VTreatmentVitals::initConnections() { - // TODO : Later we need to receive the data from BtCuff and update the data in the same way we update if user enters it. - // ACTION_VIEW_CONNECTION(AdjustVitalsResposeData); + ACTION_RECEIVE_BRIDGE_CONNECTION(_BluetoothInterface, UIBloodPressureData); connect(this, SIGNAL( enabledChanged(const bool &)), this, SLOT(onTimerChanged ( ))); connect(this, SIGNAL( intervalChanged(const quint8 &)), this, SLOT(onTimerChanged ( ))); - } /*! @@ -45,24 +44,21 @@ * \note the accepted and reason in this case should be the BtCuff status which may not necessarily comes front BtCuff itself, * and the intermediate controller like the GuiController or the BtCuffController can report from BtCuff behalf if it is connected or not responsive. */ -void View::VTreatmentVitals::onActionReceive(const AdjustVitalsResposeData &vData) +void View::VTreatmentVitals::onActionReceive(const UIBloodPressureData &vData) { if ( ! _enabled ) { // if the vitals is disabled it means Gui is probably in an incorrect state and is unable to handle the vital information. - LOG_EVENT(tr("Measured vital values ignored due to incorrect state")); + LOG_EVENT("UI," + tr("Measured vital values ignored due to incorrect state")); return; } - adjustment_Accepted ( vData.mAccepted ); - adjustment_Reason ( vData.mReason ); + // Not used yet. + // adjustment_Accepted ( vData.mAccepted ); + // adjustment_Reason ( vData.mReason ); - update(vData.mSystolic, vData.mDiastolic, vData.mHeartRate); + update(vData.mSystolic, vData.mDiastolic, vData.mPulseRate); treatmentLog(); - LOG_EVENT(tr("Cuff Vital Measurement,%1,%2,%3") - .arg(_systolic ) - .arg(_diastolic) - .arg(_heartRate) - ); + timerReset(); } /*! @@ -72,17 +68,18 @@ * \param vDiastolic - Blood Pressure Diastolic * \param vHeartRate - Heart Rate */ -void View::VTreatmentVitals::doConfirm(quint32 vSystolic, quint32 vDiastolic, quint32 vHeartRate){ +void View::VTreatmentVitals::doConfirm(quint16 vSystolic, quint16 vDiastolic, quint16 vHeartRate) { adjustment_Accepted ( true ); adjustment_Reason ( 0 ); update(vSystolic, vDiastolic, vHeartRate); treatmentLog(); - LOG_EVENT(tr("User Vital Confirmation,%1,%2,%3") + LOG_EVENT("UI," + tr("User Vital Confirmation,%1,%2,%3") .arg(_systolic ) .arg(_diastolic) .arg(_heartRate) ); + timerReset(); } /*! @@ -91,7 +88,7 @@ */ void View::VTreatmentVitals::doSkip() { - LOG_EVENT(tr("User Skipped Vital Entry")); + LOG_EVENT("UI," + tr("User Skipped Vital Entry")); } /*! @@ -100,7 +97,7 @@ */ void View::VTreatmentVitals::doTimeout() { - LOG_EVENT(tr("User Vital Entry Timed out")); + LOG_EVENT("UI," + tr("User Vital Entry Timed out")); } /*! @@ -130,7 +127,7 @@ * \param vDiastolic - Blood Pressure Diastolic * \param vHeartRate - Heart Rate */ -void View::VTreatmentVitals::update(quint32 vSystolic, quint32 vDiastolic, quint32 vHeartRate) +void View::VTreatmentVitals::update(quint16 vSystolic, quint16 vDiastolic, quint16 vHeartRate) { QDateTime currentDateTime = QDateTime::currentDateTime(); epoch (currentDateTime.toSecsSinceEpoch()); @@ -165,39 +162,44 @@ */ void View::VTreatmentVitals::timerEvent(QTimerEvent *) { + // TODO: Change the logic of the timer to count down instead of count up and reset to interval on 0. qDebug() << __FUNCTION__ << _timerCounter; if ( _interval == _timerCounter ) { - _timerCounter = 0; + timerReset(); emit didTrigger(); } _timerCounter++; } void View::VTreatmentVitals::onTimerChanged() { - if ( _interval && _enabled ) - start(); - else - stop(); + if ( _interval && _enabled ) timerStart(); + else timerStop (); } /*! * \brief View::VTreatmentVitals::start * \details Starts the timer by 1 min interval * \note the vital times are all minutes. */ -void View::VTreatmentVitals::start() +void View::VTreatmentVitals::timerStart() { _timerId = startTimer(60000); // 1 min interval } + +void View::VTreatmentVitals::timerReset() +{ + _timerCounter = 1; +} + /*! * \brief View::VTreatmentVitals::stop * \details stops the timer */ -void View::VTreatmentVitals::stop() +void View::VTreatmentVitals::timerStop() { killTimer(_timerId); _timerId = 0; - _timerCounter = 0; + timerReset(); }