Index: sources/drydemo/StateController.cpp =================================================================== diff -u -r6d7f1800f7f56813c0824df509487f527a4026b2 -r9edc9ba3995ca25a29bb74eeeae71f7d72965284 --- sources/drydemo/StateController.cpp (.../StateController.cpp) (revision 6d7f1800f7f56813c0824df509487f527a4026b2) +++ sources/drydemo/StateController.cpp (.../StateController.cpp) (revision 9edc9ba3995ca25a29bb74eeeae71f7d72965284) @@ -50,6 +50,10 @@ case ID_UI_TREATMENT_SET_POINT_BLOOD_FLOW_CHANGE_RQST: case ID_UI_TREATMENT_SET_POINTS_CHANGE_RQST: case ID_UI_TREATMENT_SET_POINT_DIALYSATE_FLOW_CHANGE_RQST: + case ID_UI_BOLUS_VOLUME_CHANGE_RQST: + case ID_UI_TREATMENT_SET_POINT_DIALYSATE_TEMP_CHANGE_RQST: + case ID_UI_UF_PAUSE_RESUME_RQST: + case ID_UI_TREATMENT_UF_VOLUME_VALIDATE_RQST: _treatmentRcvdMessages[receivedMsgID] = msg[1]; break; @@ -90,6 +94,15 @@ case ID_TD_TREATMENT_SET_POINTS_CHANGE_RESP: case ID_DD_GEN_DIALYSATE_MODE_DATA: case ID_TD_TREATMENT_SET_POINT_DIALYSATE_FLOW_CHANGE_RESP: + case ID_DD_CONDUCTIVITY_DATA: + case ID_TD_BOLUS_VOLUME_CHANGE_RESP: + case ID_UI_BLOOD_PRESSURE_RQST: + case ID_TD_BLOOD_PRESSURE_READING_RESP: + case ID_TD_BLOOD_PRESSURE_DATA: + case ID_TD_ULTRAFILTRATION_DATA: + case ID_TD_TREATMENT_SET_POINT_DIALYSATE_TEMP_CHANGE_RESP: + case ID_TD_UF_PAUSE_RESUME_RESP: + case ID_TD_TREATMENT_UF_VOLUME_VALIDATE_RESP: // Do nothing break; } @@ -347,17 +360,20 @@ static QList txStates; auto onEntry = [=](){ + // Start with UF state in dialysis + _treatmentStatus.dialysisSubState = DIALYSIS_UF_STATE; + _treatmentStatus.txState = TREAT_DIALYSIS_STATE; handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_IMMEDIATELY); - txStates = {TREAT_START_STATE, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + txStates = {TREAT_START_STATE, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, 0, 0}; handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); - txStates = {TREAT_DIALYSIS_STATE, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, 0, 0}; handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); handleTreatmentSetpointsBroadcastData(_treatmentParams.bloodFlowRateMLPM, _treatmentParams.dialysateFlowRateMLPM, _treatmentParams.dialysateTemperatureC, BC_IMMEDIATELY); + handleDDConductivityBroadcastData(BC_IMMEDIATELY); handleTreatmentTimeProcessAndBroadcastData(BC_IMMEDIATELY); handleDDGenDialysateModeBroadcastData(BC_IMMEDIATELY); - // The default elapsed time is 2 hours becasue the default tx duration is 4 hours. If the prescribed is less than 2 hours, 0 the elapsed - if ((_treatmentParams.treatmentDurationMin * SECONDS_PER_MINUTE) < DEF_TX_ELAPSED_TIME_S){ _treatmentStatus.treatmentElapsedTimeMS = 0; } + initializeTreatmentTimeAndUltrafiltration(); status = STATE_ON_ACTION; qDebug() << "Tx on entry"; }; @@ -366,7 +382,7 @@ status = STATE_ON_ACTION; handleBackToStandbyEvent(status); handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_DELAYED); - txStates = {TREAT_DIALYSIS_STATE, 0, 0, 0, 0, 0, 0, 0, _treatmentStatus.fluidBolusState, 0}; + txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, _treatmentStatus.fluidBolusState, 0}; handleTreatmentStatesBroadcastData(txStates, BC_DELAYED); handleTDPressureProcessAndBroadcastData(BC_DELAYED); handleFluidBolusRequestMessage(); @@ -378,10 +394,14 @@ handleTreatmentSetpointsBroadcastData(_treatmentParams.bloodFlowRateMLPM, _treatmentParams.dialysateFlowRateMLPM, _treatmentParams.dialysateTemperatureC, BC_DELAYED); handleDDGenDialysateModeBroadcastData(BC_DELAYED); + handleDDConductivityBroadcastData(BC_DELAYED); handleSetPointDialysateFlowChange(); + handleSetPointDialysateTemperatureChange(); + handleUltrafiltrationBroadcastData(BC_DELAYED); + handleUltrafiltrationPauseResume(); if ((_treatmentStatus.treatmentElapsedTimeMS / MILLISECONDS_PER_SECOND) >= (_treatmentParams.treatmentDurationMin * SECONDS_PER_MINUTE)) { _treatmentStatus.stateTransitionEvent = "T_Tx_2_TE"; - status = STATE_ON_EXIT; + status = STATE_ON_EXIT; } }; @@ -401,25 +421,24 @@ void StateController::onTreatmentEndStateChange(bool active) { static State_Status status = STATE_ON_ENTRY; + static QList txStates; auto onEntry = [=](){ + handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_IMMEDIATELY); + txStates = {TREAT_START_STATE, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); + txStates = {TREAT_END_STATE, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); status = STATE_ON_ACTION; - qDebug() << "Tx on entry"; + qDebug() << "Tx End on entry"; }; auto onAction = [=](){ status = STATE_ON_ACTION; - //handleBackToStandbyEvent(status); - //handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_DELAYED); - //txStates = {TREAT_DIALYSIS_STATE, 0, 0, 0, 0, 0, 0, 0, _treatmentStatus.fluidBolusState, 0}; - //handleTreatmentStatesBroadcastData(txStates, BC_DELAYED); - //handleTDPressureProcessAndBroadcastData(BC_DELAYED); - //handleFluidBolusRequestMessage(); - //if (_treatmentStatus.fluidBolusState == FLUID_BOLUS_SALINE_IN_PROGRESS_STATE){ handleFluidBolusFluidDelivery(_treatmentParams.bloodFlowRateMLPM); } - //handleFluidBolusBroadcastData(BC_DELAYED); - //handleTreatmentTimeProcessAndBroadcastData(BC_DELAYED); - //handleTreatmentPrescriptionEditRequestMessage(); - //handleSetPointBloodFlowChange(_treatmentParams.bloodFlowRateMLPM); + handleBackToStandbyEvent(status); + handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_DELAYED); + txStates = {TREAT_END_STATE, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + handleTreatmentStatesBroadcastData(txStates, BC_DELAYED); }; auto onExit = [=](){ @@ -589,17 +608,20 @@ _isSendListReady = true; } -void StateController::handleUIResponseMessage(const Message_ID_Enum msgID, const quint32 acceptReject) +void StateController::handleUIResponseMessage(const Message_ID_Enum msgID, const quint32 acceptReject, const QVariantList &rejectReasons) { QVariantList resp; resp.append(static_cast(msgID)); resp.append(Can_Id::eChlid_TD_UI); resp.append(acceptReject); - resp.append(0); - - // If the messages is fluid bolus, response exceptionally has another payload which is the target fluid blous - if (msgID == ID_TD_FLUID_BOLUS_RESP) { resp.append(_treatmentParams.fluidBlousVolumeML); } - + if (rejectReasons.isEmpty()) { + // If the default reject reasons is empty, it means there were no reject reasons or extra payloads so assume none + resp.append(static_cast(REQUEST_REJECT_REASON_NONE)); + qDebug() << "Empty" << rejectReasons; + } + else { + for (auto item: rejectReasons) { resp.append(item); } + } _isSendListReady = false; _sendMessages.append(resp); _isSendListReady = true; @@ -615,6 +637,7 @@ _treatmentStatus.accumFluidBolusDeliveredML = 0.0; _treatmentStatus.fluidBolusState = FLUID_BOLUS_IDLE_STATE; _treatmentStatus.txState = TREAT_START_STATE; + _treatmentStatus.ufVolDeliveredL = 0.0; } quint32 StateController::extractU32DataFromReceivedMessage(const Message_ID_Enum msgID, qint32 index) @@ -624,3 +647,12 @@ return u32Var.value; } + +float StateController::extractF32DataFromReceivedMessage(const Can::Message_ID_Enum msgID, qint32 index) +{ + Types::F32 f32Var; + GetValue(_treatmentRcvdMessages[msgID].toByteArray(), index, f32Var); + + return f32Var.value; +} +