Index: sources/gui/qml/components/VitalsButton.qml =================================================================== diff -u -rc843f1d6a805119ecadfa2c24f309f77e7637830 -r9bd436782039b50ac45eb38f561a36706517271b --- sources/gui/qml/components/VitalsButton.qml (.../VitalsButton.qml) (revision c843f1d6a805119ecadfa2c24f309f77e7637830) +++ sources/gui/qml/components/VitalsButton.qml (.../VitalsButton.qml) (revision 9bd436782039b50ac45eb38f561a36706517271b) @@ -28,6 +28,23 @@ } } + Text { id: _vitalCountdown + objectName: "vitalCountdown" + + color : "gray" + anchors { + top : _root.bottom + topMargin : 5 * -1 + horizontalCenter: _root.horizontalCenter + } + horizontalAlignment : Text.AlignHCenter + verticalAlignment : Text.AlignVCenter + height : 15 + width : 50 + text : vTreatmentVitals.interval ? vTreatmentVitals.countdown : "" + font.pixelSize : 16 + } + SequentialAnimation { id: _pulseAnimation loops : 2 running : false Index: sources/gui/qml/main.qml =================================================================== diff -u -r9048646630717f980a852df54349805ba63773e0 -r9bd436782039b50ac45eb38f561a36706517271b --- sources/gui/qml/main.qml (.../main.qml) (revision 9048646630717f980a852df54349805ba63773e0) +++ sources/gui/qml/main.qml (.../main.qml) (revision 9bd436782039b50ac45eb38f561a36706517271b) @@ -193,16 +193,11 @@ VTreatmentBloodFlow { id: vTreatmentBloodFlow } VTreatmentVitals { id: vTreatmentVitals - interval : vTreatmentCreate.bloodPressureMeasureInterval - enableDialog: vTDOpMode.inTreatment && vTDTreatmentStates.txTreatment - // As long as UI is in In-Tx BP/HR is updated and the dialog will pop up on interval. - onEnableDialogChanged : { - if ( vTreatmentVitals.enableDialog ) { - vTreatmentVitals.doTimerStart() - } - else { - vTreatmentVitals.doTimerStop() - } + interval : vTreatmentCreate.bloodPressureMeasureInterval + canStartInterval: vTreatmentCreate.parametersConfirmed + onCanStartIntervalChanged : { + if ( vTreatmentVitals.canStartInterval ) { vTreatmentVitals.doTimerStart() } + else { vTreatmentVitals.doTimerStop() } } } Index: sources/gui/qml/pages/treatment/TreatmentHome.qml =================================================================== diff -u -rc843f1d6a805119ecadfa2c24f309f77e7637830 -r9bd436782039b50ac45eb38f561a36706517271b --- sources/gui/qml/pages/treatment/TreatmentHome.qml (.../TreatmentHome.qml) (revision c843f1d6a805119ecadfa2c24f309f77e7637830) +++ sources/gui/qml/pages/treatment/TreatmentHome.qml (.../TreatmentHome.qml) (revision 9bd436782039b50ac45eb38f561a36706517271b) @@ -80,24 +80,6 @@ width: cellWidth + Variables.defaultMargin height: cellHeight onEditClicked: sectionVitalsClicked() - - Text { id: _vitalCountdown - objectName: "vitalCountdown" - - color : "gray" - anchors { - top : parent.top - topMargin : Variables.defaultMargin * 3.5 - right : parent.right - rightMargin : Variables.defaultMargin - } - horizontalAlignment : Text.AlignHCenter - verticalAlignment : Text.AlignVCenter - height : 15 - width : 100 - text : vTreatmentVitals.interval ? vTreatmentVitals.countdown : "" - font.pixelSize: 16 - } } TreatmentPressures { id: _treatmentPressures Index: sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentVitals.qml =================================================================== diff -u -rb88eb4be4b18985df3d35f249ee3847250e63a91 -r9bd436782039b50ac45eb38f561a36706517271b --- sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentVitals.qml (.../TreatmentAdjustmentVitals.qml) (revision b88eb4be4b18985df3d35f249ee3847250e63a91) +++ sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentVitals.qml (.../TreatmentAdjustmentVitals.qml) (revision 9bd436782039b50ac45eb38f561a36706517271b) @@ -73,7 +73,7 @@ vTreatmentVitals.doTimerStop() } - onClosed: if ( vTreatmentVitals.enableDialog ) { vTreatmentVitals.doTimerStart() } + onClosed: vTreatmentVitals.doTimerStart() onCloseClicked: { numPad.hide() @@ -177,10 +177,9 @@ // confirm only if triggered from interval timer and popup is not open _root.confirm() - if ( vTreatmentVitals.enableDialog ) { vTreatmentVitals.doTimerStart() } } else { // on rejected prompt user to enter vitals manually - if ( vTreatmentVitals.enableDialog ) { _root.open () } + _root.open () _bphrEntry.systolic = "" _bphrEntry.diastolic = "" Index: sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp =================================================================== diff -u -r0ced87f43c28bcc9f3402e19284030ad1405e9e8 -r9bd436782039b50ac45eb38f561a36706517271b --- sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp (.../VCommonAdjustmentVitals.cpp) (revision 0ced87f43c28bcc9f3402e19284030ad1405e9e8) +++ sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp (.../VCommonAdjustmentVitals.cpp) (revision 9bd436782039b50ac45eb38f561a36706517271b) @@ -66,7 +66,7 @@ .arg(_diastolic) .arg(_heartRate) ); - timerReset(); + timerStart(); } /*! @@ -75,10 +75,8 @@ */ void View::VTreatmentVitals::doSkip() { - if ( enableDialog() ) { - LOG_APPED_UI(tr("Vital Skipped")); - timerReset(); - } + LOG_APPED_UI(tr("Vital Skipped")); + timerReset(); } /*! @@ -89,21 +87,21 @@ */ void View::VTreatmentVitals::doReset() { - epoch ( 0 ); - lastRead ( ""); - systolic ( 0 ); - diastolic ( 0 ); - heartRate ( 0 ); + epoch ( 0 ); + lastRead ( ""); + systolic ( 0 ); + diastolic ( 0 ); + heartRate ( 0 ); + countdown ( ""); + totalCount ( 0 ); + canStartInterval ( 0 ); - enableDialog ( 0 ); - // force notify the Gui emit epochChanged ( 0 ); emit lastReadChanged ( ""); emit systolicChanged ( 0 ); emit diastolicChanged ( 0 ); emit heartRateChanged ( 0 ); - emit totalCountChanged ( 0 ); } /*! @@ -159,27 +157,11 @@ */ void View::VTreatmentVitals::timerEvent(QTimerEvent *) { - if ( ! _timerId ) return; // No timer started or failed starting - if ( ! _interval ) return; // if interval is 0/OFF return + if ( ! _timerId ) return; // No timer started or failed starting + if ( ! _interval ) return; // if interval is 0/OFF return + if ( ! _canStartInterval ) return; // parameters have not been confirmed yet - _counter_sec++; - emit totalCountChanged(++_totalCount); - - min_left(_counter_min ); - sec_left(60 - _counter_sec); - - countdown(QStringLiteral("%1:%2").arg(_min_left,2,10,QChar('0')).arg(_sec_left,2,10,QChar('0'))); - - if ( _counter_sec % 60 ) return; // only check every minute - - if ( ! _counter_min ) { - timerStop(); - emit didTrigger(); - } - else { - _counter_min--; - _counter_sec = 0; - } + updateTimer(); } /*! @@ -202,25 +184,53 @@ { if ( _timerId ) killTimer(_timerId); // this typically should not happen. if ( ! _interval ) return; // if interval is 0/OFF return + timerReset(); _timerId = startTimer(1000); // 1 sec interval which will used as 1 min in timerEvent (easier to debug) } +void View::VTreatmentVitals::updateTimer() +{ + _now = QDateTime::currentDateTime(); + + // minutes past last interval mark + int past = _now.time().minute() % _interval; + + // Seconds since the last interval mark + totalCount( past * 60 + _now.time().second()); + + // Seconds until the next interval mark + total_sec_left (_interval * 60 - _totalCount); + + // when exactly on mark, show full interval + if (_total_sec_left <= 1 ) { + timerStop(); + emit didTrigger(); + _total_sec_left = _interval * 60; + } + + // construct count down string + _counter_min = _total_sec_left / 60; + _counter_sec = _total_sec_left % 60; + countdown( QStringLiteral("%1:%2") .arg(_counter_min,2,10,QChar('0')) + .arg(_counter_sec,2,10,QChar('0')) ); +} + /*! * \brief View::VTreatmentVitals::timerReset * \details Resets the timer counters based on the current interval. */ void View::VTreatmentVitals::timerReset() -{ - 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. - _counter_min = _interval - 1; +{ + if ( _interval && _canStartInterval && _timerId ) { // get time past interval + updateTimer(); } - else { // if _interval == 0, counter should set to 0 too not to -1 - _counter_min = 0; + else { // if _interval == 0, clear counters + _counter_sec = 0; + _counter_min = 0; + _totalCount = 0; + _total_sec_left = 0; } - _counter_sec = 0; - _totalCount = 0; } /*! Index: sources/view/hd/adjustment/common/VCommonAdjustmentVitals.h =================================================================== diff -u -r73da05e9b761c559cd4d6741e574fc0f40475ebc -r9bd436782039b50ac45eb38f561a36706517271b --- sources/view/hd/adjustment/common/VCommonAdjustmentVitals.h (.../VCommonAdjustmentVitals.h) (revision 73da05e9b761c559cd4d6741e574fc0f40475ebc) +++ sources/view/hd/adjustment/common/VCommonAdjustmentVitals.h (.../VCommonAdjustmentVitals.h) (revision 9bd436782039b50ac45eb38f561a36706517271b) @@ -14,6 +14,7 @@ */ #pragma once +#include #include // Project @@ -39,6 +40,7 @@ int _timerId = 0; // 0 means no timer started or failed to start. int _counter_sec = 0; int _counter_min = 0; + QDateTime _now ; // Vitals data // constant range variables / units / ... @@ -50,14 +52,15 @@ CONSTANT( quint16 , heartRateMax , 180) // timer - PROPERTY( bool , enableDialog , 0) // enable the vital Dialog being triggered (pre-treatment is screen not a dialog) + PROPERTY( bool , canStartInterval , 0) PROPERTY( quint8 , interval , 0) // show the vital screen in min // timestamp PROPERTY( quint64 , epoch , 0) READONLY( QString , lastRead , "") READONLY( QString , countdown , "") READONLY( int , totalCount , 0) + PROPERTY( int , total_sec_left , 0) // vitals PROPERTY( quint16 , systolic , 0) @@ -68,10 +71,6 @@ PROPERTY( quint16 , diastolic_rt , 0) PROPERTY( quint16 , heartRate_rt , 0) - // For Debugging purposes - PROPERTY( quint8 , min_left , 0) - PROPERTY( quint8 , sec_left , 0) - VIEW_DEC(VTreatmentVitals, TreatmentVitalsData) void update (quint16 vSystolic, quint16 vDiastolic, quint16 vHeartRate); @@ -83,6 +82,7 @@ void timerStart(); void timerReset(); void timerStop (); + void updateTimer(); void timerEvent(QTimerEvent *) override;