Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r9df8ab7b66946cb653f804c8191613cefafc4d57 -r5072f7dedbe4be9dd9d2bfe9a46f53c1d3f356fc --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 9df8ab7b66946cb653f804c8191613cefafc4d57) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 5072f7dedbe4be9dd9d2bfe9a46f53c1d3f356fc) @@ -463,7 +463,7 @@ * @param loadCellID ID of load cell to get * @return the current load cell weight in grams *************************************************************************/ -F32 getLoadCellWeightInGrams( LOAD_CELL_T loadCellID ) +F32 getLoadCellWeightInGrams( LOAD_CELL_ID_T loadCellID ) { F32 result = 0.0; Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -r766708fceb0bdf1af8c7897df29d4f5036bfd3db -r5072f7dedbe4be9dd9d2bfe9a46f53c1d3f356fc --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 766708fceb0bdf1af8c7897df29d4f5036bfd3db) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 5072f7dedbe4be9dd9d2bfe9a46f53c1d3f356fc) @@ -39,24 +39,6 @@ #define FILL_RESERVOIR_TO_VOLUME_ML 1300 ///< Fill reservoir to this volume (in mL) during treatment. #endif -/// Enumeration of load cell sensors. -typedef enum Load_Cells -{ - LOAD_CELL_RESERVOIR_1_PRIMARY = 0, ///< Primary load cell for reservoir 1. - LOAD_CELL_RESERVOIR_1_BACKUP, ///< Backup load cell for reservoir 1. - LOAD_CELL_RESERVOIR_2_PRIMARY, ///< Primary load cell for reservoir 2. - LOAD_CELL_RESERVOIR_2_BACKUP, ///< Backup load cell for reservoir 2. - NUM_OF_LOAD_CELLS ///< Number of load cell sensors. -} LOAD_CELL_T; - -/// Enumeration of DG reservoirs. -typedef enum DG_Reservoirs -{ - DG_RESERVOIR_1 = 0, ///< Reservoir #1. - DG_RESERVOIR_2, ///< Reservoir #2. - NUM_OF_DG_RESERVOIRS ///< Number of reservoirs. -} DG_RESERVOIR_ID_T; - /// Enumeration of DG pressure sensors. typedef enum DG_PressureSensors { @@ -141,7 +123,7 @@ U32 getDGROPumpPressureSetPt( void ); F32 getDGROPumpFlowRateMlMin( void ); U32 getDGDrainPumpRPMSetPt( void ); -F32 getLoadCellWeightInGrams( LOAD_CELL_T loadCellID ); +F32 getLoadCellWeightInGrams( LOAD_CELL_ID_T loadCellID ); F32 getReservoirWeightSmallFilter( DG_RESERVOIR_ID_T resID ); F32 getReservoirWeightLargeFilter( DG_RESERVOIR_ID_T resID ); Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -ra51419e487a62eac8bce5f5e2a6c366b11e9e11e -r5072f7dedbe4be9dd9d2bfe9a46f53c1d3f356fc --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision a51419e487a62eac8bce5f5e2a6c366b11e9e11e) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 5072f7dedbe4be9dd9d2bfe9a46f53c1d3f356fc) @@ -52,7 +52,8 @@ #define USER_CONFIRM_CHANGE_TIMEOUT_MS ( 60 * MS_PER_SECOND ) ///< Require user to confirm UF volume change within this time. #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_TIME_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the treatment time data is published on the CAN bus. +#define TREATMENT_STATE_DATA_PUB_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the treatment state data is 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 ) @@ -77,7 +78,8 @@ static U32 treatmentTimeMS; ///< Elapsed treatment time (in ms). 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 treatmentTimeBroadcastTimerCtr; ///< Treatment time data broadcast timer counter used to schedule when to transmit data. +static U32 treatmentStateBroadcastTimerCtr; ///< Treatment state 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. static BOOL alarmStopSignalled; ///< Flag indicates an alarm w/ stop property was triggered. @@ -124,8 +126,9 @@ treatmentTimeMS = 0; lastTreatmentTimeStamp = 0; - treatmentTimeBroadcastTimerCtr = 0; - treatmentParamsRangesBroadcastTimerCtr = TREATMENT_SETTINGS_RANGES_PUB_INTERVAL; // So we send ranges immediately + treatmentTimeBroadcastTimerCtr = TREATMENT_TIME_DATA_PUB_INTERVAL; // So we send time data immediately when we begin treatment mode + treatmentStateBroadcastTimerCtr = TREATMENT_STATE_DATA_PUB_INTERVAL; // So we send state data immediately when we begin treatment mode + treatmentParamsRangesBroadcastTimerCtr = TREATMENT_SETTINGS_RANGES_PUB_INTERVAL; // So we send ranges immediately when we begin treatment mode presTreatmentTimeSecs = 0; presBloodFlowRate = 0; @@ -1137,10 +1140,17 @@ elapsedTreatmentTimeInSecs = presTreatmentTimeSecs; currentTreatmentState = TREATMENT_END_STATE; } - // Broadcast treatment time and state data at interval + // Broadcast treatment time data at interval if ( ++treatmentTimeBroadcastTimerCtr >= TREATMENT_TIME_DATA_PUB_INTERVAL ) { U32 timeRemaining = presTreatmentTimeSecs - elapsedTreatmentTimeInSecs; + + broadcastTreatmentTime( presTreatmentTimeSecs, elapsedTreatmentTimeInSecs, timeRemaining ); + treatmentTimeBroadcastTimerCtr = 0; + } + // Broadcast treatment state data at interval + if ( ++treatmentStateBroadcastTimerCtr >= TREATMENT_STATE_DATA_PUB_INTERVAL ) + { DIALYSIS_STATE_T dialysisState = getDialysisState(); UF_STATE_T uFState = getUltrafiltrationState(); SALINE_BOLUS_STATE_T salineBolusInProgress = getSalineBolusState(); @@ -1149,14 +1159,11 @@ RINSEBACK_STATE_T rBState = getCurrentRinsebackState(); TREATMENT_RECIRC_STATE_T rCState = getCurrentTreatmentRecircState(); TREATMENT_END_STATE_T endState = getCurrentTreatmentEndState(); - HEPARIN_STATE_T hepState = HEPARIN_STATE_OFF; // TODO - get Heparin state when implemented - - broadcastTreatmentTime( presTreatmentTimeSecs, elapsedTreatmentTimeInSecs, timeRemaining ); broadcastTreatmentState( (U32)currentTreatmentState, (U32)uFState, (U32)salineBolusInProgress, (U32)hepState, (U32)rBState, (U32)rCState, (U32)bldPrimeState, (U32)endState, (U32)stopState ); - treatmentTimeBroadcastTimerCtr = 0; + treatmentStateBroadcastTimerCtr = 0; } } Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -ra51419e487a62eac8bce5f5e2a6c366b11e9e11e -r5072f7dedbe4be9dd9d2bfe9a46f53c1d3f356fc --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision a51419e487a62eac8bce5f5e2a6c366b11e9e11e) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 5072f7dedbe4be9dd9d2bfe9a46f53c1d3f356fc) @@ -64,6 +64,7 @@ static U32 rinsebackTimerCtr; ///< Timer counter for time spent in rinseback sub-mode. static F32 cumulativeRinsebackVolume_mL; ///< Total cumulative rinseback volume (in mL). +static F32 targetRinsebackVolumePlusAdditional_mL; ///< Target rinseback volume w/ additional volume(s) added (in mL). static F32 additionalRinsebackVolume_mL; ///< Total volume (in mL) delivered so far for additional volume request. static U32 rinsebackMotorCount; ///< The cumulative sum of BP motor encoder counts used for independent rinseback volume check. static U32 rinsebackLastMotorCount; ///< The last BP motor encoder count read for independent rinseback volume check. @@ -120,6 +121,7 @@ { rinsebackState = RINSEBACK_STOP_INIT_STATE; rinsebackRate_mL_min = getTreatmentParameterU32( TREATMENT_PARAM_RINSEBACK_FLOW_RATE ); + targetRinsebackVolumePlusAdditional_mL = TARGET_RINSEBACK_VOLUME_ML; rinsebackTimerCtr = 0; cumulativeRinsebackVolume_mL = 0.0; additionalRinsebackVolume_mL = 0.0; @@ -481,6 +483,7 @@ { rinsebackAdditionalTimerCtr = 0; additionalRinsebackVolume_mL = 0.0; + targetRinsebackVolumePlusAdditional_mL += TARGET_ADDITIONAL_RINSEBACK_VOLUME_ML; setupForRinsebackDelivery( MIN_RINSEBACK_FLOW_RATE_ML_MIN ); result = RINSEBACK_RUN_ADDITIONAL_STATE; } @@ -934,8 +937,8 @@ if ( ++rinsebackPublishTimerCtr >= RINSEBACK_DATA_PUBLISH_INTERVAL ) { RINSEBACK_DATA_PAYLOAD_T data; - U32 timeout = MAX_RINSEBACK_TIME / TASK_GENERAL_INTERVAL; - U32 countdown = ( rinsebackTimerCtr >= MAX_RINSEBACK_TIME ? 0 : ( MAX_RINSEBACK_TIME - rinsebackTimerCtr ) / TASK_GENERAL_INTERVAL ); + U32 timeout = MAX_RINSEBACK_TIME / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); + U32 countdown = ( rinsebackTimerCtr >= MAX_RINSEBACK_TIME ? 0 : ( MAX_RINSEBACK_TIME - rinsebackTimerCtr ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); rinsebackPublishTimerCtr = 0; // If we have completed rinseback, timeout is no longer in force - indicate by zeroing timeout @@ -944,8 +947,16 @@ timeout = 0; } data.targetRinsebackVolumeMl = TARGET_RINSEBACK_VOLUME_ML; + if ( RINSEBACK_RUN_ADDITIONAL_STATE == rinsebackState ) + { + data.targetRinsebackVolumeMl = targetRinsebackVolumePlusAdditional_mL; + } data.deliveredRinsebackVolumeMl = cumulativeRinsebackVolume_mL; data.rinsebackFlowRateMlMin = rinsebackRate_mL_min; + if ( RINSEBACK_RUN_ADDITIONAL_STATE == rinsebackState ) + { + data.rinsebackFlowRateMlMin = MIN_RINSEBACK_FLOW_RATE_ML_MIN; + } data.timeout = timeout; data.countdown = countdown; broadcastRinsebackData( data );