Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -rb824ef4b479578c5aa702abd9147aef505a6fb04 -r2fe1bfe77e53e5b92dae1b89c726c59b7b95939f --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision b824ef4b479578c5aa702abd9147aef505a6fb04) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 2fe1bfe77e53e5b92dae1b89c726c59b7b95939f) @@ -183,7 +183,7 @@ // Initialize treatment mode each time we transition to it initTreatmentMode(); // Initialize treatment sub-modes each time we transition to treatment mode -// initBloodPrime(); + initBloodPrime(); initDialysis(); initTreatmentPaused(); // initRinseback(); @@ -316,6 +316,35 @@ /*********************************************************************//** * @brief + * The setBloodIsPrimed function sets that flag indicating whether the + * blood-side circuit has been primed with blood. Call this function with + * TRUE when blood prime operation is completed. Call this function with + * FALSE at start of treatment or start of rinseback operation. + * @details Inputs: none + * @details Outputs: bloodIsPrimed + * @param flag TRUE if blood side circuit is primed with blood, FALSE if not + * @return none + *************************************************************************/ +void setBloodIsPrimed( BOOL flag ) +{ + bloodIsPrimed = flag; +} + +/*********************************************************************//** + * @brief + * The getBloodIsPrimed function determines whether the blood-side circuit + * has been primed with blood (indicating blood-side circuit should be primarily blood). + * @details Inputs: bloodIsPrimed + * @details Outputs: none + * @return bloodIsPrimed + *************************************************************************/ +BOOL getBloodIsPrimed( void ) +{ + return bloodIsPrimed; +} + +/*********************************************************************//** + * @brief * The signalAlarmActionToTreatmentMode function executes the given alarm action * as appropriate while in Treatment Mode. * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if invalid alarm action given. @@ -329,7 +358,7 @@ switch( action ) { case ALARM_ACTION_STOP: - // Stop signal actively polled by mode/sub-mode/state + // signal actively polled by mode/sub-mode/state break; case ALARM_ACTION_RESUME: @@ -369,9 +398,22 @@ /*********************************************************************//** * @brief + * The signalBloodPrimeToDialysis function signals that blood prime has + * completed and it is time to move on to dialysis. + * @details Inputs: none + * @details Outputs: bloodPrimeToDialysisRequest + * @return none + *************************************************************************/ +void signalBloodPrimeToDialysis( void ) +{ + bloodPrimeToDialysisRequest = TRUE; +} + +/*********************************************************************//** + * @brief * The execTreatmentMode function executes the Treatment Mode state machine. - * @details \b Alarm: ALARM_ID_TD_TREATMENT_STOPPED_BY_USER if user presses - * the stop button + * @details \b Alarm: ALARM_ID_TD_TREATMENT_PED_BY_USER if user presses + * the button * @details \b Inputs: currentTreatmentState * @details \b Outputs: currentTreatmentState, resumeBlockedByAlarm * @return current state (sub-mode) @@ -380,7 +422,7 @@ { BOOL stop = isStopButtonPressed(); - // Trigger user stop alarm at any time in treatment mode when user presses stop button + // Trigger user alarm at any time in treatment mode when user presses button if ( TRUE == stop ) { activateAlarmNoData( ALARM_ID_TD_TREATMENT_STOPPED_BY_USER ); @@ -480,7 +522,7 @@ TREATMENT_STATE_T result = TREATMENT_BLOOD_PRIME_STATE; lastTreatmentTimeStamp = getMSTimerCount(); - //transitionToBloodPrime(); // TODO + transitionToBloodPrime(); setDialysisBloodPumpFlowRate( getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ) ); // TODO - remove later return result; @@ -500,19 +542,19 @@ // setRinsebackIsCompleted( FALSE ); -// // Handle alarm stoppage -// if ( TRUE == doesAlarmStatusIndicateStop() ) -// { -// transitionToTreatmentStop(); -// result = TREATMENT_STOP_STATE; -// } -// else -// { -// execBloodPrime(); -// -// // Handle signals from blood prime sub-mode -// if ( TRUE == bloodPrimeToDialysisRequest ) -// { + // Handle alarm page + if ( TRUE == doesAlarmStatusIndicate() ) + { + transitionToTreatmentPaused(); + result = TREATMENT_PAUSED_STATE; + } + else + { + execBloodPrime(); + + // Handle signals from blood prime sub-mode + if ( TRUE == bloodPrimeToDialysisRequest ) + { lastTreatmentTimeStamp = getMSTimerCount(); // Kick dialysis sub-mode off setDialysisBloodPumpFlowRate( getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ) ); @@ -567,8 +609,8 @@ else { execDialysis(); - // Handle alarm stoppage - if ( TRUE == doesAlarmStatusIndicateStop() ) + // Handle alarm page + if ( TRUE == doesAlarmStatusIndicate() ) { transitionToTreatmentPaused(); result = TREATMENT_PAUSED_STATE; @@ -596,18 +638,18 @@ { resumeTreatmentAlarmResponseRequest = FALSE; -// if ( TRUE == getBloodIsPrimed() ) + if ( TRUE == getBloodIsPrimed() ) { lastTreatmentTimeStamp = getMSTimerCount(); transitionToDialysis(); result = TREATMENT_DIALYSIS_STATE; } -// else -// { -// transitionToBloodPrime(); -// result = TREATMENT_BLOOD_PRIME_STATE; -// } -// signalInitiatePressureStabilization( USE_NORMAL_STABILIZATION_PERIOD ); + else + { + transitionToBloodPrime(); + result = TREATMENT_BLOOD_PRIME_STATE; + } + signalInitiatePressureStabilization( USE_NORMAL_STABILIZATION_PERIOD ); } // If user requests rinseback, go to rinseback // else if ( TRUE == initiateRinsebackAlarmResponseRequest ) @@ -631,7 +673,7 @@ // If leaving treatment paused state, zero alarm countdown timer for UI // if ( TRUE == leavingTreatmentPausedState ) // { -// TREATMENT_STOP_PAYLOAD_T data; +// TREATMENT_PAUSED_PAYLOAD_T data; // // data.timeout = 0; // data.countdown = 0; @@ -646,7 +688,7 @@ * The handleTreatmentRinsebackState function executes the rinseback state of the * Treatment Mode state machine. * @details \b Inputs: endTreatmentAlarmResponseRequest, resumeTreatmentAlarmResponseRequest, - * rinsebackToRecircRequest, rinsebackToStoppedRequest, endTreatmentRequest + * rinsebackToRecircRequest, rinsebackTopedRequest, endTreatmentRequest * @details \b Outputs: treatment rinseback sub-mode executed, sendLastTreatmentPeriodicData * @return next treatment mode state *************************************************************************/ @@ -679,10 +721,10 @@ // transitionToTreatmentRecirc(); // result = TREATMENT_RECIRC_STATE; // } -// else if ( TRUE == rinsebackToStoppedRequest ) +// else if ( TRUE == rinsebackTopedRequest ) // { -// transitionToTreatmentStop(); -// result = TREATMENT_STOP_STATE; +// transitionToTreatment(); +// result = TREATMENT_PAUSED_STATE; // } // else if ( TRUE == endTreatmentRequest ) // { @@ -696,7 +738,7 @@ * @brief * The handleTreatmentRecircState function executes the re-circulate state of the * Treatment Mode state machine. - * @details \b Inputs: endTreatmentAlarmResponseRequest, rinsebackToStoppedRequest, + * @details \b Inputs: endTreatmentAlarmResponseRequest, rinsebackTopedRequest, * endTreatmentRequest * @details \b Outputs: sendLastTreatmentPeriodicData * @return next treatment mode state @@ -718,11 +760,11 @@ // } // // // Handle signals from treatment re-circ sub-mode -// if ( TRUE == rinsebackToStoppedRequest ) +// if ( TRUE == rinsebackTopedRequest ) // { -// stopDialysis(); -// transitionToTreatmentStop(); -// result = TREATMENT_STOP_STATE; +// Dialysis(); +// transitionToTreatment(); +// result = TREATMENT__STATE; // } // else if ( TRUE == endTreatmentRequest ) // { @@ -829,10 +871,10 @@ treatmentStateBroadcastTimerCtr = 0; payload.treatmentSubMode = (U32)currentTreatmentState; - payload.bldPrimeState = 0; // getCurrentBloodPrimeState(); + payload.bldPrimeState = getCurrentBloodPrimeState(); payload.dialysisState = getDialysisState(); payload.isoUFState = 0; - payload.txStopState = getCurrentTreatmentPausedState(); + payload.txPausedState = getCurrentTreatmentPausedState(); payload.rinsebackState = 0; // getCurrentRinsebackState(); payload.txRecircState = 0; // getCurrentTreatmentRecircState(); payload.txEndState = 0; // getCurrentTreatmentEndState(); @@ -1000,7 +1042,7 @@ *************************************************************************/ static void resetSignalFlags( void ) { -// rinsebackToStoppedRequest = FALSE; +// rinsebackTopedRequest = FALSE; endTreatmentRequest = FALSE; // rinsebackToRecircRequest = FALSE; bloodPrimeToDialysisRequest = FALSE;