Index: firmware/App/Controllers/FlowSensors.c =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Controllers/FlowSensors.c (.../FlowSensors.c) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Controllers/FlowSensors.c (.../FlowSensors.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -170,6 +170,21 @@ /*********************************************************************//** * @brief + * The getMeasuredROFlowRateWithConcPumpsLPM function gets the measured flow + * rate of a flow sensor in L/min. + * @details Inputs: flowSensorStatus + * @details Outputs: flowSensorStatus + * @return the current flow rate (in L/min). + *************************************************************************/ +F32 getMeasuredROFlowRateWithConcPumpsLPM( void ) +{ + F32 flow = getF32OverrideValue( &flowSensorStatus[ RO_FLOW_SENSOR ].measuredROFlowWithCPsLPM ); + + return flow; +} + +/*********************************************************************//** + * @brief * The publishFlowSensorsData function publishes flow sensors data at * the set interval. * @details Inputs: flowSensorsDataPublicationCounter, Index: firmware/App/Controllers/FlowSensors.h =================================================================== diff -u -r0f4fbb2a56cdbe35dcedd9cad23867fd7248f86e -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Controllers/FlowSensors.h (.../FlowSensors.h) (revision 0f4fbb2a56cdbe35dcedd9cad23867fd7248f86e) +++ firmware/App/Controllers/FlowSensors.h (.../FlowSensors.h) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -42,7 +42,8 @@ void execFlowSesnorsMonitor( void ); -F32 getMeasuredFlowRateLPM( FLOW_SENSORS_T sensorId ); +F32 getMeasuredFlowRateLPM( FLOW_SENSORS_T sensorId ); +F32 getMeasuredROFlowRateWithConcPumpsLPM( void ); BOOL testSetFlowDataPublishIntervalOverride( U32 value ); BOOL testResetFlowDataPublishIntervalOverride( void ); Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -329,7 +329,7 @@ { alarm = ALARM_ID_RO_FLOW_TOO_LOW_WHILE_PRIMARY_HEATER_IS_ON; measFlow = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); - minFlow = MIN_RO_FLOWRATE_LPM; + minFlow = MIN_RO_HEATER_FLOWRATE_LPM; } else { @@ -344,8 +344,14 @@ } else { - checkPersistentAlarm( ALARM_ID_RO_FLOW_TOO_LOW_WHILE_PRIMARY_HEATER_IS_ON, FALSE, 0.0, 0.0 ); - checkPersistentAlarm( ALARM_ID_DIALYSATE_FLOW_TOO_LOW_WHILE_TRIMMER_HEATER_IS_ON, FALSE, 0.0, 0.0 ); + if ( DG_PRIMARY_HEATER == heater ) + { + checkPersistentAlarm( ALARM_ID_RO_FLOW_TOO_LOW_WHILE_PRIMARY_HEATER_IS_ON, FALSE, 0.0, 0.0 ); + } + else + { + checkPersistentAlarm( ALARM_ID_DIALYSATE_FLOW_TOO_LOW_WHILE_TRIMMER_HEATER_IS_ON, FALSE, 0.0, 0.0 ); + } } } @@ -838,9 +844,9 @@ { HEATERS_DATA_T data; - data.mainPrimayHeaterDC = heatersStatus[ DG_PRIMARY_HEATER ].dutyCycle * 100.0; // The duty cycle of the primary heater is divided into 2 parts and is applied to main // and small primary heaters. So they are always the same. + data.mainPrimayHeaterDC = heatersStatus[ DG_PRIMARY_HEATER ].dutyCycle * 100.0; data.smallPrimaryHeaterDC = heatersStatus[ DG_PRIMARY_HEATER ].dutyCycle * 100.0; data.trimmerHeaterDC = heatersStatus[ DG_TRIMMER_HEATER ].dutyCycle * 100.0; data.primaryTargetTemp = heatersStatus[ DG_PRIMARY_HEATER ].targetTemp; Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -63,7 +63,6 @@ #define FLOW_SENSOR_ZERO_READING 0xFFFF ///< Flow sensor reading indicates zero flow (or flow lower than can be detected by sensor). -#define FLOW_SAMPLES_TO_AVERAGE ( 250 / TASK_PRIORITY_INTERVAL ) ///< Averaging flow data over 250 ms intervals. #define FLOW_AVERAGE_MULTIPLIER ( 1.0F / (F32)FLOW_SAMPLES_TO_AVERAGE ) ///< Optimization - multiplying is faster than dividing. // The ADC to LPM factor is calculated using the following steps: @@ -76,7 +75,6 @@ /// Initial conversion factor from target flow rate to PWM duty cycle estimate. #define ROP_FLOW_TO_PWM_DC(flow) ( ROP_FLOW_TO_PWM_SLOPE * flow + ROP_FLOW_TO_PWM_INTERCEPT ) - #define MAX_ALLOWED_FLOW_DEVIATION 0.1F ///< Max allowed deviation from target flow. #define FLOW_OUT_OF_RANGE_PERSISTENT_INTERVAL ( 12 * MS_PER_SECOND ) ///< Flow out of range time out in counts. #define MAX_PRESSURE_TARGET_TOLERANCE 5 ///< Pressure tolerance from maximum set pressure by user in psi. @@ -90,7 +88,6 @@ #define ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE 2.51F ///< RO pump 0% duty cycle feedback voltage. #define ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE 0.05F ///< RO pump duty cycle out of range tolerance. - #define DATA_PUBLISH_COUNTER_START_COUNT 50 ///< Data publish counter start count. /// Enumeration of RO pump states. @@ -129,13 +126,8 @@ static F32 targetROPumpMaxPressure; ///< Target RO max allowed pressure (in PSI). static OVERRIDE_U32_T roPumpDataPublishInterval = { RO_PUMP_DATA_PUB_INTERVAL, RO_PUMP_DATA_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms) at which to publish RO flow data to CAN bus. -static OVERRIDE_F32_T measuredROFlowRateLPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured RO flow rate (in L/min). static U32 roControlTimerCounter; ///< Determines when to perform control on RO pump. static F32 roPumpOpenLoopTargetDutyCycle; ///< Target RO pump open loop PWM. -static S32 measuredFlowReadingsSum; ///< Raw flow reading sums for averaging. -static U32 flowFilterCounter; ///< Flow filtering counter. -static DG_FLOW_SENSORS_CAL_RECORD_T flowSensorsCalRecord; ///< Flow sensors calibration record. -static OVERRIDE_F32_T measuredROFlowRateWithConcPumpsLPM = { 0.0, 0.0, 0.0, 0 }; ///< Measure RO flow rate with concentrate pumps (L/min). static DG_RO_PUMP_CAL_RECORD_T roPumpCalRecord; ///< RO pump calibration record. static F32 roVolumeL; ///< RO water generated in liters. @@ -156,9 +148,8 @@ * @brief * The initROPump function initializes the RO Pump module. * @details Inputs: roControlTimerCounter,roPumpOpenLoopTargetDutyCycle, - * roPumpFlowRateRunningSum, roPumpPressureRunningSum, measuredFlowReadingsSum, - * flowFilterCounter, flowVerificationCounter, roPumpState, roPumpControlMode - * roPumpDataPublicationTimerCounter, rawFlowLP, targetROPumpFlowRateLPM, + * roPumpPressureRunningSum, flowFilterCounter, flowVerificationCounter, + * roPumpState, roPumpControlMode, roPumpDataPublicationTimerCounter, rawFlowLP, * roPumpPWMDutyCyclePct, roPumpDutyCyclePctSet, pendingROPumpCmdMaxPressure, * pendingROPumpCmdTargetFlow, pendingROPumpCmdCountDown, targetROPumpMaxPressure, * @details Outputs: none @@ -190,8 +181,6 @@ // Initialize the variables roControlTimerCounter = 0; roPumpOpenLoopTargetDutyCycle = 0; - measuredFlowReadingsSum = 0; - flowFilterCounter = 0; roPumpDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; roPumpState = RO_PUMP_OFF_STATE; roPumpControlMode = NUM_OF_PUMP_CONTROL_MODES; @@ -349,46 +338,10 @@ BOOL isPressureMax = ( actualPressure >= MAX_ALLOWED_MEASURED_PRESSURE_PSI ? TRUE : FALSE ); BOOL isDutyCylceOutOfRange = FALSE; - // Update sum for flow average calculation - measuredFlowReadingsSum += (S32)roFlowReading; - checkPersistentAlarm( ALARM_ID_RO_PUMP_PRESSURE_OUT_OF_RANGE, isPressureMax, actualPressure, MAX_ALLOWED_MEASURED_PRESSURE_PSI ); - // Check if a new calibration is available - if ( TRUE == isNewCalibrationRecordAvailable() ) + if ( ( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) > NEARLY_ZERO ) && ( VALVE_STATE_CLOSED == getValveStateName( VBF ) ) ) { - getNVRecord2Driver( GET_CAL_FLOW_SENSORS, (U08*)&flowSensorsCalRecord, sizeof( DG_FLOW_SENSORS_CAL_RECORD_T ), - NUM_OF_CAL_DATA_FLOW_SENSORS, ALARM_ID_DG_RO_FLOW_SENSOR_INVALID_CAL_RECORD ); - } - - // Read flow at the control set - if ( ++flowFilterCounter >= FLOW_SAMPLES_TO_AVERAGE ) - { - F32 flow = RO_FLOW_ADC_TO_LPM_FACTOR / ( (F32)measuredFlowReadingsSum * FLOW_AVERAGE_MULTIPLIER ); - - flow = pow(flow, 4) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].fourthOrderCoeff + - pow(flow, 3) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].thirdOrderCoeff + - pow(flow, 2) * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].secondOrderCoeff + - flow * flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].gain + - flowSensorsCalRecord.flowSensors[ CAL_DATA_RO_PUMP_FLOW_SENSOR ].offset; - - measuredROFlowRateWithConcPumpsLPM.data = flow; - measuredROFlowRateLPM.data = flow - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) / ML_PER_LITER ) - - ( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) / ML_PER_LITER ); - - // If the flow is less than a certain value, FPGA will return 0xFFFF meaning that - // the flow is 0. - if ( FLOW_SENSOR_ZERO_READING == roFlowReading ) - { - measuredROFlowRateLPM.data = 0.0; - } - - measuredFlowReadingsSum = 0; - flowFilterCounter = 0; - } - - if ( ( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) > NEARLY_ZERO ) && ( VALVE_STATE_CLOSED == getValveState( VBF ) ) ) - { // If the RO pump's flow is greater than zero, and the VBf valve is not open (like heat disinfect) it means RO water is being generated // Add that water to the variable roVolumeL += ( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) / ( SEC_PER_MIN * MS_PER_SECOND ) ) * TASK_PRIORITY_INTERVAL; @@ -403,7 +356,7 @@ // but the pump is not able to achieve the flow. if ( ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) && ( RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE == roPumpState ) ) { - F32 currentFlow = getMeasuredROFlowRateLPM(); + F32 currentFlow = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); F32 targetFlow = getTargetROPumpFlowRateLPM(); // The flow cannot be out of range for than 10% of the target flow BOOL isFlowOutOfRange = ( fabs( 1.0F - ( currentFlow / targetFlow ) ) > MAX_ALLOWED_FLOW_DEVIATION ? TRUE : FALSE ); @@ -508,10 +461,7 @@ SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; BOOL calStatus = FALSE; - calStatus |= getNVRecord2Driver( GET_CAL_FLOW_SENSORS, (U08*)&flowSensorsCalRecord, sizeof( DG_FLOW_SENSORS_CAL_RECORD_T ), - NUM_OF_CAL_DATA_FLOW_SENSORS, ALARM_ID_DG_RO_FLOW_SENSOR_INVALID_CAL_RECORD ); - - calStatus |= getNVRecord2Driver( GET_CAL_RO_PUMP_RECORD, (U08*)&roPumpCalRecord, sizeof( DG_RO_PUMP_CAL_RECORD_T ), + calStatus = getNVRecord2Driver( GET_CAL_RO_PUMP_RECORD, (U08*)&roPumpCalRecord, sizeof( DG_RO_PUMP_CAL_RECORD_T ), NUM_OF_CAL_DATA_FLOW_SENSORS, ALARM_ID_NO_ALARM ); if ( TRUE == calStatus ) @@ -554,31 +504,6 @@ /*********************************************************************//** * @brief - * The getMeasuredROFlowRateLPM function gets the measured RO pump flow rate. - * @details Inputs: measuredROFlowRateLPM - * @details Outputs: measuredROFlowRateLPM - * @return the current RO pump flow rate (in L/min). - *************************************************************************/ -F32 getMeasuredROFlowRateLPM( void ) -{ - return getF32OverrideValue( &measuredROFlowRateLPM ); -} - -/*********************************************************************//** - * @brief - * The getMeasuredROFlowRateWithConcPumpsLPM function gets the measured RO - * pump flow rate with the concentrate pumps. - * @details Inputs: measuredROFlowRateWithConcPumpsLPM - * @details Outputs: measuredROFlowRateWithConcPumpsLPM - * @return the current RO pump flow rate with the concentrate pumps (in L/min). - *************************************************************************/ -F32 getMeasuredROFlowRateWithConcPumpsLPM( void ) -{ - return getF32OverrideValue( &measuredROFlowRateWithConcPumpsLPM ); -} - -/*********************************************************************//** - * @brief * The getTargetROPumpPressure function gets the current target RO pump * pressure. * @details Inputs: targetROPumpPressure @@ -862,13 +787,13 @@ if ( ++roPumpDataPublicationTimerCounter >= getU32OverrideValue( &roPumpDataPublishInterval ) ) { RO_PUMP_DATA_T pumpData; + pumpData.roPumpTgtFlowRateLM = getTargetROPumpFlowRateLPM(); pumpData.roPumpTgtPressure = getTargetROPumpPressure(); pumpData.measROFlowRate = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); pumpData.roPumpDutyCycle = roPumpDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; pumpData.roPumpState = (U32)roPumpState; pumpData.roPumpFBDutyCycle = roPumpFeedbackDutyCyclePct * FRACTION_TO_PERCENT_FACTOR; - pumpData.roPumpMeasFlowWithConcPumps = getMeasuredROFlowRateWithConcPumpsLPM(); broadcastData( MSG_ID_RO_PUMP_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&pumpData, sizeof( RO_PUMP_DATA_T ) ); roPumpDataPublicationTimerCounter = 0; @@ -987,54 +912,6 @@ /*********************************************************************//** * @brief - * The testSetMeasuredROFlowRateOverride function overrides the measured - * RO flow rate. - * @details Inputs: measuredROFlowRateLPM - * @details Outputs: measuredROFlowRateLPM - * @param: value : override measured RO pump motor speed (in L/min) - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testSetMeasuredROFlowRateOverride( F32 value ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - measuredROFlowRateLPM.ovInitData = measuredROFlowRateLPM.data; - measuredROFlowRateLPM.ovData = value; - measuredROFlowRateLPM.override = OVERRIDE_KEY; - result = TRUE; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetMeasuredROFlowRateOverride function resets the override - * of the measured RO flow rate. - * @details Inputs: measuredROFlowRateLPM - * @details Outputs: measuredROFlowRateLPM - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testResetMeasuredROFlowRateOverride( void ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - measuredROFlowRateLPM.data = measuredROFlowRateLPM.ovInitData; - measuredROFlowRateLPM.override = OVERRIDE_RESET; - measuredROFlowRateLPM.ovInitData = 0.0; - measuredROFlowRateLPM.ovData = 0.0; - result = TRUE; - } - - return result; -} - -/*********************************************************************//** - * @brief * The testSetTargetDutyCycleOverride function overrides the target duty * cycle of the RO pump. * @details Inputs: none Index: firmware/App/Controllers/ROPump.h =================================================================== diff -u -r261cfc6d93996e76e26c1e9c3f5740077ad2ec22 -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision 261cfc6d93996e76e26c1e9c3f5740077ad2ec22) +++ firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -62,9 +62,6 @@ BOOL isROPumpRunning( void ); F32 getTargetROPumpFlowRateLPM( void ); -F32 getMeasuredROFlowRateLPM( void ); -F32 getMeasuredROFlowRateWithConcPumpsLPM( void ); - F32 getTargetROPumpPressure( void ); F32 getROGeneratedVolumeL( void ); @@ -73,9 +70,6 @@ BOOL testSetROPumpDataPublishIntervalOverride( U32 value ); BOOL testResetROPumpDataPublishIntervalOverride( void ); -BOOL testSetMeasuredROFlowRateOverride( F32 value ); -BOOL testResetMeasuredROFlowRateOverride( void ); - BOOL testSetTargetROPumpFlow( F32 flow ); BOOL testSetTargetROPumpPressure( U32 value ); Index: firmware/App/Controllers/UVReactors.c =================================================================== diff -u -rd7be59e36db5e9899b02dd0bfadadc50fed934c0 -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision d7be59e36db5e9899b02dd0bfadadc50fed934c0) +++ firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -20,6 +20,7 @@ #include "AlarmMgmt.h" #include "Common.h" +#include "FlowSensors.h" #include "MessageSupport.h" #include "PersistentAlarm.h" #include "SystemCommMessages.h" @@ -375,7 +376,7 @@ if ( TURN_ON == reactorsStatus[ reactor ].switchState ) { // Check if the flow is below minimum - reactorsStatus[ reactor ].isFlowBelowMin = ( getMeasuredROFlowRateLPM() < MIN_RO_UV_FLOWRATE_LPM ? TRUE : FALSE ); + reactorsStatus[ reactor ].isFlowBelowMin = ( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) < MIN_RO_UV_FLOWRATE_LPM ? TRUE : FALSE ); // If the flow is no longer below minimum and the reactor is requested to be on, turn it back on if ( FALSE == reactorsStatus[ reactor ].isFlowBelowMin ) @@ -419,7 +420,7 @@ } // Check if the flow is below minimum - BOOL isFlowBelowMin = ( getMeasuredROFlowRateLPM() < MIN_RO_UV_FLOWRATE_LPM ? TRUE : FALSE ); + BOOL isFlowBelowMin = ( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) < MIN_RO_UV_FLOWRATE_LPM ? TRUE : FALSE ); if ( TRUE == isFlowBelowMin ) { Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -45,7 +45,6 @@ static U32 pendingValveStateChanges[ NUM_OF_VALVES ]; ///< Delayed (pending) valve state changes. static U32 pendingValveStateChangeCountDowns[ NUM_OF_VALVES ]; ///< Delayed (pending) valve state change count down timers (in task intervals). -static VALVE_STATE_NAMES_T valveCurrentStateName[ NUM_OF_VALVES ]; ///< Currently valve state name. static OVERRIDE_U32_T valveStates[ NUM_OF_VALVES ]; ///< Currently commanded valves states. static OVERRIDE_U32_T valvesStatesPublishInterval = { VALVES_STATE_PUB_INTERVAL, VALVES_STATE_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms/task interval) at which to publish valves state to CAN bus. @@ -54,7 +53,8 @@ static BOOL checkValveStateName( VALVES_T valve, VALVE_STATE_NAMES_T valveStateName ); static U32 convertValveStateNameToValveState(VALVE_STATE_NAMES_T valveStateName); static U16 fromU32ArrayToU16( void ); -static void publishValvesStates( void ); +static void publishValvesStates( void ); +static U32 getValveState( U32 valveID ); /*********************************************************************//** * @brief @@ -247,7 +247,7 @@ U32 i; // flag valves that are currently commanded to be energized - for ( i = 0; i < NUM_OF_VALVES; i++) + for ( i = 0; i < NUM_OF_VALVES; i++ ) { result |= ( getValveState( i ) == ENERGIZED ? 0x0001 << i : 0 ); } @@ -394,13 +394,13 @@ /*********************************************************************//** * @brief - * The getValveState function gets the current valve state for given valve. + * The getValveStateName function gets the current valve state enum for given valve. * @details Inputs: valveStates[] * @details Outputs: none * @param valveID ID of valve to get state for * @return the current valve state for given valve in enum *************************************************************************/ -VALVE_STATE_NAMES_T getValveState( VALVES_T valveID ) +VALVE_STATE_NAMES_T getValveStateName( VALVES_T valveID ) { VALVE_STATE_NAMES_T name; @@ -470,6 +470,30 @@ valvesStatesPublicationTimerCounter = 0; } +} + +/*********************************************************************//** + * @brief + * The getValveState function gets the current valve state for given valve. + * @details Inputs: valveStates[] + * @details Outputs: none + * @param valveID ID of valve to get state for + * @return the current valve state for given valve + *************************************************************************/ +static U32 getValveState( U32 valveID ) +{ + U32 valveState = DEENERGIZED; + + if ( valveID < NUM_OF_VALVES ) + { + valveState = getU32OverrideValue( &valveStates[ valveID ] ); + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_VALVES_INVALID_VALVE_ID, valveID ) + } + + return valveState; } Index: firmware/App/Controllers/Valves.h =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Controllers/Valves.h (.../Valves.h) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Controllers/Valves.h (.../Valves.h) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -51,7 +51,8 @@ typedef enum Valves { VRF = 0, ///< Valve Reservoir Fill - VRI, ///< Valve Reservoir Inlet + VRI, ///< Valve Reservoir Inlet + RSRVD_SPACE, ///< This space has been reserved VRO, ///< Valve Reservoir Outlet VPO, ///< Valve Pressure Outlet VBF, ///< Valve Bypass Filter @@ -78,7 +79,7 @@ BOOL setValveState( VALVES_T valve, VALVE_STATE_NAMES_T valveState ); BOOL setValveStateDelayed( VALVES_T valve, VALVE_STATE_NAMES_T valveState, U32 delayMs ); -VALVE_STATE_NAMES_T getValveState( VALVES_T valveID ); +VALVE_STATE_NAMES_T getValveStateName( VALVES_T valveID ); BOOL testSetValvesStatesPublishIntervalOverride( U32 value ); BOOL testResetValvesStatesPublishIntervalOverride( void ); Index: firmware/App/Modes/ModeChemicalDisinfect.c =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -18,6 +18,7 @@ #include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "DrainPump.h" +#include "FlowSensors.h" #include "Heaters.h" #include "LoadCell.h" #include "MessageSupport.h" @@ -1084,7 +1085,7 @@ DG_CHEM_DISINFECT_STATE_T state = DG_CHEM_DISINFECT_STATE_FILL_WITH_WATER_AND_DISINFECTANT; // Get the flow rate that is used for mixing - F32 measuredROFlowRate = getMeasuredROFlowRateLPM(); + F32 measuredROFlowRate = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); // If the flow is less than the minimum, request the concentrate pump to be on but do // control it. Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -19,6 +19,7 @@ #include "ConcentratePumps.h" #include "ConductivitySensors.h" +#include "FlowSensors.h" #include "FPGA.h" #include "CPLD.h" #include "Heaters.h" @@ -471,7 +472,7 @@ bicarbMix = bicarb.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbConcMixRatio; setROPumpTargetFlowRateLPM( getTargetFillFlowRateLPM(), TARGET_RO_PRESSURE_PSI ); - handleDialysateMixing( getMeasuredROFlowRateLPM() * ML_PER_LITER, acidMix, bicarbMix ); + handleDialysateMixing( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) * ML_PER_LITER, acidMix, bicarbMix ); requestConcentratePumpOn( CONCENTRATEPUMPS_CP1_ACID ); requestConcentratePumpOn( CONCENTRATEPUMPS_CP2_BICARB ); result = DG_FILL_MODE_STATE_PRODUCE_DIALYSATE; @@ -670,7 +671,7 @@ bicarbMix = bicarb.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbConcMixRatio; setROPumpTargetFlowRateLPM( getTargetFillFlowRateLPM(), TARGET_RO_PRESSURE_PSI ); - handleDialysateMixing( getMeasuredROFlowRateLPM() * ML_PER_LITER, acidMix, bicarbMix ); + handleDialysateMixing( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) * ML_PER_LITER, acidMix, bicarbMix ); requestConcentratePumpOn( CONCENTRATEPUMPS_CP2_BICARB ); // Do the necessary setup here before transition to Produce Dialysate State @@ -710,7 +711,7 @@ bicarbMix = bicarb.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbConcMixRatio; // Prime mixing before deliver result to reservoir - handleDialysateMixing( getMeasuredROFlowRateLPM() * ML_PER_LITER, acidMix, bicarbMix ); + handleDialysateMixing( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) * ML_PER_LITER, acidMix, bicarbMix ); if ( concentratePumpPrimeCount++ > CONCENTRATE_PUMP_PRIME_INTERVAL ) { @@ -750,19 +751,18 @@ bicarbMix = bicarb.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbConcMixRatio; // Set concentrate pumps speed based on the RO pump flow rate - handleDialysateMixing( getMeasuredROFlowRateLPM() * ML_PER_LITER, acidMix, bicarbMix ); + handleDialysateMixing( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) * ML_PER_LITER, acidMix, bicarbMix ); integratedVolumeML += getMeasuredROFlowRateWithConcPumpsLPM() * ( (F32)TASK_GENERAL_INTERVAL / (F32)( SEC_PER_MIN ) ); usedAcidVolumeML.data += getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) * FLOW_INTEGRATOR; usedBicarbVolumeML.data += getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) * FLOW_INTEGRATOR; - acidConductivityTotal += acidConductivity; bicarbConductivityTotal += bicarbConductivity; conductivitySampleCount++; // DG is delivering dialysate keep collecting the sample counter and the measured flow fillStatus.fillSampleCounter += 1; - fillStatus.fillFlowRateRunningSum += getMeasuredROFlowRateLPM(); + fillStatus.fillFlowRateRunningSum += getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); fillStatus.fillTemperatureRunningSum += getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); // TODO: Check for open straw door status and alarm if closed @@ -827,7 +827,6 @@ fillStatus.fillLastTemperature = getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); calculateHeaterEstimationGain( DG_PRIMARY_HEATER ); - requestNewOperationMode( DG_MODE_GENE ); } @@ -909,9 +908,14 @@ F32 TRo = getTemperatureValue( TEMPSENSORS_OUTLET_REDUNDANT ); BOOL isDriftOut = ( fabs( TDi - TRo ) >= DIALYSATE_TEMPERATURE_SENSORS_MAX_DRIFT_C ? TRUE : FALSE ); - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_DG_DIALYSATE_TEMPERATURE_SENSORS_OUT_OF_RANGE, isDriftOut ) ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_TEMPERATURE_SENSORS_ALARM ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - activateAlarmNoData( ALARM_ID_DG_DIALYSATE_TEMPERATURE_SENSORS_OUT_OF_RANGE ); + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_DG_DIALYSATE_TEMPERATURE_SENSORS_OUT_OF_RANGE, isDriftOut ) ) + { + activateAlarmNoData( ALARM_ID_DG_DIALYSATE_TEMPERATURE_SENSORS_OUT_OF_RANGE ); + } } } Index: firmware/App/Modes/ModeFlush.c =================================================================== diff -u -rbe911666759f221ec5af10ca17350e0851023ed0 -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision be911666759f221ec5af10ca17350e0851023ed0) +++ firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -17,6 +17,7 @@ #include "ConcentratePumps.h" #include "DrainPump.h" +#include "FlowSensors.h" #include "Heaters.h" #include "LoadCell.h" #include "MessageSupport.h" @@ -715,7 +716,7 @@ { DG_FLUSH_STATE_T state = DG_FLUSH_STATE_FLUSH_CIRCULATION_DRAIN_LINE; - F32 waterFlowRate = getMeasuredROFlowRateLPM(); + F32 waterFlowRate = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); F32 waterVolume = ( ( waterFlowRate / SEC_PER_MIN ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); // Integrate volume of water moved through line Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -940,10 +940,6 @@ handleTestPressureDataBroadcastIntervalOverrideRequest( message ); break; - case MSG_ID_RO_MEASURED_FLOW_OVERRIDE: - handleTestROMeasuredFlowOverrideRequest( message ); - break; - case MSG_ID_MEASURED_FLOW_SENSORS_OVERRIDE: handleTestMeasuredFlowOverrideRequest( message ); break; @@ -1064,10 +1060,6 @@ handleTestROPumpDutyCycleOverride( message ); break; - case MSG_ID_DG_RO_FLOW_RATE_OVERRIDE: - handleTestROMeasuredFlowOverrideRequest( message ); - break; - case MSG_ID_DG_SET_RO_PUMP_TARGET_FLOW: handleTestROPumpTargetFlowOverride( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -1820,41 +1820,8 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - /*********************************************************************//** * @brief - * The handleTestROMeasuredFlowOverrideRequest function handles a request to - * override the RO flow rate. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestROMeasuredFlowOverrideRequest( 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 = testSetMeasuredROFlowRateOverride( payload.state.f32 ); - } - else - { - result = testResetMeasuredROFlowRateOverride(); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief * The handleTestMeasuredFlowOverrideRequest function handles a request to * override the measured flow sensor rate. * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d -r8074ecece0b11532c173ad951a98036f0c54ca52 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 8074ecece0b11532c173ad951a98036f0c54ca52) @@ -194,9 +194,6 @@ // MSG_ID_PRESSURE_SEND_INTERVAL_OVERRIDE: void handleTestPressureDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); -// MSG_ID_RO_MEASURED_FLOW_OVERRIDE: -void handleTestROMeasuredFlowOverrideRequest( MESSAGE_T *message ); - // MSG_ID_DIALYSATE_MEASURED_FLOW_OVERRIDE: void handleTestMeasuredFlowOverrideRequest( MESSAGE_T *message );