Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -re8f30ca933a7c373c1a4a749ad84adb2f63b7722 -rc14a0220256e92a6339a444a3e1bc85e159ccce3 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision e8f30ca933a7c373c1a4a749ad84adb2f63b7722) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision c14a0220256e92a6339a444a3e1bc85e159ccce3) @@ -36,7 +36,6 @@ #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. @@ -79,16 +78,10 @@ /// 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. @@ -146,12 +139,7 @@ // 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; @@ -166,9 +154,6 @@ dgCmdResp[ i ].rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; } - 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; @@ -235,7 +220,7 @@ // Calculate volume used from active reservoir - do not accumulate if saline bolus in progress if ( SALINE_BOLUS_STATE_IN_PROGRESS != getSalineBolusState() ) { - resUseVolumeMl += ( flowRateMlPerMs * msSinceLastVolumeCalc ); // TODO - should this calc be done and kept by Dialysis sub-mode? + resUseVolumeMl += ( flowRateMlPerMs * msSinceLastVolumeCalc ); } resUseTimer = getMSTimerCount(); @@ -395,6 +380,19 @@ return inactiveRes; } + +/*********************************************************************//** + * @brief + * The hasDGCompletedReservoirSwitch function checks if DG has completed a + * switch reservoir command. + * @details Inputs: dgActiveReservoir, dgActiveReservoirSet + * @details Outputs: none + * @return TRUE if reported active reservoir is the same as set id, otherwise FALSE + *************************************************************************/ +BOOL hasDGCompletedReservoirSwitch( void ) +{ + return ( dgActiveReservoir == dgActiveReservoirSet ); +} /*********************************************************************//** * @brief @@ -468,13 +466,13 @@ /*********************************************************************//** * @brief - * The getLoadCellWeightInGrams function gets the load cell weight. + * The getLoadCellWeight function gets the current 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_ID_T loadCellID ) +F32 getLoadCellWeight( LOAD_CELL_ID_T loadCellID ) { F32 result = 0.0; @@ -499,27 +497,6 @@ /*********************************************************************//** * @brief - * The getReservoirWeightSmallFilter function gets the load cell weight - * of the given reservoir after small (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[] @@ -558,7 +535,7 @@ } else { - // TODO + // TODO - s/w fault } } @@ -615,7 +592,7 @@ } else { - // TODO + // TODO - s/w fault } } @@ -695,16 +672,11 @@ 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 ); }