Index: firmware/App/Controllers/AlarmLamp.c =================================================================== diff -u -r0b3a29a3a189b9d357d3eaa554c7baf22de30e81 -rd4a90fda6c1f463633a4e7d45424acd2d2a0bce8 --- firmware/App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision 0b3a29a3a189b9d357d3eaa554c7baf22de30e81) +++ firmware/App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision d4a90fda6c1f463633a4e7d45424acd2d2a0bce8) @@ -70,7 +70,7 @@ static BOOL alarmLampOn = FALSE; ///< Flag indicates whether an any lamp is currently on. /// Two step alarm lamp patterns (repeating). -const struct LampPatterns lampPatterns[ NUM_OF_LAMP_PATTERNS ] = { +const struct LampPatterns LAMP_PATTERNS[ NUM_OF_LAMP_PATTERNS ] = { { { 500, 500 }, { LAMP_STATE_OFF, LAMP_STATE_OFF }, { LAMP_STATE_OFF, LAMP_STATE_OFF }, { LAMP_STATE_OFF, LAMP_STATE_OFF } }, // LAMP_PATTERN_OFF { { 500, 500 }, { LAMP_STATE_ON, LAMP_STATE_ON }, { LAMP_STATE_OFF, LAMP_STATE_OFF }, { LAMP_STATE_OFF, LAMP_STATE_OFF } }, // LAMP_PATTERN_OK { { 250, 250 }, { LAMP_STATE_OFF, LAMP_STATE_OFF }, { LAMP_STATE_OFF, LAMP_STATE_OFF }, { LAMP_STATE_ON, LAMP_STATE_OFF } }, // LAMP_PATTERN_FAULT @@ -134,7 +134,7 @@ if ( getCurrentAlarmLampPattern() != LAMP_PATTERN_MANUAL ) { // if pattern step duration has elapsed, move to next step - if ( lampPatternStepTimer >= lampPatterns[ getCurrentAlarmLampPattern() ].duration[ currentLampPatternStep ] ) + if ( lampPatternStepTimer >= LAMP_PATTERNS[ getCurrentAlarmLampPattern() ].duration[ currentLampPatternStep ] ) { // increment pattern step currentLampPatternStep++; @@ -279,17 +279,17 @@ alarmLampOn = FALSE; lampPatternStepTimer = 0; - if ( lampPatterns[ getCurrentAlarmLampPattern() ].green[ currentLampPatternStep ] == LAMP_STATE_ON ) + if ( LAMP_PATTERNS[ getCurrentAlarmLampPattern() ].green[ currentLampPatternStep ] == LAMP_STATE_ON ) { green = PIN_SIGNAL_HIGH; alarmLampOn = TRUE; } - if ( lampPatterns[ getCurrentAlarmLampPattern() ].blue[ currentLampPatternStep ] == LAMP_STATE_ON ) + if ( LAMP_PATTERNS[ getCurrentAlarmLampPattern() ].blue[ currentLampPatternStep ] == LAMP_STATE_ON ) { blue = PIN_SIGNAL_HIGH; alarmLampOn = TRUE; } - if ( lampPatterns[ getCurrentAlarmLampPattern() ].red[ currentLampPatternStep ] == LAMP_STATE_ON ) + if ( LAMP_PATTERNS[ getCurrentAlarmLampPattern() ].red[ currentLampPatternStep ] == LAMP_STATE_ON ) { red = PIN_SIGNAL_HIGH; alarmLampOn = TRUE; Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -rf94085c6fbf817a07db7225d6748b5347dfb12d3 -rd4a90fda6c1f463633a4e7d45424acd2d2a0bce8 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision f94085c6fbf817a07db7225d6748b5347dfb12d3) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision d4a90fda6c1f463633a4e7d45424acd2d2a0bce8) @@ -32,7 +32,10 @@ #define START_DG_CMD TRUE ///< Parameter for DG start/stop command function. True = start. #define STOP_DG_CMD FALSE ///< Parameter for DG start/stop command function. False = stop. -#define RESERVOIR_SETTLE_TIME_MS 5000 ///< Time (in ms) allotted for reservoir to settle (after fill, before drain). +#define RESERVOIR_SETTLE_TIME_MS 5000 ///< Time (in ms) allotted for reservoir to settle (after fill, before drain). + +#define SIZE_OF_SMALL_LOAD_CELL_AVG 8 ///< Small load cell moving average has 8 samples. +#define SIZE_OF_LARGE_LOAD_CELL_AVG 32 ///< Large load cell moving average has 32 samples. /// States of the treatment reservoir management state machine. typedef enum TreatmentReservoirMgmt_States @@ -51,39 +54,56 @@ // ********** private data ********** // DG status -static DG_OP_MODE_T dgCurrentOpMode = DG_MODE_INIT; ///< Current DG operation mode. -static U32 dgSubMode = 0; ///< Current state (sub-mode) of current DG operation mode. -static BOOL dgStarted = FALSE; ///< Flag indicates whether we've commanded the DG to start or stop. -static BOOL dgTrimmerHeaterOn = FALSE; ///< Flag indicates whether we've commanded the DG to start or stop the trimmer heater. -static BOOL dgWaterSampled = FALSE; ///< Flag indicates whether we've commanded the DG to sample water. +static DG_OP_MODE_T dgCurrentOpMode = DG_MODE_INIT; ///< Current DG operation mode. +static U32 dgSubMode = 0; ///< Current state (sub-mode) of current DG operation mode. +static BOOL dgStarted = FALSE; ///< Flag indicates whether we've commanded the DG to start or stop. +static BOOL dgTrimmerHeaterOn = FALSE; ///< Flag indicates whether we've commanded the DG to start or stop the trimmer heater. +static BOOL dgWaterSampled = FALSE; ///< Flag indicates whether we've commanded the DG to sample water. -// state machine states -static TREATMENT_RESERVOIR_MGMT_STATE_T currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_START_STATE; ///< Current state of treatment mode reservoir management. -static U32 resMgmtTimer = 0; ///< used for keeping state time. +// state machine states +/// Current state of treatment mode reservoir management. +static TREATMENT_RESERVOIR_MGMT_STATE_T currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_START_STATE; +static U32 resMgmtTimer = 0; ///< used for keeping state time. -// DG sensor data -static F32 dgPressures[ NUM_OF_DG_PRESSURE_SENSORS ]; ///< Latest pressures reported by the DG. -static F32 dgDialysateTemp = 0.0; ///< Dialysate temperature reported by the DG. -static F32 dgRedundantDialysateTemp = 0.0; ///< Redundant dialysate temperature reported by the DG. -static F32 dgPrimaryTempSet = 0.0; ///< Primary heater target temperature commanded. -static F32 dgPrimaryTemp = 0.0; ///< Latest RO water temperature reported by the DG. -static F32 dgTrimmerTempSet = 0.0; ///< Trimmer heater target temperature commanded. -static F32 dgTrimmerTemp = 0.0; ///< Latest dialysate temperature reported by the DG. +// DG sensor data +static F32 dgPressures[ NUM_OF_DG_PRESSURE_SENSORS ]; ///< Latest pressures reported by the DG. +static F32 dgDialysateTemp = 0.0; ///< Dialysate temperature reported by the DG. +static F32 dgRedundantDialysateTemp = 0.0; ///< Redundant dialysate temperature reported by the DG. +static F32 dgPrimaryTempSet = 0.0; ///< Primary heater target temperature commanded. +static F32 dgPrimaryTemp = 0.0; ///< Latest RO water temperature reported by the DG. +static F32 dgTrimmerTempSet = 0.0; ///< Trimmer heater target temperature commanded. +static F32 dgTrimmerTemp = 0.0; ///< Latest dialysate temperature reported by the DG. +/// Measured weight from load cells. +static OVERRIDE_F32_T loadCellWeightInGrams[ NUM_OF_LOAD_CELLS ]; +/// Filtered (8 sample) weight of reservoirs. +static F32 smFilteredReservoirWeightInGrams[ NUM_OF_DG_RESERVOIRS ]; +/// Filtered (32 sample) weight of reservoirs. +static F32 lgFilteredReservoirWeightInGrams[ NUM_OF_DG_RESERVOIRS ]; +// load cell filtering data +/// holds load cell samples for small load cell moving average +static F32 smLoadCellReadings[ NUM_OF_DG_RESERVOIRS ][ SIZE_OF_SMALL_LOAD_CELL_AVG ]; +static U32 smLoadCellReadingsIdx = 0; ///< index for next sample in small load cell rolling average sample array +static F32 smLoadCellReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< rolling total - used to calc small load cell moving average +/// holds load cell samples for large load cell moving average +static F32 lgLoadCellReadings[ NUM_OF_DG_RESERVOIRS ][ SIZE_OF_LARGE_LOAD_CELL_AVG ]; +static U32 lgLoadCellReadingsIdx = 0; ///< index for next sample in large load cell rolling average sample array +static F32 lgLoadCellReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< rolling total - used to calc large load cell moving average + // DG pumps data -static F32 dgROPumpFlowRateMlMin = 0.0; ///< Latest RO water flow rate reported by the DG. -static U32 dgROPumpPressureSetPtPSI = 0; ///< Latest RO pump target pressure reported by the DG. -static U32 dgDrainPumpSpeedSetPtRPM = 0; ///< Latest Drain pump target speed reported by the DG. +static F32 dgROPumpFlowRateMlMin = 0.0; ///< Latest RO water flow rate reported by the DG. +static U32 dgROPumpPressureSetPtPSI = 0; ///< Latest RO pump target pressure reported by the DG. +static U32 dgDrainPumpSpeedSetPtRPM = 0; ///< Latest Drain pump target speed reported by the DG. // reservoir data -static DG_RESERVOIR_ID_T dgActiveReservoir = DG_RESERVOIR_2; ///< Latest active reservoir reported by the DG. -static DG_RESERVOIR_ID_T dgActiveReservoirSet = DG_RESERVOIR_2; ///< Active reservoir commanded. -static U32 dgReservoirFillVolumeTarget = 0; ///< Latest fill-to volume reported by the DG. -static U32 dgReservoirFillVolumeTargetSet = 0; ///< Fill-to volume commanded. -static U32 dgReservoirDrainVolumeTarget = 0; ///< Latest drain-to volume reported by the DG. -static U32 dgReservoirDrainVolumeTargetSet = 0; ///< Drain-to volume commanded. -static U32 resUseTimer = 0; ///< used to track time pumping from active reservoir (for volume used calculation). -static F32 resUseVolumeMl = 0.0; ///< Accumulated volume used from active reservoir. +static DG_RESERVOIR_ID_T dgActiveReservoir = DG_RESERVOIR_2; ///< Latest active reservoir reported by the DG. +static DG_RESERVOIR_ID_T dgActiveReservoirSet = DG_RESERVOIR_2; ///< Active reservoir commanded. +static U32 dgReservoirFillVolumeTarget = 0; ///< Latest fill-to volume reported by the DG. +static U32 dgReservoirFillVolumeTargetSet = 0; ///< Fill-to volume commanded. +static U32 dgReservoirDrainVolumeTarget = 0; ///< Latest drain-to volume reported by the DG. +static U32 dgReservoirDrainVolumeTargetSet = 0; ///< Drain-to volume commanded. +static U32 resUseTimer = 0; ///< used to track time pumping from active reservoir (for volume used calculation). +static F32 resUseVolumeMl = 0.0; ///< Accumulated volume used from active reservoir. // ********** private function prototypes ********** @@ -97,6 +117,8 @@ *************************************************************************/ void initDGInterface( void ) { + U32 i, j; + dgStarted = FALSE; dgTrimmerHeaterOn = FALSE; dgWaterSampled = FALSE; @@ -105,8 +127,50 @@ dgActiveReservoirSet = DG_RESERVOIR_2; dgReservoirFillVolumeTargetSet = 0; dgReservoirDrainVolumeTargetSet = 0; -} + + // initialize load cell weights + for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) + { + loadCellWeightInGrams[ i ].data = 0.0; + loadCellWeightInGrams[ i ].ovInitData = 0.0; + loadCellWeightInGrams[ i ].ovData = 0.0; + loadCellWeightInGrams[ i ].override = 0; + } + // initialize reservoirs weights + for ( i = 0; i < NUM_OF_DG_RESERVOIRS; i++ ) + { + smFilteredReservoirWeightInGrams[ i ] = 0.0; + lgFilteredReservoirWeightInGrams[ i ] = 0.0; + for ( j = 0; j < SIZE_OF_SMALL_LOAD_CELL_AVG; j++ ) + { + smLoadCellReadings[ i ][ j ] = 0.0; + } + for ( j = 0; j < SIZE_OF_LARGE_LOAD_CELL_AVG; j++ ) + { + lgLoadCellReadings[ i ][ j ] = 0.0; + } + } + smLoadCellReadingsIdx = 0; + smLoadCellReadingsTotal[ DG_RESERVOIR_1 ] = 0.0; + smLoadCellReadingsTotal[ DG_RESERVOIR_2 ] = 0.0; + lgLoadCellReadingsIdx = 0; + lgLoadCellReadingsTotal[ DG_RESERVOIR_1 ] = 0.0; + lgLoadCellReadingsTotal[ DG_RESERVOIR_2 ] = 0.0; +} +/*********************************************************************//** + * @brief + * The execDGInterfaceMonitor function executes the DG Interface monitoring + * function. Ensures DG is sending fresh data in a timely manner. + * @details Inputs: TBD + * @details Outputs: TBD + * @return none + *************************************************************************/ +void execDGInterfaceMonitor( void ) +{ + // TODO - make sure DG sensor/state data is coming in timely manner (e.g. load cells s/b every 100 ms) +} + /*********************************************************************//** * @brief * The initTreatmentReservoirMgmt function initializes the treatment reservoir @@ -287,6 +351,20 @@ DG_RESERVOIR_ID_T getDGActiveReservoir( void ) { return dgActiveReservoirSet; +} + +/*********************************************************************//** + * @brief + * The getDGInactiveReservoir function gets the currently inactive reservoir. + * @details Inputs: dgActiveReservoirSet + * @details Outputs: none + * @return Currently commanded inactive reservoir. + *************************************************************************/ +DG_RESERVOIR_ID_T getDGInactiveReservoir( void ) +{ + DG_RESERVOIR_ID_T inactiveRes = ( DG_RESERVOIR_2 == dgActiveReservoirSet ? DG_RESERVOIR_1 : DG_RESERVOIR_2 ); + + return inactiveRes; } /*********************************************************************//** @@ -359,6 +437,79 @@ return result; } +/*********************************************************************//** + * @brief + * The getLoadCellWeightInGrams function gets the load cell weight. + * @details Inputs: loadCellWeightInGrams + * @details Outputs: none + * @param loadCellID ID of load cell to get + * @return the current load cell weight in grams + *************************************************************************/ +F32 getLoadCellWeightInGrams( LOAD_CELL_T loadCellID ) +{ + F32 result = 0.0; + + if ( loadCellID < NUM_OF_LOAD_CELLS ) + { + if ( OVERRIDE_KEY == loadCellWeightInGrams[ loadCellID ].override ) + { + result = loadCellWeightInGrams[ loadCellID ].ovData; + } + else + { + result = loadCellWeightInGrams[ loadCellID ].data; + } + } + else + { + activateAlarmNoData( ALARM_ID_HD_SOFTWARE_FAULT ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getReservoirWeightSmallFilter function gets the load cell weight + * of the given reservoir after large (8 sample) filter applied. + * @details Inputs: lgFilteredReservoirWeightInGrams[] + * @details Outputs: none + * @param resID ID of reservoir to get filtered weight for + * @return the current filtered weight of the given reservoir in grams + *************************************************************************/ +F32 getReservoirWeightSmallFilter( DG_RESERVOIR_ID_T resID ) +{ + F32 result = 0.0; + + if ( resID < NUM_OF_DG_RESERVOIRS ) + { + result = smFilteredReservoirWeightInGrams[ resID ]; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getReservoirWeightLargeFilter function gets the load cell weight + * of the given reservoir after large (32 sample) filter applied. + * @details Inputs: lgFilteredReservoirWeightInGrams[] + * @details Outputs: none + * @param resID ID of reservoir to get filtered weight for + * @return the current filtered weight of the given reservoir in grams + *************************************************************************/ +F32 getReservoirWeightLargeFilter( DG_RESERVOIR_ID_T resID ) +{ + F32 result = 0.0; + + if ( resID < NUM_OF_DG_RESERVOIRS ) + { + result = lgFilteredReservoirWeightInGrams[ resID ]; + } + + return result; +} + /*********************************************************************//** * @brief * The setDGOpMode function sets the latest DG operating mode reported by @@ -486,6 +637,47 @@ dgDrainPumpSpeedSetPtRPM = rpmSetPt; } +/*********************************************************************//** + * @brief + * The setNewLoadCellReadings function sets the latest DG reservoir load cell + * readings sent by the DG (in g or mL). New readings are expected once + * every 100 ms. + * @details Inputs: none + * @details Outputs: loadCellWeightInGrams[], smFilteredReservoirWeightInGrams[], + * lgFilteredReservoirWeightInGrams[] + * @param res1Primary New weight from primary load cell of reservoir 1 + * @param res1Backup New weight from backup load cell of reservoir 1 + * @param res2Primary New weight from primary load cell of reservoir 2 + * @param res2Backup New weight from backup load cell of reservoir 2 + * @return none + *************************************************************************/ +void setNewLoadCellReadings( F32 res1Primary, F32 res1Backup, F32 res2Primary, F32 res2Backup ) +{ + DG_RESERVOIR_ID_T res; + + loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_PRIMARY ].data = res1Primary; + loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_BACKUP ].data = res1Backup; + loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_2_PRIMARY ].data = res2Primary; + loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_2_BACKUP ].data = res2Backup; + + // feed new weight samples into filters and update moving averages + for ( res = DG_RESERVOIR_1; res < NUM_OF_DG_RESERVOIRS; res++ ) + { + F32 wt = ( res == DG_RESERVOIR_1 ? res1Primary : res2Primary ); + + smLoadCellReadingsTotal[ res ] -= smLoadCellReadings[ res ][ smLoadCellReadingsIdx ]; + lgLoadCellReadingsTotal[ res ] -= lgLoadCellReadings[ res ][ lgLoadCellReadingsIdx ]; + smLoadCellReadings[ res ][ smLoadCellReadingsIdx ] = wt; + lgLoadCellReadings[ res ][ lgLoadCellReadingsIdx ] = wt; + smLoadCellReadingsTotal[ res ] += wt; + lgLoadCellReadingsTotal[ res ] += wt; + smFilteredReservoirWeightInGrams[ res ] = smLoadCellReadingsTotal[ res ] / (F32)SIZE_OF_SMALL_LOAD_CELL_AVG; + lgFilteredReservoirWeightInGrams[ res ] = lgLoadCellReadingsTotal[ res ] / (F32)SIZE_OF_LARGE_LOAD_CELL_AVG; + } + smLoadCellReadingsIdx = INC_WRAP( smLoadCellReadingsIdx, 0, SIZE_OF_SMALL_LOAD_CELL_AVG - 1 ); + lgLoadCellReadingsIdx = INC_WRAP( lgLoadCellReadingsIdx, 0, SIZE_OF_LARGE_LOAD_CELL_AVG - 1 ); +} + /*********************************************************************//** * @brief * The cmdSetDGDialysateTargetTemps function sends a target dialysate @@ -626,5 +818,64 @@ dgWaterSampled = TRUE; sendDGSampleWaterCommand(); } - + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetDialOutLoadCellWeightOverride function overrides the value of the + * load cell sensor with a given weight (in grams). + * @details Inputs: loadCellWeightInGrams[] + * @details Outputs: loadCellWeightInGrams[] + * @param sensor ID of load cell sensor to override weight for + * @param value override weight (in grams) for the given sensor + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetDialOutLoadCellWeightOverride( U32 sensor, F32 value ) +{ + BOOL result = FALSE; + + if ( sensor < NUM_OF_LOAD_CELLS ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + loadCellWeightInGrams[ sensor ].ovData = value; + loadCellWeightInGrams[ sensor ].override = OVERRIDE_KEY; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetDialOutLoadCellWeightOverride function resets the override of the + * load cell sensor. + * @details Inputs: loadCellWeightInGrams[] + * @details Outputs: loadCellWeightInGrams[] + * @param sensor ID of load cell sensor to override weight for + * @return TRUE if reset successful, FALSE if not + *************************************************************************/ +BOOL testResetDialOutLoadCellWeightOverride( U32 sensor ) +{ + BOOL result = FALSE; + + if ( sensor < NUM_OF_LOAD_CELLS ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + loadCellWeightInGrams[ sensor ].override = OVERRIDE_RESET; + loadCellWeightInGrams[ sensor ].ovData = loadCellWeightInGrams[ sensor ].ovInitData; + } + } + + return result; +} + /**@}*/ Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -raeb1dea9ea10fcc70ae66023a87b565f29924c07 -rd4a90fda6c1f463633a4e7d45424acd2d2a0bce8 --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision aeb1dea9ea10fcc70ae66023a87b565f29924c07) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision d4a90fda6c1f463633a4e7d45424acd2d2a0bce8) @@ -116,6 +116,13 @@ F32 HtrTrimInternal; } DG_TEMPERATURES_T; +/// Payload record structure for a drain reservoir command message. +typedef struct +{ + U32 drainToVolumeML; + BOOL tareLoadCells; +} DRAIN_RESERVOIR_CMD_PAYLOAD_T; + // ********** public function prototypes ********** void initDGInterface( void ); @@ -151,7 +158,7 @@ void cmdStopDG( void ); void cmdSetDGActiveReservoir( DG_RESERVOIR_ID_T resID ); void cmdStartDGFill( U32 fillToVolMl ); -void cmdStartDGDrain( U32 drainToVolMl ); +void cmdStartDGDrain( U32 drainToVolMl, BOOL tareLoadCell ); void cmdStartDGTrimmerHeater( void ); void cmdStopDGTrimmerHeater( void ); void cmdDGSampleWater( void ); Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r0b3a29a3a189b9d357d3eaa554c7baf22de30e81 -rd4a90fda6c1f463633a4e7d45424acd2d2a0bce8 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 0b3a29a3a189b9d357d3eaa554c7baf22de30e81) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision d4a90fda6c1f463633a4e7d45424acd2d2a0bce8) @@ -137,7 +137,6 @@ static PUMP_CONTROL_MODE_T dialOutPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Requested control mode for dialysate outlet pump (open or closed loop). static PUMP_CONTROL_MODE_T dialOutPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Currently set control mode for dialysate outlet pump. -static OVERRIDE_F32_T loadCellWeightInGrams[ NUM_OF_LOAD_CELLS ]; ///< Measured weight from load cells. static OVERRIDE_U32_T dialOutDataPublishInterval = { DIAL_OUT_DATA_PUB_INTERVAL, DIAL_OUT_DATA_PUB_INTERVAL, DIAL_OUT_DATA_PUB_INTERVAL, 0 }; ///< Interval (in ms) at which to publish dialysate outlet data to CAN bus. static OVERRIDE_F32_T referenceUFVolumeInMl = { 0.0, 0.0, 0.0, 0 }; ///< Target ultrafiltration volume (in mL). static OVERRIDE_F32_T totalMeasuredUFVolumeInMl = { 0.0, 0.0, 0.0, 0 }; ///< Total measured ultrafiltration volume (in mL). @@ -208,12 +207,6 @@ dopLastMotorHallSensorCounts[ i ] = 0; } - // initialize load cell weights - for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) - { - loadCellWeightInGrams[ i ].data = 0.0; - } - // initialize dialysate outlet flow PI controller initializePIController( PI_CONTROLLER_ID_ULTRAFILTRATION, MIN_DIAL_OUT_PUMP_PWM_DUTY_CYCLE, DOP_P_COEFFICIENT, DOP_I_COEFFICIENT, @@ -388,30 +381,6 @@ /*********************************************************************//** * @brief - * The setDialOutUFVolumes function sets the ultrafiltration reference and - * measured total volumes (in mL). - * @details Inputs: none - * @details Outputs: loadCellWeightInGrams[] - * @param res1Primary New weight from primary load cell of reservoir 1 - * @param res1Backup New weight from backup load cell of reservoir 1 - * @param res2Primary New weight from primary load cell of reservoir 2 - * @param res2Backup New weight from backup load cell of reservoir 2 - * @return TRUE if successful, FALSE if not - *************************************************************************/ -BOOL setNewLoadCellReadings( F32 res1Primary, F32 res1Backup, F32 res2Primary, F32 res2Backup ) -{ - BOOL result = TRUE; - - loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_PRIMARY ].data = res1Primary; - loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_BACKUP ].data = res1Backup; - loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_2_PRIMARY ].data = res2Primary; - loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_2_BACKUP ].data = res2Backup; - - return result; -} - -/*********************************************************************//** - * @brief * The execDialOutFlowMonitor function executes the dialysate outlet pump * and load cell sensor monitor. Checks are performed. Data is published * at appropriate interval. @@ -1015,37 +984,6 @@ /*********************************************************************//** * @brief - * The getLoadCellWeightInGrams function gets the load cell weight. - * @details Inputs: loadCellWeightInGrams - * @details Outputs: none - * @param loadCellID ID of load cell to get - * @return the current load cell weight in grams - *************************************************************************/ -F32 getLoadCellWeightInGrams( U32 loadCellID ) -{ - F32 result = 0.0; - - if ( loadCellID < NUM_OF_LOAD_CELLS ) - { - if ( OVERRIDE_KEY == loadCellWeightInGrams[ loadCellID ].override ) - { - result = loadCellWeightInGrams[ loadCellID ].ovData; - } - else - { - result = loadCellWeightInGrams[ loadCellID ].data; - } - } - else - { - activateAlarmNoData( ALARM_ID_HD_SOFTWARE_FAULT ); - } - - return result; -} - -/*********************************************************************//** - * @brief * The getTotalTargetDialOutUFVolumeInMl function gets the target UF volume. * @details Inputs: referenceUFVolumeInMl * @details Outputs: none @@ -1520,57 +1458,4 @@ return result; } -/*********************************************************************//** - * @brief - * The testSetDialOutLoadCellWeightOverride function overrides the value of the - * load cell sensor with a given weight (in grams). - * @details Inputs: loadCellWeightInGrams[] - * @details Outputs: loadCellWeightInGrams[] - * @param sensor ID of load cell sensor to override weight for - * @param value override weight (in grams) for the given sensor - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testSetDialOutLoadCellWeightOverride( U32 sensor, F32 value ) -{ - BOOL result = FALSE; - - if ( sensor < NUM_OF_LOAD_CELLS ) - { - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - loadCellWeightInGrams[ sensor ].ovData = value; - loadCellWeightInGrams[ sensor ].override = OVERRIDE_KEY; - } - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetDialOutLoadCellWeightOverride function resets the override of the - * load cell sensor. - * @details Inputs: loadCellWeightInGrams[] - * @details Outputs: loadCellWeightInGrams[] - * @param sensor ID of load cell sensor to override weight for - * @return TRUE if reset successful, FALSE if not - *************************************************************************/ -BOOL testResetDialOutLoadCellWeightOverride( U32 sensor ) -{ - BOOL result = FALSE; - - if ( sensor < NUM_OF_LOAD_CELLS ) - { - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - loadCellWeightInGrams[ sensor ].override = OVERRIDE_RESET; - loadCellWeightInGrams[ sensor ].ovData = loadCellWeightInGrams[ sensor ].ovInitData; - } - } - - return result; -} - /**@}*/ Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r0b3a29a3a189b9d357d3eaa554c7baf22de30e81 -rd4a90fda6c1f463633a4e7d45424acd2d2a0bce8 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 0b3a29a3a189b9d357d3eaa554c7baf22de30e81) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision d4a90fda6c1f463633a4e7d45424acd2d2a0bce8) @@ -197,16 +197,16 @@ static OVERRIDE_U32_T valvesPositionOverride[ NUM_OF_VALVES ] = { VALVE_POSITION_C_CLOSE, VALVE_POSITION_C_CLOSE, 0, 0 }; ///< Valves position override -static const U16 valvesControlModesSetBits[ NUM_OF_VALVES ][ NUM_OF_VALVE_CONTROL_MODES ] = - { { VDI_SET_PID_BIT_MASK, VDI_SET_BYPASS_BIT_MASK, VDI_RESET_CONTROL_BIT_MASK }, - { VDO_SET_PID_BIT_MASK, VDO_SET_BYPASS_BIT_MASK, VDO_RESET_CONTROL_BIT_MASK }, - { VBA_SET_PID_BIT_MASK, VBA_SET_BYPASS_BIT_MASK, VBA_RESET_CONTROL_BIT_MASK }, - { VBV_SET_PID_BIT_MASK, VBV_SET_BYPASS_BIT_MASK, VBV_RESET_CONTROL_BIT_MASK } }; ///< Valves control mode set bits +static const U16 VALVE_CONTROL_MODES_SET_BITS[ NUM_OF_VALVES ][ NUM_OF_VALVE_CONTROL_MODES ] = + { { VDI_SET_PID_BIT_MASK, VDI_SET_BYPASS_BIT_MASK, VDI_RESET_CONTROL_BIT_MASK }, + { VDO_SET_PID_BIT_MASK, VDO_SET_BYPASS_BIT_MASK, VDO_RESET_CONTROL_BIT_MASK }, + { VBA_SET_PID_BIT_MASK, VBA_SET_BYPASS_BIT_MASK, VBA_RESET_CONTROL_BIT_MASK }, + { VBV_SET_PID_BIT_MASK, VBV_SET_BYPASS_BIT_MASK, VBV_RESET_CONTROL_BIT_MASK } }; ///< Valves control mode set bits -static const U16 valvesControlModesResetBits[ NUM_OF_VALVES ] = { VDI_RESET_CONTROL_BIT_MASK, VDO_RESET_CONTROL_BIT_MASK, - VBA_RESET_CONTROL_BIT_MASK, VBV_RESET_CONTROL_BIT_MASK }; ///< Valves control modes rest bits +static const U16 VALVE_CONTROL_MODES_RESET_BITS[ NUM_OF_VALVES ] = { VDI_RESET_CONTROL_BIT_MASK, VDO_RESET_CONTROL_BIT_MASK, + VBA_RESET_CONTROL_BIT_MASK, VBV_RESET_CONTROL_BIT_MASK }; ///< Valves control modes rest bits -static const U16 valvesControlStatusBits[ NUM_OF_VALVES ][ NUM_OF_VALVE_CONTROL_STATUS ] = +static const U16 VALVE_CONTROL_STATUS_BITS[ NUM_OF_VALVES ][ NUM_OF_VALVE_CONTROL_STATUS ] = { { VDI_INIT_STATUS_BIT_MASK, VDI_ENABLE_PID_STATUS_BIT_MASK, VDI_ENABLE_BYPASS_STATUS_BIT_MASK, VDI_RESET_CONTROL_BIT_MASK }, { VDO_INIT_STATUS_BIT_MASK, VDO_ENABLE_PID_STATUS_BIT_MASK, VDO_ENABLE_BYPASS_STATUS_BIT_MASK, VDO_RESET_CONTROL_BIT_MASK }, { VBA_INIT_STATUS_BIT_MASK, VBA_ENABLE_PID_STATUS_BIT_MASK, VBA_ENABLE_BYPASS_STATUS_BIT_MASK, VBA_RESET_CONTROL_BIT_MASK }, @@ -895,8 +895,8 @@ static void setValveControlMode( VALVE_T valve, VALVE_MODE_T mode ) { // Get the set and reset bits for the particular valve - U16 control = valvesControlModesSetBits[ valve ][ mode ]; - U16 reset = valvesControlModesResetBits[ valve ]; + U16 control = VALVE_CONTROL_MODES_SET_BITS[ valve ][ mode ]; + U16 reset = VALVE_CONTROL_MODES_RESET_BITS[ valve ]; // Reset the control bits of the particular valve valvesControlSetBits &= reset; @@ -963,28 +963,28 @@ // Depending on the control mode of the valve, different bit masks will be checked if ( mode == VALVE_CONTROL_MODE_ENABLE_PID ) { - if ( ! ( status & valvesControlStatusBits[ valve ][ VALVE_CONTROL_STATUS_INITIALIZED ] ) ) + if ( ! ( status & VALVE_CONTROL_STATUS_BITS[ valve ][ VALVE_CONTROL_STATUS_INITIALIZED ] ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_NOT_FUNCTIONAL, (U32)valve, (U32)mode ); result = FALSE; } - if ( ! ( status & valvesControlStatusBits[ valve ][ VALVE_CONTROL_STATUS_PID_ENABLED ] ) ) + if ( ! ( status & VALVE_CONTROL_STATUS_BITS[ valve ][ VALVE_CONTROL_STATUS_PID_ENABLED ] ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_NOT_FUNCTIONAL, (U32)valve, (U32)mode ); result = FALSE; } } else if ( mode == VALVE_CONTORL_MODE_ENABLE_BYPASS ) { - if ( ! ( status & valvesControlStatusBits[ valve ][ VALVE_CONTROL_STATUS_BYPASS_ENABLED ] ) ) + if ( ! ( status & VALVE_CONTROL_STATUS_BITS[ valve ][ VALVE_CONTROL_STATUS_BYPASS_ENABLED ] ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_NOT_FUNCTIONAL, (U32)valve, (U32)mode ); result = FALSE; } } else if ( mode == VALVE_CONTROL_MODE_DISABLE_ALL ) { - if ( ! ( status & ( ~valvesControlStatusBits[ valve ][ VALVE_CONTROL_STATUS_DISABLED ] ) ) ) + if ( ! ( status & ( ~VALVE_CONTROL_STATUS_BITS[ valve ][ VALVE_CONTROL_STATUS_DISABLED ] ) ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_NOT_FUNCTIONAL, (U32)valve, (U32)mode ); result = FALSE; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rf94085c6fbf817a07db7225d6748b5347dfb12d3 -rd4a90fda6c1f463633a4e7d45424acd2d2a0bce8 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision f94085c6fbf817a07db7225d6748b5347dfb12d3) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision d4a90fda6c1f463633a4e7d45424acd2d2a0bce8) @@ -1919,10 +1919,6 @@ setDGOpMode( mode, subMode ); checkInFromDG(); // TODO - here until we implement DG check-in w/ HD broadcast } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, FALSE ); - } } /*********************************************************************//** @@ -2276,38 +2272,6 @@ /*********************************************************************//** * @brief - * The handleTestAlarmStatusBroadcastIntervalOverrideRequest function handles a request to - * override the broadcast interval for alarm status. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestAlarmStatusBroadcastIntervalOverrideRequest( MESSAGE_T *message ) -{ - TEST_OVERRIDE_PAYLOAD_T payload; - BOOL result = FALSE; - - // verify payload length - if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) - { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); - if ( FALSE == payload.reset ) - { - result = testSetAlarmStatusPublishIntervalOverride( payload.state.u32 ); - } - else - { - result = testResetAlarmStatusPublishIntervalOverride(); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief * The handleTestBloodFlowSetPointOverrideRequest function handles a request to * override the set point for the blood flow rate (mL/min). * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rf94085c6fbf817a07db7225d6748b5347dfb12d3 -rd4a90fda6c1f463633a4e7d45424acd2d2a0bce8 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision f94085c6fbf817a07db7225d6748b5347dfb12d3) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision d4a90fda6c1f463633a4e7d45424acd2d2a0bce8) @@ -259,9 +259,6 @@ // MSG_ID_ALARM_TIME_OVERRIDE void handleTestAlarmTimeOverrideRequest( MESSAGE_T *message ); -// MSG_ID_ALARM_STATUS_SEND_INTERVAL_OVERRIDE -void handleTestAlarmStatusBroadcastIntervalOverrideRequest( MESSAGE_T *message ); - // MSG_ID_BLOOD_FLOW_SET_PT_OVERRIDE void handleTestBloodFlowSetPointOverrideRequest( MESSAGE_T *message );