Index: sources/drydemo/DryDemoDefines.h =================================================================== diff -u -ra271469db538bfc35eba9a56308760893ecbc68e -rbb80bbccaf1c911be48493868c18c656d84b2ec1 --- sources/drydemo/DryDemoDefines.h (.../DryDemoDefines.h) (revision a271469db538bfc35eba9a56308760893ecbc68e) +++ sources/drydemo/DryDemoDefines.h (.../DryDemoDefines.h) (revision bb80bbccaf1c911be48493868c18c656d84b2ec1) @@ -83,8 +83,6 @@ #define BLOOD_PRIME_FLOW_INTEGRATOR (1.0 / (SECONDS_PER_MINUTE * (MILLISECONDS_PER_SECOND / QOBJECT_TIMER_TIMEOUT_MS))) #define BLOOD_PRIME_PAUSE_TIMEOUT_S (5 * SECONDS_PER_MINUTE) #define BLOOD_PRIME_RESUME 1 -#define BLOOD_PRIME_PAUSE 2 -#define BLOOD_PRIME_RAMP_STATE 1 // Heparin substates #define HEPARIN_OFF_SUBSTATE 0 @@ -146,6 +144,14 @@ TREAT_DIALYSIS_PAUSED_STATE = 9, }; +enum Blood_Prime_States +{ + BLOOD_PRIME_RAMP_STATE = 0, + BLOOD_PRIME_RUN_STATE = 1, + BLOOD_PRIME_PAUSED_STATE = 2, + BLOOD_PRIME_FLUID_BOLUS_STATE = 3, +}; + enum Fluid_Bolus_States { FLUID_BOLUS_IDLE_STATE = 0, FLUID_BOLUS_WAIT_FOR_PUMPS_STOP_STATE = 1, 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 = [=](){ Index: sources/drydemo/StateController.h =================================================================== diff -u -ra271469db538bfc35eba9a56308760893ecbc68e -rbb80bbccaf1c911be48493868c18c656d84b2ec1 --- sources/drydemo/StateController.h (.../StateController.h) (revision a271469db538bfc35eba9a56308760893ecbc68e) +++ sources/drydemo/StateController.h (.../StateController.h) (revision bb80bbccaf1c911be48493868c18c656d84b2ec1) @@ -31,46 +31,49 @@ private: struct Treatment_Status_Vars { - bool hasTxParamsBeenInitialized; + bool hasTxParamsBeenInitialized; User_Command_ID userCmd; - QString stateTransitionEvent; - bool requestTreatmentReset; + QString stateTransitionEvent; + bool requestTreatmentReset; // Treatment time variable(s) - quint32 treatmentElapsedTimeMS; - bool isTreatmentComplete; + quint32 treatmentElapsedTimeMS; + bool isTreatmentComplete; // Fluid bolus - Fluid_Bolus_States fluidBolusState; - float accumFluidBolusDeliveredML; - float totalFluidBolusDeliveredML; - // Treatment states - Treatment_States txState; - Dialysis_States dialysisSubState; + float accumFluidBolusDeliveredML; + float totalFluidBolusDeliveredML; // UF variables - float presUFRateMLPM; - float ufVolDeliveredL; - bool validateUFVolReceived; - float validateUFVolGoalL; - float validateUFRateLHR; + float presUFRateMLPM; + float ufVolDeliveredL; + bool validateUFVolReceived; + float validateUFVolGoalL; + float validateUFRateLHR; // Treatment duration variables - bool validateTxDurReceived; - quint32 validateTxDurMin; - quint32 validateHepDurMin; + bool validateTxDurReceived; + quint32 validateTxDurMin; + quint32 validateHepDurMin; // Alarm variables - Alarm_List activeAlarm; + Alarm_List activeAlarm; // Rinseback variables - Rinseback_States rinsebackState; - quint32 rinsebackFlowMLPM; - float rinsebackAccumVolML; - float rinsebackAdditionalVolML; - bool isRinsebackComplete; - quint32 rinsebackTimerCounter; - quint32 rinsebackAdditionalTimerCounter; - float rinsebackTgtVolPlusAddVolML; + quint32 rinsebackFlowMLPM; + float rinsebackAccumVolML; + float rinsebackAdditionalVolML; + bool isRinsebackComplete; + quint32 rinsebackTimerCounter; + quint32 rinsebackAdditionalTimerCounter; + float rinsebackTgtVolPlusAddVolML; // Recirculation variables - bool hasRecircBeenRequested; - Recirculate_States recircState; + bool hasRecircBeenRequested; }; + struct Treatment_Sub_State_Vars { + Treatment_States txStates; + Blood_Prime_States bloodPrimeStates; + Fluid_Bolus_States fluidBolusState; + Dialysis_States dialysisSubState; + Rinseback_States rinsebackState; + Recirculate_States recircState; + }; + struct Treatment_Params { bool finalConfirmation; quint32 treatmentModality; @@ -108,6 +111,7 @@ QRandomGenerator _randNumGenerator; Treatment_Params _treatmentParams; Treatment_Status_Vars _treatmentStatus; + Treatment_Sub_State_Vars _treatmentSubStates; bool _isBroadcastListReady; // TODO use a mutex? bool _isSendListReady; // Todo use a mutex? drydemoXMLStates _dryDemo; @@ -152,7 +156,7 @@ void setTreatmentParametersToDefault(); void initializeTreatmentTimeAndUltrafiltration(); void handleTreatmentSetpointsBroadcastData(const quint32 bloodFlowMLPM, const quint32 dialFlowMLPM, const float dialTempC, const Broadcast_Type BCType); - void handleTreatmentStatesBroadcastData(const QList &txStates, const Broadcast_Type BCType); + void handleTreatmentStatesBroadcastData(const Broadcast_Type BCType); void handleFluidBolusRequestMessage(); void handleFluidBolusFluidDelivery(const quint32 bloodFlowMLPM); void handleFluidBolusBroadcastData(const Broadcast_Type BCType); Index: sources/drydemo/StateControllerRecirc.cpp =================================================================== diff -u -ra271469db538bfc35eba9a56308760893ecbc68e -rbb80bbccaf1c911be48493868c18c656d84b2ec1 --- sources/drydemo/StateControllerRecirc.cpp (.../StateControllerRecirc.cpp) (revision a271469db538bfc35eba9a56308760893ecbc68e) +++ sources/drydemo/StateControllerRecirc.cpp (.../StateControllerRecirc.cpp) (revision bb80bbccaf1c911be48493868c18c656d84b2ec1) @@ -13,7 +13,7 @@ if (_treatmentRcvdMessages[ID_UI_RECIRCULATE_RQST].isNull()) { return; } QVariantList reason; quint32 acceptReject = REJECT_VALUE; - //quint32 recircCmd = extractU32DataFromReceivedMessage(ID_UI_RECIRCULATE_RQST, 0); + quint32 recircCmd = extractU32DataFromReceivedMessage(ID_UI_RECIRCULATE_RQST, 0); if (_treatmentStatus.activeAlarm != ALARM_ID_NO_ALARM) { reason.append(REQUEST_REJECT_REASON_ALARM_IS_ACTIVE); @@ -22,6 +22,22 @@ return; } + switch (recircCmd) { + case REQUESTED_USER_ACTION_TX_RECIRC_RECONNECT : + break; + case REQUESTED_USER_ACTION_TX_RECIRC_CONFIRM_RECONNECT : + break; + case REQUESTED_USER_ACTION_TX_RECIRC_RESUME_RC : + break; + case REQUESTED_USER_ACTION_TX_RECIRC_END_TREATMENT : + break; + case REQUESTED_USER_ACTION_TX_RECIRC_CONFIRM_DISCONNECT : + break; + default: + // Do nothing + break; + } + handleUIResponseMessage(ID_TD_RECIRCULATE_RESP, acceptReject, reason); _treatmentRcvdMessages[ID_UI_RECIRCULATE_RQST].clear(); } Index: sources/drydemo/StateControllerRinseback.cpp =================================================================== diff -u -ra271469db538bfc35eba9a56308760893ecbc68e -rbb80bbccaf1c911be48493868c18c656d84b2ec1 --- sources/drydemo/StateControllerRinseback.cpp (.../StateControllerRinseback.cpp) (revision a271469db538bfc35eba9a56308760893ecbc68e) +++ sources/drydemo/StateControllerRinseback.cpp (.../StateControllerRinseback.cpp) (revision bb80bbccaf1c911be48493868c18c656d84b2ec1) @@ -31,17 +31,17 @@ switch (rinsebackCmd) { case REQUESTED_USER_ACTION_RINSEBACK_CONFIRM_START: - if (_treatmentStatus.rinsebackState == RINSEBACK_STOP_INIT_STATE) { - acceptReject = ACCEPT_VALUE; - _treatmentStatus.rinsebackState = RINSEBACK_RUN_STATE; + if (_treatmentSubStates.rinsebackState == RINSEBACK_STOP_INIT_STATE) { + acceptReject = ACCEPT_VALUE; + _treatmentSubStates.rinsebackState = RINSEBACK_RUN_STATE; } else { reason.append(REQUEST_REJECT_REASON_ACTION_DISABLED_IN_CURRENT_STATE); } break; case REQUESTED_USER_ACTION_RINSEBACK_INCREASE_RATE: if ((_treatmentStatus.rinsebackFlowMLPM + RINSEBACK_ADJ_FLOW_RATE_MLPM) <= RINSEBACK_MAX_RLOW_RATE_MLPM) { - if (_treatmentStatus.rinsebackState == RINSEBACK_RUN_STATE) { - acceptReject = ACCEPT_VALUE; + if (_treatmentSubStates.rinsebackState == RINSEBACK_RUN_STATE) { + acceptReject = ACCEPT_VALUE; _treatmentStatus.rinsebackFlowMLPM += RINSEBACK_ADJ_FLOW_RATE_MLPM; } else { reason.append(REQUEST_REJECT_REASON_ACTION_DISABLED_IN_CURRENT_STATE); } @@ -51,7 +51,7 @@ case REQUESTED_USER_ACTION_RINSEBACK_DECREASE_RATE: if ((_treatmentStatus.rinsebackFlowMLPM - RINSEBACK_ADJ_FLOW_RATE_MLPM) >= RINSEBACK_MIN_FLOW_RATE_MLPM) { - if (_treatmentStatus.rinsebackState == RINSEBACK_RUN_STATE) { + if (_treatmentSubStates.rinsebackState == RINSEBACK_RUN_STATE) { acceptReject = ACCEPT_VALUE; _treatmentStatus.rinsebackFlowMLPM -= RINSEBACK_ADJ_FLOW_RATE_MLPM; } @@ -61,25 +61,25 @@ break; case REQUESTED_USER_ACTION_RINSEBACK_PAUSE: - if (_treatmentStatus.rinsebackState == RINSEBACK_RUN_STATE) { - acceptReject = ACCEPT_VALUE; - _treatmentStatus.rinsebackState = RINSEBACK_PAUSED_STATE; + if (_treatmentSubStates.rinsebackState == RINSEBACK_RUN_STATE) { + acceptReject = ACCEPT_VALUE; + _treatmentSubStates.rinsebackState = RINSEBACK_PAUSED_STATE; } else { reason.append(REQUEST_REJECT_REASON_ACTION_DISABLED_IN_CURRENT_STATE); } break; case REQUESTED_USER_ACTION_RINSEBACK_RESUME: - if (_treatmentStatus.rinsebackState == RINSEBACK_PAUSED_STATE) { - acceptReject = ACCEPT_VALUE; - _treatmentStatus.rinsebackState = RINSEBACK_RUN_STATE; + if (_treatmentSubStates.rinsebackState == RINSEBACK_PAUSED_STATE) { + acceptReject = ACCEPT_VALUE; + _treatmentSubStates.rinsebackState = RINSEBACK_RUN_STATE; } else { reason.append(REQUEST_REJECT_REASON_ACTION_DISABLED_IN_CURRENT_STATE); } break; case REQUESTED_USER_ACTION_RINSEBACK_ADDITIONAL: - if (_treatmentStatus.rinsebackState == RINSEBACK_STOP_STATE) { - acceptReject = ACCEPT_VALUE; - _treatmentStatus.rinsebackState = RINSEBACK_RUN_ADDITIONAL_STATE; + if (_treatmentSubStates.rinsebackState == RINSEBACK_STOP_STATE) { + acceptReject = ACCEPT_VALUE; + _treatmentSubStates.rinsebackState = RINSEBACK_RUN_ADDITIONAL_STATE; } else { reason.append(REQUEST_REJECT_REASON_ACTION_DISABLED_IN_CURRENT_STATE); } break; @@ -88,7 +88,7 @@ if(_treatmentStatus.isTreatmentComplete) { reason.append(REQUEST_REJECT_REASON_TREATMENT_IS_COMPLETED); } - else if (_treatmentStatus.rinsebackState != RINSEBACK_STOP_STATE) { + else if (_treatmentSubStates.rinsebackState != RINSEBACK_STOP_STATE) { reason.append(REQUEST_REJECT_REASON_ACTION_DISABLED_IN_CURRENT_STATE); } // TODO implement recirc allowed too @@ -116,12 +116,12 @@ // TODO should we alarm if we timedout? - switch (_treatmentStatus.rinsebackState) { + switch (_treatmentSubStates.rinsebackState) { case RINSEBACK_RUN_STATE: _treatmentStatus.rinsebackAccumVolML += _treatmentStatus.rinsebackFlowMLPM * RINSEBACK_FLOW_INTEGRATOR; _treatmentStatus.rinsebackTimerCounter = 0; if (_treatmentStatus.rinsebackAccumVolML >= _treatmentParams.rinsebackVolumeML) { - _treatmentStatus.rinsebackState = RINSEBACK_STOP_STATE; + _treatmentSubStates.rinsebackState = RINSEBACK_STOP_STATE; _treatmentStatus.rinsebackTgtVolPlusAddVolML = _treatmentStatus.rinsebackAccumVolML; } break; @@ -141,11 +141,11 @@ _treatmentStatus.rinsebackAccumVolML += _treatmentStatus.rinsebackFlowMLPM * RINSEBACK_FLOW_INTEGRATOR; _treatmentStatus.rinsebackAdditionalVolML += _treatmentStatus.rinsebackFlowMLPM * RINSEBACK_FLOW_INTEGRATOR; if (_treatmentStatus.rinsebackAdditionalVolML >= RINSEBACK_ADDITION_VOL_ML) { - _treatmentStatus.rinsebackState = RINSEBACK_STOP_STATE; + _treatmentSubStates.rinsebackState = RINSEBACK_STOP_STATE; } // TODO add alarm? if (_treatmentStatus.rinsebackAdditionalTimerCounter * QOBJECT_TIMER_TIMEOUT_MS > RINSEBACK_MAX_ADDITION_TIME_MS) { - _treatmentStatus.rinsebackState = RINSEBACK_STOP_STATE; + _treatmentSubStates.rinsebackState = RINSEBACK_STOP_STATE; } break; Index: sources/drydemo/StateControllerStandby.cpp =================================================================== diff -u -ra271469db538bfc35eba9a56308760893ecbc68e -rbb80bbccaf1c911be48493868c18c656d84b2ec1 --- sources/drydemo/StateControllerStandby.cpp (.../StateControllerStandby.cpp) (revision a271469db538bfc35eba9a56308760893ecbc68e) +++ sources/drydemo/StateControllerStandby.cpp (.../StateControllerStandby.cpp) (revision bb80bbccaf1c911be48493868c18c656d84b2ec1) @@ -77,9 +77,9 @@ _treatmentStatus.stateTransitionEvent = ""; _treatmentStatus.totalFluidBolusDeliveredML = 0.0; _treatmentStatus.accumFluidBolusDeliveredML = 0.0; - _treatmentStatus.fluidBolusState = FLUID_BOLUS_IDLE_STATE; - _treatmentStatus.txState = TREAT_START_STATE; - _treatmentStatus.rinsebackState = RINSEBACK_STOP_INIT_STATE; + _treatmentSubStates.fluidBolusState = FLUID_BOLUS_IDLE_STATE; + _treatmentSubStates.txStates = TREAT_START_STATE; + _treatmentSubStates.rinsebackState = RINSEBACK_STOP_INIT_STATE; _treatmentStatus.ufVolDeliveredL = 0.0; _treatmentStatus.hasRecircBeenRequested = false; } @@ -114,8 +114,8 @@ switch (userAction) { case ALARM_USER_ACTION_RESUME: - _treatmentStatus.dialysisSubState = DIALYSIS_UF_STATE; - _treatmentStatus.txState = TREAT_DIALYSIS_STATE; + _treatmentSubStates.dialysisSubState = DIALYSIS_UF_STATE; + _treatmentSubStates.txStates = TREAT_DIALYSIS_STATE; _treatmentStatus.stateTransitionEvent = "T_TP_2_Tx"; break; Index: sources/drydemo/StateControllerTreatment.cpp =================================================================== diff -u -r6e845078107f7d15a3e471be421d5bce31fc51da -rbb80bbccaf1c911be48493868c18c656d84b2ec1 --- sources/drydemo/StateControllerTreatment.cpp (.../StateControllerTreatment.cpp) (revision 6e845078107f7d15a3e471be421d5bce31fc51da) +++ sources/drydemo/StateControllerTreatment.cpp (.../StateControllerTreatment.cpp) (revision bb80bbccaf1c911be48493868c18c656d84b2ec1) @@ -96,11 +96,11 @@ quint32 fluidBolusCmd = extractU32DataFromReceivedMessage(ID_UI_FLUID_BOLUS_RQST, 0); // Assume the fluid bolus is not in progress - _treatmentStatus.fluidBolusState = FLUID_BOLUS_IDLE_STATE; + _treatmentSubStates.fluidBolusState = FLUID_BOLUS_IDLE_STATE; if (fluidBolusCmd == FLUID_BOLUS_START_CMD){ - _treatmentStatus.fluidBolusState = FLUID_BOLUS_SALINE_IN_PROGRESS_STATE; - _treatmentStatus.dialysisSubState = DIALYSIS_UF_FLUID_BOLUS_STATE; + _treatmentSubStates.fluidBolusState = FLUID_BOLUS_SALINE_IN_PROGRESS_STATE; + _treatmentSubStates.dialysisSubState = DIALYSIS_UF_FLUID_BOLUS_STATE; } else { _treatmentStatus.totalFluidBolusDeliveredML += _treatmentStatus.accumFluidBolusDeliveredML; } @@ -129,8 +129,8 @@ float deliveredFluidML = qAbs(_treatmentStatus.totalFluidBolusDeliveredML - _treatmentStatus.accumFluidBolusDeliveredML); if (deliveredFluidML >= _treatmentParams.fluidBlousVolumeML) { - _treatmentStatus.fluidBolusState = FLUID_BOLUS_IDLE_STATE; - _treatmentStatus.dialysisSubState = DIALYSIS_UF_STATE; + _treatmentSubStates.fluidBolusState = FLUID_BOLUS_IDLE_STATE; + _treatmentSubStates.dialysisSubState = DIALYSIS_UF_STATE; _treatmentStatus.accumFluidBolusDeliveredML = 0.0; _treatmentStatus.totalFluidBolusDeliveredML += _treatmentStatus.accumFluidBolusDeliveredML; } @@ -212,7 +212,6 @@ _treatmentRcvdMessages[ID_UI_TREATMENT_SET_POINT_BLOOD_FLOW_CHANGE_RQST].clear(); } - void StateController::handleSetPointDialysateFlowChange() { if (_treatmentRcvdMessages[ID_UI_TREATMENT_SET_POINT_DIALYSATE_FLOW_CHANGE_RQST].isNull()) { return; } @@ -245,14 +244,14 @@ quint32 acceptReject = REJECT_VALUE; QVariantList reason; - if (_treatmentStatus.txState == TREAT_DIALYSIS_STATE) { + if (_treatmentSubStates.txStates == TREAT_DIALYSIS_STATE) { // Assume the default state is UF state - _treatmentStatus.dialysisSubState = DIALYSIS_UF_STATE; - _treatmentStatus.dialysisSubState = (cmd == 0 ? DIALYSIS_UF_PAUSED_STATE : _treatmentStatus.dialysisSubState); - acceptReject = ACCEPT_VALUE; - qDebug() << "UF Pa" << _treatmentStatus.dialysisSubState; + _treatmentSubStates.dialysisSubState = DIALYSIS_UF_STATE; + _treatmentSubStates.dialysisSubState = (cmd == 0 ? DIALYSIS_UF_PAUSED_STATE : _treatmentSubStates.dialysisSubState); + acceptReject = ACCEPT_VALUE; + qDebug() << "UF Pa" << _treatmentSubStates.dialysisSubState; } - else if (_treatmentStatus.txState != TREAT_DIALYSIS_STATE) { reason.append(REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE); } + else if (_treatmentSubStates.txStates != TREAT_DIALYSIS_STATE) { reason.append(REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE); } else { quint32 r = (cmd == 0 ? REQUEST_REJECT_REASON_UF_NOT_IN_PROGESS : REQUEST_REJECT_REASON_UF_NOT_PAUSED); reason.append(r); Index: sources/drydemo/StateControllerTreatmentBroadcasts.cpp =================================================================== diff -u -r6e845078107f7d15a3e471be421d5bce31fc51da -rbb80bbccaf1c911be48493868c18c656d84b2ec1 --- sources/drydemo/StateControllerTreatmentBroadcasts.cpp (.../StateControllerTreatmentBroadcasts.cpp) (revision 6e845078107f7d15a3e471be421d5bce31fc51da) +++ sources/drydemo/StateControllerTreatmentBroadcasts.cpp (.../StateControllerTreatmentBroadcasts.cpp) (revision bb80bbccaf1c911be48493868c18c656d84b2ec1) @@ -36,7 +36,7 @@ _isBroadcastListReady = true; } -void StateController::handleTreatmentStatesBroadcastData(const QList &txStates, const Broadcast_Type BCType) +void StateController::handleTreatmentStatesBroadcastData(const Broadcast_Type BCType) { static quint32 broadcastCounter = 0; if ((++broadcastCounter % NUN_OF_COUNTS_QART_BC_EMIT != 0) && (BCType == BC_DELAYED)) { return; } @@ -45,7 +45,16 @@ msg.append(static_cast(ID_TD_TREATMENT_STATE_DATA)); msg.append(Can_Id::eChlid_TD_Sync); - for (auto item: txStates) { msg.append(item);} + msg.append(_treatmentSubStates.txStates); + msg.append(_treatmentSubStates.bloodPrimeStates); + msg.append(_treatmentSubStates.dialysisSubState); + msg.append(0); // TODO add ISO UF + msg.append(0); // TODO add treatment paused + msg.append(_treatmentSubStates.rinsebackState); + msg.append(_treatmentSubStates.recircState); + msg.append(0); // TODO add treatment end + msg.append(_treatmentSubStates.fluidBolusState); + msg.append(0); // Heparin state _isBroadcastListReady = false; _broadcastMessages.append(msg); _isBroadcastListReady = true; @@ -120,7 +129,7 @@ void StateController::handleTreatmentTimeProcessAndBroadcastData(const Broadcast_Type BCType) { static quint32 broadcastCounter = 12; - if (_treatmentStatus.fluidBolusState == FLUID_BOLUS_IDLE_STATE) { + if (_treatmentSubStates.fluidBolusState == FLUID_BOLUS_IDLE_STATE) { _treatmentStatus.treatmentElapsedTimeMS += QOBJECT_TIMER_TIMEOUT_MS; } @@ -150,7 +159,7 @@ quint32 dummyData = 1; float dummyFloat = 150.2; - quint32 dialBypass = (_treatmentStatus.fluidBolusState == FLUID_BOLUS_SALINE_IN_PROGRESS_STATE ? BYPASS_DIALYSATE_DELIVER : ALLOW_DIALYSATE_DELIVER); + quint32 dialBypass = (_treatmentSubStates.fluidBolusState == FLUID_BOLUS_SALINE_IN_PROGRESS_STATE ? BYPASS_DIALYSATE_DELIVER : ALLOW_DIALYSATE_DELIVER); QVariantList msg; msg.append(static_cast(ID_DD_GEN_DIALYSATE_MODE_DATA)); @@ -202,7 +211,7 @@ float UFVolLMS = presUFRateLHR / (static_cast(MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MILLISECONDS_PER_SECOND)); // Only count for UF when the dialysis state is in UF - if (_treatmentStatus.dialysisSubState == DIALYSIS_UF_STATE) { + if (_treatmentSubStates.dialysisSubState == DIALYSIS_UF_STATE) { _treatmentStatus.ufVolDeliveredL += UFVolLMS * PROGRESS_TIME_BC_INTERVAL_MS; } @@ -214,7 +223,7 @@ msg.append(presUFVolL); msg.append(targetUFRateLHR); msg.append(_treatmentStatus.ufVolDeliveredL); - msg.append(static_cast(_treatmentStatus.dialysisSubState)); + msg.append(static_cast(_treatmentSubStates.dialysisSubState)); _isBroadcastListReady = false; _broadcastMessages.append(msg); _isBroadcastListReady = true;