Index: sources/drydemo/StateController.cpp =================================================================== diff -u -ra271469db538bfc35eba9a56308760893ecbc68e -rbb80bbccaf1c911be48493868c18c656d84b2ec1 --- sources/drydemo/StateController.cpp (.../StateController.cpp) (revision a271469db538bfc35eba9a56308760893ecbc68e) +++ sources/drydemo/StateController.cpp (.../StateController.cpp) (revision bb80bbccaf1c911be48493868c18c656d84b2ec1) @@ -262,50 +262,45 @@ static bool resume = true; static float rampStepML = 0.0; static bool hasFlowChngeRequested = false; - static quint32 pauseResumeState = 0; - static QList txStates; auto onEntry = [=](){ handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_IMMEDIATELY); // Clear the blood prime data immediately to prevent residual accumulated volume from a previous run handleBloodPrimeBroadcastData(0.0, 0, 0, BC_IMMEDIATELY); - accumBloodVolML = 0.0; - currBloodFlowMLPM = BLOOD_PRIME_START_FLOW_MLPM; - resume = true; - hasFlowChngeRequested = false; - _treatmentStatus.txState = TREAT_BLOOD_PRIME_STATE; - txStates = {TREAT_BLOOD_PRIME_STATE, BLOOD_PRIME_RAMP_STATE, 0, 0, 0, 0, 0, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); + accumBloodVolML = 0.0; + currBloodFlowMLPM = BLOOD_PRIME_START_FLOW_MLPM; + resume = true; + hasFlowChngeRequested = false; + _treatmentSubStates.bloodPrimeStates = BLOOD_PRIME_RAMP_STATE; + _treatmentSubStates.txStates = TREAT_BLOOD_PRIME_STATE; + handleTreatmentStatesBroadcastData(BC_IMMEDIATELY); rampStepML = getBloodPrimeRampStepML(); - status = STATE_ON_ACTION; - + status = STATE_ON_ACTION; qDebug() << "Blood prime on entry"; }; auto onAction = [=](){ status = STATE_ON_ACTION; - txStates = {TREAT_BLOOD_PRIME_STATE, pauseResumeState, 0, 0, 0, 0, 0, 0, _treatmentStatus.fluidBolusState, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_DELAYED); + //txStates = {TREAT_BLOOD_PRIME_STATE, pauseResumeState, 0, 0, 0, 0, 0, 0, _treatmentSubStates.fluidBolusState, 0}; + handleTreatmentStatesBroadcastData(BC_DELAYED); handleBackToStandbyEvent(status); if (! _treatmentRcvdMessages[ID_UI_BLOOD_PRIME_CMD_RQST].isNull()){ handleUIResponseMessage(ID_TD_BLOOD_PRIME_CMD_RESP, ACCEPT_VALUE); quint32 resumeStatus = extractU32DataFromReceivedMessage(ID_UI_BLOOD_PRIME_CMD_RQST, 0); - resume = (resumeStatus == BLOOD_PRIME_RESUME ? true : false); - pauseResumeState = (resumeStatus == BLOOD_PRIME_RESUME ? BLOOD_PRIME_RESUME : BLOOD_PRIME_PAUSE); - + resume = (resumeStatus == BLOOD_PRIME_RESUME ? true : false); + _treatmentSubStates.bloodPrimeStates = (resumeStatus == BLOOD_PRIME_RESUME ? BLOOD_PRIME_RUN_STATE : BLOOD_PRIME_PAUSED_STATE); // Send the results immediately - txStates = {TREAT_BLOOD_PRIME_STATE, BLOOD_PRIME_PAUSE, 0, 0, 0, 0, 0, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); + handleTreatmentStatesBroadcastData(BC_IMMEDIATELY); _treatmentRcvdMessages[ID_UI_BLOOD_PRIME_CMD_RQST].clear(); } handleSetPointBloodFlowChange(currBloodFlowMLPM, hasFlowChngeRequested); handleTDPressureProcessAndBroadcastData(BC_DELAYED); handleFluidBolusRequestMessage(); - if (_treatmentStatus.fluidBolusState == FLUID_BOLUS_SALINE_IN_PROGRESS_STATE){ + if (_treatmentSubStates.fluidBolusState == FLUID_BOLUS_SALINE_IN_PROGRESS_STATE){ handleFluidBolusFluidDelivery(currBloodFlowMLPM); handleFluidBolusBroadcastData(BC_DELAYED); // If fluid bolus is in progress, do not run the blood prime @@ -317,13 +312,11 @@ handleBloodPrimeVolML(resume, rampStepML, hasFlowChngeRequested, currBloodFlowMLPM, accumBloodVolML); handleTreatmentSetpointsBroadcastData(currBloodFlowMLPM, _treatmentParams.dialysateFlowRateMLPM, _treatmentParams.dialysateTemperatureC, BC_IMMEDIATELY); - if (accumBloodVolML > BLOOD_PRIME_VOLUME_ML) { _treatmentStatus.stateTransitionEvent = "T_BP_2_Tx"; status = STATE_ON_EXIT; // Send the final volume value prior to trnasiotining to treatment handleBloodPrimeBroadcastData(accumBloodVolML, 0, 0, BC_IMMEDIATELY); - qDebug() << "VOL" << accumBloodVolML; } }; @@ -344,20 +337,16 @@ { static State_Status status = STATE_ON_ENTRY; static bool hasFlowChngeRequested = false; - static QList txStates; if (_treatmentStatus.requestTreatmentReset) { status = STATE_ON_ENTRY; _treatmentStatus.requestTreatmentReset = false; } auto onEntry = [=](){ - hasFlowChngeRequested = false; + hasFlowChngeRequested = false; // Start with UF state in dialysis - _treatmentStatus.dialysisSubState = DIALYSIS_UF_STATE; - _treatmentStatus.txState = TREAT_DIALYSIS_STATE; + _treatmentSubStates.dialysisSubState = DIALYSIS_UF_STATE; + _treatmentSubStates.txStates = TREAT_DIALYSIS_STATE; handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_IMMEDIATELY); - txStates = {TREAT_START_STATE, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); - txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); + handleTreatmentStatesBroadcastData(BC_IMMEDIATELY); handleTreatmentSetpointsBroadcastData(_treatmentParams.bloodFlowRateMLPM, _treatmentParams.dialysateFlowRateMLPM, _treatmentParams.dialysateTemperatureC, BC_IMMEDIATELY); handleDDConductivityBroadcastData(BC_IMMEDIATELY); @@ -373,11 +362,10 @@ status = STATE_ON_ACTION; handleBackToStandbyEvent(status); handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_DELAYED); - txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, _treatmentStatus.fluidBolusState, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_DELAYED); + handleTreatmentStatesBroadcastData(BC_DELAYED); // Fluid bolus functions handleFluidBolusRequestMessage(); - if (_treatmentStatus.fluidBolusState == FLUID_BOLUS_SALINE_IN_PROGRESS_STATE){ handleFluidBolusFluidDelivery(_treatmentParams.bloodFlowRateMLPM); } + if (_treatmentSubStates.fluidBolusState == FLUID_BOLUS_SALINE_IN_PROGRESS_STATE){ handleFluidBolusFluidDelivery(_treatmentParams.bloodFlowRateMLPM); } handleFluidBolusBroadcastData(BC_DELAYED); // Broadcast functions handleTreatmentTimeProcessAndBroadcastData(BC_DELAYED); @@ -429,18 +417,15 @@ void StateController::onTreatmentPauseStateChange(bool active) { static State_Status status = STATE_ON_ENTRY; - static QList txStates; + //static QList txStates; auto onEntry = [=](){ triggerAnAlarm(ALARM_ID_TD_TREATMENT_STOPPED_BY_USER); // Start with UF state in dialysis - _treatmentStatus.dialysisSubState = DIALYSIS_UF_PAUSED_STATE; - _treatmentStatus.txState = TREAT_PAUSED_STATE; + _treatmentSubStates.dialysisSubState = DIALYSIS_UF_PAUSED_STATE; + _treatmentSubStates.txStates = TREAT_PAUSED_STATE; handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_IMMEDIATELY); - txStates = {TREAT_START_STATE, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); - txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); + handleTreatmentStatesBroadcastData(BC_IMMEDIATELY); status = STATE_ON_ACTION; qDebug() << "Tx pause on entry"; }; @@ -450,8 +435,7 @@ handleBackToStandbyEvent(status); handleAlarmUserAction(status); handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_DELAYED); - txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, _treatmentStatus.fluidBolusState, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_DELAYED); + handleTreatmentStatesBroadcastData(BC_DELAYED); }; auto onExit = [=](){ @@ -469,19 +453,15 @@ void StateController::onTreatmentRinsebackStateChange(bool active) { static State_Status status = STATE_ON_ENTRY; - static QList txStates; auto onEntry = [=](){ // Start with UF state in dialysis - _treatmentStatus.dialysisSubState = DIALYSIS_UF_PAUSED_STATE; - _treatmentStatus.txState = TREAT_RINSEBACK_STATE; - _treatmentStatus.rinsebackState = RINSEBACK_STOP_INIT_STATE; + _treatmentSubStates.dialysisSubState = DIALYSIS_UF_PAUSED_STATE; + _treatmentSubStates.txStates = TREAT_RINSEBACK_STATE; + _treatmentSubStates.rinsebackState = RINSEBACK_STOP_INIT_STATE; handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_IMMEDIATELY); - txStates = {TREAT_START_STATE, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); - txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, _treatmentStatus.rinsebackState, 0, 0, 0, 0}; initializeRinseback(); - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); + handleTreatmentStatesBroadcastData(BC_IMMEDIATELY); handleRinsebackBroadcastData(BC_IMMEDIATELY); status = STATE_ON_ACTION; qDebug() << "Tx rinseback on entry"; @@ -491,8 +471,7 @@ status = STATE_ON_ACTION; handleBackToStandbyEvent(status); handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_DELAYED); - txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, _treatmentStatus.rinsebackState, 0, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_DELAYED); + handleTreatmentStatesBroadcastData(BC_DELAYED); handleRinsebackRequestMessage(); handleRinsebackDelivery(); handleRinsebackBroadcastData(BC_DELAYED); @@ -519,32 +498,27 @@ void StateController::onTreatmentRecriculateStateChange(bool active) { static State_Status status = STATE_ON_ENTRY; - static QList txStates; auto onEntry = [=](){ // Start with UF state in dialysis - _treatmentStatus.dialysisSubState = DIALYSIS_UF_STATE; - _treatmentStatus.txState = TREAT_RECIRC_STATE; - _treatmentStatus.recircState = TREATMENT_RECIRC_DISCONNECT_PATIENT_STATE; + _treatmentSubStates.dialysisSubState = DIALYSIS_UF_STATE; + _treatmentSubStates.txStates = TREAT_RECIRC_STATE; + _treatmentSubStates.recircState = TREATMENT_RECIRC_DISCONNECT_PATIENT_STATE; handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_IMMEDIATELY); - txStates = {TREAT_START_STATE, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, 0, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); - txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, _treatmentStatus.recircState, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_IMMEDIATELY); + handleTreatmentStatesBroadcastData(BC_IMMEDIATELY); status = STATE_ON_ACTION; - qDebug() << "Tx recric on entry"; + qDebug() << "Tx recirc on entry"; }; auto onAction = [=](){ status = STATE_ON_ACTION; handleBackToStandbyEvent(status); handleTDOpModeTransitionBroadcastData(MODE_TREA, 0, BC_DELAYED); - txStates = {_treatmentStatus.txState, 0, _treatmentStatus.dialysisSubState, 0, 0, 0, _treatmentStatus.recircState, 0, 0, 0}; - handleTreatmentStatesBroadcastData(txStates, BC_DELAYED); + handleTreatmentStatesBroadcastData(BC_DELAYED); }; auto onExit = [=](){ - qDebug() << "Tx recric in exit"; + qDebug() << "Tx recirc in exit"; _dryDemo.submitEvent(_treatmentStatus.stateTransitionEvent); status = STATE_ON_ENTRY; }; @@ -559,14 +533,10 @@ 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); + handleTreatmentStatesBroadcastData(BC_IMMEDIATELY); status = STATE_ON_ACTION; qDebug() << "Tx End on entry"; }; @@ -575,8 +545,7 @@ status = STATE_ON_ACTION; 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); + handleTreatmentStatesBroadcastData(BC_DELAYED); }; auto onExit = [=](){