Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r174c9ba02da6790f01ea9141ab1cc1d28388f2f8 -r2c85a6499b030fa3021cd5d8567af9dbc01bf552 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 174c9ba02da6790f01ea9141ab1cc1d28388f2f8) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 2c85a6499b030fa3021cd5d8567af9dbc01bf552) @@ -56,10 +56,10 @@ // DG status static DG_OP_MODE_T dgCurrentOpMode = DG_MODE_INIT; ///< Current DG operation mode. -static U32 dgSubMode = 0; ///< Current state (sub-mode) of current DG operation mode. +static U32 dgSubMode = 0; ///< Current state (sub-mode) of current DG operation mode. +static BOOL dgStartCommandSent = FALSE; ///< Flag indicates command to start DG has been sent. static BOOL dgStarted = FALSE; ///< Flag indicates whether we have commanded the DG to start or stop. static BOOL dgTrimmerHeaterOn = FALSE; ///< Flag indicates whether we have commanded the DG to start or stop the trimmer heater. -static BOOL dgWaterSampled = FALSE; ///< Flag indicates whether we have commanded the DG to sample water. // State machine states /// Current state of treatment mode reservoir management. @@ -105,8 +105,9 @@ static DG_CMD_RESPONSE_T dgCmdResp[ NUM_OF_DG_COMMANDS ]; ///< Keep the latest DG command response for each command. // ********** private function prototypes ********** + +static void checkDGRestart( void ); - /*********************************************************************//** * @brief * The initDGInterface function initializes the DGInterface module. @@ -120,7 +121,6 @@ dgStarted = FALSE; dgTrimmerHeaterOn = FALSE; - dgWaterSampled = FALSE; dgPrimaryTempSet = 0.0; dgTrimmerTempSet = 0.0; dgActiveReservoirSet = DG_RESERVOIR_2; @@ -169,6 +169,9 @@ void execDGInterfaceMonitor( void ) { // TODO - make sure DG sensor/state data is coming in timely manner (e.g. load cells s/b every 100 ms) + + // Check to see if DG has restarted + checkDGRestart(); } @@ -693,7 +696,7 @@ *************************************************************************/ void cmdStartDG( void ) { - dgStarted = TRUE; + dgStartCommandSent = TRUE; sendDGStartStopCommand( START_DG_CMD ); } @@ -798,8 +801,22 @@ { dgCmdResp[ DG_CMD_START_FILL ].commandID = DG_CMD_NONE; dgReservoirFillVolumeTargetSet = fillToVolMl; - sendDGFillCommand( fillToVolMl ); + sendDGFillCommand( DG_CMD_START, fillToVolMl ); } + +/*********************************************************************//** + * @brief + * The cmdStopDGFill function sends a fill command with stop parameter message to the DG. + * @details Inputs: none + * @details Outputs: fill command with stop parameter sent to DG. + * @return none + *************************************************************************/ +void cmdStopDGFill( void ) +{ + dgCmdResp[ DG_CMD_STOP_FILL ].commandID = DG_CMD_NONE; + dgReservoirFillVolumeTargetSet = 0; + sendDGFillCommand( DG_CMD_STOP, 0 ); +} /*********************************************************************//** * @brief @@ -828,10 +845,9 @@ * @details Outputs: sample water command sent to DG. * @return none *************************************************************************/ -void cmdDGSampleWater( void ) +void cmdDGSampleWater( SAMPLE_WATER_CMD_T cmd ) { - dgWaterSampled = TRUE; - sendDGSampleWaterCommand(); + sendDGSampleWaterCommand( cmd ); } /*********************************************************************//** @@ -897,7 +913,33 @@ return hasCommandResp; } +/*********************************************************************//** + * @brief + * The checkDGRestart function checks to see if DG has restarted after started + * by HD and triggers appropriate alarm. + * @details Inputs: dgStarted + * @details Outputs: triggers a fault alarm if DG restarted + * @return none + *************************************************************************/ +static void checkDGRestart( void ) +{ + if ( ( dgStartCommandSent == TRUE ) && ( DG_MODE_CIRC == dgCurrentOpMode ) ) + { + dgStartCommandSent = FALSE; + dgStarted = TRUE; + } + if ( TRUE == dgStarted ) + { + if ( ( DG_MODE_FAUL != dgCurrentOpMode ) && ( DG_MODE_CIRC != dgCurrentOpMode ) && + ( DG_MODE_FILL != dgCurrentOpMode ) && ( DG_MODE_DRAI != dgCurrentOpMode ) ) + { + activateAlarmNoData( ALARM_ID_DG_RESTARTED_FAULT ); + } + } +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/