Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -rc67def50892f9a7c2f1f22985b5351465a8f6773 -r1a685471524555a374854c0c9ec8e208e71fe2df --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision c67def50892f9a7c2f1f22985b5351465a8f6773) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 1a685471524555a374854c0c9ec8e208e71fe2df) @@ -53,11 +53,14 @@ #define PREVENT_UF_VOL_CHANGE_IF_NEARLY_DONE_SEC ( 10 * SEC_PER_MIN ) ///< Prevent UF volume change if treatment within this much time from end of treatment (in seconds). #define TREATMENT_TIME_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the treatment time & state data is published on the CAN bus. -#define TREATMENT_SETTINGS_RANGES_PUB_INTERVAL ( ( 60 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which updated, valid treatment setting ranges are published on the CAN bus. +/// Interval (ms/task time) at which updated, valid treatment setting ranges are published on the CAN bus. +#define TREATMENT_SETTINGS_RANGES_PUB_INTERVAL ( ( 60 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) -#define CALC_ELAPSED_TREAT_TIME_IN_SECS() ( treatmentTimeMS / MS_PER_SECOND ) ///< Macro to calculate the elapsed treatment time in seconds. -#define CALC_ELAPSED_TREAT_TIME_IN_MIN() ( ( treatmentTimeMS / MS_PER_SECOND ) / SEC_PER_MIN ) ///< Macro to calculate the elapsed treatment time in minutes. -#define CALC_TREAT_TIME_REMAINING_IN_SECS() ( (S32)presTreatmentTimeSecs - (S32)( treatmentTimeMS / MS_PER_SECOND ) ) ///< Macro to calculate the remaining treatment time in seconds. +#define CALC_ELAPSED_TREAT_TIME_IN_SECS() ( treatmentTimeMS / MS_PER_SECOND ) ///< Macro to calculate the elapsed treatment time in seconds. +/// Macro to calculate the elapsed treatment time in minutes. +#define CALC_ELAPSED_TREAT_TIME_IN_MIN() ( ( treatmentTimeMS / MS_PER_SECOND ) / SEC_PER_MIN ) +/// Macro to calculate the remaining treatment time in seconds. +#define CALC_TREAT_TIME_REMAINING_IN_SECS() ( (S32)presTreatmentTimeSecs - (S32)( treatmentTimeMS / MS_PER_SECOND ) ) // ********** private data ********** @@ -73,9 +76,9 @@ static U32 lastTreatmentTimeStamp; ///< Last time elapsed treatment time was recorded (a timestamp in ms). static U32 treatmentTimeBroadcastTimerCtr; ///< Treatment data broadcast timer counter used to schedule when to transmit data. static U32 treatmentParamsRangesBroadcastTimerCtr; ///< Treatment parameter ranges broadcast timer counter used to schedule when to transmit updated ranges. +// TODO - test code - remove later +static BUTTON_STATE_T lastOffButtonState = BUTTON_STATE_RELEASED; -static BUTTON_STATE_T lastOffButtonState = BUTTON_STATE_RELEASED; // TODO - test code - remove later - static BOOL pendingUserEndTreatmentRequest; ///< Flag indicates user has requested treatment end. static U32 pendingParamChangesTimer; ///< User required to confirm UF volume change within 1 minute. @@ -85,7 +88,6 @@ // ********** private function prototypes ********** -static void broadcastTreatmentTimeAndState( void ); static void broadcastTreatmentSettingsRanges( void ); static TREATMENT_STATE_T handleTreatmentStartState( void ); static TREATMENT_STATE_T handleTreatmentDialysisState( void ); @@ -136,17 +138,6 @@ // initialize treatment sub-modes each time we transition to treatment mode initDialysis(); initTreatmentStop(); - // temporary test code. TODO - remove later -#ifndef UF_TEST_ENABLED -#ifndef RUN_PUMPS_OPEN_LOOP - setBloodPumpTargetFlowRate( 400, MOTOR_DIR_REVERSE, PUMP_CONTROL_MODE_CLOSED_LOOP ); - setDialInPumpTargetFlowRate( 400, MOTOR_DIR_REVERSE, PUMP_CONTROL_MODE_CLOSED_LOOP ); -#else - setBloodPumpTargetFlowRate( 400, MOTOR_DIR_REVERSE, PUMP_CONTROL_MODE_OPEN_LOOP ); - setDialInPumpTargetFlowRate( 400, MOTOR_DIR_REVERSE, PUMP_CONTROL_MODE_OPEN_LOOP ); -#endif - setDialOutPumpTargetRate( 400, MOTOR_DIR_REVERSE, PUMP_CONTROL_MODE_OPEN_LOOP ); -#endif #ifdef RM46_EVAL_BOARD_TARGET // TODO - temporary test code for eval board start = getMSTimerCount(); @@ -196,16 +187,14 @@ *************************************************************************/ U32 execTreatmentMode( void ) { -#if 0 +#ifdef DISABLE_UI_TREATMENT_WORKFLOW BOOL stop = isStopButtonPressed(); if ( TRUE == stop ) { requestNewOperationMode( MODE_POST ); } - broadcastTreatmentTimeAndState(); - broadcastTreatmentSettingsRanges(); -#else +#endif // treatment mode state machine switch ( currentTreatmentState ) { @@ -267,7 +256,6 @@ // call various execs for treatment mode execTreatmentReservoirMgmt(); execAirTrapMonitorTreatment(); -#endif #ifdef RM46_EVAL_BOARD_TARGET // TODO - temporary test code for eval board - move to next mode after 5 min if ( TRUE == didTimeout( start, 300000U ) ) @@ -299,15 +287,15 @@ presTreatmentTimeSecs = SEC_PER_MIN * getTreatmentParameterU32( TREATMENT_PARAM_TREATMENT_DURATION ); presBloodFlowRate = getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ); presDialysateFlowRate = getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ); - presMaxUFVolumeML = getTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME ); + presMaxUFVolumeML = getTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME ) * (F32)ML_PER_LITER; presUFRate = presMaxUFVolumeML / (F32)getTreatmentParameterU32( TREATMENT_PARAM_TREATMENT_DURATION ); #else // TODO - test code - presTreatmentTimeSecs = 3600; + presTreatmentTimeSecs = 14400; presBloodFlowRate = 300; presDialysateFlowRate = 300; - presMaxUFVolumeML = 600.0; - presUFRate = 10.0; + presMaxUFVolumeML = 2400.0; + presUFRate = 0.0; #endif // kick dialysis sub-mode off @@ -486,6 +474,8 @@ sendChangeTreatmentDurationResponse( result, rejectReason, presTreatmentTimeSecs / SEC_PER_MIN, presMaxUFVolumeML ); // send new ranges for settings broadcastTreatmentSettingsRanges(); + // send time/state data immediately for UI update + broadcastTreatmentTimeAndState(); return result; } @@ -651,6 +641,8 @@ sendChangeUFSettingsOptionResponse( result, rejectReason, presMaxUFVolumeML, presTreatmentTimeSecs / SEC_PER_MIN, presUFRate ); // send new ranges for settings broadcastTreatmentSettingsRanges(); + // send time/state data immediately for UI update + broadcastTreatmentTimeAndState(); return result; } @@ -722,7 +714,7 @@ * @details Outputs: treatment time and state messages sent on interval * @return none *************************************************************************/ -static void broadcastTreatmentTimeAndState( void ) +void broadcastTreatmentTimeAndState( void ) { U32 elapsedTreatmentTimeInSecs;