Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -ra56db4650fe5652d633e0c51b29da32d5d708608 -rfef80429278a165c2f512cb78606bd7b39f4a464 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision a56db4650fe5652d633e0c51b29da32d5d708608) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision fef80429278a165c2f512cb78606bd7b39f4a464) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include // Used for fabs() and pow() functions +#include // Used for fabs() functions #include "can.h" #include "etpwm.h" Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -ra56db4650fe5652d633e0c51b29da32d5d708608 -rfef80429278a165c2f512cb78606bd7b39f4a464 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision a56db4650fe5652d633e0c51b29da32d5d708608) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision fef80429278a165c2f512cb78606bd7b39f4a464) @@ -99,11 +99,6 @@ static DG_RESERVOIR_ID_T dgActiveReservoir; ///< Latest active reservoir reported by the DG. static DG_RESERVOIR_ID_T dgActiveReservoirSet; ///< 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 DG_DISINFECT_UI_STATES_T disinfectsStatus; ///< DG disinfects status. static DG_MIXING_RATIOS_T dgMixingRatios; ///< DG mixing ratios. static HEATERS_DATA_T dgHeatersData; ///< DG heaters data. @@ -136,8 +131,6 @@ dgTrimmerTempCheckTimerCtr = 0; dgActiveReservoirSet = DG_RESERVOIR_1; dgActiveReservoir = DG_RESERVOIR_1; - dgReservoirFillVolumeTargetSet = 0; - dgReservoirDrainVolumeTargetSet = 0; dgDialysateTemp = 0.0F; dgCurrentOpMode = DG_MODE_INIT; dgSubMode = 0; @@ -466,18 +459,31 @@ /*********************************************************************//** * @brief - * The getDialysateTemperature function gets the latest dialysate temperature. - * @details Inputs: dgDialysateTemp + * The getDGDisinfectsStates function returns the DG disinfects readings. + * @details Inputs: none * @details Outputs: none - * @return the current dialysate temperature + * @return the current DG disinfects readings *************************************************************************/ -F32 getDialysateTemperature( void ) +DG_DISINFECT_UI_STATES_T getDGDisinfectsStates( void ) { - return dgDialysateTemp; + return disinfectsStatus; } /*********************************************************************//** * @brief + * The getRedundantDialysateTemperature function gets the latest redundant + * dialysate temperature. + * @details Inputs: dgRedundantDialysateTemp + * @details Outputs: none + * @return the latest redundant dialysate temperature + *************************************************************************/ +F32 getRedundantDialysateTemperature( void ) +{ + return dgRedundantDialysateTemp; +} + +/*********************************************************************//** + * @brief * The getHeatDisinfectTemperatureSensorValue function gets the latest * heat disinfect temperature sensor value. * @details Inputs: dgDialysateTemp @@ -504,21 +510,21 @@ /*********************************************************************//** * @brief - * The getDGDisinfectsStates function returns the DG disinfects readings. - * @details Inputs: none + * The getDialysateTemperature function returns the DG dialysate temperature. + * @details Inputs: dgDialysateTemp * @details Outputs: none - * @return the current DG disinfects readings + * @return the latest dialysate temperature *************************************************************************/ -DG_DISINFECT_UI_STATES_T getDGDisinfectsStates( void ) +F32 getDialysateTemperature( void ) { - return disinfectsStatus; + return dgDialysateTemp; } /*********************************************************************//** * @brief * The getDGMixingRatios function returns the DG mixing ratios and the fill * prep time. - * @details Inputs: none + * @details Inputs: dgMixingRatios * @details Outputs: none * @return getDGMixingRatios which is the DG mixing ratios *************************************************************************/ @@ -598,8 +604,7 @@ * The setDGReservoirsData function sets the latest reservoir data * reported by the DG. * @details Inputs: none - * @details Outputs: dgActiveReservoir, dgReservoirFillVolumeTarget, - * dgReservoirDrainVolumeTarget, dgReservoirsDataFreshFlag + * @details Outputs: dgActiveReservoir, dgReservoirsDataFreshFlag * @param resID ID of active reservoir * @param fillVol Reservoir fill to volume reported by DG * @param drainVol Reservoir drain to volume reported by DG @@ -610,8 +615,6 @@ if ( resID < NUM_OF_DG_RESERVOIRS ) { dgActiveReservoir = resID; - dgReservoirFillVolumeTarget = fillVol; - dgReservoirDrainVolumeTarget = drainVol; } else { @@ -909,7 +912,6 @@ void cmdStartDGFill( U32 fillToVolMl, F32 targetFlowLPM ) { dgCmdResp[ DG_CMD_START_FILL ].commandID = DG_CMD_NONE; - dgReservoirFillVolumeTargetSet = fillToVolMl; sendDGFillCommand( DG_CMD_START, fillToVolMl, targetFlowLPM ); } @@ -924,7 +926,6 @@ void cmdStopDGFill( void ) { dgCmdResp[ DG_CMD_STOP_FILL ].commandID = DG_CMD_NONE; - dgReservoirFillVolumeTargetSet = 0; sendDGFillCommand( DG_CMD_STOP, 0, 0 ); } @@ -948,7 +949,6 @@ payload.tareLoadCells = tareLoadCell; payload.rinseConcentrateLines = rinse; payload.cmd = start; - dgReservoirDrainVolumeTargetSet = drainToVolMl; sendDGDrainCommand( &payload ); } Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r7b74c2bf11c26a510aee4a6045fc0bed6a456401 -rfef80429278a165c2f512cb78606bd7b39f4a464 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 7b74c2bf11c26a510aee4a6045fc0bed6a456401) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision fef80429278a165c2f512cb78606bd7b39f4a464) @@ -14,8 +14,9 @@ * @date (original) 04-Mar-2021 * ***************************************************************************/ -#include +#include // Used for fabs() functions + #include "AlarmMgmt.h" #include "FPGA.h" #include "ModeTreatmentParams.h" @@ -163,10 +164,12 @@ #define SYRINGE_PUMP_STALL_SPEED_THRESHOLD 0.05F ///< Minimum syringe pump speed to be considered not stalled. #define SYRINGE_PUMP_ADC_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Syringe pump ADC FPGA error timeout in milliseconds. + #define SYRINGE_PUMP_DAC_MAX_RETRIES 5 ///< Syringe pump DAC retries to write. #define SYRINGE_PUMP_DAC_TIMER ( 200 / TASK_PRIORITY_INTERVAL ) ///< Syringe pump DAC timer between retries. #define SYRINGE_PUMP_OCCLUSION_PERSISTENCE 50 ///< Syringe pump occlusion persistence timer in milliseconds. #define SYRINGE_PUMP_EMPTY_FORCE_COUNT 5 ///< Syringe pump empty force voltage count persistence. + /// Defined states for the syringe pump control state machine. typedef enum SyringePump_States { @@ -342,6 +345,7 @@ initPersistentAlarm( ALARM_ID_HD_SYRINGE_PUMP_CONTROLLER_DIRECTION_ERROR, 0, SYRINGE_PUMP_DIR_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_SYRINGE_PUMP_RUNNING_WHILE_BP_OFF_ERROR, 0, SYRINGE_PUMP_OFF_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_SYRINGE_PUMP_SPEED_ERROR, 0, SYRINGE_PUMP_RATE_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_SYRINGE_PUMP_OCCLUSION, 0, SYRINGE_PUMP_OCCLUSION_PERSISTENCE); initTimeWindowedCount( TIME_WINDOWED_COUNT_SYRINGE_PUMP_OFF_ERROR, SYRINGE_PUMP_OFF_ERROR_MAX_CNT, SYRINGE_PUMP_OFF_ERROR_TIME_WIN_MS ); initFPGAPersistentAlarm( FPGA_PERS_ERROR_SYRINGE_PUMP_ADC, ALARM_ID_HD_SYRINGE_PUMP_FPGA_ADC_FAULT, Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -ra56db4650fe5652d633e0c51b29da32d5d708608 -rfef80429278a165c2f512cb78606bd7b39f4a464 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision a56db4650fe5652d633e0c51b29da32d5d708608) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision fef80429278a165c2f512cb78606bd7b39f4a464) @@ -1201,31 +1201,34 @@ maxDeviation = MAX_DEVIATION_FROM_TRAGET_IN_POS_B; } - // Check if the current position has deviated from the position it is supposed to be in - // For more than a certain amount of time. If it has, raise an alarm - // Absolute value is used for comparison to cover +/- from the commanded position - if ( abs( currentPosition - commandedPosition ) > maxDeviation ) + if ( FALSE == isACPowerLost() ) { - valvesStatus[ valve ].positionOutOfRangeCounter++; - } + // Check if the current position has deviated from the position it is supposed to be in + // For more than a certain amount of time. If it has, raise an alarm + // Absolute value is used for comparison to cover +/- from the commanded position + if ( abs( currentPosition - commandedPosition ) > maxDeviation ) + { + valvesStatus[ valve ].positionOutOfRangeCounter++; + } - if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) - { - // If the valve's deviation from target was more than the counts for the define period of time trigger the alarm. - // Also, set the state to Idle so in the fault mode, the valve can transition to Pos C. The exec state is directly set here - // because this is a monitor function that is called in the controller function. - valvesStatus[ valve ].execState = VALVE_STATE_IDLE; - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE, (U32)valve, currentPosition ); + if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) + { + // If the valve's deviation from target was more than the counts for the define period of time trigger the alarm. + // Also, set the state to Idle so in the fault mode, the valve can transition to Pos C. The exec state is directly set here + // because this is a monitor function that is called in the controller function. + valvesStatus[ valve ].execState = VALVE_STATE_IDLE; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE, (U32)valve, currentPosition ); - if ( VALVE_POSITION_C_CLOSE == valvesStatus[ valve ].commandedPosition ) + if ( VALVE_POSITION_C_CLOSE == valvesStatus[ valve ].commandedPosition ) + { + activateSafetyShutdown(); + } + } + else if ( ( TRUE == isValveCloseToCommandedPosition( valve, commandedPositionEnum ) ) && ( valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) ) { - activateSafetyShutdown(); + valvesStatus[ valve ].positionOutOfRangeCounter = 0; } } - else if ( ( TRUE == isValveCloseToCommandedPosition( valve, commandedPositionEnum ) ) && ( valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) ) - { - valvesStatus[ valve ].positionOutOfRangeCounter = 0; - } } else { Index: firmware/App/Drivers/Battery.c =================================================================== diff -u -ra56db4650fe5652d633e0c51b29da32d5d708608 -rfef80429278a165c2f512cb78606bd7b39f4a464 --- firmware/App/Drivers/Battery.c (.../Battery.c) (revision a56db4650fe5652d633e0c51b29da32d5d708608) +++ firmware/App/Drivers/Battery.c (.../Battery.c) (revision fef80429278a165c2f512cb78606bd7b39f4a464) @@ -203,6 +203,7 @@ if ( TRUE == didTimeout( lastBatteryMonitorTime, BATTERY_MONITOR_INTERVAL_MS ) ) { lastBatteryMonitorTime = getMSTimerCount(); + getBatteryManagementData(); } } Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -ra56db4650fe5652d633e0c51b29da32d5d708608 -rfef80429278a165c2f512cb78606bd7b39f4a464 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision a56db4650fe5652d633e0c51b29da32d5d708608) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision fef80429278a165c2f512cb78606bd7b39f4a464) @@ -1374,7 +1374,7 @@ handleTestSetTreatmentParameter( message ); break; - case MSG_ID_VALVES_STATES_PUBLISH_INTERVAL_OVERRIDE: + case MSG_ID_HD_VALVES_STATES_PUBLISH_INTERVAL_OVERRIDE: handleTestHDValvesBroadcastIntervalOverrideRequest( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -ra56db4650fe5652d633e0c51b29da32d5d708608 -rfef80429278a165c2f512cb78606bd7b39f4a464 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a56db4650fe5652d633e0c51b29da32d5d708608) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision fef80429278a165c2f512cb78606bd7b39f4a464) @@ -2108,7 +2108,7 @@ if ( (ALARM_ID_T)alarmID < NUM_OF_ALARM_IDS ) { - activateAlarm2Data( (ALARM_ID_T)alarmID, alm1, alm2 ); + activateAlarm2Data( (ALARM_ID_T)alarmID, alm1, alm2, TRUE ); } } } @@ -5504,6 +5504,7 @@ if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) { result = testSetBatteryRemainingCapacityOverride( payload.state.f32 ); @@ -8332,11 +8333,8 @@ *************************************************************************/ void handleTestHDDialinCheckIn( MESSAGE_T* message ) { - BOOL status = FALSE; - if ( 0 == message->hdr.payloadLen ) { - status = TRUE; setDialinCheckInTimeStamp(); } } Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -ra56db4650fe5652d633e0c51b29da32d5d708608 -rfef80429278a165c2f512cb78606bd7b39f4a464 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision a56db4650fe5652d633e0c51b29da32d5d708608) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision fef80429278a165c2f512cb78606bd7b39f4a464) @@ -944,9 +944,6 @@ // MSG_ID_HD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE BOOL sendBloodLeakEmbeddedModeCommandResponse( U08 cmd, U32 responseLen, U08* response ); -// MSG_ID_HD_SEND_ALARMS_COMMAND -void handleResendAllAlarmsCommand( MESSAGE_T* message ); - // MSG_ID_HD_BLOOD_PUMP_SET_PWM void handleTestBloodPumpSetPWM( MESSAGE_T* message );