/************************************************************************** * * Copyright (c) 2020-2023 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 DGInterface.h * * @author (last) Sean Nash * @date (last) 08-Aug-2023 * * @author (original) Sean * @date (original) 08-Apr-2020 * ***************************************************************************/ #ifndef __DG_H__ #define __DG_H__ #include "HDCommon.h" #include "DGDefs.h" /** * @defgroup DGInterface DGInterface * @brief DG interface/monitor module. Interfaces with and monitors the * DG (dialysate generator) sub-system. * * @addtogroup DGInterface * @{ */ // ********** public definitions ********** #define DEFAULT_TARGET_FILL_FLOW_RATE_LPM 0.8F ///< Default target fill flow rate in L/min. #define DRAIN_RESERVOIR_TO_VOLUME_ML 0 ///< Drain reservoir to this volume (in mL) during treatment. #define LOAD_CELL_PRIMARY_BACKUP_MAX_ALLOWED_DRIFT_GRAMS 10.0F ///< Reservoir load cell drift difference allowed #define LOAD_CELL_ILLEGAL_WEIGHT_VALUE -10000.0F ///< Initial value for Load Cells, known bad value /// DG Concentrate ratios data structure. typedef struct { F32 acidMixingRatio; ///< Acid mixing ratio F32 bicarbMixingRatio; ///< Bicarb mixing ratio U32 timeFillPrepMS; ///< Fill prepare time in milliseconds } DG_MIXING_RATIOS_T; /// Payload record structure for a reservoirs data message. typedef struct { U32 resID; ///< Active reservoir ID U32 setFillToVolumeMl; ///< Reservoir set fill to target volume in ml U32 setDrainToVolumeMl; ///< Reservoir set drain to target volume in ml U32 timeReservoirCycleMS; ///< Reservoir time cycle in milliseconds U32 timeReservoirFill2SwitchMS; ///< Reservoir time fill to switch in milliseconds F32 timeUFDecayMS; ///< Ultrafilter decay time in milliseconds F32 tempUFFill; ///< Ultrafilter fill temperature in C F32 tempReservoirUseActual; ///< Reservoir actual use temperature in C F32 tempReservoirEndFill; ///< Reservoir end of the fill temperature in C F32 tempAvgFill; ///< Average fill temperature in C F32 tempLastFill; ///< Last fill temperature in C F32 timereservoirFillMS; ///< Reservoir fill time in milliseconds F32 tempRsrvr0ActualTrimmer; ///< Temperature actual reservoir in C. F32 tempFillMixAvgTrimmer; ///< Temperature fill mix average trimmer in C. F32 tempRsrvrEndFillTrimmer; ///< Temperature reservoir end fill trimmer in C. } DG_RESERVOIRS_DATA_PAYLOAD_T; /// Payload record structure for a drain reservoir command message. typedef struct { U32 drainToVolumeML; ///< Drain to target volume in ml BOOL tareLoadCells; ///< Flag indicates to tare load cells or not BOOL rinseConcentrateLines; ///< Flag indicates to rinse concentrate lines or not BOOL cmd; ///< Flag indicates to start or stop the drain mode } DRAIN_RESERVOIR_CMD_PAYLOAD_T; /// DG command response data record structure. typedef struct { U32 commandID; ///< The command DG is responding to BOOL rejected; ///< Flag indicates if the command has been rejected U32 rejectCode; ///< Reason code for rejecting the command } DG_CMD_RESPONSE_T; /// DG heat/chemical disinfects and flush state for UI structure. typedef struct DG_Disinfects { U32 chemDisinfectUIState; ///< DG chemical disinfect UI state U32 heatDisinfectUIState; ///< DG heat disinfect UI state U32 flushUIState; ///< DG flush UI state } DG_DISINFECT_UI_STATES_T; /// HD version of the DG service record typedef struct { DG_SERVICE_RECORD_T dgServiceRecord; ///< HD version of the DG service record. DG_USAGE_INFO_RECORD_T dgUsageInfo; ///< HD version of the DG usage info. BOOL isDGServiceRecordAvailable; ///< Flag to indicate DG service record is available. BOOL isDGUsageInfoAvailable; ///< Flag to indicate DG usage info is available. } DG_SERVICE_AND_USAGE_DATA_T; // ********** public function prototypes ********** void initDGInterface( void ); void execDGInterfaceMonitor( void ); DG_OP_MODE_T getDGOpMode( void ); U32 getDGSubMode( void ); DG_RESERVOIR_ID_T getDGActiveReservoir( void ); DG_RESERVOIR_ID_T getDGInactiveReservoir( void ); BOOL hasDGCompletedReservoirSwitch( void ); BOOL getDialysateFlowDataFreshFlag( void ); F32 getDGDialysateFlowRateLMin( void ); F32 getDGRawDialysateFlowRateLMin( void ); F32 getLoadCellWeight( LOAD_CELL_ID_T loadCellID ); F32 getReservoirWeight( DG_RESERVOIR_ID_T resID ); F32 getReservoirWeightLargeFilter( DG_RESERVOIR_ID_T resID ); F32 getReservoirBackupWeightLargeFilter( DG_RESERVOIR_ID_T resID ); F32 getDialysateTemperature( void ); F32 getRedundantDialysateTemperature( void ); F32 getHeatDisinfectTemperatureSensorValue( void ); BOOL getTrimmerHeaterCommandedOn( void ); DG_DISINFECT_UI_STATES_T getDGDisinfectsStates( void ); F32 getDialysateTemperature( void ); DG_MIXING_RATIOS_T getDGMixingRatios( void ); void getHDVersionDGServiceAndUsageData( DG_SERVICE_AND_USAGE_DATA_T* data ); void setDGOpMode( U32 opMode, U32 subMode ); void setDialysateTemperatureReadings( F32 tdi, F32 tro, F32 thd ); void setDGReservoirsData( DG_RESERVOIR_ID_T resID, U32 fillVol, U32 drainVol ); void setDialysateFlowData( FLOW_SENSORS_DATA_T flowRates ); void setNewLoadCellReadings( F32 res1Primary, F32 res1Backup, F32 res2Primary, F32 res2Backup ); void setDGDisinfectsStates( DG_DISINFECT_UI_STATES_T states ); void setDGMixingRatios( DG_MIXING_RATIOS_T ratios ); void setDGHeatersData( HEATERS_DATA_T *data ); void setHDVersionDGServiceRecord( DG_SERVICE_RECORD_T* data ); void setHDVersionDGUsageInfo( DG_USAGE_INFO_RECORD_T* data ); void cmdSetDGDialysateHeatingParams( DG_CMD_DIALYSATE_HEATING_PARAMS_T heatingParams ); void cmdStartDG( void ); void cmdStopDG( void ); void cmdSetDGActiveReservoir( DG_SWITCH_RSRVRS_CMD_T *cmd ); void cmdChangeDGValveSetting( DG_VALVE_SETTING_ID_T valveSettingID ); void cmdStartDGFill( U32 fillToVolMl, F32 targetFlowLPM ); void cmdStopDGFill( void ); void cmdStartDGDrain( U32 drainToVolMl, BOOL tareLoadCell, BOOL rinse, BOOL start ); void cmdStartDGTrimmerHeater( void ); void cmdStopDGTrimmerHeater( void ); void cmdDGSampleWater( SAMPLE_WATER_CMD_T cmd ); void cmdStartDGFlush( void ); void cmdDGParkConcentratePumps( void ); void cmdStopDGFlush( void ); void cmdStartDGHeatDisinfect( void ); void cmdStopDGHeatDisinfect( void ); void cmdStartDGChemicalDisinfect( void ); void cmdStopDGChemicalDisinfect( void ); void cmdStartDGChemicalFlushDisinfect( void ); void cmdStopDGChemFlushDisinfect( void ); void cmdStopDGActiveCool( void ); void cmdStartDGROPermeateSampleMode( void ); void cmdStopDGROPermeateSampleMode( void ); void cmdRequestDGMixingRatios( void ); void cmdSetDGToServiceMode( void ); void handleDGCommandResponse( DG_CMD_RESPONSE_T *dgCmdRespPtr ); BOOL getDGCommandResponse( U32 commandID, DG_CMD_RESPONSE_T *cmdRespPtr ); void checkDialysateTemperature( void ); BOOL testSetDialOutLoadCellWeightOverride( U32 sensor, F32 value ); BOOL testResetDialOutLoadCellWeightOverride( U32 sensor ); /**@}*/ #endif