Index: drydemo.pro.user =================================================================== diff -u -r3b740846dabcba2ed00f2e48824a6ff155e78d26 -r2a3dd98b9aeffdcac34d74e9eba9f0b4089ce339 --- drydemo.pro.user (.../drydemo.pro.user) (revision 3b740846dabcba2ed00f2e48824a6ff155e78d26) +++ drydemo.pro.user (.../drydemo.pro.user) (revision 2a3dd98b9aeffdcac34d74e9eba9f0b4089ce339) @@ -1,6 +1,6 @@ - + EnvironmentId Index: sources/MessageGlobals.h =================================================================== diff -u -r3b740846dabcba2ed00f2e48824a6ff155e78d26 -r2a3dd98b9aeffdcac34d74e9eba9f0b4089ce339 --- sources/MessageGlobals.h (.../MessageGlobals.h) (revision 3b740846dabcba2ed00f2e48824a6ff155e78d26) +++ sources/MessageGlobals.h (.../MessageGlobals.h) (revision 2a3dd98b9aeffdcac34d74e9eba9f0b4089ce339) @@ -138,6 +138,7 @@ ID_HD_NEW_PARAMS_RESP = 0x3600, ID_UI_RQST_TX = 0x3800, ID_UI_CONFIRM_TX_PARAMS = 0x3B00, + ID_UI_ALARM_USER_ACTION_RQST = 0x4000, ID_HD_PRIMING_TIME_BC = 0x4300, ID_UI_PRESSURE_LIMITS_CHANGE_RQST = 0x4600, ID_HD_PRESSURE_LIMITS_CHANGE_RESP = 0x4700, Index: sources/StateController.cpp =================================================================== diff -u -r794e12f4334ba060aa9a474d6eae787d572814d5 -r2a3dd98b9aeffdcac34d74e9eba9f0b4089ce339 --- sources/StateController.cpp (.../StateController.cpp) (revision 794e12f4334ba060aa9a474d6eae787d572814d5) +++ sources/StateController.cpp (.../StateController.cpp) (revision 2a3dd98b9aeffdcac34d74e9eba9f0b4089ce339) @@ -54,6 +54,7 @@ case ID_UI_CONFIRM_TX_PARAMS: case ID_UI_SALINE_BOLUS_RQST: case ID_UI_PRESSURE_LIMITS_CHANGE_RQST: + case ID_UI_ALARM_USER_ACTION_RQST: _treatmentRcvdMessages[receivedMsgID] = msg[1]; break; @@ -258,18 +259,6 @@ void StateController::prepareOcclusionBroadcastData() { - //qint32 minArtMMHG = static_cast(MIN_ART_PRES_LIMIT_MMHG); - //qint32 maxArtMMHG = static_cast(MAX_ART_PRES_LIMIT_MMHG); - - //float artWinMaxMMHGFloat = static_cast(_treatmentParams.areterialPresLimitWindowMMHG) + 20.0; - //float artWinMinMMHGFloat = static_cast(_treatmentParams.areterialPresLimitWindowMMHG) - 20.0; - - //float venUpperFloatWindowMMHG = static_cast(0); - //float venLowerFloatWindowMMHG = static_cast(400); - - //float artRandomMMHG = _randNumGenerator.generateDouble() * (maxArtMMHG - minArtMMHG) + minArtMMHG; - //float venRandomMMHG = _randNumGenerator.generateDouble() * (venUpperFloatWindowMMHG - venLowerFloatWindowMMHG) + venLowerFloatWindowMMHG; - QVariantList msg; msg.append(static_cast(ID_PRESSURE_OCCLUSION_DATA_BC)); msg.append(Can_Id::eChlid_HD_Sync); @@ -351,7 +340,7 @@ _isBroadcastListReady = true; } -void StateController::prepareTreatmentParamsRangesBroadcastData() +void StateController::prepareTreatmentParamsRangesBroadcastData(bool isResetInSB) { // Calculations are from broadcastTreatmentSettingsRanges in the HD quint32 elapsedTimeMins = _treatmentVars.treatmentElapsedTimeS / SECONDS_PER_MINUTE; @@ -379,12 +368,18 @@ quint32 minDialFlowRateMLPM = MIN_DIAL_RATE_MLPM; quint32 maxDialFlowRateMLPM = (maxQdMLPM > MIN_DIAL_RATE_MLPM ? maxQdMLPM : minDialFlowRateMLPM); - maxTimeMins = qMin(maxTimeMins, (quint32)MAX_TX_TIME_MINS) ; + maxTimeMins = qMin(maxTimeMins, (quint32)MAX_TX_TIME_MINS); maxUFVol = qMin(maxUFVol, (float)MAX_UF_VOL_ML); maxDialFlowRateMLPM = qMin(maxDialFlowRateMLPM, (quint32)MAX_DIAL_RATE_MLPM); //qDebug() << "New UF" << minUFVolML << maxUFVol1 << maxUFVol2 << maxUFVol << maxDialFlowRateMLPM; + if (isResetInSB) { + maxTimeMins = (quint32)MAX_TX_TIME_MINS; + maxUFVol = (float)MAX_UF_VOL_ML; + maxDialFlowRateMLPM = (quint32)MAX_DIAL_RATE_MLPM; + } + QVariantList msg; msg.append(static_cast(ID_HD_TX_PARAMS_RANGES_DATA)); msg.append(Can_Id::eChlid_HD_Sync); @@ -487,29 +482,48 @@ Types::U32 txDurMinType; GetValue(payload.toByteArray(), IDIndex, txDurMinType); - quint32 txDurMin = txDurMinType.value; + quint32 txDurMins = txDurMinType.value; quint32 elapsedTimeMins = _treatmentVars.treatmentElapsedTimeS / SECONDS_PER_MINUTE; - if ((txDurMin > elapsedTimeMins) && (txDurMin >= MIN_TX_TIME_MINS)) { - float UFVolumeL = ((txDurMin - elapsedTimeMins) * _treatmentVars.prescribedUFRate) + _treatmentVars.refUFVolumeML; + if ((txDurMins > elapsedTimeMins) && (txDurMins >= MIN_TX_TIME_MINS)) { + float UFVolumeL = ((txDurMins - elapsedTimeMins) * _treatmentVars.prescribedUFRate) + _treatmentVars.refUFVolumeML; UFVolumeL /= MILLILITERS_PER_LITER; // Upper and lower range values are from #defines - quint32 dialVolumeML = _treatmentParams.dialysateFlowRateMLPM * txDurMin; - bool isMinTxTimeValid = (txDurMin >= MIN_TX_TIME_MINS ? true : false); - bool isTxTimeValid = (txDurMin <= MAX_TX_TIME_MINS ? true : false); + quint32 dialVolumeML = _treatmentParams.dialysateFlowRateMLPM * txDurMins; + bool isMinTxTimeValid = (txDurMins >= MIN_TX_TIME_MINS ? true : false); + bool isTxTimeValid = (txDurMins <= MAX_TX_TIME_MINS ? true : false); bool isMinUFVolValid = ((UFVolumeL >= MIN_UF_VOL_L) || (UFVolumeL <= 0.0) ? true : false); // TODO fix the UF Vol bool isUFVolValid = (UFVolumeL <= MAX_UF_VOL_L ? true : false); qDebug() << "Test of tx" << _treatmentVars.prescribedUFRate << elapsedTimeMins << UFVolumeL << isUFVolValid << dialVolumeML; - if (isMinTxTimeValid && isTxTimeValid && isMinUFVolValid && isUFVolValid && (dialVolumeML <= MAX_DIALYSATE_VOLUME_ML)) { - _treatmentVars.prescribedTreatmentTimeS = txDurMin * SECONDS_PER_MINUTE; - _treatmentVars.prescribedMaxUFVolML = UFVolumeL * MILLILITERS_PER_LITER; + // NOTE: In firmware it is checked that the current dialysate volume is <= 15000 mL before allowing the user + // to change the treatment time but per marketings request that has been disabled + if (isMinTxTimeValid && isTxTimeValid && isMinUFVolValid && isUFVolValid /*&& (dialVolumeML <= MAX_DIALYSATE_VOLUME_ML)*/) { + _treatmentVars.prescribedTreatmentTimeS = txDurMins * SECONDS_PER_MINUTE; + // NOTE: in drydemo right now we readjust the UF rate based the on the elapsed time and the new requested time + // in firmware the UF volume is changed and it is reuqested not to changed the UF volume + _treatmentVars.prescribedUFRate = (_treatmentVars.prescribedMaxUFVolML - _treatmentVars.refUFVolumeML) + / (txDurMins - elapsedTimeMins); + //_treatmentVars.prescribedMaxUFVolML = UFVolumeL * MILLILITERS_PER_LITER; accept = ACCEPT_VALUE; - qDebug() << "New tx time" << txDurMin * SECONDS_PER_MINUTE << accept; + qDebug() << "New tx time" << txDurMins * SECONDS_PER_MINUTE << _treatmentVars.prescribedUFRate; } } + else { + // If the requested treatment is out of acceptable range, just update the prescribed + // treatment time to newly requested time. + // Set the elapsed time prescribed treatment time - 1. This to make sure that when + // elapsed time is incremented in the next cylce the prescribed - elapsed time = 0 + // So the remaining time is zero and therefore the treatment time is over and the screen + // tranistions to treatment end per marketing request. + // NOTE: this only works if the prescibed time is greater than 2 hours so the minimum treatment time in the range + // is greater than 60 minutes. + accept = ACCEPT_VALUE; + _treatmentVars.prescribedTreatmentTimeS = txDurMins * SECONDS_PER_MINUTE; + _treatmentVars.treatmentElapsedTimeS = _treatmentVars.prescribedTreatmentTimeS - 1; + } prepareTreatmentTimeChangeResponse(accept, _treatmentVars.prescribedTreatmentTimeS, @@ -732,13 +746,13 @@ enum Alarm_ID { ALARM_ID_HD_ACTIVE_RESERVOIR_RECIRCULATION_OUT_OF_RANGE = 68, - ALARM_ID_HD_ARTERIAL_PRESSURE_SELF_TEST_FAILURE = 70, - ALARM_ID_HD_VENOUS_PRESSURE_SELF_TEST_FAILURE = 71 + ALARM_ID_HD_ARTERIAL_PRESSURE_SELF_TEST_FAILURE = 70, + ALARM_ID_HD_VENOUS_PRESSURE_SELF_TEST_FAILURE = 71 }; quint32 alarmID = 0; quint32 alarmPriority = static_cast(NONE); - quint16 alarmFlags = 0; + quint16 alarmFlags = 0x40FB; // This is the bit status that only has the ok button enabled QVariantList msg; msg.append(static_cast(ID_HD_ALARM_STATUS_BC)); @@ -748,17 +762,14 @@ if (cmd == CMD_HIGH_PRIO_ALARM) { alarmPriority = static_cast(HIGH); alarmID = static_cast(ALARM_ID_HD_VENOUS_PRESSURE_SELF_TEST_FAILURE); - alarmFlags = 86; } else if (cmd == CMD_MEDIUM_PRIO_ALARM) { alarmPriority = static_cast(MEDIUM); alarmID = static_cast(ALARM_ID_HD_ACTIVE_RESERVOIR_RECIRCULATION_OUT_OF_RANGE); - alarmFlags = 2; } else if (cmd == CMD_LOW_PRIO_ALARM) { alarmPriority = static_cast(LOW); alarmID = static_cast(ALARM_ID_HD_ARTERIAL_PRESSURE_SELF_TEST_FAILURE); - alarmFlags = 18; } } @@ -846,10 +857,6 @@ venArrayIndex = (venArrayIndex >= arraySize - 1 ? 0 : venArrayIndex + 1); venReadingCount = (venReadingCount >= arraySize + 1 ? arraySize + 1 : venReadingCount + 1); _treatmentVars.curVenPresMMHG = venRunningSumMMHG / venReadingCount; - - //qDebug() << "Pressure" << _treatmentParams.areterialPresLimitWindowMMHG << - // _treatmentParams.venousPresLimitWindowMMHG << - // _treatmentParams.venousPresLimitAsymWindowMMHG ; } void StateController::handlePressureChangeReqeust(const QVariant &payload) @@ -896,7 +903,7 @@ // jumped to the Ultrafiltration page the min and max UF volumes are set prior to it. QVariant emptyVar; setTreatmentParams(false, emptyVar); - prepareTreatmentParamsRangesBroadcastData(); + prepareTreatmentParamsRangesBroadcastData(true); // In standby reset the treatment values // Send message 0xBA in case the dry demo menu stayed open to be closed upon transitioning to standby prepareMsgBA(MODE_STAN, CONFIRM_CMD_ACCEPT_CLOSE); @@ -938,7 +945,7 @@ // jumped to the Ultrafiltration page the min and max UF volumes are set prior to it. QVariant emptyVar; setTreatmentParams(false, emptyVar); - prepareTreatmentParamsRangesBroadcastData(); + prepareTreatmentParamsRangesBroadcastData(true); // In standby reset the treatment values } bool isMsgBBRequested = false; @@ -962,6 +969,12 @@ qDebug() << "Idle in action" << cmdIDEnum; } + if (!_treatmentRcvdMessages[ID_UI_ALARM_USER_ACTION_RQST].isNull()) { + // If the clear command was received from the user, clear the alarm + handleAlarmStatus(false, CMD_HIGH_PRIO_ALARM); + _treatmentRcvdMessages[ID_UI_ALARM_USER_ACTION_RQST].clear(); + } + // If the use has requested message 0xBB then ignore create treatment button if ((!_treatmentRcvdMessages[ID_UI_RQST_TX].isNull()) && (!isMsgBBRequested)) { if (isTreatmenStartRequested(_treatmentRcvdMessages[ID_UI_RQST_TX])) { @@ -1394,7 +1407,7 @@ auto inEntry = [=](){ qDebug() << "UF on entry"; - prepareTreatmentParamsRangesBroadcastData(); + prepareTreatmentParamsRangesBroadcastData(true); // Reset the treatment params values QList preTxStates({7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); prepareHDModeTransitionBroadcastData(MODE_PRET, 0); prepareStatesBroadcastData(ID_PRE_TX_STATES_BC, preTxStates); @@ -1556,13 +1569,19 @@ prepareBloodFlowBroadcastData(curBloodFlowMLPM); prepareBloodPrimeBroadcastData(accumBloodVolML); prepareOcclusionBroadcastData(); - prepareTreatmentParamsRangesBroadcastData(); + prepareTreatmentParamsRangesBroadcastData(true); // Reset the params and get ready for a new treatment if (curBloodFlowMLPM < _treatmentParams.bloodFlowRateMLPM) { + // If interim blood flow is less than the target blood flow, keep adding + // to the blood flow ramp curBloodFlowMLPM += BLOOD_PRIME_FLOW_CHNG_MLPM; } if (curBloodFlowMLPM >= _treatmentParams.bloodFlowRateMLPM) { + // If the interim blood flow is >= target blood flow: + // If target blood flow is less than 250 which is the starting flow in blood prime, + // then keep subtracting the target (e.g. target 110 and we start from 250 mL/min) + // If the target blood flow is > than 250 mL/min set the interim flow to target blood flow if (_treatmentParams.bloodFlowRateMLPM < BLOOD_PRIME_START_FLOW_MLPM) { curBloodFlowMLPM -= BLOOD_PRIME_FLOW_CHNG_MLPM; @@ -1618,6 +1637,7 @@ _treatmentVars.prescribedMaxUFVolML = _treatmentVars.txParamsUFVolL * MILLILITERS_PER_LITER; _treatmentVars.prescribedUFRate = _treatmentVars.prescribedMaxUFVolML / _treatmentParams.txDurationMins; _treatmentVars.refUFVolumeML = (_treatmentVars.treatmentElapsedTimeS / SECONDS_PER_MINUTE) * _treatmentVars.prescribedUFRate; + qDebug() << "Treatment UF start vals" << _treatmentVars.txParamsUFVolL << _treatmentVars.prescribedUFRate << _treatmentVars.prescribedMaxUFVolML @@ -1674,9 +1694,9 @@ isSalineBolRqstd = false; } else if (cumSalineVolML >= SALINE_BOLUS_MAX_VOL_ML) { - salineSubState = SALINE_BOLUS_MAX_DELIVERED; - bolSalineVolML = 0.0; - isSalineBolRqstd= false; + salineSubState = SALINE_BOLUS_MAX_DELIVERED; + bolSalineVolML = 0.0; + isSalineBolRqstd = false; } } @@ -1704,7 +1724,7 @@ prepareBloodFlowBroadcastData(bloodFlowMLPM); prepareDialysateFlowBroadcastData(); prepareDialysateOutFlowBroadcastData(); - prepareTreatmentParamsRangesBroadcastData(); + prepareTreatmentParamsRangesBroadcastData(false); // In treatment updated the lastest changes prepareSalineBolusBroadcastData(cumSalineVolML, bolSalineVolML); } @@ -1739,7 +1759,7 @@ static quint32 rbFlowMLPM = _treatmentParams.rinsebackFlowRateMLPM; auto inEntry = [=](){ - // Call the treatment params first in case the use just started from the end treatment + // Call the treatment params first in case the user just started from the end treatment // but we need rinseback flow rate in mL/min that comes from the treatment params QVariant empty; setTreatmentParams(false, empty); @@ -1820,6 +1840,8 @@ _dryDemo.submitEvent("Transition_back_2_idle"); } + generateOcclusionPresureValues(false, _treatmentVars.broadcastIntervalCount); + if (_treatmentVars.broadcastIntervalCount % NUM_OF_COUNTS_TIMER_BC_EMIT == 0) { if ((rbSubState != RINSEBACK_RUN_STATE) && (rbCountDownS != 0)) { // If the rinseback is not in the run state, count down rinseback timer Index: sources/StateController.h =================================================================== diff -u -r794e12f4334ba060aa9a474d6eae787d572814d5 -r2a3dd98b9aeffdcac34d74e9eba9f0b4089ce339 --- sources/StateController.h (.../StateController.h) (revision 794e12f4334ba060aa9a474d6eae787d572814d5) +++ sources/StateController.h (.../StateController.h) (revision 2a3dd98b9aeffdcac34d74e9eba9f0b4089ce339) @@ -216,7 +216,7 @@ void prepareBloodFlowBroadcastData(quint32 flowMLPM); void prepareDialysateFlowBroadcastData(); void prepareDialysateOutFlowBroadcastData(); - void prepareTreatmentParamsRangesBroadcastData(); + void prepareTreatmentParamsRangesBroadcastData(bool isResetInSB); void prepareHDModeTransitionBroadcastData(Can::HD_OP_MODE mode, quint32 subMode); void prepareStatesBroadcastData(Can::Message_ID_Enum msgID, const QList &preTxStates); void prepareBloodPrimeBroadcastData(float accumulatedVolML);