Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r09cde48e11d32be58fe9e1e7c88ada33cff664f5 -rac029c36127b916d68c0039a470c3e4c68879adf --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 09cde48e11d32be58fe9e1e7c88ada33cff664f5) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision ac029c36127b916d68c0039a470c3e4c68879adf) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2020-2023 Diality Inc. - All Rights Reserved. +* Copyright (c) 2020-2024 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 Reservoirs.c * -* @author (last) Michael Garthwaite -* @date (last) 18-Aug-2023 +* @author (last) Dara Navaei +* @date (last) 02-Mar-2024 * * @author (original) Sean * @date (original) 18-Mar-2020 @@ -101,7 +101,7 @@ static HEATERS_TEMPERATURE_CALC_DATA_T heatersTempCalc; ///< Heaters temperature calculations data structure. static U32 dataPublishCounter; ///< used to schedule reservoir data publication to CAN bus. -static OVERRIDE_U32_T activeReservoir = { 0, 0, 0, 0 }; ///< The active reservoir that the DG is filling/draining/etc. +static OVERRIDE_U32_T activeReservoir = { 0, 0, 0, 0 }; ///< The active reservoir that serves the HD dialysate need. static OVERRIDE_U32_T fillVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir fill volume (in mL). static OVERRIDE_U32_T drainVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir drain volume (in mL). static OVERRIDE_U32_T reservoirDataPublishInterval = { RESERVOIR_DATA_PUB_INTERVAL, @@ -125,6 +125,7 @@ static RESERVOIRS_PREVIOUS_STATUS reservoirPreviousStatus[ NUM_OF_DG_RESERVOIRS ]; ///< Reservoirs previous status. static HD_MODE_SUB_MODE_T hdModes; ///< HD operations mode. static NV_OPS_T nvOps; ///< Non-volatile memory operations. +static BOOL transferInProgress; ///< Flag indicates if transfer is in progress between reservoirs. // ********** private function prototypes ********** @@ -149,6 +150,7 @@ dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; nvOps.hasDisStatusBeenWrittenToNV = FALSE; nvOps.hasROGenVolBeenWrittenToNV = FALSE; + transferInProgress = FALSE; memset( &reservoirPreviousStatus, 0.0, sizeof( RESERVOIRS_PREVIOUS_STATUS ) * NUM_OF_DG_RESERVOIRS ); } @@ -173,7 +175,8 @@ getNVRecord2Driver( GET_CAL_HEATING_RECORD, (U08*)&heatingConstsCalRecord, sizeof( heatingConstsCalRecord ), NUM_OF_CAL_DATA_RSRVRS, ALARM_ID_DG_HEATING_INVALID_CAL_RECORD ); - getNVRecord2Driver( GET_CAL_FILL_CONDUCTIVITIES_RECORD, (U08*)&fillCondCalRecord, sizeof( fillCondCalRecord ), 0, ALARM_ID_NO_ALARM ); + getNVRecord2Driver( GET_CAL_FILL_CONDUCTIVITIES_RECORD, (U08*)&fillCondCalRecord, sizeof( fillCondCalRecord ), + NUM_OF_ACID_TYPE, ALARM_ID_DG_FILL_CONDUCTIVITIES_INVALID_CAL_RECORD ); } // If the mode is fault or it is standby and the RO volume has not been written already, write it @@ -223,7 +226,8 @@ calStatus |= getNVRecord2Driver( GET_CAL_BICARB_CONCENTRATES, (U08*)&bicarbConcentrateCalRecord, sizeof( bicarbConcentrateCalRecord ), NUM_OF_ACID_AND_BICARB_NV_DATA_TO_CHECK, ALARM_ID_DG_BICARB_CONCENTRATE_INVALID_CAL_RECORD ); - calStatus |= getNVRecord2Driver( GET_CAL_FILL_CONDUCTIVITIES_RECORD, (U08*)&fillCondCalRecord, sizeof( fillCondCalRecord ), 0, ALARM_ID_NO_ALARM ); + calStatus |= getNVRecord2Driver( GET_CAL_FILL_CONDUCTIVITIES_RECORD, (U08*)&fillCondCalRecord, sizeof( fillCondCalRecord ), + NUM_OF_ACID_TYPE, ALARM_ID_DG_FILL_CONDUCTIVITIES_INVALID_CAL_RECORD ); if ( TRUE == calStatus ) { @@ -285,6 +289,11 @@ cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_INVALID_MODE; } + if ( FALSE == cmdResponse.rejected ) + { + transferInProgress = FALSE; + } + sendCommandResponseMsg( &cmdResponse ); } @@ -333,6 +342,11 @@ cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_INVALID_MODE; } + if ( FALSE == cmdResponse.rejected ) + { + transferInProgress = TRUE; + } + sendCommandResponseMsg( &cmdResponse ); } @@ -354,16 +368,16 @@ cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; // fill command only valid in generation idle mode - if ( ( DG_MODE_GENE == getCurrentOperationMode() ) && ( ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == getCurrentGenIdleState() ) || - ( DG_GEN_IDLE_MODE_STATE_HANDLE_BAD_FILL == getCurrentGenIdleState() ) ) ) + if ( ( DG_MODE_GENE == getCurrentOperationMode() ) && + ( ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == getCurrentGenIdleState() ) || ( DG_GEN_IDLE_MODE_STATE_HANDLE_BAD_FILL == getCurrentGenIdleState() ) ) ) { // validate parameters if ( fillToVolMl < MAX_FILL_VOLUME_ML ) { fillVolumeTargetMl.data = fillToVolMl; cmdResponse.rejected = FALSE; - if ( ( FALSE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) || // reject moving to fill mode if + if ( ( FALSE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) && // reject moving to fill mode if ( FALSE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) // alarm is active { requestNewOperationMode( DG_MODE_FILL ); @@ -543,6 +557,18 @@ /*********************************************************************//** * @brief + * The isReservoirTransferInProgress function gets the transferInProgress flag. + * @details Inputs: transferInProgress + * @details Outputs: none + * @return reservoir in progress flag. + *************************************************************************/ +BOOL isReservoirTransferInProgress( void ) +{ + return transferInProgress; +} + +/*********************************************************************//** + * @brief * The getTargetDialysateFlowLPM function returns the target dialysate flow * rate in L/min. * @details Inputs: none @@ -1224,7 +1250,7 @@ * @details Outputs: acidConcentrateCalRecord, bicarbConcentrateCalRecord * @param acid which is the acid dialysate mixing ratio * @param bicarb which is the bicarb dialysate mixing ratio - * @return TRUE if tare successful, FALSE if not + * @return TRUE if set successful, FALSE if not *************************************************************************/ BOOL testSetDialysateMixingRatios( F32 acid, F32 bicarb ) { @@ -1246,7 +1272,7 @@ * reservoir data publish interval. * @details Inputs: reservoirDataPublishInterval * @details Outputs: reservoirDataPublishInterval - * @param: value override reservoir data publish interval with (in ms) + * @param value override reservoir data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetReservoirDataPublishIntervalOverride( U32 value )