Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r934a19c673175bc12c5634326f4f1af821c1916c -r981de1f5228152ec6877aceae3d66ebf5efc7101 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 934a19c673175bc12c5634326f4f1af821c1916c) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) @@ -14,9 +14,10 @@ * @date (original) 08-Apr-2020 * ***************************************************************************/ - -#include "DialInFlow.h" + +#include "DialInFlow.h" #include "DGDefs.h" +#include "ModeInitPOST.h" #include "ModeTreatment.h" #include "OperationModes.h" #include "SystemCommMessages.h" @@ -36,8 +37,8 @@ #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. - +#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 { @@ -83,14 +84,14 @@ static F32 lgFilteredReservoirWeightInGrams[ NUM_OF_DG_RESERVOIRS ]; // Load cell filtering data -/// Holds load cell samples for small load cell moving average +/// 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 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 +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. @@ -668,6 +669,8 @@ void setNewLoadCellReadings( F32 res1Primary, F32 res1Backup, F32 res2Primary, F32 res2Backup ) { DG_RESERVOIR_ID_T res; + DG_RESERVOIR_ID_T activeRes = getDGActiveReservoir(); + BOOL inTreatment = ( MODE_TREA == getCurrentOperationMode() ? TRUE : FALSE ); loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_PRIMARY ].data = res1Primary; loadCellWeightInGrams[ LOAD_CELL_RESERVOIR_1_BACKUP ].data = res1Backup; @@ -677,8 +680,7 @@ // 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 ); - + F32 wt = ( res == DG_RESERVOIR_1 ? res1Primary : res2Primary ); smLoadCellReadingsTotal[ res ] -= smLoadCellReadings[ res ][ smLoadCellReadingsIdx ]; lgLoadCellReadingsTotal[ res ] -= lgLoadCellReadings[ res ][ lgLoadCellReadingsIdx ]; smLoadCellReadings[ res ][ smLoadCellReadingsIdx ] = wt; Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -r934a19c673175bc12c5634326f4f1af821c1916c -r981de1f5228152ec6877aceae3d66ebf5efc7101 --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 934a19c673175bc12c5634326f4f1af821c1916c) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) @@ -38,7 +38,7 @@ #else #define FILL_RESERVOIR_TO_VOLUME_ML 1300 ///< Fill reservoir to this volume (in mL) during treatment. #endif - + /// Enumeration of DG pressure sensors. typedef enum DG_PressureSensors { Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r8bcfdd2cad1ae2f66973c918153cbe40cc29099a -r981de1f5228152ec6877aceae3d66ebf5efc7101 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 8bcfdd2cad1ae2f66973c918153cbe40cc29099a) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) @@ -52,6 +52,8 @@ #define MIN_SALINE_BOLUS_VOLUME_PCT 0.8 ///< Minimum saline bolus volume measured by independent means (as % of target). #define MAX_SALINE_BOLUS_VOLUME_PCT 1.2 ///< Maximum saline bolus volume measured by independent means (as % of target). +#define MAX_ACTIVE_LOAD_CELL_CHANGE_G 50.0 ///< Maximum delta between new and previous measured UF volume. + // ********** private data ********** static DIALYSIS_STATE_T currentDialysisState; ///< Current state of the dialysis sub-mode state machine. @@ -1102,11 +1104,23 @@ { DG_RESERVOIR_ID_T activeRes = getDGActiveReservoir(); F32 latestResVolume = getReservoirWeightSmallFilter( activeRes ); +#ifndef DISABLE_UF_ALARMS + F32 deltaVolume = latestResVolume - resFinalVolume[ activeRes ]; - // Calculate UF volumes and provide to dialysate outlet pump controller - measUFVolume = measUFVolumeFromPriorReservoirs + ( latestResVolume - resStartVolume[ activeRes ] ); - resFinalVolume[ activeRes ] = latestResVolume; - setDialOutUFVolumes( refUFVolume, measUFVolume ); + // ensure volume change is not too excessive - indication that load cell was impacted by some kind of shock + if ( fabs(deltaVolume) > MAX_ACTIVE_LOAD_CELL_CHANGE_G ) + { + ALARM_ID_T deltaAlarm = ( getDGActiveReservoir() == DG_RESERVOIR_1 ? ALARM_ID_HD_LOAD_CELL_ACCELERATION_RES_1_ALARM : ALARM_ID_HD_LOAD_CELL_ACCELERATION_RES_2_ALARM ); + SET_ALARM_WITH_1_F32_DATA( deltaAlarm, deltaVolume ); + } + else +#endif + { + // Calculate UF volumes and provide to dialysate outlet pump controller + measUFVolume = measUFVolumeFromPriorReservoirs + ( latestResVolume - resStartVolume[ activeRes ] ); + resFinalVolume[ activeRes ] = latestResVolume; + setDialOutUFVolumes( refUFVolume, measUFVolume ); + } } /*********************************************************************//** Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -rc7f14267973d4c9731fa0dc42607eeea23722b13 -r981de1f5228152ec6877aceae3d66ebf5efc7101 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision c7f14267973d4c9731fa0dc42607eeea23722b13) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) @@ -275,7 +275,7 @@ * @brief * The handleSelfTestDryState function performs dry self-test. * @details Inputs: none - * @details Outputs: transition to prime sub-mode when blood pump finished homing + * @details Outputs: transition to prime state on user request * @return current state (sub-mode) *************************************************************************/ static HD_PRE_TREATMENT_MODE_STATE_T handleSelfTestDryState( void ) Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rbc8403b288e167f51c9e991c2a07bb455c77c19a -r981de1f5228152ec6877aceae3d66ebf5efc7101 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision bc8403b288e167f51c9e991c2a07bb455c77c19a) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) @@ -4034,71 +4034,4 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestHDCalibrationDataRequest function handles a request for - * HD calibration data. - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestHDCalibrationDataRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( 0 == message->hdr.payloadLen ) - { - CALIBRATION_DATA_T cal; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Get calibration data - result = getCalibrationData( &cal ); - if ( TRUE == result ) - { - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_CALIBRATION_DATA; - msg.hdr.payloadLen = sizeof( CALIBRATION_DATA_T ); - - memcpy( payloadPtr, &cal, sizeof( CALIBRATION_DATA_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - } - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleTestEraseHDCalibrationDataRequest function handles a request for - * HD calibration data erasure. - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestEraseHDCalibrationDataRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - U32 key; - - memcpy( &key, message->payload, sizeof(U32) ); - - result = testResetCalibrationData( key ); - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rbc8403b288e167f51c9e991c2a07bb455c77c19a -r981de1f5228152ec6877aceae3d66ebf5efc7101 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision bc8403b288e167f51c9e991c2a07bb455c77c19a) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) @@ -196,6 +196,9 @@ // MSG_ID_ALARM_TRIGGERED BOOL broadcastAlarmTriggered( U32 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ); +// MSG_ID_ALARM_CONDITION_CLEARED +BOOL broadcastAlarmConditionCleared( U32 alarm ); + // MSG_ID_ALARM_CLEARED BOOL broadcastAlarmCleared( U32 alarm );