Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -rb66dabe73c8418e0e4ee358ce787b6d9bd9e128e -r844f98879b7425c207b58562e623ab960adbc357 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision b66dabe73c8418e0e4ee358ce787b6d9bd9e128e) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 844f98879b7425c207b58562e623ab960adbc357) @@ -34,16 +34,20 @@ // ********** private definitions ********** -/// Maximum time in this mode before blood sitting warning given (in general task intervals). +/// Maximum time in this mode before blood sitting alarm given (in general task intervals). static const U32 MAX_TIME_BLOOD_SITTING = ( ( 5 * SEC_PER_MIN * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ); +/// Maximum time in this mode before blood sitting warning given (in general task intervals). +static const U32 WARN_TIME_BLOOD_SITTING = ( ( 4 * SEC_PER_MIN * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ); /// Treatment stop status broadcast interval. -static const U32 TREATMENT_STOP_DATA_PUBLISH_INTERVAL = ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); +#define TREATMENT_STOP_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) // ********** private data ********** static TREATMENT_STOP_STATE_T currentTxStopState; ///< Current treatment stop state. static U32 bloodSittingTimerCtr; ///< Timer counter tracks time in this mode while blood is sitting. static U32 stopPublishTimerCtr; ///< Timer counter (in GP task intervals) counts time to next status broadcast. +/// Interval (in task intervals) at which to publish treatment stop sub-mode data to CAN bus. +static OVERRIDE_U32_T treatmentStopPublishInterval = { TREATMENT_STOP_DATA_PUBLISH_INTERVAL, TREATMENT_STOP_DATA_PUBLISH_INTERVAL, TREATMENT_STOP_DATA_PUBLISH_INTERVAL, 0 }; // ********** private function prototypes ********** @@ -77,6 +81,8 @@ *************************************************************************/ void transitionToTreatmentStop( void ) { + initTreatmentStop(); + // Set user alarm recovery actions allowed in this sub-mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); if ( TRUE == getRinsebackCompleted() ) @@ -135,8 +141,12 @@ void execTreatmentStop( void ) { // Ensure we do not sit in stopped state for too long - if ( ++bloodSittingTimerCtr > MAX_TIME_BLOOD_SITTING ) + if ( ++bloodSittingTimerCtr > WARN_TIME_BLOOD_SITTING ) { + activateAlarmNoData( ALARM_ID_BLOOD_SITTING_WARNING ); + } + if ( bloodSittingTimerCtr > MAX_TIME_BLOOD_SITTING ) + { // Activate the alarm activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_NO_RINSEBACK ); } @@ -224,7 +234,7 @@ *************************************************************************/ static void publishTreatmentStopData( void ) { - if ( ++stopPublishTimerCtr >= TREATMENT_STOP_DATA_PUBLISH_INTERVAL ) + if ( ++stopPublishTimerCtr >= getU32OverrideValue( &treatmentStopPublishInterval ) ) { U32 timeout = MAX_TIME_BLOOD_SITTING / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); U32 countdown = ( bloodSittingTimerCtr >= MAX_TIME_BLOOD_SITTING ? 0 : ( MAX_TIME_BLOOD_SITTING - bloodSittingTimerCtr ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); @@ -234,4 +244,57 @@ } } + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetTreatmentStopPublishIntervalOverride function sets the override of the + * treatment stop sub-mode data publication interval. + * @details Inputs: none + * @details Outputs: treatmentStopPublishInterval + * @param ms milliseconds between treatment stop sub-mode broadcasts + * @return TRUE if override set successful, FALSE if not + *************************************************************************/ +BOOL testSetTreatmentStopPublishIntervalOverride( U32 ms ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + U32 intvl = ms / TASK_GENERAL_INTERVAL; + + result = TRUE; + treatmentStopPublishInterval.ovData = intvl; + treatmentStopPublishInterval.override = OVERRIDE_KEY; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetTreatmentStopPublishIntervalOverride function resets the override of the + * treatment stop sub-mode data publication interval. + * @details Inputs: none + * @details Outputs: treatmentStopPublishInterval + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetTreatmentStopPublishIntervalOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + treatmentStopPublishInterval.override = OVERRIDE_RESET; + treatmentStopPublishInterval.ovData = treatmentStopPublishInterval.ovInitData; + } + + return result; +} + /**@}*/