Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r9df8618dfd95d3af354e6cbb590ebe6f6fd7ccdd -r6e07046677cba738be6f78b155f4f23120a43081 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 9df8618dfd95d3af354e6cbb590ebe6f6fd7ccdd) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 6e07046677cba738be6f78b155f4f23120a43081) @@ -14,8 +14,9 @@ * @date (original) 08-Apr-2020 * ***************************************************************************/ - + #include "DialInFlow.h" +#include "DGDefs.h" #include "ModeTreatment.h" #include "OperationModes.h" #include "SystemCommMessages.h" @@ -105,6 +106,9 @@ static U32 dgReservoirDrainVolumeTargetSet = 0; ///< Drain-to volume commanded. static U32 resUseTimer = 0; ///< Used to track time pumping from active reservoir (for volume used calculation). static F32 resUseVolumeMl = 0.0; ///< Accumulated volume used from active reservoir. + +// DG command response +static DG_CMD_RESPONSE_T dgCmdResp; ///< Used to keep the latest DG command response. // ********** private function prototypes ********** @@ -151,6 +155,11 @@ lgLoadCellReadings[ i ][ j ] = 0.0; } } + + dgCmdResp.commandID = DG_CMD_NONE; + dgCmdResp.rejected = TRUE; + dgCmdResp.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; + smLoadCellReadingsIdx = 0; smLoadCellReadingsTotal[ DG_RESERVOIR_1 ] = 0.0; smLoadCellReadingsTotal[ DG_RESERVOIR_2 ] = 0.0; @@ -735,7 +744,8 @@ *************************************************************************/ void cmdStartDGTrimmerHeater( void ) { - dgTrimmerHeaterOn = TRUE; + dgTrimmerHeaterOn = TRUE; + dgCmdResp.commandID = DG_CMD_NONE; sendDGStartStopTrimmerHeaterCommand( START_DG_CMD ); } @@ -749,7 +759,8 @@ *************************************************************************/ void cmdStopDGTrimmerHeater( void ) { - dgTrimmerHeaterOn = FALSE; + dgTrimmerHeaterOn = FALSE; + dgCmdResp.commandID = DG_CMD_NONE; sendDGStartStopTrimmerHeaterCommand( STOP_DG_CMD ); } @@ -766,7 +777,8 @@ { if ( resID < NUM_OF_DG_RESERVOIRS ) { - dgActiveReservoirSet = resID; + dgActiveReservoirSet = resID; + dgCmdResp.commandID = DG_CMD_NONE; sendDGSwitchReservoirCommand( (U32)resID ); } else @@ -784,7 +796,8 @@ * @return none *************************************************************************/ void cmdStartDGFill( U32 fillToVolMl ) -{ +{ + dgCmdResp.commandID = DG_CMD_NONE; dgReservoirFillVolumeTargetSet = fillToVolMl; sendDGFillCommand( fillToVolMl ); } @@ -802,6 +815,7 @@ { DRAIN_RESERVOIR_CMD_PAYLOAD_T payload; + dgCmdResp.commandID = DG_CMD_NONE; payload.drainToVolumeML = drainToVolMl; payload.tareLoadCells = tareLoadCell; dgReservoirDrainVolumeTargetSet = drainToVolMl; @@ -821,7 +835,38 @@ sendDGSampleWaterCommand(); } +/*********************************************************************//** + * @brief + * The handleDGCommandResponse function processes the latest DG command response. + * @details Inputs: none + * @details Outputs: process command response from DG + * @param cmdRespPtr pointer to DG command response data record + * @return none + *************************************************************************/ +void handleDGCommandResponse( U08 *cmdRespPtr ) +{ + memcpy( &dgCmdResp, cmdRespPtr, sizeof( DG_CMD_RESPONSE_T ) ); + if ( ( TRUE == dgCmdResp.rejected ) && ( DG_CMD_REQUEST_REJECT_REASON_INVALID_PARAMETER == dgCmdResp.rejectCode ) ) + { + activateAlarmNoData( ALARM_ID_DG_COMMAND_INVALID_PARAMETER_FAULT ); + } +} + +/*********************************************************************//** + * @brief + * The getDGCommandResponse function gets the latest command response from DG. + * @details Inputs: dgCmdResp + * @details Outputs: none + * @param cmdRespPtr pointer to data record to copy DG command response to + * @return none + *************************************************************************/ +void getDGCommandResponse( DG_CMD_RESPONSE_T *cmdRespPtr ) +{ + memcpy( &cmdRespPtr, &dgCmdResp, sizeof( DG_CMD_RESPONSE_T ) ); +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/