Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r61fc45d7a43557312d6abd00a6b01e6823b44f04 -r2b9d10664884e9b20d391cc3178d3c85347cdf2c --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 61fc45d7a43557312d6abd00a6b01e6823b44f04) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) @@ -918,7 +918,7 @@ drainPumpMeasuredRPM.ovData = value; drainPumpMeasuredRPM.override = OVERRIDE_KEY; drainPumpMeasuredRPM.ovInitData = drainPumpMeasuredRPM.data; - status = TRUE; + status = TRUE; } } @@ -942,10 +942,106 @@ { drainPumpMeasuredRPM.ovData = drainPumpMeasuredRPM.ovInitData; drainPumpMeasuredRPM.override = OVERRIDE_RESET; - status = TRUE; + status = TRUE; } return status; } +/*********************************************************************//** + * @brief + * The testSetDrainPumpMeasuredCurrentOverride function overrides the drain pump + * measured current data. + * @details Inputs: none + * @details Outputs: drainPumpMeasuredCurrentA + * @param value override drain pump measured current data + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetDrainPumpMeasuredCurrentOverride( F32 value ) +{ + BOOL status = FALSE; + + // Check if the user is logged in + if ( TRUE == isTestingActivated() ) + { + drainPumpMeasuredCurrentA.ovData = value; + drainPumpMeasuredCurrentA.override = OVERRIDE_KEY; + drainPumpMeasuredCurrentA.ovInitData = drainPumpMeasuredCurrentA.data; + status = TRUE; + } + + return status; +} + +/*********************************************************************//** + * @brief + * The testResetDrainPumpMeasuredCurrentOverride function resets the drain pump + * measured current data. + * @details Inputs: none + * @details Outputs: drainPumpMeasuredCurrentA + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetDrainPumpMeasuredCurrentOverride( void ) +{ + BOOL status = FALSE; + + // Check if the user is logged in + if ( TRUE == isTestingActivated() ) + { + drainPumpMeasuredCurrentA.ovData = drainPumpMeasuredCurrentA.ovInitData; + drainPumpMeasuredCurrentA.override = OVERRIDE_RESET; + status = TRUE; + } + + return status; +} + +/*********************************************************************//** + * @brief + * The testSetDrainPumpMeasuredDirectionOverride function overrides the drain pump + * measured direction data. + * @details Inputs: none + * @details Outputs: drainPumpMeasuredDir + * @param value override drain pump measured direction data + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetDrainPumpMeasuredDirectionOverride( U32 value ) +{ + BOOL status = FALSE; + + // Check if the user is logged in + if ( TRUE == isTestingActivated() ) + { + drainPumpMeasuredDir.ovData = value; + drainPumpMeasuredDir.override = OVERRIDE_KEY; + drainPumpMeasuredDir.ovInitData = drainPumpMeasuredDir.data; + status = TRUE; + } + + return status; +} + +/*********************************************************************//** + * @brief + * The testResetDrainPumpMeasuredDirectionOverride function resets the drain pump + * measured direction data. + * @details Inputs: none + * @details Outputs: drainPumpMeasuredDir + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetDrainPumpMeasuredDirectionOverride( void ) +{ + BOOL status = FALSE; + + // Check if the user is logged in + if ( TRUE == isTestingActivated() ) + { + drainPumpMeasuredDir.ovData = drainPumpMeasuredDir.ovInitData; + drainPumpMeasuredDir.override = OVERRIDE_RESET; + status = TRUE; + } + + return status; +} + /**@}*/ Index: firmware/App/Controllers/DrainPump.h =================================================================== diff -u -r0c296cef29037819be204c45a23d4d38a52b2718 -r2b9d10664884e9b20d391cc3178d3c85347cdf2c --- firmware/App/Controllers/DrainPump.h (.../DrainPump.h) (revision 0c296cef29037819be204c45a23d4d38a52b2718) +++ firmware/App/Controllers/DrainPump.h (.../DrainPump.h) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) @@ -76,12 +76,17 @@ BOOL testResetDrainPumpDataPublishIntervalOverride( void ); BOOL testSetTargetDrainPumpRPM( U32 value ); - BOOL testSetTargetDrainPumpOutletPressure( F32 value ); BOOL testSetDrainPumpMeasuredRPMOverride( U32 value ); BOOL testResetDrainPumpMeasuredRPMOverride( void ); +BOOL testSetDrainPumpMeasuredCurrentOverride( F32 value ); +BOOL testResetDrainPumpMeasuredCurrentOverride( void ); + +BOOL testSetDrainPumpMeasuredDirectionOverride( U32 value ); +BOOL testResetDrainPumpMeasuredDirectionOverride( void ); + /**@}*/ #endif Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r0c296cef29037819be204c45a23d4d38a52b2718 -r2b9d10664884e9b20d391cc3178d3c85347cdf2c --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 0c296cef29037819be204c45a23d4d38a52b2718) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) @@ -65,7 +65,8 @@ #define HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Heaters voltage out of range time out in milliseconds. #define HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL 0.2F ///< Heaters max voltage out of range tolerance. #define TRIMMER_HEATER_MAX_POWER_W 66.5F ///< Trimmer heater maximum power in Watts. -#define HEATER_CONTROL_CHECK_INTERVAL_COUNT ( ( 30 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Heater control interval count. +#define TRIMMER_HEATER_INITIAL_CONTROL_INTERVAL_COUNT ( ( 10 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Trimmer heater initial control interval count. +#define TRIMMER_HEATER_CONTROL_INTERVAL_COUNT ( ( 30 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Trimmer heater control interval count. #define DELTA_TEMPERATURE_TIME_COSNTANT_C 8.6F ///< Delta temperature calculated from time constant. #define PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C 0.015F ///< Primary heaters duty cycle per temperature in C. @@ -93,11 +94,12 @@ BOOL hasTargetBeenReached; ///< Heater flag to indicate whether the target temperature has been reached. F32 calculatedTemperature; ///< Heater calculated temperature. DG_RESERVOIR_ID_T inactiveRsrvr; ///< Heater inactive reservoir. + U32 controlIntervalCounter; ///< Heater control interval counter. + BOOL isThisFirstControl; ///< Heater is this first control interval. } HEATER_STATUS_T; static HEATER_STATUS_T heatersStatus[ NUM_OF_DG_HEATERS ]; ///< Heaters status. static U32 dataPublicationTimerCounter; ///< Data publication timer counter. -static U32 heaterControlCounter; ///< Heater control counter. static OVERRIDE_U32_T heatersDataPublishInterval = { HEATERS_DATA_PUBLISH_INTERVAL, HEATERS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Heaters data publish time interval. // ********** private function prototypes ********** @@ -125,27 +127,27 @@ * The initHeaters initializes the heaters driver. * @details Inputs: none * @details Outputs: voltageMonitorTimeCounter, heaterStatus, - * hasTreatmentInternalTempBeenSet, dataPublicationTimerCounter, - * trimmerHeaterControlCounter + * hasTreatmentInternalTempBeenSet, dataPublicationTimerCounter * @return none *************************************************************************/ void initHeaters( void ) { DG_HEATERS_T heater; dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; - heaterControlCounter = 0; for ( heater = DG_PRIMARY_HEATER; heater < NUM_OF_DG_HEATERS; heater++ ) { - heatersStatus[ heater ].targetTemp = 0.0F; - heatersStatus[ heater ].state = HEATER_EXEC_STATE_OFF; - heatersStatus[ heater ].startHeaterSignal = FALSE; - heatersStatus[ heater ].isHeaterOn = FALSE; - heatersStatus[ heater ].dutyCycle = 0.0F; - heatersStatus[ heater ].targetFlow = 0.0F; - heatersStatus[ heater ].hasTargetTempChanged = FALSE; - heatersStatus[ heater ].heaterEstGain = HEATERS_NEUTRAL_EST_GAIN; - heatersStatus[ heater ].hasTargetBeenReached = FALSE; + heatersStatus[ heater ].targetTemp = 0.0F; + heatersStatus[ heater ].state = HEATER_EXEC_STATE_OFF; + heatersStatus[ heater ].startHeaterSignal = FALSE; + heatersStatus[ heater ].isHeaterOn = FALSE; + heatersStatus[ heater ].dutyCycle = 0.0F; + heatersStatus[ heater ].targetFlow = 0.0F; + heatersStatus[ heater ].hasTargetTempChanged = FALSE; + heatersStatus[ heater ].heaterEstGain = HEATERS_NEUTRAL_EST_GAIN; + heatersStatus[ heater ].hasTargetBeenReached = FALSE; + heatersStatus[ heater ].controlIntervalCounter = 0; + heatersStatus[ heater ].isThisFirstControl = TRUE; } // Initialize the persistent alarms @@ -534,7 +536,20 @@ { state = HEATER_EXEC_STATE_PRIMARY_RAMP_TO_TARGET; } + else if ( TRUE == heatersStatus[ heater ].hasTargetTempChanged ) + { + F32 inletTemperature = getTemperatureValue( (U32)TEMPSENSORS_HEAT_DISINFECT ); + F32 targetTemperature = heatersStatus[ heater ].targetTemp; + F32 targetFlow = getTargetROPumpFlowRateLPM(); + F32 dutyCycle = calculatePrimaryHeaterDutyCycle( targetTemperature, inletTemperature, targetFlow, TRUE ); + heatersStatus[ heater ].calculatedTemperature = targetTemperature; + heatersStatus[ heater ].targetFlow = targetFlow; + heatersStatus[ heater ].hasTargetTempChanged = FALSE; + + setHeaterDutyCycle( heater, dutyCycle ); + } + return state; } @@ -620,7 +635,7 @@ heatersStatus[ heater ].calculatedTemperature = currentTemperature; heatersStatus[ heater ].inactiveRsrvr = getInactiveReservoir(); heatersStatus[ heater ].targetFlow = targetFlowLPM; - heaterControlCounter = 0; + heatersStatus[ heater ].isThisFirstControl = TRUE; // Cap the minimum duty cycle. So if it is calculated to negative, set it to 0 dutyCycle = MAX( dutyCycle, HEATERS_MIN_DUTY_CYCLE ); @@ -641,28 +656,34 @@ { HEATERS_STATE_T state = HEATER_EXEC_STATE_TRIMMER_CONTROL_TO_TARGET; F32 tempDutyCycle = 0.0F; + DG_HEATERS_T heater = DG_TRIMMER_HEATER; + U32 controlInterval = ( TRUE == heatersStatus[ heater ].isThisFirstControl ? TRIMMER_HEATER_INITIAL_CONTROL_INTERVAL_COUNT : + TRIMMER_HEATER_CONTROL_INTERVAL_COUNT ); // If the inactive reservoir has changed from the last run transition to ramp state to recalculate the // duty cycle for the next delivery - if ( heatersStatus[ DG_TRIMMER_HEATER ].inactiveRsrvr != getInactiveReservoir() ) + if ( heatersStatus[ heater ].inactiveRsrvr != getInactiveReservoir() ) { state = HEATER_EXEC_STATE_TRIMMER_RAMP_TO_TARGET; } - else if ( ++heaterControlCounter > HEATER_CONTROL_CHECK_INTERVAL_COUNT ) + else if ( ++heatersStatus[ heater ].controlIntervalCounter > controlInterval ) { + // Reset the control counter + heatersStatus[ heater ].controlIntervalCounter = 0; + heatersStatus[ heater ].isThisFirstControl = FALSE; + // When the trimmer heater is on, its duty cycle is adjusted at the control interval. For this control check, // dialysate inlet temperature sensor is used rather than the theoretical calculations. F32 outletRedundantTemperature = getTemperatureValue( TEMPSENSORS_OUTLET_REDUNDANT ); - F32 targetTemperature = heatersStatus[ DG_TRIMMER_HEATER ].targetTemp; - F32 targetFlowLPM = heatersStatus[ DG_TRIMMER_HEATER ].targetFlow; + F32 targetTemperature = heatersStatus[ heater ].targetTemp; + F32 targetFlowLPM = heatersStatus[ heater ].targetFlow; F32 dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, outletRedundantTemperature, targetFlowLPM, TRUE ); - heaterControlCounter = 0; - tempDutyCycle = heatersStatus[ DG_TRIMMER_HEATER ].dutyCycle + dutyCycle; + tempDutyCycle = heatersStatus[ heater ].dutyCycle + dutyCycle; tempDutyCycle = MIN( tempDutyCycle, HEATERS_MAX_DUTY_CYCLE ); tempDutyCycle = MAX( tempDutyCycle, HEATERS_MIN_DUTY_CYCLE ); - setHeaterDutyCycle( DG_TRIMMER_HEATER, tempDutyCycle ); + setHeaterDutyCycle( heater, tempDutyCycle ); } return state; @@ -776,11 +797,10 @@ BOOL hasFlowChanged = ( fabs( targetFlow - heatersStatus[ heater ].targetFlow ) > NEARLY_ZERO ? TRUE : FALSE ); // Check if the target flow has changed or the target temperature has changed. - if ( ( TRUE == hasFlowChanged ) || ( TRUE == heatersStatus[ heater ].hasTargetTempChanged ) ) + if ( TRUE == hasFlowChanged ) { - status = TRUE; - heatersStatus[ heater ].targetFlow = targetFlow; - heatersStatus[ heater ].hasTargetTempChanged = FALSE; + status = TRUE; + heatersStatus[ heater ].targetFlow = targetFlow; } return status; Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r0c296cef29037819be204c45a23d4d38a52b2718 -r2b9d10664884e9b20d391cc3178d3c85347cdf2c --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 0c296cef29037819be204c45a23d4d38a52b2718) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) @@ -41,11 +41,12 @@ static U32 valvesStatesPublicationTimerCounter; ///< Timer counter used to schedule valve state publication to CAN bus. static U16 commandedValvesStates = ALL_VALVES_DEENERGIZED; ///< Initialize commanded valves states bit field. -static U32 valveStateMismatchCounter = 0; ///< Initialize valve state mismatch counter. +static U32 valveStateMismatchCounter; ///< Initialize valve state mismatch counter. 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 OVERRIDE_U32_T valveStates[ NUM_OF_VALVES ]; ///< Currently commanded valves states. +static OVERRIDE_U32_T valveStates[ NUM_OF_VALVES ]; ///< Currently commanded valves states. +static OVERRIDE_U32_T valveSensedStates[ NUM_OF_VALVES ]; ///< Valve sensed state override. 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. // ********** private function prototypes ********** @@ -60,7 +61,9 @@ * @brief * The initValves function initializes the Valves module. * @details Inputs: none - * @details Outputs: Valves module initialized + * @details Outputs: valveStates, pendingValveStateChanges, valveSensedStates, + * pendingValveStateChangeCountDowns, valveStateMismatchCounter, + * commandedValvesStates * @return none *************************************************************************/ void initValves( void ) @@ -70,15 +73,20 @@ // initialize commanded valve states for ( i = 0; i < NUM_OF_VALVES; i++ ) { - valveStates[ i ].data = DEENERGIZED; - valveStates[ i ].ovInitData = DEENERGIZED; - valveStates[ i ].ovData = DEENERGIZED; - valveStates[ i ].override = OVERRIDE_RESET; + valveStates[ i ].data = DEENERGIZED; + valveStates[ i ].ovInitData = DEENERGIZED; + valveStates[ i ].ovData = DEENERGIZED; + valveStates[ i ].override = OVERRIDE_RESET; + pendingValveStateChanges[ i ] = DEENERGIZED; + pendingValveStateChangeCountDowns[ i ] = 0; + valveSensedStates[ i ].data = DEENERGIZED; + valveSensedStates[ i ].ovInitData = DEENERGIZED; + valveSensedStates[ i ].ovData = DEENERGIZED; + valveSensedStates[ i ].override = OVERRIDE_RESET; + } - pendingValveStateChanges[ i ] = DEENERGIZED; - pendingValveStateChangeCountDowns[ i ] = 0; - } - commandedValvesStates = fromU32ArrayToU16(); + valveStateMismatchCounter = 0; + commandedValvesStates = fromU32ArrayToU16(); setFPGAValveStates( commandedValvesStates ); // initially set all valves to de-energized state via FPGA valvesStatesPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; // reset valves states publication timer @@ -395,8 +403,8 @@ /*********************************************************************//** * @brief * The getValveStateName function gets the current valve state enum for given valve. - * @details Inputs: valveStates[] - * @details Outputs: none + * @details Inputs: valveStates[], valveSensedStates + * @details Outputs: valveSensedStates * @param valveID ID of valve to get state for * @return the current valve state for given valve in enum *************************************************************************/ @@ -409,6 +417,11 @@ { U32 valveState = getU32OverrideValue( &valveStates[ valveID ] ); + if ( OVERRIDE_KEY == valveSensedStates[ valveID ].override ) + { + valveState = valveSensedStates[ valveID ].ovData; + } + // Convert the bit status of the valve to the valve name switch ( valveID ) { @@ -441,6 +454,15 @@ case VRF: name = ( DEENERGIZED == valveState ? VALVE_STATE_R2_C_TO_NO : VALVE_STATE_R1_C_TO_NC ); break; + } + + if ( OVERRIDE_KEY == valveSensedStates[ valveID ].override ) + { + valveSensedStates[ valveID ].ovData = (U32)name; + } + else + { + valveSensedStates[ valveID ].data = (U32)name; } } else @@ -464,9 +486,15 @@ if ( ++valvesStatesPublicationTimerCounter >= getU32OverrideValue( &valvesStatesPublishInterval ) ) { DG_VALVES_DATA_T data; + U32 i; - data.valvesStatus = getFPGAValveStates(); + data.valvesStatus = getFPGAValveStates(); + for ( i = 0; i < NUM_OF_VALVES; i++ ) + { + data.valvesSensedState[ i ] = getU32OverrideValue( &valveSensedStates[ i ] ); + } + broadcastData( MSG_ID_DG_VALVES_STATES, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( DG_VALVES_DATA_T ) ); valvesStatesPublicationTimerCounter = 0; @@ -600,6 +628,59 @@ } return result; +} + +/*********************************************************************//** + * @brief + * The testSetValveSensedStateOverride function overrides the value of the + * specified sensed state with a given value. + * @details Inputs: none + * @details Outputs: valveSensedStates + * @param valve ID of valve to override for + * @param value override value for the given valve ID + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetValveSensedStateOverride( U32 valve, U32 status ) +{ + BOOL result = FALSE; + + if ( valve < NUM_OF_VALVES ) + { + if ( TRUE == isTestingActivated() ) + { + valveSensedStates[ valve ].ovData = status; + valveSensedStates[ valve ].override = OVERRIDE_KEY; + result = TRUE; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetValveSensedStateOverride function resets the override of + * the specified valve's sensed state. + * @details Inputs: none + * @details Outputs: valveSensedStates + * @param valve ID of valve to reset override state for + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testResetValveSensedStateOverride( U32 valve ) +{ + BOOL result = FALSE; + + if ( valve < NUM_OF_VALVES ) + { + if ( TRUE == isTestingActivated() ) + { + valveSensedStates[ valve ].override = OVERRIDE_RESET; + valveSensedStates[ valve ].ovData = valveSensedStates[ valve ].ovInitData; + result = TRUE; + } + } + + return result; } /**@}*/ Index: firmware/App/Controllers/Valves.h =================================================================== diff -u -r0c296cef29037819be204c45a23d4d38a52b2718 -r2b9d10664884e9b20d391cc3178d3c85347cdf2c --- firmware/App/Controllers/Valves.h (.../Valves.h) (revision 0c296cef29037819be204c45a23d4d38a52b2718) +++ firmware/App/Controllers/Valves.h (.../Valves.h) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) @@ -33,44 +33,47 @@ /// Enumeration of available valve state names per valve type (from SA and DG SRS documents). typedef enum ValveStateNames { - VALVE_STATE_OPEN = 0, ///< Open valve state, used only for VPi, VBf, VRD1, VRD2, and VSP - VALVE_STATE_CLOSED, ///< Closed valve state, used only for VPi, VBf, VRD1, VRD2, and VSP - VALVE_STATE_OPEN_C_TO_NC, ///< Open Common to Normally Closed valve state, used only for VPd - VALVE_STATE_NOFILL_C_TO_NO, ///< No Fill Common to Normally Open valve state, used only for VPo - VALVE_STATE_FILL_C_TO_NC, ///< Fill Common to Normally Closed valve state, used only for VPo - VALVE_STATE_DRAIN_C_TO_NO, ///< Drain Common to Normally Open valve state, used only for VDr and VRc. It is also used for VPd in V3 - VALVE_STATE_RECIRC_C_TO_NC, ///< Recirculate Common to Normally Closed valve state, used only for VDr and VRc - VALVE_STATE_R1_C_TO_NO, ///< Reservoir 1 Common to Normally Open valve state, used only for VRo and VRi - VALVE_STATE_R1_C_TO_NC, ///< Reservoir 1 Common to Normally Closed valve state, used only for VRf - VALVE_STATE_R2_C_TO_NO, ///< Reservoir 2 Common to Normally Open valve state, used only for VRf - VALVE_STATE_R2_C_TO_NC, ///< Reservoir 2 Common to Normally Closed valve state, used only for VRo and VRi - NUM_OF_VALVE_STATES ///< number of valve states + VALVE_STATE_OPEN = 0, ///< Open valve state, used only for VPi, VBf, VRD1, VRD2, and VSP + VALVE_STATE_CLOSED, ///< Closed valve state, used only for VPi, VBf, VRD1, VRD2, and VSP + VALVE_STATE_OPEN_C_TO_NC, ///< Open Common to Normally Closed valve state, used only for VPd + VALVE_STATE_NOFILL_C_TO_NO, ///< No Fill Common to Normally Open valve state, used only for VPo + VALVE_STATE_FILL_C_TO_NC, ///< Fill Common to Normally Closed valve state, used only for VPo + VALVE_STATE_DRAIN_C_TO_NO, ///< Drain Common to Normally Open valve state, used only for VDr and VRc. It is also used for VPd in V3 + VALVE_STATE_RECIRC_C_TO_NC, ///< Recirculate Common to Normally Closed valve state, used only for VDr and VRc + VALVE_STATE_R1_C_TO_NO, ///< Reservoir 1 Common to Normally Open valve state, used only for VRo and VRi + VALVE_STATE_R1_C_TO_NC, ///< Reservoir 1 Common to Normally Closed valve state, used only for VRf + VALVE_STATE_R2_C_TO_NO, ///< Reservoir 2 Common to Normally Open valve state, used only for VRf + VALVE_STATE_R2_C_TO_NC, ///< Reservoir 2 Common to Normally Closed valve state, used only for VRo and VRi + NUM_OF_VALVE_STATES ///< number of valve states } VALVE_STATE_NAMES_T; /// Enumeration of valves. typedef enum Valves { - VRF = 0, ///< Valve Reservoir Fill - VRI, ///< Valve Reservoir Inlet - RSRVD_SPACE, ///< This space has been reserved - VRO, ///< Valve Reservoir Outlet - VPO, ///< Valve Pressure Outlet - VBF, ///< Valve Bypass Filter - VRC, ///< Valve Recirculate - VDR, ///< Valve Drain - VPI, ///< Valve Pressure Inlet - VSP, ///< Valve Sampling Port - VRD1, ///< Valve Reservoir 1 Drain - VRD2, ///< Valve Reservoir 2 Drain - VPD, ///< Valve Production Drain - NUM_OF_VALVES ///< Number of valves + VRF = 0, ///< Valve Reservoir Fill + VRI, ///< Valve Reservoir Inlet + RSRVD_SPACE, ///< This space has been reserved + VRO, ///< Valve Reservoir Outlet + VPO, ///< Valve Pressure Outlet + VBF, ///< Valve Bypass Filter + VRC, ///< Valve Recirculate + VDR, ///< Valve Drain + VPI, ///< Valve Pressure Inlet + VSP, ///< Valve Sampling Port + VRD1, ///< Valve Reservoir 1 Drain + VRD2, ///< Valve Reservoir 2 Drain + VPD, ///< Valve Production Drain + NUM_OF_VALVES ///< Number of valves } VALVES_T; +#pragma pack(push, 1) /// Valves publish structure typedef struct { - U16 valvesStatus; ///< DG valves status. -} DG_VALVES_DATA_T; + U16 valvesStatus; ///< DG valves status. + U08 valvesSensedState[ NUM_OF_VALVES ]; ///< DG valves sensed states. +} DG_VALVES_DATA_T; +#pragma pack(pop) // ********** public function prototypes ********** @@ -82,9 +85,13 @@ VALVE_STATE_NAMES_T getValveStateName( VALVES_T valveID ); BOOL testSetValvesStatesPublishIntervalOverride( U32 value ); -BOOL testResetValvesStatesPublishIntervalOverride( void ); +BOOL testResetValvesStatesPublishIntervalOverride( void ); + BOOL testSetValveStateOverride( U32 valve, U32 state ); -BOOL testResetValveStateOverride( U32 valveID ); +BOOL testResetValveStateOverride( U32 valveID ); + +BOOL testSetValveSensedStateOverride( U32 valve, U32 status ); +BOOL testResetValveSensedStateOverride( U32 valve ); /**@}*/ Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r61fc45d7a43557312d6abd00a6b01e6823b44f04 -r2b9d10664884e9b20d391cc3178d3c85347cdf2c --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 61fc45d7a43557312d6abd00a6b01e6823b44f04) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) @@ -232,6 +232,7 @@ { checkRORejectionRatio(); checkDialysateTemperatureSensors(); + setHeaterTargetTemperature( DG_PRIMARY_HEATER, getPrimaryHeaterTargetTemperature() ); fillState = ( TRUE == areInletWaterConditionsAlarmsActive() ? DG_FILL_MODE_STATE_PAUSED : fillState ); @@ -731,14 +732,20 @@ static DG_FILL_MODE_STATE_T handleDeliverDialysateState( void ) { DG_ACID_CONCENTRATES_RECORD_T acid; - F32 acidMix; DG_BICARB_CONCENTRATES_RECORD_T bicarb; - F32 bicarbMix; - DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; - DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); - F32 acidConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); - F32 bicarbConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); + F32 acidMix = 0.0F; + F32 bicarbMix = 0.0F; + DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; + DG_RESERVOIR_ID_T inactiveRsrvr = getInactiveReservoir(); + F32 acidConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); + F32 bicarbConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); + F32 inletTemperature = getTemperatureValue( (U32)TEMPSENSORS_CONDUCTIVITY_SENSOR_2 ); + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + { + inletTemperature = getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); + } + getAcidConcentrateCalRecord( &acid ); getBicarbConcentrateCalRecord( &bicarb ); @@ -769,7 +776,7 @@ // DG is delivering dialysate keep collecting the sample counter and the measured flow fillStatus.fillSampleCounter += 1; fillStatus.fillFlowRateRunningSum += getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); - fillStatus.fillTemperatureRunningSum += getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); + fillStatus.fillTemperatureRunningSum += inletTemperature; // TODO: Check for open straw door status and alarm if closed // Check if run out of time to fill the reservoir @@ -779,9 +786,9 @@ } // If we've reached our target fill to volume (by weight), we're done filling - go back to generation idle mode // SRSDG 398 - if ( TRUE == hasTargetFillVolumeBeenReached( inactiveReservoir ) ) + if ( TRUE == hasTargetFillVolumeBeenReached( inactiveRsrvr ) ) { - F32 filledVolumeML = getReservoirWeight( inactiveReservoir ) - reservoirBaseWeight; + F32 filledVolumeML = getReservoirWeight( inactiveRsrvr ) - reservoirBaseWeight; F32 integratedVolumeToLoadCellReadingPercent = fabs( 1.0F - ( filledVolumeML / integratedVolumeML ) ); F32 avgAcidConductivity = acidConductivityTotal / conductivitySampleCount; F32 avgBicarbConductivity = bicarbConductivityTotal / conductivitySampleCount; @@ -830,7 +837,7 @@ fillStatus.fillFlowRateRunningSum = 0.0F; fillStatus.fillTemperatureRunningSum = 0.0F; fillStatus.fillSampleCounter = 0; - fillStatus.fillLastTemperature = getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); + fillStatus.fillLastTemperature = inletTemperature; calculateHeaterEstimationGain( DG_PRIMARY_HEATER ); requestNewOperationMode( DG_MODE_GENE ); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r61fc45d7a43557312d6abd00a6b01e6823b44f04 -r2b9d10664884e9b20d391cc3178d3c85347cdf2c --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 61fc45d7a43557312d6abd00a6b01e6823b44f04) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) @@ -1068,6 +1068,10 @@ handleTestROPumpDutyCycleOverride( message ); break; + case MSG_ID_DG_VALVES_SENSED_STATE_OVERRIDE: + handleTestDGValvesSensedStateOverrideRequest( message ); + break; + case MSG_ID_DG_SET_RO_PUMP_TARGET_FLOW: handleTestROPumpTargetFlowOverride( message ); break; @@ -1204,6 +1208,14 @@ handleTestTareReservoirRequest( message ); break; + case MSG_ID_DG_DRAIN_PUMP_CURRENT_OVERRIDE: + handleTestDGDrainPumpCurrentOverrideRequest( message ); + break; + + case MSG_ID_DG_DRAIN_PUMP_DIRECTION_OVERRIDE: + handleTestDGDrainPumpDirectionOverrideRequest( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r61fc45d7a43557312d6abd00a6b01e6823b44f04 -r2b9d10664884e9b20d391cc3178d3c85347cdf2c --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 61fc45d7a43557312d6abd00a6b01e6823b44f04) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) @@ -2964,8 +2964,6 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } - - /*********************************************************************//** * @brief * The handleGetDGCalibrationRecord function handles a request to get the DG @@ -3372,6 +3370,7 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } + /*********************************************************************//** * The handleSetFansDutyCycleOverrideRequest function handles a * request to override the fans duty cycle. @@ -3508,7 +3507,7 @@ * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestHDCommunicationStatusOverrideRequest(MESSAGE_T *message) +void handleTestHDCommunicationStatusOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; @@ -3565,6 +3564,101 @@ } /*********************************************************************//** +* The handleTestDGDrainPumpCurrentOverrideRequest function handles a +* request to override the drain pump measured current. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestDGDrainPumpCurrentOverrideRequest( 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 = testSetDrainPumpMeasuredCurrentOverride( payload.state.f32 ); + } + else + { + result = testResetDrainPumpMeasuredCurrentOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* The handleTestDGDrainPumpDirectionOverrideRequest function handles a +* request to override the drain pump measured direction. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestDGDrainPumpDirectionOverrideRequest( 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 = testSetDrainPumpMeasuredDirectionOverride( payload.state.u32 ); + } + else + { + result = testResetDrainPumpMeasuredDirectionOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* The handleTestDGValvesSensedStateOverrideRequest function handles a +* request to override the valves sensed state. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestDGValvesSensedStateOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetValveSensedStateOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetValveSensedStateOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief * The handleGetDGUsageInfoRecord function handles a request to get the DG * usage information record. Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r61fc45d7a43557312d6abd00a6b01e6823b44f04 -r2b9d10664884e9b20d391cc3178d3c85347cdf2c --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 61fc45d7a43557312d6abd00a6b01e6823b44f04) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) @@ -403,6 +403,15 @@ // MSG_ID_HD_OP_MODE BOOL handleSetHDOperationMode( MESSAGE_T *message ); +// MSG_ID_DG_DRAIN_PUMP_CURRENT_OVERRIDE +void handleTestDGDrainPumpCurrentOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DG_DRAIN_PUMP_DIRECTION_OVERRIDE +void handleTestDGDrainPumpDirectionOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DG_VALVES_SENSED_STATE_OVERRIDE +void handleTestDGValvesSensedStateOverrideRequest( MESSAGE_T *message ); + /**@}*/ #endif