Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r9d7ad180a18e29ba08bf65228d61b6179ddbfcca -re0e66d4c302c2aa43951ca316689ed4debbff1fb --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 9d7ad180a18e29ba08bf65228d61b6179ddbfcca) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision e0e66d4c302c2aa43951ca316689ed4debbff1fb) @@ -117,14 +117,14 @@ static PUMP_CONTROL_MODE_T dialOutPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Requested control mode for dialysate outlet pump (open or closed loop). static PUMP_CONTROL_MODE_T dialOutPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Currently set control mode for dialysate outlet pump. -DATA_DECL( U32, DialOutDataPub, DialOutDataPublishInterval, DIAL_OUT_DATA_PUB_INTERVAL, DIAL_OUT_DATA_PUB_INTERVAL ); ///< Interval (in ms) at which to publish dialysate outlet data to CAN bus. -DATA_ARRAY_DECL( F32, LoadCellWeightsInGrams, NUM_OF_LOAD_CELLS, loadCellWeightInGrams ); ///< Measured weight from load cells. -DATA_DECL( F32, TotalTargetDialOutVolInMl, referenceUFVolumeInMl, 0.0, 0.0 ); ///< Target ultrafiltration volume (in mL). -DATA_DECL( F32, TotalMeasuredUFVolumeInMl, totalMeasuredUFVolumeInMl, 0.0, 0.0 ); ///< Total measured ultrafiltration volume (in mL). -DATA_DECL( F32, MeasuredDialOutPumpMCSpeed, dialOutPumpMCSpeedRPM, 0.0, 0.0 ); ///< Measured dialysate outlet pump motor controller speed. -DATA_DECL( F32, MeasuredDialOutPumpMCCurrent, dialOutPumpMCCurrentmA, 0.0, 0.0 ); ///< Measured dialysate outlet pump motor controller current. -DATA_DECL( F32, MeasuredDialOutPumpRotorSpeed, dialOutPumpRotorSpeedRPM, 0.0, 0.0 ); ///< Measured dialysate outlet pump rotor speed. -DATA_DECL( F32, MeasuredDialOutPumpSpeed, dialOutPumpSpeedRPM, 0.0, 0.0 ); ///< Measured dialysate outlet pump motor speed. +static OVERRIDE_F32_T loadCellWeightInGrams[ NUM_OF_LOAD_CELLS ]; ///< Measured weight from load cells. +static OVERRIDE_U32_T dialOutDataPublishInterval = { DIAL_OUT_DATA_PUB_INTERVAL, DIAL_OUT_DATA_PUB_INTERVAL, DIAL_OUT_DATA_PUB_INTERVAL, 0 }; ///< Interval (in ms) at which to publish dialysate outlet data to CAN bus. +static OVERRIDE_F32_T referenceUFVolumeInMl = { 0.0, 0.0, 0.0, 0 }; ///< Target ultrafiltration volume (in mL). +static OVERRIDE_F32_T totalMeasuredUFVolumeInMl = { 0.0, 0.0, 0.0, 0 }; ///< Total measured ultrafiltration volume (in mL). +static OVERRIDE_F32_T dialOutPumpMCSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate outlet pump motor controller speed. +static OVERRIDE_F32_T dialOutPumpMCCurrentmA = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate outlet pump motor controller current. +static OVERRIDE_F32_T dialOutPumpRotorSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate outlet pump rotor speed. +static OVERRIDE_F32_T dialOutPumpSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate outlet pump motor speed. static U32 dopControlTimerCounter = 0; ///< Timer counter to determine when to control dialysate outlet pump. static U32 dopCurrErrorDurationCtr = 0; ///< Timer counter for motor current error persistence. @@ -732,12 +732,22 @@ * The getPublishDialOutFlowDataInterval function gets the dialysate out flow \n * data publication interval. * @details - * Inputs : DialOutDataPublishInterval + * Inputs : dialOutDataPublishInterval * Outputs : none * @return the current dialysate out flow data publication interval (in ms). *************************************************************************/ -static DATA_GET( U32, getPublishDialOutDataInterval, DialOutDataPublishInterval ) +static U32 getPublishDialOutDataInterval( void ) +{ + U32 result = dialOutDataPublishInterval.data; + if ( OVERRIDE_KEY == dialOutDataPublishInterval.override ) + { + result = dialOutDataPublishInterval.ovData; + } + + return result; +} + /*********************************************************************//** * @brief * The getLoadCellWeightInGrams function gets the load cell weight. @@ -747,7 +757,26 @@ * @param loadCellID : ID of load cell to get * @return the current load cell weight in grams *************************************************************************/ -DATA_ARRAY_GET( F32, getLoadCellWeightInGrams, loadCellID, NUM_OF_LOAD_CELLS - 1, loadCellWeightInGrams, 0.0 ) +F32 getLoadCellWeightInGrams( U32 loadCellID ) +{ + F32 result = 0.0; + if ( loadCellID <= NUM_OF_LOAD_CELLS - 1 ) + { + if ( OVERRIDE_KEY == loadCellWeightInGrams[ loadCellID ].override ) + { + result = loadCellWeightInGrams[ loadCellID ].ovData; + } + else + { + result = loadCellWeightInGrams[ loadCellID ].data; + } + } + else + { + activateAlarmNoData( ALARM_ID_SOFTWARE_FAULT ); + } + return result; +} /*********************************************************************//** * @brief @@ -757,7 +786,15 @@ * Outputs : none * @return the current target UF volume in mL. *************************************************************************/ -DATA_GET( F32, getTotalTargetDialOutUFVolumeInMl, referenceUFVolumeInMl ) +F32 getTotalTargetDialOutUFVolumeInMl( void ) +{ + F32 result = referenceUFVolumeInMl.data; + if ( OVERRIDE_KEY == referenceUFVolumeInMl.override ) + { + result = referenceUFVolumeInMl.ovData; + } + return result; +} /*********************************************************************//** * @brief @@ -767,7 +804,15 @@ * Outputs : none * @return the current UF volume (in mL). *************************************************************************/ -DATA_GET( F32, getTotalMeasuredUFVolumeInMl, totalMeasuredUFVolumeInMl ) +F32 getTotalMeasuredUFVolumeInMl( void ) +{ + F32 result = totalMeasuredUFVolumeInMl.data; + if ( OVERRIDE_KEY == totalMeasuredUFVolumeInMl.override ) + { + result = totalMeasuredUFVolumeInMl.ovData; + } + return result; +} /*********************************************************************//** * @brief @@ -778,7 +823,15 @@ * Outputs : none * @return the current dialysate outlet pump rotor speed (in RPM). *************************************************************************/ -DATA_GET( F32, getMeasuredDialOutPumpRotorSpeed, dialOutPumpRotorSpeedRPM ) +F32 getMeasuredDialOutPumpRotorSpeed( void ) +{ + F32 result = dialOutPumpRotorSpeedRPM.data; + if ( OVERRIDE_KEY == dialOutPumpRotorSpeedRPM.override ) + { + result = dialOutPumpRotorSpeedRPM.ovData; + } + return result; +} /*********************************************************************//** * @brief @@ -789,7 +842,15 @@ * Outputs : none * @return the current dialysate outlet pump motor speed (in RPM). *************************************************************************/ -DATA_GET( F32, getMeasuredDialOutPumpSpeed, dialOutPumpSpeedRPM ) +F32 getMeasuredDialOutPumpSpeed( void ) +{ + F32 result = dialOutPumpSpeedRPM.data; + if ( OVERRIDE_KEY == dialOutPumpSpeedRPM.override ) + { + result = dialOutPumpSpeedRPM.ovData; + } + return result; +} /*********************************************************************//** * @brief @@ -801,7 +862,15 @@ * @param none * @return the current dialOut pump speed (in RPM). *************************************************************************/ -DATA_GET( F32, getMeasuredDialOutPumpMCSpeed, dialOutPumpMCSpeedRPM ) +F32 getMeasuredDialOutPumpMCSpeed( void ) +{ + F32 result = dialOutPumpMCSpeedRPM.data; + if ( OVERRIDE_KEY == dialOutPumpMCSpeedRPM.override ) + { + result = dialOutPumpMCSpeedRPM.ovData; + } + return result; +} /*********************************************************************//** * @brief @@ -812,8 +881,17 @@ * Outputs : none * @return the current dialOut pump current (in mA). *************************************************************************/ -DATA_GET( F32, getMeasuredDialOutPumpMCCurrent, dialOutPumpMCCurrentmA) +F32 getMeasuredDialOutPumpMCCurrent( void ) +{ + F32 result = dialOutPumpMCCurrentmA.data; + if ( OVERRIDE_KEY == dialOutPumpMCCurrentmA.override ) + { + result = dialOutPumpMCCurrentmA.ovData; + } + return result; +} + /**@}*/ @@ -828,7 +906,7 @@ * dialout vol data publish interval. * @details * Inputs : none - * Outputs : DialOutDataPublishInterval + * Outputs : dialOutDataPublishInterval * @param value : override dialout vol data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -841,8 +919,8 @@ U32 intvl = value / TASK_PRIORITY_INTERVAL; result = TRUE; - DialOutDataPublishInterval.ovData = intvl; - DialOutDataPublishInterval.override = OVERRIDE_KEY; + dialOutDataPublishInterval.ovData = intvl; + dialOutDataPublishInterval.override = OVERRIDE_KEY; } return result; @@ -854,7 +932,7 @@ * of the dialout vol data publish interval. * @details * Inputs : none - * Outputs : DialOutDataPublishInterval + * Outputs : dialOutDataPublishInterval * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetDialOutPumpAndLoadCellDataPublishIntervalOverride( void ) @@ -864,8 +942,8 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - DialOutDataPublishInterval.override = OVERRIDE_RESET; - DialOutDataPublishInterval.ovData = DialOutDataPublishInterval.ovInitData; + dialOutDataPublishInterval.override = OVERRIDE_RESET; + dialOutDataPublishInterval.ovData = dialOutDataPublishInterval.ovInitData; } return result; @@ -875,99 +953,337 @@ * @brief * The testSetDialOutUFRefVolumeOverride function overrides the target \n * dialout vol rate. \n - * The testResetDialOutUFRefVolumeOverride function resets the override of the \n - * target dialout vol rate. * @details - * Inputs : none - * Outputs : TotalTargetDialOutVolInMl + * Inputs : referenceUFVolumeInMl + * Outputs : referenceUFVolumeInMl * @param value : override target dialout vol rate (in mL/min) * @return TRUE if override successful, FALSE if not *************************************************************************/ -DATA_OVERRIDE_FUNC( F32, testSetDialOutUFRefVolumeOverride, testResetDialOutUFRefVolumeOverride, referenceUFVolumeInMl ) +BOOL testSetDialOutUFRefVolumeOverride( F32 value ) +{ + BOOL result = FALSE; + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + referenceUFVolumeInMl.ovData = value; + referenceUFVolumeInMl.override = OVERRIDE_KEY; + } + + return result; +} + /*********************************************************************//** * @brief + * The testResetDialOutUFRefVolumeOverride function resets the override of the \n + * target dialout vol rate. + * @details + * Inputs : referenceUFVolumeInMl + * Outputs : referenceUFVolumeInMl + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetDialOutUFRefVolumeOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + referenceUFVolumeInMl.override = OVERRIDE_RESET; + referenceUFVolumeInMl.ovData = referenceUFVolumeInMl.ovInitData; + } + + return result; +} + +/*********************************************************************//** + * @brief * The testSetDialOutUFTotVolumeOverride function overrides the measured \n * dialout vol rate. \n - * The testResetDialOutUFTotVolumeOverride function resets the override of the \n - * measured dialout vol rate. * @details - * Inputs : none + * Inputs : totalMeasuredUFVolumeInMl * Outputs : totalMeasuredUFVolumeInMl * @param value : override measured dialout vol rate (in mL/min) * @return TRUE if override successful, FALSE if not *************************************************************************/ -DATA_OVERRIDE_FUNC( F32, testSetDialOutUFTotVolumeOverride, testResetDialOutUFTotVolumeOverride, totalMeasuredUFVolumeInMl ) +BOOL testSetDialOutUFTotVolumeOverride( F32 value ) +{ + BOOL result = FALSE; + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + totalMeasuredUFVolumeInMl.ovData = value; + totalMeasuredUFVolumeInMl.override = OVERRIDE_KEY; + } + + return result; +} + /*********************************************************************//** - * @brief testSetMeasuredDialOutPumpRotorSpeedOverride and testResetMeasuredDialOutPumpRotorSpeedOverride + * @brief + * The testResetDialOutUFTotVolumeOverride function resets the override of the \n + * measured dialout vol rate. + * @details + * Inputs : totalMeasuredUFVolumeInMl + * Outputs : totalMeasuredUFVolumeInMl + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetDialOutUFTotVolumeOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + totalMeasuredUFVolumeInMl.override = OVERRIDE_RESET; + totalMeasuredUFVolumeInMl.ovData = totalMeasuredUFVolumeInMl.ovInitData; + } + + return result; +} + +/*********************************************************************//** + * @brief * The testSetMeasuredDialOutPumpRotorSpeedOverride function overrides the measured \n * dialIn pump rotor speed. \n - * The testResetMeasuredDialOutPumpRotorSpeedOverride function resets the override of the \n - * measured dialIn pump rotor speed. * @details - * Inputs : none + * Inputs : DialOutPumpRotorSpeedRPM * Outputs : DialOutPumpRotorSpeedRPM * @param value : override measured dialIn pump rotor speed (in RPM) * @return TRUE if override successful, FALSE if not *************************************************************************/ -DATA_OVERRIDE_FUNC( F32, testSetMeasuredDialOutPumpRotorSpeedOverride, testResetMeasuredDialOutPumpRotorSpeedOverride, dialOutPumpRotorSpeedRPM ) +BOOL testSetMeasuredDialOutPumpRotorSpeedOverride( F32 value ) +{ + BOOL result = FALSE; + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialOutPumpRotorSpeedRPM.ovData = value; + dialOutPumpRotorSpeedRPM.override = OVERRIDE_KEY; + } + + return result; +} + /*********************************************************************//** - * @brief testSetMeasuredDialOutPumpSpeedOverride and testResetMeasuredDialOutPumpSpeedOverride + * @brief + * The testResetMeasuredDialOutPumpRotorSpeedOverride function resets the override of the \n + * measured dialIn pump rotor speed. + * @details + * Inputs : DialOutPumpRotorSpeedRPM + * Outputs : DialOutPumpRotorSpeedRPM + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetMeasuredDialOutPumpRotorSpeedOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialOutPumpRotorSpeedRPM.override = OVERRIDE_RESET; + dialOutPumpRotorSpeedRPM.ovData = dialOutPumpRotorSpeedRPM.ovInitData; + } + + return result; +} + +/*********************************************************************//** + * @brief * The testSetMeasuredDialOutPumpSpeedOverride function overrides the measured \n * dialIn pump motor speed. \n - * The testResetMeasuredDialOutPumpSpeedOverride function resets the override of the \n - * measured dialIn pump motor speed. * @details - * Inputs : none - * Outputs : DialOutPumpSpeedRPM + * Inputs : dialOutPumpSpeedRPM + * Outputs : dialOutPumpSpeedRPM * @param value : override measured dialIn pump motor speed (in RPM) * @return TRUE if override successful, FALSE if not *************************************************************************/ -DATA_OVERRIDE_FUNC( F32, testSetMeasuredDialOutPumpSpeedOverride, testResetMeasuredDialOutPumpSpeedOverride, dialOutPumpSpeedRPM ) +BOOL testSetMeasuredDialOutPumpSpeedOverride( F32 value ) +{ + BOOL result = FALSE; + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialOutPumpSpeedRPM.ovData = value; + dialOutPumpSpeedRPM.override = OVERRIDE_KEY; + } + + return result; +} + /*********************************************************************//** - * @brief testSetMeasuredDialOutPumpMCSpeedOverride and testResetMeasuredDialOutPumpMCSpeedOverride + * @brief + * The testResetMeasuredDialOutPumpSpeedOverride function resets the override of the \n + * measured dialIn pump motor speed. + * @details + * Inputs : dialOutPumpSpeedRPM + * Outputs : dialOutPumpSpeedRPM + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetMeasuredDialOutPumpSpeedOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialOutPumpSpeedRPM.override = OVERRIDE_RESET; + dialOutPumpSpeedRPM.ovData = dialOutPumpSpeedRPM.ovInitData; + } + + return result; +} + +/*********************************************************************//** + * @brief * The testSetMeasuredDialOutPumpMCSpeedOverride function overrides the measured \n * dialIn pump motor speed. \n - * The testResetMeasuredDialOutPumpMCSpeedOverride function resets the override of the \n - * measured dialIn pump motor speed. * @details - * Inputs : none + * Inputs : dialOutPumpMCSpeedRPM * Outputs : dialOutPumpMCSpeedRPM * @param value : override measured dialIn pump speed (in RPM) * @return TRUE if override successful, FALSE if not *************************************************************************/ -DATA_OVERRIDE_FUNC( F32, testSetMeasuredDialOutPumpMCSpeedOverride, testResetMeasuredDialOutPumpMCSpeedOverride, dialOutPumpMCSpeedRPM ) +BOOL testSetMeasuredDialOutPumpMCSpeedOverride( F32 value ) +{ + BOOL result = FALSE; + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialOutPumpMCSpeedRPM.ovData = value; + dialOutPumpMCSpeedRPM.override = OVERRIDE_KEY; + } + + return result; +} + /*********************************************************************//** - * @brief testSetMeasuredDialOutPumpMCCurrentOverride and testResetMeasuredDialOutPumpMCCurrentOverride + * @brief + * The testResetMeasuredDialOutPumpMCSpeedOverride function resets the override of the \n + * measured dialIn pump motor speed. + * @details + * Inputs : dialOutPumpMCSpeedRPM + * Outputs : dialOutPumpMCSpeedRPM + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetMeasuredDialOutPumpMCSpeedOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialOutPumpMCSpeedRPM.override = OVERRIDE_RESET; + dialOutPumpMCSpeedRPM.ovData = dialOutPumpMCSpeedRPM.ovInitData; + } + + return result; +} + +/*********************************************************************//** + * @brief * The testSetMeasuredDialOutPumpMCCurrentOverride function overrides the measured \n * dialIn pump motor current. \n - * The testResetMeasuredDialOutPumpMCCurrentOverride function resets the override of the \n - * measured dialIn pump motor current. * @details - * Inputs : none + * Inputs : dialOutPumpMCCurrentmA * Outputs : dialOutPumpMCCurrentmA * @param value : override measured dialIn pump current (in mA) * @return TRUE if override successful, FALSE if not *************************************************************************/ -DATA_OVERRIDE_FUNC( F32, testSetMeasuredDialOutPumpMCCurrentOverride, testResetMeasuredDialOutPumpMCCurrentOverride, dialOutPumpMCCurrentmA ) +BOOL testSetMeasuredDialOutPumpMCCurrentOverride( F32 value ) +{ + BOOL result = FALSE; + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialOutPumpMCCurrentmA.ovData = value; + dialOutPumpMCCurrentmA.override = OVERRIDE_KEY; + } + + return result; +} + /*********************************************************************//** * @brief + * The testResetMeasuredDialOutPumpMCCurrentOverride function resets the override of the \n + * measured dialIn pump motor current. + * @details + * Inputs : dialOutPumpMCCurrentmA + * Outputs : dialOutPumpMCCurrentmA + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetMeasuredDialOutPumpMCCurrentOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialOutPumpMCCurrentmA.override = OVERRIDE_RESET; + dialOutPumpMCCurrentmA.ovData = dialOutPumpMCCurrentmA.ovInitData; + } + + return result; +} + +/*********************************************************************//** + * @brief * The testSetDialOutLoadCellWeightOverride function overrides the value of the \n * load cell sensor with a given weight (in grams). \n + * @details + * Inputs : loadCellWeightInGrams[] + * Outputs : loadCellWeightInGrams[] + * @param sensor : ID of load cell sensor to override weight for + * @param value : override weight (in grams) for the given sensor + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetDialOutLoadCellWeightOverride( U32 sensor, F32 value ) +{ + BOOL result = FALSE; + + if ( sensor < NUM_OF_LOAD_CELLS ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + loadCellWeightInGrams[ sensor ].ovData = value; + loadCellWeightInGrams[ sensor ].override = OVERRIDE_KEY; + } + } + + return result; +} + +/*********************************************************************//** + * @brief * The testResetDialOutLoadCellWeightOverride function resets the override of the \n * load cell sensor. * @details - * Inputs : none + * Inputs : loadCellWeightInGrams[] * Outputs : loadCellWeightInGrams[] * @param sensor : ID of load cell sensor to override weight for - * @param value : override weight (in grams) for the given sensor * @return TRUE if override successful, FALSE if not *************************************************************************/ -DATA_ARRAY_OVERRIDE_FUNC( F32, testSetDialOutLoadCellWeightOverride, testResetDialOutLoadCellWeightOverride, loadCellWeightInGrams, sensor, NUM_OF_LOAD_CELLS-1 ) +BOOL testResetDialOutLoadCellWeightOverride( U32 sensor ) +{ + BOOL result = FALSE; + if ( sensor < NUM_OF_LOAD_CELLS ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + loadCellWeightInGrams[ sensor ].override = OVERRIDE_RESET; + loadCellWeightInGrams[ sensor ].ovData = loadCellWeightInGrams[ sensor ].ovInitData; + } + } + return result; +} + + Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r521a0569bf3097e9f7075d9c0e99dca9af3e6410 -re0e66d4c302c2aa43951ca316689ed4debbff1fb --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 521a0569bf3097e9f7075d9c0e99dca9af3e6410) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision e0e66d4c302c2aa43951ca316689ed4debbff1fb) @@ -246,9 +246,11 @@ BOOL resumeUF( void ) { BOOL result = FALSE; + TREATMENT_STATE_T trtState = getTreatmentState(); OP_MODE currMode = getCurrentOperationMode(); - if ( ( MODE_TREA == currMode ) && ( DIALYSIS_UF_STATE == currentDialysisState ) && ( UF_PAUSED_STATE == currentUFState ) ) + if ( ( MODE_TREA == currMode ) && ( TREATMENT_DIALYSIS_STATE == trtState ) && + ( DIALYSIS_UF_STATE == currentDialysisState ) && ( UF_PAUSED_STATE == currentUFState ) ) { S32 inletPumpRate = getTargetDialInFlowRate(); Index: firmware/App/Modes/Dialysis.h =================================================================== diff -u -r9d7ad180a18e29ba08bf65228d61b6179ddbfcca -re0e66d4c302c2aa43951ca316689ed4debbff1fb --- firmware/App/Modes/Dialysis.h (.../Dialysis.h) (revision 9d7ad180a18e29ba08bf65228d61b6179ddbfcca) +++ firmware/App/Modes/Dialysis.h (.../Dialysis.h) (revision e0e66d4c302c2aa43951ca316689ed4debbff1fb) @@ -53,15 +53,15 @@ { UF_CMD_PAUSE = 0, ///< Pause UF command. UF_CMD_RESUME, ///< Resume UF command. - NUM_OF_UF_CMDS ///< # of UF commands. + NUM_OF_UF_CMDS ///< Number of UF commands. } UF_CMD_T; /// Enumeration of system message IDs. typedef enum UF_Adjustments { UF_ADJ_TREATMENT_TIME = 0, ///< Adjust treatment time to achieve new ultrafiltration volume. UF_ADJ_UF_RATE, ///< Adjust UF rate to achieve new ultrafiltration volume. - NUM_OF_UF_ADJS ///< # of UF adjustments. + NUM_OF_UF_ADJS ///< Number of UF adjustments. } UF_ADJ_T; // ********** private function prototypes ********** Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r521a0569bf3097e9f7075d9c0e99dca9af3e6410 -re0e66d4c302c2aa43951ca316689ed4debbff1fb --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 521a0569bf3097e9f7075d9c0e99dca9af3e6410) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision e0e66d4c302c2aa43951ca316689ed4debbff1fb) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -32,41 +32,46 @@ static U32 start; #endif + /** + * @addtogroup TreatmentMode + * @{ + */ + // ********** private definitions ********** -#define MAX_TREATMENT_TIME_MINUTES ( 8 * MIN_PER_HOUR ) -#define MAX_UF_RATE_ML_MIN ( (F32)2500 / (F32)MIN_PER_HOUR ) -#define MAX_DIALYSATE_VOLUME_ML ( 180 * ML_PER_LITER ) +#define MAX_TREATMENT_TIME_MINUTES ( 8 * MIN_PER_HOUR ) ///< Maximum treatment time (in minutes). +#define MAX_UF_RATE_ML_MIN ( (F32)2500 / (F32)MIN_PER_HOUR ) ///< Maximum ultrafiltration rate (in mL/min). +#define MAX_DIALYSATE_VOLUME_ML ( 180 * ML_PER_LITER ) ///< Maximum dialysate volume (in mL). -#define TREATMENT_TIME_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) // interval (ms/task time) at which the treatment time data is published on the CAN bus +#define TREATMENT_TIME_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the treatment time & state data is published on the CAN bus // ********** private data ********** -static TREATMENT_STATE_T currentTreatmentState; +static TREATMENT_STATE_T currentTreatmentState; ///< Current state (sub-mode) of treatment mode. -static U32 presTreatmentTimeSecs; -static U32 presBloodFlowRate; -static U32 presDialysateFlowRate; -static F32 presMaxUFVolumeML; -static F32 presUFRate; +static U32 presTreatmentTimeSecs; ///< Prescribed treatment time (in minutes). +static U32 presBloodFlowRate; ///< Prescribed blood flow rate (in mL/min). +static U32 presDialysateFlowRate; ///< Prescribed dialysate flow rate (in mL/min). +static F32 presMaxUFVolumeML; ///< Prescribed ultrafiltration volume (in mL). +static F32 presUFRate; ///< Prescribed ultrafiltration rate (in mL/min). -static U32 treatmentTimeMS; -static U32 lastTreatmentTimeStamp; -static U32 treatmentTimeBroadcastTimerCtr; +static U32 treatmentTimeMS; ///< Elapsed treatment time (in ms). +static U32 lastTreatmentTimeStamp; ///< Last time elapsed treatment time was recorded (a timestamp in ms). +static U32 treatmentTimeBroadcastTimerCtr; ///< Treatment data broadcast timer counter used to schedule when to transmit data. -static BUTTON_STATE_T lastOffButtonState = BUTTON_STATE_RELEASED; +static BUTTON_STATE_T lastOffButtonState = BUTTON_STATE_RELEASED; // TODO - test code - remove later -static F32 pendingUFVolumeChange; ///< An ultrafiltration volume change (mL) is pending user confirmation. -static F32 pendingUFRateChange; ///< An ultrafiltration rate change (mL/min) is pending user confirmation. -static U32 pendingTreatmentTimeChange; ///< A treatment time change (min) is pending user confirmation. +static F32 pendingUFVolumeChange; ///< An ultrafiltration volume change (mL) is pending user confirmation. +static F32 pendingUFRateChange; ///< An ultrafiltration rate change (mL/min) is pending user confirmation. +static U32 pendingTreatmentTimeChange; ///< A treatment time change (min) is pending user confirmation. // ********** private function prototypes ********** static TREATMENT_STATE_T handleTreatmentStartState( void ); static TREATMENT_STATE_T handleTreatmentDialysisState( void ); static TREATMENT_STATE_T handleTreatmentStopState( void ); -/************************************************************************* +/*********************************************************************//** * @brief * The initTreatmentMode function initializes the Treatment Mode module. * @details @@ -84,7 +89,7 @@ treatmentTimeBroadcastTimerCtr = 0; } -/************************************************************************* +/*********************************************************************//** * @brief * The transitionToTreatmentMode function prepares for transition to treatment mode. * @details @@ -112,7 +117,7 @@ #endif } -/************************************************************************* +/*********************************************************************//** * @brief * The getTreatmentState function gets the current treatment mode state. * @details @@ -125,7 +130,7 @@ return currentTreatmentState; } -/************************************************************************* +/*********************************************************************//** * @brief * The execTreatmentMode function executes the Treatment Mode state machine. * @details @@ -229,7 +234,7 @@ #endif } -/************************************************************************* +/*********************************************************************//** * @brief * The handleTreatmentStartState function handles the Start state of \n * the Treatment Mode state machine. @@ -261,7 +266,7 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The handleTreatmentDialysisState function handles the Dialysis state of \n * the Treatment Mode state machine. @@ -302,7 +307,7 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The handleTreatmentStopState function executes the Stop state of the \n * Treatment Mode state machine. @@ -338,7 +343,7 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The verifyTreatmentDurationSettingChange function verifies the user treatment \n * duration setting change. @@ -377,7 +382,7 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The verifyUFSettingsChange function verifies new ultrafiltration settings \n * from the user. @@ -454,7 +459,7 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The verifyUFSettingsConfirmation function verifies the user confirmed \n * ultrafiltration settings change(s) and, if valid, implements the new settings. Index: firmware/App/Modes/ModeTreatment.h =================================================================== diff -u -r521a0569bf3097e9f7075d9c0e99dca9af3e6410 -re0e66d4c302c2aa43951ca316689ed4debbff1fb --- firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision 521a0569bf3097e9f7075d9c0e99dca9af3e6410) +++ firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision e0e66d4c302c2aa43951ca316689ed4debbff1fb) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -20,6 +20,14 @@ #include "HDCommon.h" #include "Dialysis.h" +/** + * @defgroup TreatmentMode TreatmentMode + * @brief TreatmentMode module. + * + * @addtogroup TreatmentMode + * @{ + */ + // ********** public definitions ********** /// Sub-mode states while in treatment mode @@ -36,19 +44,21 @@ TREATMENT_RECIRC_STOP_STATE, ///< Recirculate stopped. Blood pump off. Blood lines open. Waiting for patient to unshunt and connect and resume treatment. TREATMENT_DIALYSIS_END_STATE, ///< Dialysis has ended. Blood pump slowed. Dialyzer is bypassed. Dialysate is recirculated. User can rinseback. TREATMENT_END_STATE, ///< Treatment has ended. All pumps off. Dialyzer is bypassed. Blood lines are closed. User to disconnect. - NUM_OF_TREATMENT_STATES ///< # of treatment states (sub-modes). + NUM_OF_TREATMENT_STATES ///< Number of treatment states (sub-modes). } TREATMENT_STATE_T; // ********** private function prototypes ********** -void initTreatmentMode( void ); // initialize this module -void transitionToTreatmentMode( void ); // prepares for transition to treatment mode -void execTreatmentMode( void ); // execute the treatment mode state machine (call from OperationModes) +void initTreatmentMode( void ); // initialize this module +void transitionToTreatmentMode( void ); // prepares for transition to treatment mode +void execTreatmentMode( void ); // execute the treatment mode state machine (call from OperationModes) TREATMENT_STATE_T getTreatmentState( void ); BOOL verifyTreatmentDurationSettingChange( U32 treatmentTime ); BOOL verifyUFSettingsChange( F32 uFVolume, UF_ADJ_T adjustment ); BOOL verifyUFSettingsConfirmation( BOOL confirmed, F32 uFVolume, U32 treatmentTime, F32 uFRate ); +/**@}*/ + #endif