Index: sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp =================================================================== diff -u -r79a6cfcb10472261f3ec26eaf0baf6f1245cd311 -rec7f919fdb70ff29a8de627937e4ad7008e59c1c --- sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp (.../VCommonAdjustmentVitals.cpp) (revision 79a6cfcb10472261f3ec26eaf0baf6f1245cd311) +++ sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp (.../VCommonAdjustmentVitals.cpp) (revision ec7f919fdb70ff29a8de627937e4ad7008e59c1c) @@ -31,8 +31,6 @@ void View::VTreatmentVitals::initConnections() { ACTION_RECEIVE_BRIDGE_CONNECTION(_BluetoothInterface, UIBloodPressureData); - connect(this, SIGNAL( enableDialogChanged (const bool &)), - this, SLOT(onTimerChanged ( ))); connect(this, SIGNAL( intervalChanged (const quint8 &)), this, SLOT(onTimerChanged ( ))); } @@ -46,21 +44,16 @@ */ void View::VTreatmentVitals::onActionReceive(const UIBloodPressureData &vData) { - if ( ! ( _enableDialog || _enableUpdate ) ) { - // if the vitals is disabled it means Gui is probably in an incorrect state and is unable to handle the vital information. - LOG_EVENT_UI(tr("Measured vital values ignored due to incorrect state [%1,%2,%3]") - .arg(vData.mSystolic ) - .arg(vData.mDiastolic) - .arg(vData.mPulseRate)); - return; - } - // Not used yet. // adjustment_Accepted ( vData.mAccepted ); // adjustment_Reason ( vData.mReason ); - if ( _enableDialog ) { emit didTrigger(vData.mSystolic, vData.mDiastolic, vData.mPulseRate); } - if ( _enableUpdate ) { update (vData.mSystolic, vData.mDiastolic, vData.mPulseRate); } + emit didTrigger(vData.mSystolic, vData.mDiastolic, vData.mPulseRate); + // if the vitals is disabled it means Gui is probably in an incorrect state and is unable to handle the vital information. + LOG_EVENT_UI(tr("Vital received,%1,%2,%3") + .arg(vData.mSystolic ) + .arg(vData.mDiastolic) + .arg(vData.mPulseRate)); } /*! @@ -78,7 +71,7 @@ update(vSystolic, vDiastolic, vHeartRate); treatmentLog(); - LOG_EVENT_UI(tr("User Vital Confirmation,%1,%2,%3") + LOG_EVENT_UI(tr("Vital Confirmed,%1,%2,%3") .arg(_systolic ) .arg(_diastolic) .arg(_heartRate) @@ -92,19 +85,11 @@ */ void View::VTreatmentVitals::doSkip() { - LOG_EVENT_UI(tr("User Skipped Vital Entry")); + LOG_EVENT_UI(tr("Vital Skipped")); + timerReset(); } /*! - * \brief View::VTreatmentVitals::doTimeout - * \details logs the vital entry timeout - */ -void View::VTreatmentVitals::doTimeout() -{ - LOG_EVENT_UI(tr("User Vital Entry Timed out")); -} - -/*! * \brief View::VTreatmentVitals::doReset * \details reset the previously read vital values * \param vEnabled - Disable or enable the vitals. @@ -117,8 +102,8 @@ systolic ( 0 ); diastolic ( 0 ); heartRate ( 0 ); + enableDialog ( 0 ); - enableUpdate ( 0 ); // force notify the Gui emit epochChanged ( 0 ); @@ -170,19 +155,25 @@ */ 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. - // DEBUG: qDebug() << __FUNCTION__ << _timerCounter; - if ( _interval == _timerCounter ) { - timerReset(); + if ( ! _interval ) return; // if interval is 0/OFF return + + _secCounter++; + if ( _secCounter % 60 ) return; // only check every minute + + if ( ! _timerCounter ) { + timerStop(); emit didTrigger(); } - _timerCounter++; + else { + _timerCounter--; + _secCounter = 0; + } } void View::VTreatmentVitals::onTimerChanged() { - if ( _interval && _enableDialog ) timerStart(); - else timerStop (); + if ( _interval ) timerReset(); + else timerStop (); // Timer stop is resetting timer too. } /*! @@ -192,18 +183,25 @@ */ void View::VTreatmentVitals::timerStart() { - _timerId = startTimer(60000); // 1 min interval + _timerId = startTimer(1000); // 1 sec interval which will used as 1 min in timerEvent (easier to debug) } void View::VTreatmentVitals::timerReset() { - _timerCounter = 1; + if ( _interval ) { + // ( -1 ) :the interval is 0 based but if as an example we set the counter to 5 then 5 itself gets a minute to pass which makes it 6 min. + _timerCounter = _interval - 1; + } + else { // if _interval == 0, counter should set to 0 too not to -1 + _timerCounter = 0; + } + _secCounter = 0; } /*! * \brief View::VTreatmentVitals::stop - * \details stops the timer + * \details stops the timer and resets the interval */ void View::VTreatmentVitals::timerStop() {