Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -rc548570b37339819da825092dd07c7081437f30b -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision c548570b37339819da825092dd07c7081437f30b) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -33,9 +33,9 @@ // ********** private data ********** -static OVERRIDE_U32_T measuredLoadCellReadingsRaw[ NUM_OF_LOAD_CELLS ]; ///< Latest measured raw load cell readings. +static U32 measuredLoadCellReadingsRaw[ NUM_OF_LOAD_CELLS ]; ///< Latest measured raw load cell readings. static U32 measuredLoadCellReadingsSum[ NUM_OF_LOAD_CELLS ]; ///< Raw load cell sums for averaging. -static F32 filteredLoadCellWeights[ NUM_OF_LOAD_CELLS ]; ///< Latest filtered load cell weights. +static OVERRIDE_F32_T filteredLoadCellWeights[ NUM_OF_LOAD_CELLS ]; ///< Latest filtered load cell weights. static U32 loadCellDataPublicationTimerCounter = 0; ///< used to schedule load cell data publication to CAN bus. // ********** private function prototypes ********** @@ -54,14 +54,14 @@ for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) { - measuredLoadCellReadingsRaw[ i ].data = 0; - measuredLoadCellReadingsRaw[ i ].ovData = 0; - measuredLoadCellReadingsRaw[ i ].ovInitData = 0; - measuredLoadCellReadingsRaw[ i ].override = OVERRIDE_RESET; + filteredLoadCellWeights[ i ].data = 0.0; + filteredLoadCellWeights[ i ].ovData = 0.0; + filteredLoadCellWeights[ i ].ovInitData = 0.0; + filteredLoadCellWeights[ i ].override = OVERRIDE_RESET; measuredLoadCellReadingsSum[ i ] = 0; - filteredLoadCellWeights[ i ] = 0.0; + measuredLoadCellReadingsRaw[ i ] = 0.0; } } @@ -76,27 +76,28 @@ void execLoadCell(void) { // get latest raw load cell readings - measuredLoadCellReadingsRaw[ LOAD_CELL_A1 ].data = getFPGALoadCellA1(); - measuredLoadCellReadingsRaw[ LOAD_CELL_A2 ].data = getFPGALoadCellA2(); - measuredLoadCellReadingsRaw[ LOAD_CELL_B1 ].data = getFPGALoadCellB1(); - measuredLoadCellReadingsRaw[ LOAD_CELL_B2 ].data = getFPGALoadCellB2(); + measuredLoadCellReadingsRaw[ LOAD_CELL_A1 ] = getFPGALoadCellA1(); + measuredLoadCellReadingsRaw[ LOAD_CELL_A2 ] = getFPGALoadCellA2(); + measuredLoadCellReadingsRaw[ LOAD_CELL_B1 ] = getFPGALoadCellB1(); + measuredLoadCellReadingsRaw[ LOAD_CELL_B2 ] = getFPGALoadCellB2(); // update sums for load cell average calculations - measuredLoadCellReadingsSum[ LOAD_CELL_A1 ] += getMeasuredRawLoadCellReading( LOAD_CELL_A1 ); - measuredLoadCellReadingsSum[ LOAD_CELL_A2 ] += getMeasuredRawLoadCellReading( LOAD_CELL_A2 ); - measuredLoadCellReadingsSum[ LOAD_CELL_B1 ] += getMeasuredRawLoadCellReading( LOAD_CELL_B1 ); - measuredLoadCellReadingsSum[ LOAD_CELL_B2 ] += getMeasuredRawLoadCellReading( LOAD_CELL_B2 ); + measuredLoadCellReadingsSum[ LOAD_CELL_A1 ] += measuredLoadCellReadingsRaw[ LOAD_CELL_A1 ]; + measuredLoadCellReadingsSum[ LOAD_CELL_A2 ] += measuredLoadCellReadingsRaw[ LOAD_CELL_A2 ]; + measuredLoadCellReadingsSum[ LOAD_CELL_B1 ] += measuredLoadCellReadingsRaw[ LOAD_CELL_B1 ]; + measuredLoadCellReadingsSum[ LOAD_CELL_B2 ] += measuredLoadCellReadingsRaw[ LOAD_CELL_B2 ]; + // broadcast load cell data if we are at scheduled interval. if ( ++loadCellDataPublicationTimerCounter == LOAD_CELL_REPORT_PERIOD ) { loadCellDataPublicationTimerCounter = 0; // calculate load cell average weights - filteredLoadCellWeights[ LOAD_CELL_A1 ] = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_A1 ]) * ADC2GRAM; // division for averaging folded into ADC2GRAM - filteredLoadCellWeights[ LOAD_CELL_A2 ] = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_A2 ]) * ADC2GRAM; - filteredLoadCellWeights[ LOAD_CELL_B1 ] = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_B1 ]) * ADC2GRAM; - filteredLoadCellWeights[ LOAD_CELL_B2 ] = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_B2 ]) * ADC2GRAM; + filteredLoadCellWeights[ LOAD_CELL_A1 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_A1 ]) * ADC2GRAM; // division for averaging folded into ADC2GRAM + filteredLoadCellWeights[ LOAD_CELL_A2 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_A2 ]) * ADC2GRAM; + filteredLoadCellWeights[ LOAD_CELL_B1 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_B1 ]) * ADC2GRAM; + filteredLoadCellWeights[ LOAD_CELL_B2 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_B2 ]) * ADC2GRAM; // broadcast load cell data - broadcastLoadCellData( filteredLoadCellWeights[ LOAD_CELL_A1 ], filteredLoadCellWeights[ LOAD_CELL_A2 ], - filteredLoadCellWeights[ LOAD_CELL_B1 ], filteredLoadCellWeights[ LOAD_CELL_B2 ] ); + broadcastLoadCellData( getLoadCellFilteredWeight( LOAD_CELL_A1 ), getLoadCellFilteredWeight( LOAD_CELL_A2 ), + getLoadCellFilteredWeight( LOAD_CELL_B1 ), getLoadCellFilteredWeight( LOAD_CELL_B2 ) ); // reset sums for next averaging measuredLoadCellReadingsSum[ LOAD_CELL_A1 ] = 0; measuredLoadCellReadingsSum[ LOAD_CELL_A2 ] = 0; @@ -107,27 +108,27 @@ /************************************************************************* * @brief - * The getMeasuredRawLoadCellReading function gets the measured raw load cell \n - * reading for a given load cell ID. + * The getLoadCellFilteredWeight function gets the measured filtered load cell \n + * weight for a given load cell ID. * @details - * Inputs : measuredLoadCellReadingsRaw + * Inputs : filteredLoadCellWeights[] * Outputs : none - * @param loadCellID : ID of load cell to get raw reading for. - * @return the measured raw load cell reading for the given load cell ID. + * @param loadCellID : ID of load cell to get filtered weight for. + * @return the filtered load cell weight for the given load cell ID. *************************************************************************/ -U32 getMeasuredRawLoadCellReading( U32 loadCellID ) +U32 getLoadCellFilteredWeight( U32 loadCellID ) { U32 result = 0; if ( loadCellID < NUM_OF_LOAD_CELLS ) { - if ( OVERRIDE_KEY == measuredLoadCellReadingsRaw[ loadCellID ].override ) + if ( OVERRIDE_KEY == filteredLoadCellWeights[ loadCellID ].override ) { - result = measuredLoadCellReadingsRaw[ loadCellID ].ovData; + result = filteredLoadCellWeights[ loadCellID ].ovData; } else { - result = measuredLoadCellReadingsRaw[ loadCellID ].data; + result = filteredLoadCellWeights[ loadCellID ].data; } } else @@ -138,33 +139,7 @@ return result; } -/************************************************************************* - * @brief - * The getLoadCellFilteredWeight function gets the measured filtered load cell \n - * weight for a given load cell ID. - * @details - * Inputs : Load_cell_a1_ave[] - * Outputs : none - * @param loadCellID : ID of load cell to get filtered weight for. - * @return the measured filtered load cell weight for the given load cell ID. - *************************************************************************/ -F32 getLoadCellFilteredWeight( LOAD_CELL_ID_T loadCellID ) -{ - F32 result = 0; - if ( loadCellID < NUM_OF_LOAD_CELLS ) - { - result = filteredLoadCellWeights[ loadCellID ]; - } - else - { - activateAlarmNoData( ALARM_ID_SOFTWARE_FAULT ); - } - - return result; -} - - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -176,20 +151,20 @@ * load cell A1. * @details * Inputs : none - * Outputs : measuredLoadCellReadingsRaw[] - * @param value : override measured load cell reading + * Outputs : filteredLoadCellWeights[] + * @param value : override filtered load cell weight * @param loadCellID : ID of the load cell to override. * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetLoadCellOverride( U32 value, U32 loadCellID ) +BOOL testSetLoadCellOverride( F32 value, U32 loadCellID ) { BOOL result = FALSE; if ( TRUE == isTestingActivated() ) { result = TRUE; - measuredLoadCellReadingsRaw[ loadCellID ].ovData = value; - measuredLoadCellReadingsRaw[ loadCellID ].override = OVERRIDE_KEY; + filteredLoadCellWeights[ loadCellID ].ovData = value; + filteredLoadCellWeights[ loadCellID ].override = OVERRIDE_KEY; } return result; @@ -201,7 +176,7 @@ * load cell A1. * @details * Inputs : none - * Outputs : measuredLoadCellReadingsRaw[] + * Outputs : filteredLoadCellWeights[] * @param loadCellID : ID of the load cell to override. * @return TRUE if reset successful, FALSE if not *************************************************************************/ @@ -212,8 +187,8 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - measuredLoadCellReadingsRaw[ loadCellID ].override = OVERRIDE_RESET; - measuredLoadCellReadingsRaw[ loadCellID ].ovData = measuredLoadCellReadingsRaw[ loadCellID ].ovInitData; + filteredLoadCellWeights[ loadCellID ].override = OVERRIDE_RESET; + filteredLoadCellWeights[ loadCellID ].ovData = filteredLoadCellWeights[ loadCellID ].ovInitData; } return result; Index: firmware/App/Controllers/LoadCell.h =================================================================== diff -u -rdd3356035996866e5db7678d352f933fc22ad789 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Controllers/LoadCell.h (.../LoadCell.h) (revision dd3356035996866e5db7678d352f933fc22ad789) +++ firmware/App/Controllers/LoadCell.h (.../LoadCell.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -45,10 +45,9 @@ void initLoadCell( void ); // Initialize the LoadCell module. void execLoadCell( void ); // Execute the LoadCell monitor. -DATA_ARRAY_GET_PROTOTYPE( U32, getMeasuredRawLoadCellReading, loadCellID ); -F32 getLoadCellFilteredWeight( LOAD_CELL_ID_T loadCellID ); +DATA_ARRAY_GET_PROTOTYPE( U32, getLoadCellFilteredWeight, loadCellID ); -BOOL testSetLoadCellOverride( U32 value, U32 loadCellID ); +BOOL testSetLoadCellOverride( F32 value, U32 loadCellID ); BOOL testResetLoadCellOverride( U32 loadCellID ); /**@}*/ Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rc548570b37339819da825092dd07c7081437f30b -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision c548570b37339819da825092dd07c7081437f30b) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -85,8 +85,8 @@ static OVERRIDE_U32_T roPumpDataPublishInterval = { 0, 0, 0, 0 }; ///< interval (in ms) at which to publish RO flow data to CAN bus. static OVERRIDE_U32_T targetROPumpPressure = { 0, 0, 0, 0 }; ///< Target RO pressure (in PSI). -static OVERRIDE_F32_T measuredROPumpPressure = { 0.0, 0.0, 0.0, 0 }; ///< measured RO pressure (in PSI). static OVERRIDE_F32_T measuredROFlowRateLPM = { 0.0, 0.0, 0.0, 0 }; ///< measured RO flow rate (in LPM). +static F32 measuredROPumpPressure = 0.0; ///< measured RO pressure (in PSI). static U32 roControlTimerCounter = 0; ///< determines when to perform control on ro pump @@ -185,20 +185,19 @@ void execROPumpMonitor( void ) { S32 roFlow = (S32)getFPGAROPumpFlowRate(); - F32 roPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); measuredROFlowRateLPM.data = (F32)(roFlow) * RO_FLOW_ADC_TO_LPM_FACTOR; - measuredROPumpPressure.data = (F32)((S16)roPressure); + measuredROPumpPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); // check RO flow // TODO - check flow // check pressure while RO pump is on if ( TRUE == isROPumpOn ) { - if ( roPressure < MIN_RO_PRESSURE || roPressure > MAX_RO_PRESSURE ) + if ( measuredROPumpPressure < MIN_RO_PRESSURE || measuredROPumpPressure > MAX_RO_PRESSURE ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_RO_PUMP_OUT_PRESSURE_OUT_OF_RANGE, roPressure ) // TODO - add persistence + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_RO_PUMP_OUT_PRESSURE_OUT_OF_RANGE, measuredROPumpPressure ) // TODO - add persistence } } @@ -290,7 +289,7 @@ if ( roPumpControlModeSet == PUMP_CONTROL_MODE_CLOSED_LOOP ) { F32 tgtPres = (F32)getTargetROPumpPressure(); - F32 actPres = getMeasuredROPumpPressure(); + F32 actPres = measuredROPumpPressure; F32 newPWM; newPWM = runPIController( PI_CONTROLLER_ID_RO_PUMP, tgtPres, actPres ); @@ -387,28 +386,6 @@ /*********************************************************************//** * @brief - * The getMeasuredROPumpPressure function gets the measured RO pump \n - * pressure. - * @details - * Inputs : measuredROPumpPressure - * Outputs : none - * @param none - * @return the current RO pressure (in PSI). - *************************************************************************/ -F32 getMeasuredROPumpPressure( void ) -{ - F32 result = measuredROPumpPressure.data; - - if ( OVERRIDE_KEY == measuredROPumpPressure.override ) - { - result = measuredROPumpPressure.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief * The getMeasuredROFlowRate function gets the measured RO pump \n * flow rate. * @details Index: firmware/App/Controllers/ROPump.h =================================================================== diff -u -r416a8fba5774e6cd64c69513e082afbd79f75ccf -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision 416a8fba5774e6cd64c69513e082afbd79f75ccf) +++ firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -38,19 +38,18 @@ void execROPumpMonitor( void ); void execROPumpController( void ); -BOOL setROPumpTargetPressure( U32 flowRate, PUMP_CONTROL_MODE_T mode ); +BOOL setROPumpTargetPressure( U32 roPressure, PUMP_CONTROL_MODE_T mode ); void signalROPumpHardStop( void ); SELF_TEST_STATUS_T execROPumpTest( void ); DATA_GET_PROTOTYPE( U32, getTargetROPumpPressure ); -DATA_GET_PROTOTYPE( F32, getMeasuredROPumpPressure); DATA_GET_PROTOTYPE( F32, getMeasuredROFlowRate ); BOOL testSetROPumpDataPublishIntervalOverride( U32 value ); BOOL testResetROPumpDataPublishIntervalOverride( void ); -BOOL testSetTargetROPressureOverride( S32 value ); -BOOL testResetTargetROPressureOverride( void ); +BOOL testSetTargetROPumpPressureOverride( S32 value ); +BOOL testResetTargetROPumpPressureOverride( void ); BOOL testSetMeasuredROFlowRateOverride( F32 value ); BOOL testResetMeasuredROFlowRateOverride( void ); Index: firmware/App/Modes/ModeChemicalDisinfect.c =================================================================== diff -u -r138efd92a8645e0d2fe422409ef5a33dd2929a25 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 138efd92a8645e0d2fe422409ef5a33dd2929a25) +++ firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -17,48 +17,74 @@ #include "ModeChemicalDisinfect.h" #include "OperationModes.h" +/** + * @addtogroup ChemicalDisinfectMode + * @{ + */ + +// ********** private definitions ********** + +/// Enumeration of chem. disinfect mode states. +typedef enum Chem_States +{ + CHEM_DISINFECT_STATE_START = 0, ///< Start chemical disinfect mode state. + NUM_OF_CHEM_DISINFECT_STATES ///< Number of chemical disinfect mode states. +} CHEM_DISINFECT_STATE_T; + // ********** private data ********** +static CHEM_DISINFECT_STATE_T chemState = CHEM_DISINFECT_STATE_START; ///< Currently active chemical disinfect state. + // ********** private function prototypes ********** -/************************************************************************* +/*********************************************************************//** * @brief * The initChemicalDisinfectMode function initializes the chemical disinfect Mode module. * @details * Inputs : none * Outputs : Module initialized. - * @param none * @return none *************************************************************************/ void initChemicalDisinfectMode( void ) { + chemState = CHEM_DISINFECT_STATE_START; } -/************************************************************************* +/*********************************************************************//** * @brief * The transitionToChemicalDisinfectMode function prepares for transition to \n * chemical disinfect mode. * @details * Inputs : none * Outputs : none - * @param none * @return none *************************************************************************/ void transitionToChemicalDisinfectMode( void ) { + initChemicalDisinfectMode(); } -/************************************************************************* +/*********************************************************************//** * @brief * The execChemicalDisinfectMode function executes the chemical disinfect Mode state machine. * @details * Inputs : none * Outputs : none - * @param none * @return none *************************************************************************/ void execChemicalDisinfectMode( void ) { + // execute current chemical disinfect state + switch ( chemState ) + { + case CHEM_DISINFECT_STATE_START: + break; + default: + chemState = CHEM_DISINFECT_STATE_START; + // TODO - s/w fault + break; + } } +/**@}*/ Index: firmware/App/Modes/ModeChemicalDisinfect.h =================================================================== diff -u -r138efd92a8645e0d2fe422409ef5a33dd2929a25 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeChemicalDisinfect.h (.../ModeChemicalDisinfect.h) (revision 138efd92a8645e0d2fe422409ef5a33dd2929a25) +++ firmware/App/Modes/ModeChemicalDisinfect.h (.../ModeChemicalDisinfect.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -19,10 +19,21 @@ #include "DGCommon.h" +/** + * @defgroup ChemicalDisinfectMode ChemicalDisinfectMode + * @brief Chemical disinfect mode module. + * Manages chemical disinfect mode functions via a state machine. + * + * @addtogroup ChemicalDisinfectMode + * @{ + */ + // ********** private function prototypes ********** void initChemicalDisinfectMode( void ); // initialize this module void transitionToChemicalDisinfectMode( void ); // prepares for transition to chemical disinfection mode void execChemicalDisinfectMode( void ); // execute the chemical disinfection mode state machine (call from OperationModes) +/**@}*/ + #endif Fisheye: Tag c48a99d2d1c852adcc986253b6c420a90dab7bfe refers to a dead (removed) revision in file `firmware/App/Modes/ModeDisinfect.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag c48a99d2d1c852adcc986253b6c420a90dab7bfe refers to a dead (removed) revision in file `firmware/App/Modes/ModeDisinfect.h'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r499e5de29e706d09f79ba22511068990c4044e84 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 499e5de29e706d09f79ba22511068990c4044e84) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -14,51 +14,109 @@ * **************************************************************************/ +#include "DrainPump.h" #include "ModeDrain.h" #include "OperationModes.h" +/** + * @addtogroup DrainMode + * @{ + */ + +// ********** private definitions ********** + +#define TARGET_DRAIN_PUMP_RPM 2000 ///< Target drain pump speed. + +/// Enumeration of drain mode states. +typedef enum Drain_States +{ + DRAIN_STATE_START = 0, ///< Start drain mode state. + DRAIN_STATE_DRAIN, ///< Drain drain mode state. + NUM_OF_DRAIN_STATES ///< Number of drain mode states. +} DRAIN_STATE_T; + // ********** private data ********** +static DRAIN_STATE_T drainState = DRAIN_STATE_START; ///< Currently active drain state. + // ********** private function prototypes ********** -/************************************************************************* - * @brief initDrainMode +static DRAIN_STATE_T handleDrainState( void ); + +/*********************************************************************//** + * @brief * The initOpParamsMode function initializes the Drain Mode module. * @details * Inputs : none * Outputs : Operating Parameters Mode module initialized. - * @param none * @return none *************************************************************************/ void initDrainMode( void ) { + drainState = DRAIN_STATE_START; } -/************************************************************************* - * @brief transitionToDrainMode +/*********************************************************************//** + * @brief * The transitionToDrainMode function prepares for transition to drain \n * mode. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void transitionToDrainMode( void ) { + // re-initialize each time we transition to drain mode + initDrainMode(); + + // TODO - set initial actuator states + // VDr to drain } -/************************************************************************* - * @brief execDrainMode +/*********************************************************************//** + * @brief * The execDrainMode function executes the Drain Mode state machine. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void execDrainMode( void ) { + // execute current drain state + switch ( drainState ) + { + case DRAIN_STATE_START: + setDrainPumpTargetSpeed( TARGET_DRAIN_PUMP_RPM ); + drainState = DRAIN_STATE_DRAIN; + break; + case DRAIN_STATE_DRAIN: + drainState = handleDrainState(); + break; + + default: + drainState = DRAIN_STATE_START; + // TODO - s/w fault + break; + } } +/*********************************************************************//** + * @brief + * The handleDrainState function handles the drain state of the Drain Mode \n + * state machine. + * @details + * Inputs : none + * Outputs : + * @return the next state + *************************************************************************/ +static DRAIN_STATE_T handleDrainState( void ) +{ + DRAIN_STATE_T result = DRAIN_STATE_DRAIN; + + return result; +} + +/**@}*/ Index: firmware/App/Modes/ModeDrain.h =================================================================== diff -u -rb64c49fdcf2b6d95e61e63f8e258c4e600935bbd -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeDrain.h (.../ModeDrain.h) (revision b64c49fdcf2b6d95e61e63f8e258c4e600935bbd) +++ firmware/App/Modes/ModeDrain.h (.../ModeDrain.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -8,7 +8,7 @@ * @file ModeDrain.h * * @date 19-Sep-2019 - * @author L. Baloa + * @author S. Nash * * @brief Header file for Drain Mode. * @@ -19,10 +19,21 @@ #include "DGCommon.h" +/** + * @defgroup DrainMode DrainMode + * @brief Drain mode module. + * Manages drain mode functions via a state machine. + * + * @addtogroup DrainMode + * @{ + */ + // ********** private function prototypes ********** void initDrainMode( void ); // initialize this module void transitionToDrainMode( void ); // prepares for transition to operating parameters mode void execDrainMode( void ); // execute the drain mode state machine +/**@}*/ + #endif Index: firmware/App/Modes/ModeFault.c =================================================================== diff -u -r499e5de29e706d09f79ba22511068990c4044e84 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision 499e5de29e706d09f79ba22511068990c4044e84) +++ firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -17,46 +17,72 @@ #include "OperationModes.h" #include "ModeFault.h" +/** + * @addtogroup FaultMode + * @{ + */ + +// ********** private definitions ********** + +/// Enumeration of fault mode states. +typedef enum Fault_States +{ + FAULT_STATE_START = 0, ///< Start solo fault state. + NUM_OF_FAULT_STATES ///< Number of fault mode states. +} FAULT_STATE_T; + // ********** private data ********** +static FAULT_STATE_T faultState = FAULT_STATE_START; ///< Currently active fault state. + // ********** private function prototypes ********** -/************************************************************************* - * @brief initFaultMode +/*********************************************************************//** + * @brief * The initFaultMode function initializes the Fault Mode module. * @details * Inputs : none * Outputs : Fault Mode module initialized. - * @param none * @return none *************************************************************************/ void initFaultMode( void ) { + faultState = FAULT_STATE_START; } -/************************************************************************* - * @brief transitionToFaultMode +/*********************************************************************//** + * @brief * The transitionToFaultMode function prepares for transition to fault mode. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void transitionToFaultMode( void ) { } -/************************************************************************* - * @brief execFaultMode +/*********************************************************************//** + * @brief * The execFaultMode function executes the Fault Mode state machine. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void execFaultMode( void ) { + // execute current fault state + switch ( faultState ) + { + case FAULT_STATE_START: + break; + + default: + faultState = FAULT_STATE_START; + // TODO - s/w fault + break; + } } +/**@}*/ Index: firmware/App/Modes/ModeFault.h =================================================================== diff -u -rb64c49fdcf2b6d95e61e63f8e258c4e600935bbd -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision b64c49fdcf2b6d95e61e63f8e258c4e600935bbd) +++ firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -19,10 +19,21 @@ #include "DGCommon.h" +/** + * @defgroup FaultMode FaultMode + * @brief Fault mode module. + * Manages fault mode functions via a state machine. + * + * @addtogroup FaultMode + * @{ + */ + // ********** private function prototypes ********** void initFaultMode( void ); // initialize this module void transitionToFaultMode( void ); // prepares for transition to fault mode void execFaultMode( void ); // execute the fault mode state machine (call from OperationModes) +/**@}*/ + #endif Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -rf43eb1e9e0803776ec7420b16e1db8760b020bd9 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision f43eb1e9e0803776ec7420b16e1db8760b020bd9) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -14,6 +14,7 @@ * **************************************************************************/ +#include "FPGA.h" #include "OperationModes.h" #include "Timers.h" #include "ModeFill.h" @@ -32,12 +33,10 @@ #define QUARTER_SECOND 250 #define HALF_SECOND 500 -/// Enumberation of fill mode states. +/// Enumeration of fill mode states. typedef enum Fill_Mode_States { FILL_MODE_STATE_START = 0, ///< Start fill mode state. - FILL_MODE_STATE_CHECK_INLET_WATER, ///< Check inlet water state. - FILL_MODE_STATE_CREATE_PRODUCT_WATER, ///< Create product water state. FILL_MODE_STATE_DIALYSATE_PRODUCTION, ///< Dialysate production state. FILL_MODE_STATE_DELIVER_DIALYSATE, ///< Deliver dialysate state. NUM_OF_FILL_MODE_STATES ///< Number of fill mode states. @@ -49,8 +48,6 @@ // ********** private function prototypes ********** -static FILL_MODE_STATE_T handleCheckInletWaterState( void ); -static FILL_MODE_STATE_T handleCreateProductWaterState( void ); static FILL_MODE_STATE_T handleDialysateProductionState( void ); static FILL_MODE_STATE_T handleDeliverDialysateState( void ); @@ -78,7 +75,13 @@ *************************************************************************/ void transitionToFillMode( void ) { - fillState = FILL_MODE_STATE_START; + // re-initialize fill mode each time we transition to fill mode + initFillMode(); + + // TODO - set initial actuator states + setFPGAValveStates(0x014F); + // VDr, VPo to drain + // Conc. pumps on } /*********************************************************************//** @@ -95,17 +98,9 @@ switch ( fillState ) { case FILL_MODE_STATE_START: - fillState = FILL_MODE_STATE_CHECK_INLET_WATER; + fillState = FILL_MODE_STATE_DIALYSATE_PRODUCTION; break; - case FILL_MODE_STATE_CHECK_INLET_WATER: - fillState = handleCheckInletWaterState(); - break; - - case FILL_MODE_STATE_CREATE_PRODUCT_WATER: - fillState = handleCreateProductWaterState(); - break; - case FILL_MODE_STATE_DIALYSATE_PRODUCTION: fillState = handleDialysateProductionState(); break; @@ -123,40 +118,6 @@ /*********************************************************************//** * @brief - * The handleCheckInletWaterState function executes the Check Inlet Water \n - * state of the Fill Mode state machine. - * @details - * Inputs : none - * Outputs : - * @param none - * @return the next state - *************************************************************************/ -static FILL_MODE_STATE_T handleCheckInletWaterState( void ) -{ - FILL_MODE_STATE_T result = FILL_MODE_STATE_CHECK_INLET_WATER; - - return result; -} - -/*********************************************************************//** - * @brief - * The handleCreateProductWaterState function executes the Create Product \n - * Water state of the Fill Mode state machine. - * @details - * Inputs : none - * Outputs : - * @param none - * @return the next state - *************************************************************************/ -static FILL_MODE_STATE_T handleCreateProductWaterState( void ) -{ - FILL_MODE_STATE_T result = FILL_MODE_STATE_CREATE_PRODUCT_WATER; - - return result; -} - -/*********************************************************************//** - * @brief * The handleDialysateProductionState function executes the Dialysate Production \n * state of the Fill Mode state machine. * @details @@ -169,6 +130,14 @@ { FILL_MODE_STATE_T result = FILL_MODE_STATE_DIALYSATE_PRODUCTION; + // TODO - transition when temperature and mix is in range + if ( 1 ) + { + // TODO - VPo to reservoir + setFPGAValveStates(0x015F); + result = FILL_MODE_STATE_DELIVER_DIALYSATE; + } + return result; } @@ -186,6 +155,15 @@ { FILL_MODE_STATE_T result = FILL_MODE_STATE_DELIVER_DIALYSATE; + // TODO - transition back when temperature or mix out of range + + if ( 0 ) + { + // TODO - VPo to drain + setFPGAValveStates(0x014F); + result = FILL_MODE_STATE_DIALYSATE_PRODUCTION; + } + return result; } Index: firmware/App/Modes/ModeFill.h =================================================================== diff -u -r138efd92a8645e0d2fe422409ef5a33dd2929a25 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision 138efd92a8645e0d2fe422409ef5a33dd2929a25) +++ firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -8,7 +8,7 @@ * @file ModeFill.h * * @date 19-Nov-2019 - * @author L. Baloa + * @author S. Nash * * @brief Header file for Fill Mode. * Index: firmware/App/Modes/ModeFlush.c =================================================================== diff -u -r499e5de29e706d09f79ba22511068990c4044e84 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision 499e5de29e706d09f79ba22511068990c4044e84) +++ firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -8,7 +8,7 @@ * @file ModeFlush.c * * @date 20-Dec-2019 - * @author L. Baloa + * @author S. Nash * * @brief Top-level state machine for flush mode. * @@ -17,47 +17,74 @@ #include "ModeFlush.h" #include "OperationModes.h" +/** + * @addtogroup FlushMode + * @{ + */ + +// ********** private definitions ********** + +/// Enumeration of flush mode states. +typedef enum Flush_States +{ + FLUSH_STATE_START = 0, ///< Start flush mode state. + NUM_OF_FLUSH_STATES ///< Number of flush mode states. +} FLUSH_STATE_T; + // ********** private data ********** +static FLUSH_STATE_T flushState = FLUSH_STATE_START; ///< Currently active flush state. + // ********** private function prototypes ********** -/************************************************************************* - * @brief initFlushMode +/*********************************************************************//** + * @brief * The initFlushMode function initializes flush Mode module. * @details * Inputs : none * Outputs : none - * @param none * @return none *************************************************************************/ void initFlushMode( void ) { + flushState = FLUSH_STATE_START; } -/************************************************************************* - * @brief transitionToFlushMode +/*********************************************************************//** + * @brief * The transitionToFlushMode function prepares for transition to \n * flush mode. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void transitionToFlushMode( void ) { + initFlushMode(); } -/************************************************************************* - * @brief execFlushMode +/*********************************************************************//** + * @brief * The execFlushMode function executes the flush Mode state machine. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void execFlushMode( void ) { + // execute current flush state + switch ( flushState ) + { + case FLUSH_STATE_START: + break; + + default: + flushState = FLUSH_STATE_START; + // TODO - s/w fault + break; + } } +/**@}*/ Index: firmware/App/Modes/ModeFlush.h =================================================================== diff -u -rb64c49fdcf2b6d95e61e63f8e258c4e600935bbd -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeFlush.h (.../ModeFlush.h) (revision b64c49fdcf2b6d95e61e63f8e258c4e600935bbd) +++ firmware/App/Modes/ModeFlush.h (.../ModeFlush.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -8,7 +8,7 @@ * @file ModeFlush.h * * @date 20-Dec-2019 - * @author L. Baloa + * @author S. Nash * * @brief Header file for Flush Mode. * @@ -19,10 +19,21 @@ #include "DGCommon.h" +/** + * @defgroup FlushMode FlushMode + * @brief Flush mode module. Manages the state machine for the + * flush mode. + * + * @addtogroup FlushMode + * @{ + */ + // ********** private function prototypes ********** void initFlushMode( void ); // initialize this module void transitionToFlushMode( void ); // prepares for transition to pre-treatment mode void execFlushMode( void ); // execute the pre-treatment mode state machine (call from OperationModes) +/**@}*/ + #endif Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u --- firmware/App/Modes/ModeHeatDisinfect.c (revision 0) +++ firmware/App/Modes/ModeHeatDisinfect.c (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -0,0 +1,89 @@ +/**********************************************************************//** + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * @file ModeHeatDisinfect.c + * + * @date 20-Dec-2019 + * @author S. Nash + * + * @brief Top-level state machine for the heat disinfect mode. + * + **************************************************************************/ + +#include "ModeHeatDisinfect.h" +#include "OperationModes.h" + +/** + * @addtogroup HeatDisinfectMode + * @{ + */ + +// ********** private definitions ********** + +/// Enumeration of heat disinfection mode states. +typedef enum Heat_States +{ + HEAT_DISINFECT_STATE_START = 0, ///< Start heat disinfect mode state. + NUM_OF_HEAT_DISINFECT_STATES ///< Number of heat disinfect mode states. +} HEAT_DISINFECT_STATE_T; + +// ********** private data ********** + +static HEAT_DISINFECT_STATE_T heatState = HEAT_DISINFECT_STATE_START; ///< Currently active heat disinfect state. + +// ********** private function prototypes ********** + +/*********************************************************************//** + * @brief + * The initHeatDisinfectMode function initializes the heat disinfect Mode module. + * @details + * Inputs : none + * Outputs : none + * @return none + *************************************************************************/ +void initHeatDisinfectMode( void ) +{ + heatState = HEAT_DISINFECT_STATE_START; +} + +/*********************************************************************//** + * @brief + * The transitionToHeatDisinfectMode function prepares for transition to heat disinfect mode. + * @details + * Inputs : none + * Outputs : none + * @return none + *************************************************************************/ +void transitionToHeatDisinfectMode( void ) +{ + initHeatDisinfectMode(); +} + +/*********************************************************************//** + * @brief + * The execHeatDisinfectMode function executes the heat disinfect Mode state machine. + * @details + * Inputs : none + * Outputs : none + * @return none + *************************************************************************/ +void execHeatDisinfectMode( void ) +{ + // execute current heat disinfect state + switch ( heatState ) + { + case HEAT_DISINFECT_STATE_START: + break; + + default: + heatState = HEAT_DISINFECT_STATE_START; + // TODO - s/w fault + break; + } +} + +/**@}*/ Index: firmware/App/Modes/ModeHeatDisinfect.h =================================================================== diff -u --- firmware/App/Modes/ModeHeatDisinfect.h (revision 0) +++ firmware/App/Modes/ModeHeatDisinfect.h (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -0,0 +1,39 @@ +/**********************************************************************//** + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * @file ModeHeatDisinfect.h + * + * @date 20-Dec-2019 + * @author S. Nash + * + * @brief Header file for Heat Disinfect Mode. + * + **************************************************************************/ + +#ifndef __MODE_HEAT_DISINFECT_H__ +#define __MODE_HEAT_DISINFECT_H__ + +#include "DGCommon.h" + +/** + * @defgroup HeatDisinfectMode HeatDisinfectMode + * @brief Heat disinfection mode module. Manages the state machine for the + * heat disinfection mode. + * + * @addtogroup HeatDisinfectMode + * @{ + */ + +// ********** private function prototypes ********** + +void initHeatDisinfectMode( void ); // initialize this module +void transitionToHeatDisinfectMode( void ); // prepares for transition to heat disinfect mode +void execHeatDisinfectMode( void ); // execute the heat disinfect mode state machine (call from OperationModes) + +/**@}*/ + +#endif Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r499e5de29e706d09f79ba22511068990c4044e84 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 499e5de29e706d09f79ba22511068990c4044e84) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -20,36 +20,41 @@ #include "WatchdogMgmt.h" #include "ModeInitPOST.h" +/** + * @addtogroup InitAndPOSTMode + * @{ + */ + // ********** private definitions ********** +/// Enumeration of init & POST mode states. typedef enum POST_States { - POST_STATE_START = 0, - POST_STATE_FPGA, - POST_STATE_WATCHDOG, - POST_STATE_COMPLETED, - POST_STATE_FAILED, - NUM_OF_POST_STATES + POST_STATE_START = 0, ///< Start initialize & POST mode state. + POST_STATE_FPGA, ///< FPGA POST test state. + POST_STATE_WATCHDOG, ///< Watchdog POST test state. + POST_STATE_COMPLETED, ///< POST completed successfully state. + POST_STATE_FAILED, ///< POST failed state. + NUM_OF_POST_STATES ///< Number of initialize & POST mode states. } POST_STATE_T; // ********** private data ********** -static POST_STATE_T postState = POST_STATE_START; -static BOOL postCompleted = FALSE; -static BOOL postPassed = FALSE; -static BOOL tempPOSTPassed = TRUE; +static POST_STATE_T postState = POST_STATE_START; ///< Currently active initialize & POST state. +static BOOL postCompleted = FALSE; ///< Flag indicating POST completed. +static BOOL postPassed = FALSE; ///< Flag indicating all POST tests passed. +static BOOL tempPOSTPassed = TRUE; ///< Temporary flag indicating all POST tests completed so far have passed. // ********** private function prototypes ********** static POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ); -/************************************************************************* - * @brief initInitAndPOSTMode +/*********************************************************************//** + * @brief * The initInitAndPOSTMode function initializes the Initialize & POST Mode module. * @details * Inputs : none * Outputs : Initialize & POST Mode module initialized. - * @param none * @return none *************************************************************************/ void initInitAndPOSTMode( void ) @@ -60,27 +65,25 @@ tempPOSTPassed = TRUE; } -/************************************************************************* - * @brief transitionToInitAndPOSTMode +/*********************************************************************//** + * @brief * The transitionToInitAndPOSTMode function prepares for transition to\n * initialize & POST mode. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void transitionToInitAndPOSTMode( void ) { } -/************************************************************************* - * @brief execInitAndPOSTMode +/*********************************************************************//** + * @brief * The execInitAndPOSTMode function executes the Initialize & POST Mode state machine. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void execInitAndPOSTMode( void ) @@ -135,39 +138,37 @@ } } -/************************************************************************* - * @brief isPOSTCompleted +/*********************************************************************//** + * @brief * The isPOSTCompleted function determines whether all HD POST have \n * been run and completed. If true, call the isPOSTPassed() to see final \n * result (pass/fail). * @details * Inputs : postCompleted * Outputs : none - * @param none * @return true if all HD POST tests have completed, false if not *************************************************************************/ BOOL isPOSTCompleted( void ) { return postCompleted; } -/************************************************************************* - * @brief isPOSTPassed +/*********************************************************************//** + * @brief * The isPOSTPassed function determines whether all HD POST have passed. \n * Call this function after POST is complete (call isPOSTCompleted function). * @details * Inputs : postPassed * Outputs : none - * @param none * @return true if all HD POST tests have passed, false if not *************************************************************************/ BOOL isPOSTPassed( void ) { return postPassed; } -/************************************************************************* - * @brief handlePOSTStatus +/*********************************************************************//** + * @brief * The handlePOSTStatus function handles a status result returned by a * POST function. * @details @@ -191,3 +192,5 @@ return result; } + +/**@}*/ Index: firmware/App/Modes/ModeInitPOST.h =================================================================== diff -u -rb64c49fdcf2b6d95e61e63f8e258c4e600935bbd -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision b64c49fdcf2b6d95e61e63f8e258c4e600935bbd) +++ firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -19,6 +19,15 @@ #include "DGCommon.h" +/** + * @defgroup InitAndPOSTMode InitAndPOSTMode + * @brief Initialization and POST mode module. + * Manages initialization and POST mode functions via a state machine. + * + * @addtogroup InitAndPOSTMode + * @{ + */ + // ********** private function prototypes ********** void initInitAndPOSTMode( void ); // initialize this module @@ -27,4 +36,6 @@ BOOL isPOSTCompleted( void ); BOOL isPOSTPassed( void ); +/**@}*/ + #endif Index: firmware/App/Modes/ModeRecirculate.c =================================================================== diff -u -r138efd92a8645e0d2fe422409ef5a33dd2929a25 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision 138efd92a8645e0d2fe422409ef5a33dd2929a25) +++ firmware/App/Modes/ModeRecirculate.c (.../ModeRecirculate.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -14,7 +14,10 @@ * **************************************************************************/ +#include "FPGA.h" #include "OperationModes.h" +#include "ROPump.h" +#include "TaskGeneral.h" #include "Timers.h" #include "ModeRecirculate.h" @@ -29,27 +32,23 @@ // ********** private definitions ********** -/// Enumberation of re-circulation mode states. -typedef enum Recirculate_Mode_States -{ - RECIRCULATE_MODE_STATE_START = 0, ///< Start re-circulation mode state. - RECIRCULATE_MODE_STATE_CHECK_INLET_WATER, ///< Check inlet water state. - RECIRCULATE_MODE_STATE_RECIRC_PRODUCT_WATER, ///< Re-circulate product water state. - NUM_OF_RECIRCULATE_MODE_STATES ///< Number of fill mode states. -} RECIRCULATE_MODE_STATE_T; +#define TARGET_RO_PRESSURE_PSI 120 ///< Target pressure for RO pump. +#define FLUSH_LINES_VOLUME_ML 100.0 ///< Water volume to flush when starting re-circulate mode. // ********** private data ********** static RECIRCULATE_MODE_STATE_T recircState; ///< Currently active re-circulation state. +static F32 flushLinesVolume = 0.0; ///< Volume of water pumped by RO pump during flush lines state. // ********** private function prototypes ********** -static RECIRCULATE_MODE_STATE_T handleCheckInletWaterState( void ); -static RECIRCULATE_MODE_STATE_T handleRecircProductWaterState( void ); +static RECIRCULATE_MODE_STATE_T handleFlushLinesState( void ); +static RECIRCULATE_MODE_STATE_T handleRecircWaterState( void ); +static RECIRCULATE_MODE_STATE_T handleRecircPauseState( void ); /*********************************************************************//** - * @brief initFillMode - * The initFillMode function initializes the Fill Mode module. + * @brief + * The initRecirculateMode function initializes the Fill Mode module. * @details * Inputs : none * Outputs : Fill Mode module initialized. @@ -58,47 +57,60 @@ void initRecirculateMode( void ) { recircState = RECIRCULATE_MODE_STATE_START; + flushLinesVolume = 0.0; } /*********************************************************************//** - * @brief transitionToFillMode - * The transitionToFillMode function prepares for transition to \n + * @brief + * The transitionToRecirculateMode function prepares for transition to \n * fill mode. * @details * Inputs : none - * Outputs : fillState + * Outputs : recircState * @return none *************************************************************************/ void transitionToRecirculateMode( void ) { - recircState = RECIRCULATE_MODE_STATE_START; + // re-initialize each time we transition to re-circulate mode + initRecirculateMode(); + + // TODO - set initial actuator states + setFPGAValveStates(0x014F); + // VPi open, VRc re-circ, VDr and VPo to drain + // UV on + // Primary heater on } /*********************************************************************//** - * @brief execFillMode - * The execFillMode function executes the Fill Mode state machine. + * @brief + * The execRecirculateMode function executes the Re-circulate Mode state machine. * @details - * Inputs : fillState - * Outputs : fillState + * Inputs : recircState + * Outputs : recircState * @return none *************************************************************************/ void execRecirculateMode( void ) { - // execute current Fill state + // execute current re-circulate state switch ( recircState ) { case RECIRCULATE_MODE_STATE_START: - recircState = RECIRCULATE_MODE_STATE_CHECK_INLET_WATER; + setROPumpTargetPressure( TARGET_RO_PRESSURE_PSI, PUMP_CONTROL_MODE_CLOSED_LOOP ); + recircState = RECIRCULATE_MODE_STATE_FLUSH_LINES; break; - case RECIRCULATE_MODE_STATE_CHECK_INLET_WATER: - recircState = handleCheckInletWaterState(); + case RECIRCULATE_MODE_STATE_FLUSH_LINES: + recircState = handleFlushLinesState(); break; - case RECIRCULATE_MODE_STATE_RECIRC_PRODUCT_WATER: - recircState = handleRecircProductWaterState(); + case RECIRCULATE_MODE_STATE_RECIRC_WATER: + recircState = handleRecircWaterState(); break; + case RECIRCULATE_MODE_STATE_PAUSE: + recircState = handleRecircPauseState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, 0, recircState ) // TODO - add s/w fault enum to 1st data param recircState = RECIRCULATE_MODE_STATE_START; @@ -108,36 +120,92 @@ /*********************************************************************//** * @brief - * The handleCheckInletWaterState function executes the Check Inlet Water \n - * state of the Fill Mode state machine. + * The handleCheckInletWaterState function executes the flush lines \n + * state of the Re-circulate Mode state machine. * @details * Inputs : none * Outputs : - * @param none * @return the next state *************************************************************************/ -static RECIRCULATE_MODE_STATE_T handleCheckInletWaterState( void ) +static RECIRCULATE_MODE_STATE_T handleFlushLinesState( void ) { - RECIRCULATE_MODE_STATE_T result = RECIRCULATE_MODE_STATE_CHECK_INLET_WATER; + RECIRCULATE_MODE_STATE_T result = RECIRCULATE_MODE_STATE_FLUSH_LINES; + F32 waterFlowRate = getMeasuredROFlowRate(); + F32 waterVolume = ( ( waterFlowRate / SEC_PER_MIN ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); + flushLinesVolume += waterVolume; + + // when enough water volume has flowed to flush the lines, transition to re-circ state + if ( flushLinesVolume >= FLUSH_LINES_VOLUME_ML ) + { + // TODO - change VDr from drain to re-circulate + result = RECIRCULATE_MODE_STATE_RECIRC_WATER; + } + return result; } /*********************************************************************//** * @brief - * The handleRecircProductWaterState function executes the Create Product \n - * Water state of the Fill Mode state machine. + * The handleRecircProductWaterState function executes the re-circulate \n + * water state of the Re-circulate Mode state machine. * @details * Inputs : none * Outputs : - * @param none * @return the next state *************************************************************************/ -static RECIRCULATE_MODE_STATE_T handleRecircProductWaterState( void ) +static RECIRCULATE_MODE_STATE_T handleRecircWaterState( void ) { - RECIRCULATE_MODE_STATE_T result = RECIRCULATE_MODE_STATE_RECIRC_PRODUCT_WATER; + RECIRCULATE_MODE_STATE_T result = RECIRCULATE_MODE_STATE_RECIRC_WATER; return result; } +/*********************************************************************//** + * @brief + * The handleRecircPauseState function executes the pause state of the \n + * Re-circulate Mode state machine. + * @details + * Inputs : none + * Outputs : + * @return the next state + *************************************************************************/ +static RECIRCULATE_MODE_STATE_T handleRecircPauseState( void ) +{ + RECIRCULATE_MODE_STATE_T result = RECIRCULATE_MODE_STATE_PAUSE; + + return result; +} + +/*********************************************************************//** + * @brief + * The requestDGStop function handles an HD request to stop (return to Standby mode). + * @details + * Inputs : none + * Outputs : DG standby mode requested + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestDGStop( void ) +{ + BOOL result = TRUE; + + requestNewOperationMode( MODE_STAN ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getRecirculateModeState function returns the current state of the \n + * re-circulate mode. + * @details + * Inputs : recircState + * Outputs : none + * @return the current state of re-circulate mode. + *************************************************************************/ +RECIRCULATE_MODE_STATE_T getRecirculateModeState( void ) +{ + return recircState; +} + /**@}*/ Index: firmware/App/Modes/ModeRecirculate.h =================================================================== diff -u -r138efd92a8645e0d2fe422409ef5a33dd2929a25 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeRecirculate.h (.../ModeRecirculate.h) (revision 138efd92a8645e0d2fe422409ef5a33dd2929a25) +++ firmware/App/Modes/ModeRecirculate.h (.../ModeRecirculate.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -30,12 +30,25 @@ // ********** public definitions ********** +/// Enumeration of re-circulation mode states. +typedef enum Recirculate_Mode_States +{ + RECIRCULATE_MODE_STATE_START = 0, ///< Start re-circulation mode state. + RECIRCULATE_MODE_STATE_FLUSH_LINES, ///< Flush lines state. + RECIRCULATE_MODE_STATE_RECIRC_WATER, ///< Re-circulate water state. + RECIRCULATE_MODE_STATE_PAUSE, ///< Pause state (pumps, heaters, lamps off). + NUM_OF_RECIRCULATE_MODE_STATES ///< Number of fill mode states. +} RECIRCULATE_MODE_STATE_T; + // ********** private function prototypes ********** void initRecirculateMode( void ); // initialize this module void transitionToRecirculateMode( void ); // prepares for transition to Recirculate mode void execRecirculateMode( void ); // execute the Recirculate mode state machine (call from OperationModes) +BOOL requestDGStop( void ); // HD requests DG stop (go back to standby mode) +RECIRCULATE_MODE_STATE_T getRecirculateModeState( void ); // get the current state of re-circulate mode + /**@}*/ #endif Index: firmware/App/Modes/ModeService.c =================================================================== diff -u -r499e5de29e706d09f79ba22511068990c4044e84 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeService.c (.../ModeService.c) (revision 499e5de29e706d09f79ba22511068990c4044e84) +++ firmware/App/Modes/ModeService.c (.../ModeService.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/*********************************************************************//*** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -17,46 +17,72 @@ #include "OperationModes.h" #include "ModeService.h" +/** + * @addtogroup ServiceMode + * @{ + */ + +// ********** private definitions ********** + +/// Enumeration of service mode states. +typedef enum Service_States +{ + SERVICE_STATE_START = 0, ///< Start service mode state. + NUM_OF_SERVICE_STATES ///< Number of service mode states. +} SERVICE_STATE_T; + // ********** private data ********** +static SERVICE_STATE_T serviceState = SERVICE_STATE_START; ///< Currently active service state. + // ********** private function prototypes ********** -/************************************************************************* - * @brief initServiceMode +/*********************************************************************//** + * @brief * The initServiceMode function initializes the Service Mode module. * @details * Inputs : none * Outputs : Service Mode module initialized. - * @param none * @return none *************************************************************************/ void initServiceMode( void ) { + serviceState = SERVICE_STATE_START; } -/************************************************************************* - * @brief transitionToServiceMode +/*********************************************************************//** + * @brief * The transitionToServiceMode function prepares for transition to service mode. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void transitionToServiceMode( void ) { } -/************************************************************************* - * @brief execServiceMode +/*********************************************************************//** + * @brief * The execServiceMode function executes the Service Mode state machine. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void execServiceMode( void ) { + // execute current service state + switch ( serviceState ) + { + case SERVICE_STATE_START: + break; + + default: + serviceState = SERVICE_STATE_START; + // TODO - s/w fault + break; + } } +/**@}*/ Index: firmware/App/Modes/ModeService.h =================================================================== diff -u -rb64c49fdcf2b6d95e61e63f8e258c4e600935bbd -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeService.h (.../ModeService.h) (revision b64c49fdcf2b6d95e61e63f8e258c4e600935bbd) +++ firmware/App/Modes/ModeService.h (.../ModeService.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -19,10 +19,21 @@ #include "DGCommon.h" +/** + * @defgroup ServiceMode ServiceMode + * @brief Service mode module. + * Manages service mode functions via a state machine. + * + * @addtogroup ServiceMode + * @{ + */ + // ********** private function prototypes ********** void initServiceMode( void ); // initialize this module void transitionToServiceMode( void ); // prepares for transition to service mode void execServiceMode( void ); // execute the service mode state machine (call from OperationModes) +/**@}*/ + #endif Index: firmware/App/Modes/ModeSolo.c =================================================================== diff -u -r200edfc2ef75cf499887b4c85d22264ded0db125 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeSolo.c (.../ModeSolo.c) (revision 200edfc2ef75cf499887b4c85d22264ded0db125) +++ firmware/App/Modes/ModeSolo.c (.../ModeSolo.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2020 Diality Inc. - All Rights Reserved. * @@ -18,46 +18,73 @@ #include "ModeSolo.h" #include "CPLD.h" +/** + * @addtogroup SoloStandbyMode + * @{ + */ + +// ********** private definitions ********** + +/// Enumeration of solo standby mode states. +typedef enum Solo_States +{ + SOLO_STANDBY_STATE_START = 0, ///< Start solo standby mode state. + NUM_OF_SOLO_STANDBY_STATES ///< Number of solo standby mode states. +} SOLO_STANDBY_STATE_T; + // ********** private data ********** +static SOLO_STANDBY_STATE_T soloState = SOLO_STANDBY_STATE_START; ///< Currently active solo standby state. + // ********** private function prototypes ********** -/************************************************************************* +/*********************************************************************//** * @brief * The initSoloMode function initializes the Standby-Solo Mode module. * @details * Inputs : none * Outputs : Standby-Solo Mode module initialized. - * @param none * @return none *************************************************************************/ void initSoloMode( void ) { + soloState = SOLO_STANDBY_STATE_START; } -/************************************************************************* +/*********************************************************************//** * @brief * The transitionToSoloMode function prepares for transition to standby-solo mode. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void transitionToSoloMode( void ) { + initSoloMode(); } -/************************************************************************* +/*********************************************************************//** * @brief * The execSoloMode function executes the Standby-Solo Mode state machine. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void execSoloMode( void ) { + // execute current solo standby state + switch ( soloState ) + { + case SOLO_STANDBY_STATE_START: + break; + default: + soloState = SOLO_STANDBY_STATE_START; + // TODO - s/w fault + break; + } } + +/**@}*/ Index: firmware/App/Modes/ModeSolo.h =================================================================== diff -u -rf43eb1e9e0803776ec7420b16e1db8760b020bd9 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeSolo.h (.../ModeSolo.h) (revision f43eb1e9e0803776ec7420b16e1db8760b020bd9) +++ firmware/App/Modes/ModeSolo.h (.../ModeSolo.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -19,10 +19,21 @@ #include "DGCommon.h" +/** + * @defgroup SoloStandbyMode SoloStandbyMode + * @brief Solo Standby mode module. + * Manages Solo standby mode functions via a state machine. + * + * @addtogroup SoloStandbyMode + * @{ + */ + // ********** private function prototypes ********** void initSoloMode( void ); // initialize this module void transitionToSoloMode( void ); // prepares for transition to standby-solo mode void execSoloMode( void ); // execute the standby-solo mode state machine (call from OperationModes) +/**@}*/ + #endif Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rf43eb1e9e0803776ec7420b16e1db8760b020bd9 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision f43eb1e9e0803776ec7420b16e1db8760b020bd9) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -14,9 +14,11 @@ * **************************************************************************/ +#include "CPLD.h" #include "OperationModes.h" +#include "SystemComm.h" +#include "Timers.h" #include "ModeStandby.h" -#include "CPLD.h" /** * @addtogroup StandbyMode @@ -25,57 +27,67 @@ // ********** private definitions ********** +#define WATER_SAMPLE_TIME_MS ( 10 * MS_PER_SECOND ) ///< Duration of water sample state (in ms). + /// Enumeration of standby mode states. typedef enum Standby_Mode_States { STANDBY_MODE_STATE_START = 0, ///< Start standby mode state. STANDBY_MODE_STATE_IDLE, ///< Idle standby mode state. + STANDBY_MODE_STATE_SAMPLE_WATER, ///< Sample water standby mode state. NUM_OF_STANDBY_MODE_STATES ///< Number of standby mode states. } STANDBY_MODE_STATE_T; // ********** private data ********** static STANDBY_MODE_STATE_T standbyState = STANDBY_MODE_STATE_START; ///< Currently active standby state. +static BOOL pendingSampleWaterRequest = FALSE; ///< Flag indicating HD has requested a water sample. +static BOOL pendingStartDGRequest = FALSE; ///< Flag indicating HD has requested DG start (go to re-circulate mode). +static U32 waterSampleStartTime = 0; ///< Time stamp for start of water sample state. // ********** private function prototypes ********** -STANDBY_MODE_STATE_T handleStandbyIdleState( void ); +static STANDBY_MODE_STATE_T handleStandbyIdleState( void ); +static STANDBY_MODE_STATE_T handleStandbySampleWaterState( void ); /*********************************************************************//** - * @brief initStandbyMode + * @brief * The initStandbyMode function initializes the Standby Mode module. * @details * Inputs : none * Outputs : Standby Mode module initialized. - * @param none * @return none *************************************************************************/ void initStandbyMode( void ) { + standbyState = STANDBY_MODE_STATE_START; + pendingSampleWaterRequest = FALSE; + pendingStartDGRequest = FALSE; + waterSampleStartTime = 0; } /*********************************************************************//** - * @brief transitionToStandbyMode + * @brief * The transitionToStandbyMode function prepares for transition to standby mode. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void transitionToStandbyMode( void ) { // reset to start state each time we transition to standby mode standbyState = STANDBY_MODE_STATE_START; + + // TODO - set initial actuator states } /*********************************************************************//** - * @brief execStandbyMode + * @brief * The execStandbyMode function executes the Standby Mode state machine. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void execStandbyMode( void ) @@ -91,6 +103,10 @@ standbyState = handleStandbyIdleState(); break; + case STANDBY_MODE_STATE_SAMPLE_WATER: + standbyState = handleStandbySampleWaterState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, 0, standbyState ) // TODO - add s/w fault enum to 1st data param standbyState = STANDBY_MODE_STATE_START; @@ -103,24 +119,99 @@ * The handleStandbyIdleState function executes the Idle state of the \n * Standby Mode state machine. * @details + * Inputs : pendingSampleWaterRequest, pendingStartDGRequest + * Outputs : possibly op mode + * @return the next state + *************************************************************************/ +static STANDBY_MODE_STATE_T handleStandbyIdleState( void ) +{ + STANDBY_MODE_STATE_T result = STANDBY_MODE_STATE_IDLE; + + // go to standby solo mode if HD is turned off or stops communicating. + if ( FALSE == isHDCommunicating() ) + { // TODO if HD comm loss, should we wait an hour or so before going to solo standby? + requestNewOperationMode( MODE_SOLO ); + } + // if HD requests water sample, go to water sample state + else if ( TRUE == pendingSampleWaterRequest ) + { + pendingSampleWaterRequest = FALSE; + waterSampleStartTime = getMSTimerCount(); + // TODO - open VPi and VSP valves + result = STANDBY_MODE_STATE_SAMPLE_WATER; + } + else if ( TRUE == pendingStartDGRequest ) + { + pendingStartDGRequest = FALSE; + requestNewOperationMode( MODE_CIRC ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleStandbySampleWaterState function executes the sample water state \n + * of the Standby Mode state machine. + * @details * Inputs : none * Outputs : - * @param none * @return the next state *************************************************************************/ -STANDBY_MODE_STATE_T handleStandbyIdleState( void ) +static STANDBY_MODE_STATE_T handleStandbySampleWaterState( void ) { - STANDBY_MODE_STATE_T result = STANDBY_MODE_STATE_IDLE; + STANDBY_MODE_STATE_T result = STANDBY_MODE_STATE_SAMPLE_WATER; - // go to standby or standby solo mode depending on whether HD is connected -// if ( FALSE == isHDCommunicating() ) // TODO - handle switching between standby and standby-solo modes -// { -// requestNewOperationMode( MODE_SOLO ); -// } + // VPi and VSP valves open for 10 seconds, then close and return to idle state + if ( TRUE == didTimeout( waterSampleStartTime, WATER_SAMPLE_TIME_MS ) ) + { + // TODO - close VPi and VSP valves. + result = STANDBY_MODE_STATE_IDLE; + } - // TODO - what is DG supposed to be doing while in standby mode? + return result; +} +/*********************************************************************//** + * @brief + * The requestWaterSample function handles an HD request to sample water. + * @details + * Inputs : standbyState + * Outputs : pendingSampleWaterRequest + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestWaterSample( void ) +{ + BOOL result = FALSE; + + if ( STANDBY_MODE_STATE_IDLE == standbyState ) + { + result = TRUE; + pendingSampleWaterRequest = TRUE; + } + return result; } +/*********************************************************************//** + * @brief + * The requestDGStart function handles an HD request to start (go to re-circulate mode). + * @details + * Inputs : standbyState + * Outputs : pendingSampleWaterRequest + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestDGStart( void ) +{ + BOOL result = FALSE; + + if ( STANDBY_MODE_STATE_IDLE == standbyState ) + { + result = TRUE; + pendingStartDGRequest = TRUE; + } + + return result; +} + /**@}*/ Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -rf43eb1e9e0803776ec7420b16e1db8760b020bd9 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision f43eb1e9e0803776ec7420b16e1db8760b020bd9) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -8,7 +8,7 @@ * @file ModeStandby.h * * @date 11-Dec-2019 - * @author L. Baloa + * @author S. Nash * * @brief Header file for Standby Mode. * @@ -20,11 +20,11 @@ #include "DGCommon.h" /** - * @defgroup StandbyMode StandbyMode - * @brief Standby mode module. - * Manages standby mode functions via a state machine. + * @defgroup ChemicalDisinfectMode ChemicalDisinfectMode + * @brief Chemical disinfect mode module. + * Manages chemical disinfect mode functions via a state machine. * - * @addtogroup StandbyMode + * @addtogroup ChemicalDisinfectMode * @{ */ @@ -34,6 +34,9 @@ void transitionToStandbyMode( void ); // prepares for transition to standby mode void execStandbyMode( void ); // execute the standby mode state machine (call from OperationModes) +BOOL requestWaterSample( void ); // HD requests water sample +BOOL requestDGStart( void ); // HD requests DG start (go to re-circulate mode) + /**@}*/ #endif Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -rc548570b37339819da825092dd07c7081437f30b -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision c548570b37339819da825092dd07c7081437f30b) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -8,7 +8,7 @@ * @file OperationModes.c * * @date 11-Dec-2019 - * @author L. Baloa + * @author S. Nash * * @brief Top-level state machine for the HD operation modes. * @@ -20,11 +20,11 @@ #include "TaskGeneral.h" #include "OperationModes.h" #include "ModeChemicalDisinfect.h" -#include "ModeDisinfect.h" #include "ModeDrain.h" #include "ModeFault.h" #include "ModeFill.h" #include "ModeFlush.h" +#include "ModeHeatDisinfect.h" #include "ModeInitPOST.h" #include "ModeRecirculate.h" #include "ModeService.h" @@ -49,17 +49,17 @@ /// This matrix determines legal transitions from one mode to another. static const OP_MODE MODE_TRANSITION_TABLE[NUM_OF_MODES - 1][NUM_OF_MODES - 1] = { -// from to-> FAULT SERVICE INIT STANBY STBY-SOLO RE-CIRC FILL DRAIN FLUSH DISINFECT CHEM DIS +// from to-> FAULT SERVICE INIT STANBY STBY-SOLO RE-CIRC FILL DRAIN FLUSH HEAT DIS CHEM DIS /* FAUL */{ MODE_FAUL, MODE_SERV, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG }, /* SERV */{ MODE_FAUL, MODE_SERV, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG }, /* INIT */{ MODE_FAUL, MODE_NLEG, MODE_INIT, MODE_STAN, MODE_SOLO, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG }, /* STAN */{ MODE_FAUL, MODE_SERV, MODE_NLEG, MODE_STAN, MODE_SOLO, MODE_CIRC, MODE_NLEG, MODE_NLEG, MODE_FLUS, MODE_NLEG, MODE_CHEM }, - /* SOLO */{ MODE_FAUL, MODE_NLEG, MODE_NLEG, MODE_STAN, MODE_SOLO, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_FLUS, MODE_DISI, MODE_NLEG }, + /* SOLO */{ MODE_FAUL, MODE_NLEG, MODE_NLEG, MODE_STAN, MODE_SOLO, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_FLUS, MODE_HEAT, MODE_NLEG }, /* CIRC */{ MODE_FAUL, MODE_NLEG, MODE_NLEG, MODE_STAN, MODE_NLEG, MODE_CIRC, MODE_FILL, MODE_DRAI, MODE_NLEG, MODE_NLEG, MODE_NLEG }, /* FILL */{ MODE_FAUL, MODE_NLEG, MODE_NLEG, MODE_STAN, MODE_NLEG, MODE_CIRC, MODE_FILL, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG }, /* DRAI */{ MODE_FAUL, MODE_NLEG, MODE_NLEG, MODE_STAN, MODE_NLEG, MODE_CIRC, MODE_NLEG, MODE_DRAI, MODE_NLEG, MODE_NLEG, MODE_NLEG }, /* FLUS */{ MODE_FAUL, MODE_NLEG, MODE_NLEG, MODE_STAN, MODE_SOLO, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_FLUS, MODE_NLEG, MODE_NLEG }, - /* DISI */{ MODE_FAUL, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_SOLO, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_DISI, MODE_NLEG }, + /* HEAT */{ MODE_FAUL, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_SOLO, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_HEAT, MODE_NLEG }, /* CHEM */{ MODE_FAUL, MODE_NLEG, MODE_NLEG, MODE_STAN, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_CHEM } }; @@ -104,7 +104,7 @@ initFillMode(); initDrainMode(); initFlushMode(); - initDisinfectMode(); + initHeatDisinfectMode(); initChemicalDisinfectMode(); // initialize broadcast timer counter @@ -182,8 +182,8 @@ execFlushMode(); break; - case MODE_DISI: - execDisinfectMode(); + case MODE_HEAT: + execHeatDisinfectMode(); break; case MODE_CHEM: @@ -317,8 +317,8 @@ case MODE_FLUS: transitionToFlushMode(); break; - case MODE_DISI: - transitionToDisinfectMode(); + case MODE_HEAT: + transitionToHeatDisinfectMode(); break; case MODE_CHEM: transitionToChemicalDisinfectMode(); Index: firmware/App/Modes/OperationModes.h =================================================================== diff -u -r138efd92a8645e0d2fe422409ef5a33dd2929a25 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/OperationModes.h (.../OperationModes.h) (revision 138efd92a8645e0d2fe422409ef5a33dd2929a25) +++ firmware/App/Modes/OperationModes.h (.../OperationModes.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -8,7 +8,7 @@ * @file OperationModes.h * * @date 11-Dec-2019 - * @author L. Baloa + * @author S. Nash * * @brief Header file for Operation Modes. * @@ -42,7 +42,7 @@ MODE_FILL, ///< Fill mode. MODE_DRAI, ///< Drain mode. MODE_FLUS, ///< Flush mode. - MODE_DISI, ///< Disinfect mode. + MODE_HEAT, ///< Heat Disinfect mode. MODE_CHEM, ///< Chemical Disinfect mode. MODE_NLEG, ///< Not legal - an illegal mode transition occurred. NUM_OF_MODES Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r216bd924f989182e648ee5f33f4c91c43ac438ac -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 216bd924f989182e648ee5f33f4c91c43ac438ac) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -89,17 +89,17 @@ U32 fpgaLCB2; U32 fpgaADC2Temp; - U32 fpgaCD1; - U32 fpgaCD2; + U32 fpgaCD1Temp; // Conductivity sensor 1 in the mixing area + U32 fpgaCD2Temp; U32 fpgaTPiTemp; U32 fpgaTPoTemp; U32 fpgaRTDTemp; - U32 fpgaTHDo; + U32 fpgaTHDo; // TRo U32 fpgaTHDoTemp; U32 fpgaTDi; - U32 fpgaTDiTemp; + U32 fpgaTDiTemp; // Dialysate inlet sensor U32 fpgaCPoEc; U32 fpgaCPoTds; @@ -144,12 +144,12 @@ U16 fpgaValveStates; U08 fpgaID; U08 fpgaRev; - U08 fpgaADC1Control; - U08 fpgaDiag; - U08 fpgaADC2Control; - U08 fpgaRTDControl; - U08 fpgaTHDoControl; - U08 fpgaTDiControl; + //U08 fpgaADC1Control; + //U08 fpgaDiag; + //U08 fpgaADC2Control; + //U08 fpgaRTDControl; + //U08 fpgaTHDoControl; + //U08 fpgaTDiControl; } FPGA_ACTUATORS_T; #pragma pack(pop) @@ -1090,7 +1090,7 @@ *************************************************************************/ U32 getFPGATPiTemp( void ) { - return ( fpgaSensorReadings.fpgaTPiTemp & MASK_OFF_U32_MSB ); + return fpgaSensorReadings.fpgaTPiTemp; } /*********************************************************************//** @@ -1105,11 +1105,160 @@ *************************************************************************/ U32 getFPGATPoTemp( void ) { - return ( fpgaSensorReadings.fpgaTPoTemp & MASK_OFF_U32_MSB ); + return fpgaSensorReadings.fpgaTPoTemp; } /*********************************************************************//** * @brief + * The getFPGATD1Temp function gets the latest conductivity sensor 1 \n + * temperature reading in ADC. + * @details + * Inputs : fpgaSensorReadings.fpgaCD1Temp + * Outputs : none + * @param none + * @return last conductivity sensor 1 outlet temperature reading + *************************************************************************/ +U32 getFPGACD1Temp( void ) +{ + return fpgaSensorReadings.fpgaCD1Temp; +} + +/*********************************************************************//** + * @brief + * The getFPGATD2Temp function gets the latest conductivity sensor 2 \n + * temperature reading in ADC. + * @details + * Inputs : fpgaSensorReadings.fpgaCD2Temp + * Outputs : none + * @param none + * @return last conductivity sensor 2 outlet temperature reading + *************************************************************************/ +U32 getFPGACD2Temp( void ) +{ + return fpgaSensorReadings.fpgaCD2Temp; +} + +/*********************************************************************//** + * @brief + * The getFPGARTDErrorCount function gets error count of the RTD. It covers \n + * all the four conductivity sensors which include temperature sensors + * @details + * Inputs : fpgaSensorReadings.fpgaRTDErrorCnt + * Outputs : none + * @param none + * @return Last error count of the RTD conductivity sensors + *************************************************************************/ +U08 getFPGARTDErrorCount( void ) +{ + return fpgaSensorReadings.fpgaRTDErrorCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGARTDReadCount function gets the read count of the RTD \n + * conductivity sensors. It covers all the 4 conductivity sensors + * @details + * Inputs : fpgaSensorReadings.fpgaRTDReadCnt + * Outputs : none + * @param none + * @return Last read count of the RTC conductivity sensors + *************************************************************************/ +U08 getFPGARTDReadCount( void ) +{ + return fpgaSensorReadings.fpgaRTDReadCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGATRoTemp function gets the latest redundant sensor outlet \n + * temperature reading in ADC. + * @details + * Inputs : fpgaSensorReadings.fpgaTHDoTemp + * Outputs : none + * @param none + * @return Last redundant sensor outlet temperature reading + *************************************************************************/ +U32 getFPGATHDoTemp( void ) +{ + return fpgaSensorReadings.fpgaTHDoTemp; +} + +/*********************************************************************//** + * @brief + * The getFPGATHDoErrorCount gets the error count of the THDo (redundant) \n + * temperature sensor + * @details + * Inputs : fpgaSensorReadings.fpgaTHDoErrorCnt + * Outputs : none + * @param none + * @return Last redundant sensor outlet temperature error count + *************************************************************************/ +U08 getFPGATHDoErrorCount( void ) +{ + return fpgaSensorReadings.fpgaTHDoErrorCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGATHDoReadCount gets the read count of the THDo (redundant) \n + * @details + * Inputs : fpgaSensorReadings.fpgaTHDoReadCnt + * Outputs : none + * @param none + * @return Last redundant sensor outlet temperature error count reading + *************************************************************************/ +U08 getFPGATHDoReadCount( void ) +{ + return fpgaSensorReadings.fpgaTHDoReadCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGATDiTemp function gets the latest dialysate inlet \n + * temperature reading in ADC. + * @details + * Inputs : fpgaSensorReadings.fpgaTDiTemp + * Outputs : none + * @param none + * @return last primary heater outlet temperature reading + *************************************************************************/ +U32 getFPGATDiTemp( void ) +{ + return fpgaSensorReadings.fpgaTDiTemp; +} + +/*********************************************************************//** + * @brief + * The getFPGATDiErrorCount function gets the latest dialysate inlet \n + * temperature error count. + * @details + * Inputs : fpgaSensorReadings.fpgaTDiErrorCnt + * Outputs : none + * @param none + * @return Last dialysate inlet error count + *************************************************************************/ +U08 getFPGATDiErrorCount( void ) +{ + return fpgaSensorReadings.fpgaTDiErrorCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGATDiReadCount function gets the latest dialysate inlet \n + * temperature read count. + * @details + * Inputs : fpgaSensorReadings.fpgaTDiReadCnt + * Outputs : none + * @param none + * @return Last dialysate inlet read count + *************************************************************************/ +U08 getFPGATDiReadCount( void ) +{ + return fpgaSensorReadings.fpgaTDiReadCnt; +} + +/*********************************************************************//** + * @brief * The getFPGAPrimaryHeaterTemp function gets the latest primary heater \n * internal temperature reading. * @details @@ -1125,8 +1274,38 @@ /*********************************************************************//** * @brief + * The getFPGAPrimaryHeaterFlags function gets the latest primary heater \n + * internal temperature sensor flags read + * @details + * Inputs : fpgaSensorReadings.fpgaPrimaryHeaterFlags + * Outputs : none + * @param none + * @return Last primary heater internal temperature sensor flag read + *************************************************************************/ +U08 getFPGAPrimaryHeaterFlags( void ) +{ + return fpgaSensorReadings.fpgaPrimaryHeaterFlags; +} + +/*********************************************************************//** + * @brief + * The geetFPGAPrimaryHeaterReadCount function gets the latest primary heater \n + * internal temperature sensor read count + * @details + * Inputs : fpgaSensorReadings.fpgaPrimaryHeaterReadCnt + * Outputs : none + * @param none + * @return Last primary heater internal temperature sensor read count + *************************************************************************/ +U08 getFPGAPrimaryHeaterReadCount( void ) +{ + return fpgaSensorReadings.fpgaPrimaryHeaterReadCnt; +} + +/*********************************************************************//** + * @brief * The getFPGATrimmerHeaterTemp function gets the latest trimmer heater \n - * internal temperature reading. + * internal temperature sensor reading. * @details * Inputs : fpgaSensorReadings.fpgaTrimmerHeaterIntTemp * Outputs : none @@ -1137,3 +1316,33 @@ { return fpgaSensorReadings.fpgaTrimmerHeaterIntTemp; } + +/*********************************************************************//** + * @brief + * The getFPGATrimmerHeaterFlags function gets the latest trimmer heater \n + * internal temperature flags read. + * @details + * Inputs : fpgaSensorReadings.fpgaTrimmerHeaterFlags + * Outputs : none + * @param none + * @return Last trimmer heater internal temperature flags read + *************************************************************************/ +U08 getFPGATrimmerHeaterFlags( void ) +{ + return fpgaSensorReadings.fpgaTrimmerHeaterFlags; +} + +/*********************************************************************//** + * @brief + * The getFPGATrimmerHeaterReadCount function gets the latest trimmer heater \n + * internal temperature read count. + * @details + * Inputs : fpgaSensorReadings.fpgaTrimmerHeaterReadCnt + * Outputs : none + * @param none + * @return Last trimmer heater internal temperature read count + *************************************************************************/ +U08 getFPGATrimmerHeaterReadCount( void ) +{ + return fpgaSensorReadings.fpgaTrimmerHeaterReadCnt; +} Index: firmware/App/Services/FPGA.h =================================================================== diff -u -r16dfbeeca1bcf1d2115c2f7549999fdaae0700e9 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 16dfbeeca1bcf1d2115c2f7549999fdaae0700e9) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -43,9 +43,34 @@ U32 getFPGALoadCellA2( void ); U32 getFPGALoadCellB1( void ); U32 getFPGALoadCellB2( void ); + U32 getFPGATPiTemp( void ); U32 getFPGATPoTemp( void ); + +U32 getFPGACD1Temp( void ); +U32 getFPGACD2Temp( void ); + +U08 getFPGARTDErrorCount( void ); +U08 getFPGARTDReadCount( void ); + +U32 getFPGATHDoTemp( void ); + +U08 getFPGATHDoErrorCount( void ); +U08 getFPGATHDoReadCount( void ); + +U32 getFPGATDiTemp( void ); + +U08 getFPGATDiErrorCount( void ); +U08 getFPGATDiReadCount( void ); + U16 getFPGAPrimaryHeaterTemp( void ); + +U08 getFPGAPrimaryHeaterFlags( void ); +U08 getFPGAPrimaryHeaterReadCount( void ); + U16 getFPGATrimmerHeaterTemp( void ); +U08 getFPGATrimmerHeaterFlags( void ); +U08 getFPGATrimmerHeaterReadCount( void ); + #endif Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r65cca9d3650f1da299e0c0c682bc557439a407f2 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 65cca9d3650f1da299e0c0c682bc557439a407f2) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -17,9 +17,10 @@ #include // for memcpy() -#include "TaskGeneral.h" +#include "ModeRecirculate.h" #include "OperationModes.h" #include "SystemCommMessages.h" +#include "TaskGeneral.h" #include "Reservoirs.h" /** @@ -30,9 +31,9 @@ // ********** private definitions ********** #define MIN_RESERVOIR_VOLUME_ML 0 ///< Minimum reservoir volume in mL. -#define MAX_RESERVOIR_VOLUME_ML 3000 ///< Maximum reservoir volume in mL. +#define MAX_RESERVOIR_VOLUME_ML 2500 ///< Maximum reservoir volume in mL. #define DEFAULT_FILL_VOLUME_ML 1500 ///< Default fill volume for treatment in mL. -#define DISINFECT_FILL_VOLUME_ML 2900 ///> Fill volume for disinfection in mL. +#define DISINFECT_FILL_VOLUME_ML 2400 ///> Fill volume for disinfection in mL. #define MAX_FILL_VOLUME_ML MAX_RESERVOIR_VOLUME_ML ///> Maximum fill volume in mL. #define DEFAULT_DRAIN_VOLUME_ML 100 ///> Default drain volume in mL. #define MAX_DRAIN_VOLUME_ML MAX_RESERVOIR_VOLUME_ML ///> Maximum drain volume in mL. @@ -128,7 +129,8 @@ BOOL result = FALSE; // fill command only valid in re-circulate mode - if ( MODE_CIRC == getCurrentOperationMode() ) + if ( ( MODE_CIRC == getCurrentOperationMode() ) && + ( RECIRCULATE_MODE_STATE_RECIRC_WATER == getRecirculateModeState() ) ) { // validate parameters if ( fillToVolMl < MAX_FILL_VOLUME_ML ) @@ -212,6 +214,38 @@ return result; } +/*********************************************************************//** + * @brief + * The startTrimmerHeater function handles a start trimmer heater command \n + * from the HD. + * @details + * Inputs : none + * Outputs : start trimmer heater + * @return TRUE if stop drain command successful, FALSE if not. + *************************************************************************/ +BOOL startTrimmerHeater( void ) +{ + BOOL result = FALSE; + // TODO + return result; +} + +/*********************************************************************//** + * @brief + * The stopTrimmerHeater function handles a stop trimmer heater command \n + * from the HD. + * @details + * Inputs : none + * Outputs : stop trimmer heater + * @return TRUE if stop drain command successful, FALSE if not. + *************************************************************************/ +BOOL stopTrimmerHeater( void ) +{ + BOOL result = FALSE; + // TODO + return result; +} + /************************************************************************* * GET SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Services/Reservoirs.h =================================================================== diff -u -r5ff39fd6948ae3656b4035c85325bd8fca0a37f3 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision 5ff39fd6948ae3656b4035c85325bd8fca0a37f3) +++ firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -48,6 +48,8 @@ BOOL stopFill( void ); // handle stop fill command from HD BOOL startDrain( U32 drainToVolMl ); // handle drain command from HD BOOL stopDrain( void ); // handle stop drain command from HD +BOOL startTrimmerHeater( void ); // handle start trimmer heater control command from HD +BOOL stopTrimmerHeater( void ); // handle stop trimmer heater control command from HD DATA_GET_PROTOTYPE( RESERVOIR_ID_T, getActiveReservoir ); DATA_GET_PROTOTYPE( U32, getReservoirFillVolumeTargetMl ); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r5a61bccd959265c00e5276ba23391198ca82b6dd -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 5a61bccd959265c00e5276ba23391198ca82b6dd) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -990,22 +990,26 @@ handleFWVersionCmd( message ); break; - case MSG_ID_DG_SWITCH_RESERVOIR: + case MSG_ID_DG_SWITCH_RESERVOIR_CMD: handleSwitchReservoirCmd( message ); break; - case MSG_ID_DG_FILL: + case MSG_ID_DG_FILL_CMD: handleFillCmd( message ); break; - case MSG_ID_DG_DRAIN: + case MSG_ID_DG_DRAIN_CMD: handleDrainCmd( message ); break; - case MSG_ID_STARTING_STOPPING_TREATMENT: + case MSG_ID_STARTING_STOPPING_TREATMENT_CMD: handleStartStopTreatmentMsg( message ); break; + case MSG_ID_DG_SAMPLE_WATER_CMD: + handleSampleWaterCmd( message ); + break; + case MSG_ID_DG_TESTER_LOGIN_REQUEST: handleTesterLogInRequest( message ); break; @@ -1040,6 +1044,34 @@ handleTestLoadCellOverrideRequest( message ); break; + case MSG_ID_PRESSURE_OVERRIDE: + handleTestPressureSensorOverrideRequest( message ); + break; + + case MSG_ID_PRESSURE_SEND_INTERVAL_OVERRIDE: + handleTestPressureDataBroadcastIntervalOverrideRequest( message ); + break; + + case MSG_ID_RO_PUMP_SET_PT_OVERRIDE: + handleTestROPumpSetPointOverrideRequest( message ); + break; + + case MSG_ID_RO_MEASURED_FLOW_OVERRIDE: + handleTestROMeasuredFlowOverrideRequest( message ); + break; + + case MSG_ID_RO_PUMP_SEND_INTERVAL_OVERRIDE: + handleTestROPumpDataBroadcastIntervalOverrideRequest( message ); + break; + + case MSG_ID_DRAIN_PUMP_SET_PT_OVERRIDE: + handleTestDrainPumpSetPointOverrideRequest( message ); + break; + + case MSG_ID_DRAIN_PUMP_SEND_INTERVAL_OVERRIDE: + handleTestDrainPumpDataBroadcastIntervalOverrideRequest( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rc548570b37339819da825092dd07c7081437f30b -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c548570b37339819da825092dd07c7081437f30b) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -21,6 +21,8 @@ #include "DrainPump.h" #include "LoadCell.h" #include "MsgQueues.h" +#include "ModeStandby.h" +#include "ModeRecirculate.h" #include "OperationModes.h" #include "Reservoirs.h" #include "ROPump.h" @@ -705,20 +707,38 @@ { BOOL startingTreatment; - result = TRUE; memcpy( &startingTreatment, message->payload, sizeof(U32) ); if ( MODE_STAN == getCurrentOperationMode() && TRUE == startingTreatment ) { - requestNewOperationMode( MODE_CIRC ); + result = requestDGStart(); } else if ( MODE_CIRC == getCurrentOperationMode() && FALSE == startingTreatment ) { - requestNewOperationMode( MODE_STAN ); + result = requestDGStop(); } - else + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} + +/************************************************************************* + * @brief + * The handleSampleWaterCmd function handles a sample water command from the HD. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSampleWaterCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == 0 ) + { + if ( MODE_STAN == getCurrentOperationMode() ) { - result = FALSE; + result = requestWaterSample(); } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); @@ -912,3 +932,45 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } + +// MSG_ID_PRESSURE_OVERRIDE: +void handleTestPressureSensorOverrideRequest( MESSAGE_T *message ) +{ + +} + +// MSG_ID_PRESSURE_SEND_INTERVAL_OVERRIDE: +void handleTestPressureDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + +} + +// MSG_ID_RO_PUMP_SET_PT_OVERRIDE: +void handleTestROPumpSetPointOverrideRequest( MESSAGE_T *message ) +{ + +} + +// MSG_ID_RO_MEASURED_FLOW_OVERRIDE: +void handleTestROMeasuredFlowOverrideRequest( MESSAGE_T *message ) +{ + +} + +// MSG_ID_RO_PUMP_SEND_INTERVAL_OVERRIDE: +void handleTestROPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + +} + +// MSG_ID_DRAIN_PUMP_SET_PT_OVERRIDE: +void handleTestDrainPumpSetPointOverrideRequest( MESSAGE_T *message ) +{ + +} + +// MSG_ID_DRAIN_PUMP_SEND_INTERVAL_OVERRIDE: +void handleTestDrainPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + +} Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rc548570b37339819da825092dd07c7081437f30b -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision c548570b37339819da825092dd07c7081437f30b) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -74,6 +74,9 @@ // MSG_ID_STARTING_STOPPING_TREATMENT void handleStartStopTreatmentMsg( MESSAGE_T *message ); +// MSG_ID_DG_SAMPLE_WATER_CMD +void handleSampleWaterCmd( MESSAGE_T *message ); + // *********** public test support message functions ********** #ifdef DEBUG_ENABLED @@ -100,5 +103,26 @@ // MSG_ID_SET_RTC_TIMESTAMP void handleSetRTCTimestamp( MESSAGE_T *message ); +// MSG_ID_PRESSURE_OVERRIDE: +void handleTestPressureSensorOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_PRESSURE_SEND_INTERVAL_OVERRIDE: +void handleTestPressureDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_RO_PUMP_SET_PT_OVERRIDE: +void handleTestROPumpSetPointOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_RO_MEASURED_FLOW_OVERRIDE: +void handleTestROMeasuredFlowOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_RO_PUMP_SEND_INTERVAL_OVERRIDE: +void handleTestROPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DRAIN_PUMP_SET_PT_OVERRIDE: +void handleTestDrainPumpSetPointOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DRAIN_PUMP_SEND_INTERVAL_OVERRIDE: +void handleTestDrainPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + #endif