Index: firmware/App/Controllers/FlowSensors.c =================================================================== diff -u -r2e21405574597474db0ebae86cdd7fa2d517f71c -r44f739bf3e9dfe0bfb5910a6a32fc4c5b1533af3 --- firmware/App/Controllers/FlowSensors.c (.../FlowSensors.c) (revision 2e21405574597474db0ebae86cdd7fa2d517f71c) +++ firmware/App/Controllers/FlowSensors.c (.../FlowSensors.c) (revision 44f739bf3e9dfe0bfb5910a6a32fc4c5b1533af3) @@ -36,7 +36,7 @@ #define FLOW_SENSORS_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the Dialysate flow data is published on the CAN bus. #define FLOW_SENSORS_EDGES_BUFFER_LENGTH 100 ///< Flow sensors edges buffer length. #define FLOW_SENSORS_PULSES_PER_LITER 110000 ///< Flow sensors pulses per liter -#define FLOW_OUT_OF_RANGE_PERSISTENT_INTERVAL ( 12 * MS_PER_SECOND ) ///< Flow out of range time out in counts. +#define FLOW_OUT_OF_RANGE_TIME_OUT_MS ( 12 * MS_PER_SECOND ) ///< Flow out of range time out in milliseconds. #define DATA_PUBLISH_COUNTER_START_COUNT 20 ///< Data publish counter start count. static const F32 FLOW_SENSORS_LITERS_PER_PULSES = ( 1.0 / (F32)FLOW_SENSORS_PULSES_PER_LITER ); ///< Flow sensors liters/pulses coefficient. @@ -81,7 +81,8 @@ } // Initialize the persistent alarm for flow out of upper and lower range - initPersistentAlarm( ALARM_ID_DIALYSATE_FLOW_RATE_OUT_OF_RANGE, FLOW_OUT_OF_RANGE_PERSISTENT_INTERVAL, FLOW_OUT_OF_RANGE_PERSISTENT_INTERVAL ); + initPersistentAlarm( ALARM_ID_DG_DIALYSATE_FLOW_RATE_OUT_OF_MAX_RANGE, FLOW_OUT_OF_RANGE_TIME_OUT_MS, FLOW_OUT_OF_RANGE_TIME_OUT_MS ); + initPersistentAlarm( ALARM_ID_DG_RO_FLOW_RATE_OUT_OF_MAX_RANGE, FLOW_OUT_OF_RANGE_TIME_OUT_MS, FLOW_OUT_OF_RANGE_TIME_OUT_MS ); dataPublicationCounter = DATA_PUBLISH_COUNTER_START_COUNT; } @@ -114,10 +115,12 @@ void execFlowSensorsMonitor( void ) { U08 i; - U08 countsIndex; - U16 oldestEdgeCount; - U16 oldest2CurrentEdgeDiff; - F32 flowBeforeCalibrationLPM; + U08 countsIndex = 0; + U16 oldestEdgeCount = 0; + U16 oldest2CurrentEdgeDiff = 0; + F32 flowBeforeCalibrationLPM = 0.0F; + F32 currentFlowLPM = 0.0F; + BOOL isFlowOutOfRange = FALSE; // Check if a new calibration is available if ( TRUE == isNewCalibrationRecordAvailable() ) @@ -162,11 +165,16 @@ flowSensorStatus[ i ].edgeCountsIndex = INC_WRAP( countsIndex, 0, ( FLOW_SENSORS_EDGES_BUFFER_LENGTH - 1 ) ); } - // TODO dialysate flow alarm. Is it needed? - //currentFlow = getMeasuredFlowRateLPM( DIALYSATE_FLOW_SENSOR ); - //isFlowOutOfUpperRange = ( currentFlow > MAX_DIALYSATE_FLOWRATE_LPM ? TRUE : FALSE ); - //checkPersistentAlarm( ALARM_ID_DIALYSATE_FLOW_RATE_OUT_OF_RANGE, isFlowOutOfUpperRange, currentFlow, MAX_DIALYSATE_FLOWRATE_LPM ); + // Check the dialysate flow rate for the maximum allowed flow rate + currentFlowLPM = getMeasuredFlowRateLPM( DIALYSATE_FLOW_SENSOR ); + isFlowOutOfRange = ( currentFlowLPM > MAX_FLOWRATE_LPM ? TRUE : FALSE ); + checkPersistentAlarm( ALARM_ID_DG_DIALYSATE_FLOW_RATE_OUT_OF_MAX_RANGE, isFlowOutOfRange, currentFlowLPM, MAX_FLOWRATE_LPM ); + // Check the RO flow rate for the maximum allowed flow rate + currentFlowLPM = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); + isFlowOutOfRange = ( currentFlowLPM > MAX_FLOWRATE_LPM ? TRUE : FALSE ); + checkPersistentAlarm( ALARM_ID_DG_RO_FLOW_RATE_OUT_OF_MAX_RANGE, isFlowOutOfRange, currentFlowLPM, MAX_FLOWRATE_LPM ); + publishFlowSensorsData(); }