Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -r54f45c387430e440ab4607451fc84dea61f273f1 -r54b6f11358a56a5044fbe55ceccb67da903776dd --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 54f45c387430e440ab4607451fc84dea61f273f1) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 54b6f11358a56a5044fbe55ceccb67da903776dd) @@ -18,7 +18,8 @@ #include "AlarmMgmt.h" #include "FPGA.h" #include "InternalADC.h" -#include "OperationModes.h" +#include "OperationModes.h" +#include "PersistentAlarm.h" #include "Pressures.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" @@ -71,8 +72,6 @@ static S32 measuredPressureReadingsSum[ NUM_OF_PRESSURE_SENSORS ]; ///< Raw pressure sensor sums for averaging. static U32 pressureFilterCounter = 0; ///< Used to schedule pressure sensor filtering. -static U32 inletWaterLowPressureCounter = 0; ///< Persistence counter for inlet water low pressure. -static U32 inletWaterPressureInRangeCounter = 0; ///< Persistence counter for inlet water in range pressure. static PRESSURE_SELF_TEST_STATE_T pressuresSelfTestState; ///< Current pressure self test state. static SELF_TEST_STATUS_T pressuresSelfTestResult; ///< Self test result of the Pressures module. @@ -110,9 +109,12 @@ pressuresState = PRESSURE_INIT_STATE; pressuresSelfTestState = PRESSURE_SELF_TEST_STATE_START; - inletWaterLowPressureCounter = 0; - inletWaterPressureInRangeCounter = 0; - pressuresDataPublicationTimerCounter = 0; + pressuresDataPublicationTimerCounter = 0; + + initPersistentAlarm( PERSISTENT_ALARM_INLET_WATER_LOW_PRESSURE, ALARM_ID_INLET_WATER_LOW_PRESSURE, + FALSE, INLET_WATER_PRESSURE_PERSISTENCE_COUNT, INLET_WATER_PRESSURE_PERSISTENCE_COUNT ); + initPersistentAlarm( PERSISTENT_ALARM_INLET_WATER_PRESSURE_FAULT, ALARM_ID_INLET_WATER_PRESSURE_FAULT, + FALSE, INLET_WATER_PRESSURE_PERSISTENCE_COUNT, INLET_WATER_PRESSURE_PERSISTENCE_COUNT ); } /*********************************************************************//** @@ -243,31 +245,31 @@ * and triggers an alarm when pressure value is out of allowed range. * @details * Inputs : RO pump inlet pressure sensor value - * Outputs : Triggers or clears pressure persistent alarm + * Outputs : Triggers low pressure persistent alarm * @return none *************************************************************************/ void checkInletPressure( void ) { F32 const pressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_INLET ); - if ( pressure < MIN_INLET_WATER_PRESSURE ) - { - ++inletWaterLowPressureCounter; - inletWaterPressureInRangeCounter = 0; - if ( inletWaterLowPressureCounter > INLET_WATER_PRESSURE_PERSISTENCE_COUNT ) - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_INLET_WATER_LOW_PRESSURE, pressure ); - } - } - else - { - ++inletWaterPressureInRangeCounter; - inletWaterLowPressureCounter = 0; - if ( inletWaterPressureInRangeCounter > INLET_WATER_PRESSURE_PERSISTENCE_COUNT ) - { - clearAlarm( ALARM_ID_INLET_WATER_LOW_PRESSURE ); - } - } + BOOL const isPressureTooLow = ( pressure < MIN_INLET_WATER_PRESSURE ); + checkPersistentAlarm( PERSISTENT_ALARM_INLET_WATER_LOW_PRESSURE, isPressureTooLow, pressure ); } + +/*********************************************************************//** + * @brief + * The checkInletPressureFault function checks inlet water pressure value + * and triggers a machine fault when pressure value is out of allowed range. + * @details + * Inputs : RO pump inlet pressure sensor value + * Outputs : Triggers pressure fault persistent alarm + * @return none + *************************************************************************/ +void checkInletPressureFault( void ) +{ + F32 const pressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_INLET ); + BOOL const isPressureTooLow = ( pressure < MIN_INLET_WATER_PRESSURE ); + checkPersistentAlarm( PERSISTENT_ALARM_INLET_WATER_PRESSURE_FAULT, isPressureTooLow, pressure ); +} /*********************************************************************//** * @brief