Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -re2cf7feff54dad3fc5be72619fa64b5421fc6f9f -r9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision e2cf7feff54dad3fc5be72619fa64b5421fc6f9f) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526) @@ -166,10 +166,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 { @@ -349,6 +351,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 -r6872cd9877a06d2246640b57444b857c6935b677 -r9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 6872cd9877a06d2246640b57444b857c6935b677) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526) @@ -1203,31 +1203,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/Services/AlarmMgmt.c =================================================================== diff -u -re2cf7feff54dad3fc5be72619fa64b5421fc6f9f -r9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision e2cf7feff54dad3fc5be72619fa64b5421fc6f9f) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526) @@ -256,6 +256,33 @@ /*********************************************************************//** * @brief + * The isACPowerLost function determines whether A/C power loss has + * been detected. This function sets the alarms blocked condition to + * allow smooth alarm recovery. + * + * @details Inputs: alarmStatus + * @details Outputs: alarmsBlockedTimer + * @return TRUE if A/C power loss alarm is in effect, FALSE if not + *************************************************************************/ +BOOL isACPowerLost( void ) +{ + BOOL result = TRUE; + + // Continue to block new alarms until the alarms are cleared. + if ( ( FALSE == isAlarmConditionDetected( ALARM_ID_HD_AC_POWER_LOST ) ) && + ( FALSE == isAlarmConditionDetected( ALARM_ID_HD_AC_POWER_LOST_IN_TREATMENT ) ) ) + { + result = FALSE; + } + else + { + alarmsBlockedTimer = ALARM_BLOCKED_COUNT_AFTER_AC_RETURN; + } + return result; +} + +/*********************************************************************//** + * @brief * The activateAlarm function activates a given alarm. * @details Inputs: none * @details Outputs: alarmIsActive[], alarmStartedAt[], alarmStatus is updated @@ -264,6 +291,11 @@ *************************************************************************/ static void activateAlarm( ALARM_ID_T alarm ) { + // Block new alarms, occuring during loss of AC power + if ( ( TRUE == getCPLDACPowerLossDetected() ) ) + { + alarmsBlockedTimer = ALARM_BLOCKED_COUNT_AFTER_AC_RETURN; + } // Verify valid alarm index if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -rb687ab5673dc5da53537f538056ea12842b3f6ce -r9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision b687ab5673dc5da53537f538056ea12842b3f6ce) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526) @@ -205,6 +205,7 @@ void setAlarmUserActionEnabled( ALARM_USER_ACTION_T action, BOOL enabled ); void signalAlarmSilence( ALARM_SILENCE_CMD_T cmd ); void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ); +BOOL isACPowerLost( void ); BOOL isAlarmActive( ALARM_ID_T alarm ); BOOL isAlarmConditionDetected( ALARM_ID_T alarm ); BOOL isAnyAlarmActive( void ); Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -rd106a0eefd1e2ffe5873cd862ebbd53c1002de27 -r9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision d106a0eefd1e2ffe5873cd862ebbd53c1002de27) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526) @@ -30,6 +30,11 @@ #include "TaskGeneral.h" #include "Timers.h" +/** + * @addtogroup Reservoirs + * @{ + */ + // ********** private definitions ********** #define RESERVOIR_FRESH_SETTLE_TIME_MS 15000 ///< Allocated time to settle the freshly filled reservoir in milliseconds. Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -re2cf7feff54dad3fc5be72619fa64b5421fc6f9f -r9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision e2cf7feff54dad3fc5be72619fa64b5421fc6f9f) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526) @@ -31,6 +31,7 @@ #include "ModeStandby.h" #include "ModeInitPOST.h" #include "OperationModes.h" +#include "Reservoirs.h" #include "RTC.h" #include "SampleWater.h" #include "SafetyShutdown.h" @@ -5526,6 +5527,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 ); @@ -8479,4 +8481,36 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleTestHDRecirulationPctOverrideRequest function handles a + * request to override pending ACKs. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestHDRecirulationPctOverrideRequest( 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 = testSetRecirculationLevelPctOverride( payload.state.f32 ); + } + else + { + result = testResetRecirculationLevelPctOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -re2cf7feff54dad3fc5be72619fa64b5421fc6f9f -r9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision e2cf7feff54dad3fc5be72619fa64b5421fc6f9f) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 9e611165fe4a2eaeccd7b2a37c8e4dfc8498b526) @@ -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 ); @@ -1013,6 +1010,9 @@ // MSG_ID_HD_CAN_RECEIVE_ACK_MESSAGE_OVERRIDE void handleTestHDPendingACKOverrideRequest( MESSAGE_T* message ); +// MSG_ID_HD_RECIRULATION_PCT_OVERRIDE +void handleTestHDRecirulationPctOverrideRequest( MESSAGE_T* message ); + /**@}*/ #endif