Index: firmware/App/Controllers/DialysatePumps.c =================================================================== diff -u -r5422509f9d8db102b62952ba9f5923e832d6b2fa -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision 5422509f9d8db102b62952ba9f5923e832d6b2fa) +++ firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -258,6 +258,7 @@ * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT when invalid pump id supplied. * @param pumpId pump id to set the new speed. * @param rpm new dialysate pump target RPM + * @param isOpenLoopControlEnabled dialysate pump control method * @return TRUE if new target RPM is set, FALSE if not *************************************************************************/ BOOL setDialysatePumpTargetRPM( DIALYSATE_PUMPS_T pumpId, U32 rpm, BOOL isOpenLoopControlEnabled ) Index: firmware/App/Modes/ModeGenDialysate.c =================================================================== diff -u -r5422509f9d8db102b62952ba9f5923e832d6b2fa -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 5422509f9d8db102b62952ba9f5923e832d6b2fa) +++ firmware/App/Modes/ModeGenDialysate.c (.../ModeGenDialysate.c) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -43,13 +43,6 @@ #define FRESH_DIAL_PUMP_INITIAL_RPM 2500 ///< Nominal RPM target for fresh dialysate pump to maintain required pressure. #define SPENT_DIAL_PUMP_INITIAL_RPM 2000 ///< Nominal RPM target for spent dialysate pump to maintain required pressure. #define HYD_CHAMBER_FLUID_TEMP_C_MIN 35.0F ///< Minimum hydraulics fluid temperature in deg celcius -#define HYD_CHAMBER_PRES_CHECK_TIME_OUT ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< Time out period when hydraulics chamber pressure check initiated -#define SPENT_DIAL_PRES_CHECK_TIME_OUT ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< Time out period when spent dialysate pressure check initiated -//TODO : Needs further finetuning. currently max negative pressure reaches around 11.5 psi +/- 5% values defined for now -//#define HYD_CHAMBER_TARGET_NEG_PRESS_MIN_PSI (-11.7877F) ///< Hydraulics chamber minimum negative pressure(D9/PHo) in psi. -//#define HYD_CHAMBER_TARGET_NEG_PRESS_MAX_PSI (-12.2789F) ///< Hydraulics chamber maximum negative pressure(D9/PHo) in psi. -#define HYD_CHAMBER_TARGET_NEG_PRESS_MIN_PSI (-10.000F) ///< Hydraulics chamber minimum negative pressure(D9/PHo) in psi. -#define HYD_CHAMBER_TARGET_NEG_PRESS_MAX_PSI (-12.075F) ///< Hydraulics chamber maximum negative pressure(D9/PHo) in psi. #define GEN_DIALYSATE_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the gen dialysate mode data published. /// Payload record structure for Gen dialysate execution state set request @@ -62,8 +55,6 @@ static DD_GEND_MODE_STATE_T genDialysateState = DD_GEND_STATE_START; ///< Currently active gen dialysate state. static OVERRIDE_F32_T targetHydChamberFluidTemp; ///< Target hydraulics chamber fluid temperature. -static U32 hydChamberPressureCheckStartTimeMS; ///< Current time when hydraulics chamber pressure check satrted in milliseconds. -static U32 spentDialPressureCheckStartTimeMS; ///< Current time when spent dialysate pressure check started in milliseconds. static OVERRIDE_U32_T isDialDeliveryInProgress; ///< To indicate dialysate started delivering to dialyzer for treatment (overrideable) static OVERRIDE_U32_T isDialysateGoodtoDeliver; ///< Flag indicating whether ready to deliver dialysate or not. static U32 genDialysateDataPublicationTimerCounter; ///< Used to schedule generate dialysate data publication to CAN bus. @@ -75,13 +66,10 @@ static void setModeGenDStateTransition( DD_GEND_MODE_STATE_T state ); static BOOL hydChamberWaterInletControl( void ); -static DD_GEND_MODE_STATE_T handleGenDHydraulicsChamberWaterInletCheckState( void ); -static DD_GEND_MODE_STATE_T handleGenDHydChamberPressureCheckState( void ); -static DD_GEND_MODE_STATE_T handleGenDFreshDialysatePressureCheckState( void ); -static DD_GEND_MODE_STATE_T handleGenDSpentDialysatePressureCheckState( void ); -static DD_GEND_MODE_STATE_T handleGenDProduceDialysateState( void ); +static DD_GEND_MODE_STATE_T handleGenDDialysateBypassState( void ); static DD_GEND_MODE_STATE_T handleGenDDialysateDeliveryState( void ); static DD_GEND_MODE_STATE_T handleGenDDialysateDeliveryPauseState( void ); +static DD_GEND_MODE_STATE_T handleGenDDialysateIsolatedUFState( void ); static F32 getGenDialysateTargetTemperature( void ); static void publishGenDialysateModeData( void ); @@ -107,8 +95,6 @@ isDialDeliveryInProgress.ovData = FALSE; isDialDeliveryInProgress.ovInitData = FALSE; isDialDeliveryInProgress.override = OVERRIDE_RESET; - hydChamberPressureCheckStartTimeMS = 0; - spentDialPressureCheckStartTimeMS = 0; genDialysateDataPublishInterval.data = GEN_DIALYSATE_DATA_PUBLISH_INTERVAL; genDialysateDataPublishInterval.ovData = GEN_DIALYSATE_DATA_PUBLISH_INTERVAL; genDialysateDataPublishInterval.ovInitData = 0; @@ -180,84 +166,25 @@ // Do nothing break; - case DD_GEND_HYD_CHAMBER_WATER_INLET_CHECK_STATE: - // Close all balancing chamber and hydraulics valves - valveControlForBCClosedState(); - setHydValvesStatetoClosedState(); - setUFValvesStatetoClosedState(); + case DD_GEND_DIALYSATE_BYPASS_STATE: + //Previous state setValveState( M4_VALV, VALVE_STATE_OPEN ); - // Get the target temperature from TD targetHydChamberFluidTemp.data = getTDTargetDialysateTemperature(); - // Turn on the primary heater setHeaterTargetTemperature( D5_HEAT, getGenDialysateTargetTemperature() ); startHeater( D5_HEAT ); lastDialTargetTemperatureSet = getGenDialysateTargetTemperature(); - break; - case DD_GEND_HYD_CHAMBER_PRESSURE_CHECK_STATE: - //Previous state - setValveState( M4_VALV, VALVE_STATE_OPEN ); - startHeater( D5_HEAT ); - - // Open up VHo valve setValveState( D14_VALV, VALVE_STATE_OPEN ); - // Start timer for hyd chamber negative pressure check state - hydChamberPressureCheckStartTimeMS = getMSTimerCount(); - // Start D12/DGP pump - setDialysatePumpTargetRPM( D12_PUMP, FRESH_DIAL_PUMP_INITIAL_RPM, TRUE ); - break; - - case DD_GEND_FRESH_DIALYSATE_PRESSURE_CHECK_STATE: - //Previous state - setValveState( M4_VALV, VALVE_STATE_OPEN ); - startHeater( D5_HEAT ); - setValveState( D14_VALV, VALVE_STATE_OPEN ); - setDialysatePumpTargetRPM( D12_PUMP, FRESH_DIAL_PUMP_INITIAL_RPM, TRUE ); - - // Lets be DGP continue running since pressure relief valve was set/ tuned part of priming process - hydChamberPressureCheckStartTimeMS = getMSTimerCount(); - break; - - case DD_GEND_SPENT_DIALYSATE_PRESSURE_CHECK_STATE: - //Previous state - setValveState( M4_VALV, VALVE_STATE_OPEN ); - startHeater( D5_HEAT ); - setValveState( D14_VALV, VALVE_STATE_OPEN ); - setDialysatePumpTargetRPM( D12_PUMP, FRESH_DIAL_PUMP_INITIAL_RPM, TRUE ); - - // Start the timer for spent dialysate pressure check - spentDialPressureCheckStartTimeMS = getMSTimerCount(); - - // Open only fresh side balancing chamber valves - valveControlForBCFreshSideOnlyOpenState(); - - // Make sure valves are in correct position - setValveState( D53_VALV, VALVE_STATE_OPEN ); // Drain valve - setValveState( D35_VALV, VALVE_STATE_CLOSED ); // VDI - setValveState( D40_VALV, VALVE_STATE_CLOSED ); // VDO - setValveState( D34_VALV, VALVE_STATE_OPEN ); // Bypass valve - - // Start D48/SDP pump - setDialysatePumpTargetRPM( D48_PUMP, SPENT_DIAL_PUMP_INITIAL_RPM, TRUE ); - break; - - case DD_GEND_PRODUCE_DIALYSATE_STATE: - //Previous state - setValveState( M4_VALV, VALVE_STATE_OPEN ); - startHeater( D5_HEAT ); - setValveState( D14_VALV, VALVE_STATE_OPEN ); setDialysatePumpTargetRPM( D12_PUMP, FRESH_DIAL_PUMP_INITIAL_RPM, FALSE ); setValveState( D53_VALV, VALVE_STATE_OPEN ); // Drain valve setValveState( D35_VALV, VALVE_STATE_CLOSED ); // VDI setValveState( D40_VALV, VALVE_STATE_CLOSED ); // VDO setValveState( D34_VALV, VALVE_STATE_OPEN ); // Bypass valve setDialysatePumpTargetRPM( D48_PUMP, SPENT_DIAL_PUMP_INITIAL_RPM, FALSE ); - //Close previously opened BC valves - valveControlForBCClosedState(); - + transitionToBalChamberFill(); break; case DD_GEND_DIALYSATE_DELIVERY_STATE: @@ -293,6 +220,10 @@ //close the DD - water inlet and drain valves? break; + case DD_GEND_ISOLATED_UF_STATE: + //TODO : define actuators states + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_GEND_MODE_INVALID_EXEC_STATE1, state ) break; @@ -319,11 +250,8 @@ } } - // Manage water inlet temperature - if ( genDialysateState > DD_GEND_HYD_CHAMBER_WATER_INLET_CHECK_STATE ) - { - hydChamberWaterInletControl(); - } + // Manage water level control + hydChamberWaterInletControl(); // Update any dynamic treatment parameter changes updateTreatmentSettings(); @@ -332,30 +260,14 @@ switch ( genDialysateState ) { case DD_GEND_STATE_START: - setModeGenDStateTransition( DD_GEND_HYD_CHAMBER_WATER_INLET_CHECK_STATE ); - genDialysateState = DD_GEND_HYD_CHAMBER_WATER_INLET_CHECK_STATE; + setModeGenDStateTransition( DD_GEND_DIALYSATE_BYPASS_STATE ); + genDialysateState = DD_GEND_DIALYSATE_BYPASS_STATE; break; - case DD_GEND_HYD_CHAMBER_WATER_INLET_CHECK_STATE: - genDialysateState = handleGenDHydraulicsChamberWaterInletCheckState(); + case DD_GEND_DIALYSATE_BYPASS_STATE: + genDialysateState = handleGenDDialysateBypassState(); break; - case DD_GEND_HYD_CHAMBER_PRESSURE_CHECK_STATE: - genDialysateState = handleGenDHydChamberPressureCheckState(); - break; - - case DD_GEND_FRESH_DIALYSATE_PRESSURE_CHECK_STATE: - genDialysateState = handleGenDFreshDialysatePressureCheckState(); - break; - - case DD_GEND_SPENT_DIALYSATE_PRESSURE_CHECK_STATE: - genDialysateState = handleGenDSpentDialysatePressureCheckState(); - break; - - case DD_GEND_PRODUCE_DIALYSATE_STATE: - genDialysateState = handleGenDProduceDialysateState(); - break; - case DD_GEND_DIALYSATE_DELIVERY_STATE: genDialysateState = handleGenDDialysateDeliveryState(); break; @@ -364,6 +276,10 @@ genDialysateState = handleGenDDialysateDeliveryPauseState(); break; + case DD_GEND_ISOLATED_UF_STATE: + genDialysateState = handleGenDDialysateIsolatedUFState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_GEND_MODE_INVALID_EXEC_STATE, genDialysateState ) genDialysateState = DD_GEND_STATE_START; @@ -423,132 +339,33 @@ /*********************************************************************//** * @brief - * The handleGenDHydraulicsChamberWaterInletCheckState function checks the - * water level and allow the water into hydraulics for dialysate generation. - * @details \b Inputs: floater levels. + * The handleGenDDialysateIsolatedUFState function performs the + * Isolated ultrafiltration operations. + * @details \b Inputs: none. * @details \b Outputs: none * @return the current state of gen dialysate mode *************************************************************************/ -static DD_GEND_MODE_STATE_T handleGenDHydraulicsChamberWaterInletCheckState( void ) +static DD_GEND_MODE_STATE_T handleGenDDialysateIsolatedUFState( void ) { - DD_GEND_MODE_STATE_T state = DD_GEND_HYD_CHAMBER_WATER_INLET_CHECK_STATE; + DD_GEND_MODE_STATE_T state = DD_GEND_ISOLATED_UF_STATE; - // Allow water inlet to hydraulics chamber - if ( TRUE == hydChamberWaterInletControl() ) - { - // if water level is met, move to pressure check state - setModeGenDStateTransition( DD_GEND_HYD_CHAMBER_PRESSURE_CHECK_STATE ); - state = DD_GEND_HYD_CHAMBER_PRESSURE_CHECK_STATE; - } + //TODO: define isoalted ultrafilteration. return state; } /*********************************************************************//** * @brief - * The handleGenDHydChamberPressureCheckState function checks the - * hydraulics chamber pressure at chamber 4 of hydraulics. - * @details \b Inputs: pressure sensor readings, hydChamberPressureCheckStartTimeMS - * @details \b Outputs: none - * @return the current state of gen dialysate mode - *************************************************************************/ -static DD_GEND_MODE_STATE_T handleGenDHydChamberPressureCheckState( void ) -{ - DD_GEND_MODE_STATE_T state = DD_GEND_HYD_CHAMBER_PRESSURE_CHECK_STATE; - F32 hydPressure = getFilteredPressure( D9_PRES ); - - // Hydraulics chamber negative pressure is in range ( -24 to -25 inHg ) - if ( ( hydPressure <= HYD_CHAMBER_TARGET_NEG_PRESS_MIN_PSI ) && ( hydPressure >= HYD_CHAMBER_TARGET_NEG_PRESS_MAX_PSI ) ) - { - // Proceed to next state - setModeGenDStateTransition( DD_GEND_FRESH_DIALYSATE_PRESSURE_CHECK_STATE ); - state = DD_GEND_FRESH_DIALYSATE_PRESSURE_CHECK_STATE; - } - else if ( TRUE == didTimeout( hydChamberPressureCheckStartTimeMS, HYD_CHAMBER_PRES_CHECK_TIME_OUT ) ) - { - // time out alarm and pause the dialysate generation? - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DD_GEND_HYD_CHAMBER_PRESS_OUT_OF_RANGE, hydPressure ); - state = DD_GEND_DIALYSATE_DELIVERY_PAUSE; - } - - return state; -} - -/*********************************************************************//** - * @brief - * The handleGenDFreshDialysatePressureCheckState function checks the - * positive pressure level ( chamber 5) of hydraulics chamber or fresh - * dialysate side. - * @details \b Inputs: pressure sensor readings,hydChamberPressureCheckStartTimeMS - * @details \b Outputs: none - * @return the current state of gen dialysate mode - *************************************************************************/ -static DD_GEND_MODE_STATE_T handleGenDFreshDialysatePressureCheckState( void ) -{ - DD_GEND_MODE_STATE_T state = DD_GEND_FRESH_DIALYSATE_PRESSURE_CHECK_STATE; - F32 hydPressure = getFilteredPressure( D18_PRES ); - - // Hydraulics chamber postive pressure is in range - if ( ( hydPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( hydPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) - { - // Proceed to next state - setModeGenDStateTransition( DD_GEND_SPENT_DIALYSATE_PRESSURE_CHECK_STATE ); - state = DD_GEND_SPENT_DIALYSATE_PRESSURE_CHECK_STATE; - } - else if ( TRUE == didTimeout( hydChamberPressureCheckStartTimeMS, HYD_CHAMBER_PRES_CHECK_TIME_OUT ) ) - { - // time out alarm and pause the dialysate generation? - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DD_GEND_FRESH_DIAL_PRESS_OUT_OF_RANGE, hydPressure ); - state = DD_GEND_DIALYSATE_DELIVERY_PAUSE; - } - - return state; -} - -/*********************************************************************//** - * @brief - * The handleGenDSpentDialysatePressureCheckState function checks the - * spent dialyaste pressure is in range to begin balancing chamber dialysate - * delivery. - * @details \b Inputs: pressure sensor readings,spentDialPressureCheckStartTimeMS. - * @details \b Outputs: none - * @return the current state of gen dialysate mode - *************************************************************************/ -static DD_GEND_MODE_STATE_T handleGenDSpentDialysatePressureCheckState( void ) -{ - DD_GEND_MODE_STATE_T state = DD_GEND_SPENT_DIALYSATE_PRESSURE_CHECK_STATE; - F32 spentdialPressure = getFilteredPressure( D51_PRES ); - - // Spent dialysate pressure is in range - if ( ( spentdialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentdialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) - { - // Proceed to next state - transitionToBalChamberFill(); - setModeGenDStateTransition( DD_GEND_PRODUCE_DIALYSATE_STATE ); - state = DD_GEND_PRODUCE_DIALYSATE_STATE; - } - else if ( TRUE == didTimeout( spentDialPressureCheckStartTimeMS, SPENT_DIAL_PRES_CHECK_TIME_OUT ) ) - { - // time out alarm and pause the dialysate generation? - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DD_GEND_SPENT_DIAL_PRESS_OUT_OF_RANGE, spentdialPressure ); - state = DD_GEND_DIALYSATE_DELIVERY_PAUSE; - } - - return state; -} - -/*********************************************************************//** - * @brief - * The handleGenDProduceDialysateState function produces dialysate + * The handleGenDDialysateBypassState function produces dialysate * by executing balancing chamber and decides to pass the dialysate - * for treatment. + * to dialyzer for treatment. * @details \b Inputs: none * @details \b Outputs: balancing chamber state. * @return the current state of gen dialysate mode *************************************************************************/ -static DD_GEND_MODE_STATE_T handleGenDProduceDialysateState( void ) +static DD_GEND_MODE_STATE_T handleGenDDialysateBypassState( void ) { - DD_GEND_MODE_STATE_T state = DD_GEND_PRODUCE_DIALYSATE_STATE; + DD_GEND_MODE_STATE_T state = DD_GEND_DIALYSATE_BYPASS_STATE; //Execute balancing chamber execBalancingChamberControl(); @@ -584,9 +401,9 @@ //transition to produce dialystate state if ( ( FALSE == getDialGoodToDeliverStatus() ) || ( TRUE == getTDDialyzerBypass() ) ) { - setModeGenDStateTransition( DD_GEND_PRODUCE_DIALYSATE_STATE ); + setModeGenDStateTransition( DD_GEND_DIALYSATE_BYPASS_STATE ); isDialDeliveryInProgress.data = FALSE; - state = DD_GEND_PRODUCE_DIALYSATE_STATE; + state = DD_GEND_DIALYSATE_BYPASS_STATE; } return state; Index: firmware/App/Modes/ModePostGenDialysate.c =================================================================== diff -u -r25792f5c501f0c092e2b95d53e627b2e809f3c5c -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Modes/ModePostGenDialysate.c (.../ModePostGenDialysate.c) (revision 25792f5c501f0c092e2b95d53e627b2e809f3c5c) +++ firmware/App/Modes/ModePostGenDialysate.c (.../ModePostGenDialysate.c) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -83,8 +83,10 @@ * @brief * The execPostGenDialysateMode function executes the Post-Gen Dialysate mode * state machine. - * @details \b Inputs: none + * @details \b Inputs: postGenDialysateState * @details \b Outputs: Post-Gen Dialysate mode state machine executed + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when wrong post gen dialysate + * state invoked * @return current state of Post-Gen Dialysate Mode *************************************************************************/ U32 execPostGenDialysateMode( void ) @@ -141,8 +143,10 @@ * @brief * The publishPostGenDialysateState function publishes Post-Generation dialysate * mode data. - * @details Inputs: postGenDialysatePublishTimerCounter, postGenDialysateModePublishInterval - * @details Outputs: postGenDialysatePublishTimerCounter + * @details \b Inputs: postGenDialysatePublishTimerCounter, postGenDialysateModePublishInterval + * @details \b Outputs: postGenDialysatePublishTimerCounter + * @details \b Message \Sent: MSG_ID_DD_POST_GEN_DIALYSATE_STATE_DATA to publish the + * post generate dialysate mode data. * @return none *************************************************************************/ static void publishPostGenDialysateState( void ) Index: firmware/App/Modes/ModePreGenDialysate.c =================================================================== diff -u -r25792f5c501f0c092e2b95d53e627b2e809f3c5c -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision 25792f5c501f0c092e2b95d53e627b2e809f3c5c) +++ firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -19,6 +19,7 @@ #include "DialysatePumps.h" #include "Heaters.h" #include "ModePreGenDialysate.h" +#include "ModeFault.h" #include "Messaging.h" #include "OperationModes.h" #include "TaskGeneral.h" @@ -38,6 +39,7 @@ // ********** private data ********** static DD_PRE_GEN_DAILYSATE_STATE_T preGenDialysateState; ///< Currently active pre-gen dialysate state. +static OVERRIDE_U32_T pendingStartDDGenDialRequest; ///< Flag indicating TD has requested DD start the generation dialysate request(Overridable). static U32 preGenDialysatePublishTimerCounter; ///< Pre-Gen Dialysate data broadcast timer counter used to schedule when to transmit data. static OVERRIDE_U32_T preGenDialysateModePublishInterval; ///< Interval (in task intervals) at which to publish pre-gen dialysate mode data to CAN bus. @@ -57,6 +59,10 @@ void initPreGenDialysateMode( void ) { preGenDialysateState = DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK; + pendingStartDDGenDialRequest.data = FALSE; + pendingStartDDGenDialRequest.ovData = FALSE; + pendingStartDDGenDialRequest.ovInitData = FALSE; + pendingStartDDGenDialRequest.override = OVERRIDE_RESET; preGenDialysateModePublishInterval.data = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; preGenDialysateModePublishInterval.ovData = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; preGenDialysateModePublishInterval.ovInitData = 0; @@ -74,6 +80,8 @@ U32 transitionToPreGenDialysateMode( void ) { initPreGenDialysateMode(); + deenergizeActuators( PARK_CONC_PUMPS ); + setCurrentSubState( NO_SUB_STATE ); return preGenDialysateState; @@ -83,12 +91,21 @@ * @brief * The execPreGenDialysateMode function executes the Pre-Gen Dialysate mode * state machine. - * @details \b Inputs: none + * @details \b Inputs: preGenDialysateState * @details \b Outputs: Pre-Gen Dialysate mode state machine executed + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when wrong pre gen dialysate + * state invoked * @return current state of Pre-Gen Dialysate Mode *************************************************************************/ U32 execPreGenDialysateMode( void ) { + //TODO: To be placed in correct states once states defined. + if ( TRUE == getU32OverrideValue( &pendingStartDDGenDialRequest ) ) + { + pendingStartDDGenDialRequest.data = FALSE; + requestNewOperationMode( DD_MODE_GEND ); + } + // execute current pre-gen dialysate state switch ( preGenDialysateState ) { @@ -125,24 +142,49 @@ /*********************************************************************//** * @brief + * The requestDDGenDialStart function handles an TD request to start + * generation dialysis mode. + * @details \b Inputs: Pre generation dailysate state + * @details \b Outputs: pendingStartDDGenDialRequest + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestDDGenDialStart( void ) +{ + BOOL result = FALSE; + + if ( DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND == preGenDialysateState ) + { + result = TRUE; + pendingStartDDGenDialRequest.data = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The handlePreGenDialysateFillCompleteCheckState function checks the * hydrochamber fill and transition to next state. - * @details \b Inputs: none + * @details \b Inputs: state * @details \b Outputs: none * @return current state of PreGenDialysate mode *************************************************************************/ static DD_PRE_GEN_DAILYSATE_STATE_T handlePreGenDialysateFillCompleteCheckState( void ) { //TODO: define hydroblock fill complete process - return preGenDialysateState; + DD_PRE_GEN_DAILYSATE_STATE_T state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; + + return state; } /*********************************************************************//** * @brief * The publishPreGenDialysateState function publishes Pre-Generation dialysate * mode data. - * @details Inputs: preGenDialysatePublishTimerCounter, preGenDialysateModePublishInterval - * @details Outputs: preGenDialysatePublishTimerCounter + * @details \b Inputs: preGenDialysatePublishTimerCounter, preGenDialysateModePublishInterval + * @details \b Outputs: preGenDialysatePublishTimerCounter + * @details \b Message \Sent: MSG_ID_DD_PRE_GEN_DIALYSATE_STATE_DATA to publish the + * pre generate dialysate mode data. * @return none *************************************************************************/ static void publishPreGenDialysateState( void ) @@ -182,4 +224,21 @@ return result; } +/*********************************************************************//** + * @brief + * The testDDstartGenDialysateOverride function sets the override value + * to start the gen dialysate operation mode. + * @details Inputs: pendingStartDDGenDialRequest + * @details Outputs: pendingStartDDGenDialRequest + * @param message Override message from Dialin which includes the flag + * to override the operation mode. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testDDstartGenDialysateOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &pendingStartDDGenDialRequest, FALSE, TRUE ); + + return result; +} + /**@}*/ Index: firmware/App/Modes/ModePreGenDialysate.h =================================================================== diff -u -r25792f5c501f0c092e2b95d53e627b2e809f3c5c -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Modes/ModePreGenDialysate.h (.../ModePreGenDialysate.h) (revision 25792f5c501f0c092e2b95d53e627b2e809f3c5c) +++ firmware/App/Modes/ModePreGenDialysate.h (.../ModePreGenDialysate.h) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -43,8 +43,10 @@ U32 transitionToPreGenDialysateMode( void ); // prepares for transition to pre-gen dialysate mode U32 execPreGenDialysateMode( void ); // execute the pre-gen dilaysate mode state machine (call from OperationModes) DD_PRE_GEN_DAILYSATE_STATE_T getCurrentPreGenDialysateState( void ); // get the current state of the pre-gen dialysate mode. +BOOL requestDDGenDialStart( void ); // start generate dialysate delivery BOOL testDDPreGenDialysateDataPublishIntervalOverride( MESSAGE_T *message ); // pre-gen dialysate publish override request +BOOL testDDstartGenDialysateOverride( MESSAGE_T *message ); // start gen dialysate override request /**@}*/ Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r322747d530c1b8205be257557e53dcfe9caad50a -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 322747d530c1b8205be257557e53dcfe9caad50a) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -43,7 +43,7 @@ static DD_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. -static OVERRIDE_U32_T pendingStartDDRequest; ///< Flag indicating TD has requested DD start the dialysis delivery(Overridable). +static OVERRIDE_U32_T pendingStartDDPreGenRequest; ///< Flag indicating TD has requested DD start the pre generation dialysate request(Overridable). static BOOL pendingBalanceChamberSwOnlyRequest; ///< Flag indicating balancing chamber switch only request. //static BOOL pendingStartDDFlushRequest; ///< Flag indicating TD has requested DD start flush. //static BOOL pendingStartDDHeatDisinfectRequest; ///< Flag indicating TD has requested DD start heat disinfect. @@ -65,10 +65,10 @@ void initStandbyMode( void ) { standbyState = DD_STANDBY_MODE_STATE_IDLE; - pendingStartDDRequest.data = FALSE; - pendingStartDDRequest.ovData = FALSE; - pendingStartDDRequest.ovInitData = FALSE; - pendingStartDDRequest.override = OVERRIDE_RESET; + pendingStartDDPreGenRequest.data = FALSE; + pendingStartDDPreGenRequest.ovData = FALSE; + pendingStartDDPreGenRequest.ovInitData = FALSE; + pendingStartDDPreGenRequest.override = OVERRIDE_RESET; pendingBalanceChamberSwOnlyRequest = FALSE; // pendingStartDDFlushRequest = FALSE; // pendingStartDDHeatDisinfectRequest = FALSE; @@ -173,7 +173,7 @@ * @brief * The handleStandbyIdleState function executes the idle state of the * standby mode state machine. - * @details \b Inputs: pendingSampleWaterRequest, pendingStartDDRequest, + * @details \b Inputs: pendingSampleWaterRequest, pendingStartDDPreGenRequest, * pendingStartDDFlushRequest, pendingStartDDHeatDisinfectRequest, * pendingStartDDChemicalDisinfectRequest * @details \b Outputs: Idle state of the standby mode executed, @@ -192,10 +192,10 @@ // { // define the alarm // } - if ( TRUE == getU32OverrideValue( &pendingStartDDRequest ) ) + if ( TRUE == getU32OverrideValue( &pendingStartDDPreGenRequest ) ) { - pendingStartDDRequest.data = FALSE; - requestNewOperationMode( DD_MODE_GEND ); + pendingStartDDPreGenRequest.data = FALSE; + requestNewOperationMode( DD_MODE_PREG ); } //Test request to handle only balancing chamber switching else if ( TRUE == pendingBalanceChamberSwOnlyRequest ) @@ -248,19 +248,20 @@ /*********************************************************************//** * @brief - * The requestDDStart function handles an TD request to start (go to generation dialysis mode). + * The requestDDPreGenStart function handles an TD request to start/ + * go to pre generation dialysis mode. * @details \b Inputs: standbyState - * @details \b Outputs: pendingStartDDRequest + * @details \b Outputs: pendingStartDDPreGenRequest * @return TRUE if request accepted, FALSE if not. *************************************************************************/ -BOOL requestDDStart( void ) +BOOL requestDDPreGenStart( void ) { BOOL result = FALSE; if ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) { - result = TRUE; - pendingStartDDRequest.data = TRUE; + result = TRUE; + pendingStartDDPreGenRequest.data = TRUE; } return result; @@ -503,17 +504,17 @@ /*********************************************************************//** * @brief - * The testDDstartGenDialysateOverride function sets the override value - * to start the gen dialysate operation mode. - * @details Inputs: pendingStartDDRequest - * @details Outputs: pendingStartDDRequest + * The testDDstartPreGenDialysateOverride function sets the override value + * to start the pre-gen dialysate operation mode. + * @details Inputs: pendingStartDDPreGenRequest + * @details Outputs: pendingStartDDPreGenRequest * @param message Override message from Dialin which includes the flag * to override the operation mode. * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testDDstartGenDialysateOverride( MESSAGE_T *message ) +BOOL testDDstartPreGenDialysateOverride( MESSAGE_T *message ) { - BOOL result = u32Override( message, &pendingStartDDRequest, FALSE, TRUE ); + BOOL result = u32Override( message, &pendingStartDDPreGenRequest, FALSE, TRUE ); return result; } Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -r313982ccc772f1bbe182877dff7e00381b04e0f4 -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 313982ccc772f1bbe182877dff7e00381b04e0f4) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -45,7 +45,7 @@ U32 execStandbyMode( void ); // execute the standby mode state machine (call from OperationModes) BOOL areInletWaterConditionsAlarmsActive( void ); // checks water inlet pressure, temperature and conductivity alarms. -BOOL requestDDStart( void ); // TD requests DD start (go to generation dialysate mode) +BOOL requestDDPreGenStart( void ); // TD requests DD start (go to generation dialysate mode) BOOL requestBCSwitchingOnlyStart( void ); // request to start performing balancing chamber switching only without dosing/pressure validation void requestBCSwitchingOnlyStop( void ); // request to stop balancing chamber switching only without dosing/pressure validation @@ -54,7 +54,7 @@ BOOL startDDHeatDisinfectActiveCool( void ); DD_STANDBY_MODE_STATE_T getCurrentStandbyState( void ); // get the current state of the standby mode. -BOOL testDDstartGenDialysateOverride( MESSAGE_T *message ); // Overide start gen dialysate mode +BOOL testDDstartPreGenDialysateOverride( MESSAGE_T *message ); // Overide start pre-gen dialysate mode /**@}*/ Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r5422509f9d8db102b62952ba9f5923e832d6b2fa -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 5422509f9d8db102b62952ba9f5923e832d6b2fa) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -138,7 +138,7 @@ // any new mode requests? newMode = arbitrateModeRequest(); // will return current mode if no pending requests - if ( getTestConfigStatus( TEST_CONFIG_RECOVER_TREATMENT ) != TRUE ) + if ( ( isTestingActivated() != TRUE ) && ( getTestConfigStatus( TEST_CONFIG_RECOVER_TREATMENT ) != TRUE ) ) { // If the test configuration is not enabled check for the legality of the transition request newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r5422509f9d8db102b62952ba9f5923e832d6b2fa -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 5422509f9d8db102b62952ba9f5923e832d6b2fa) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -151,6 +151,8 @@ MSG_ID_DD_HEATERS_PWM_PERIOD_OVERIDE_REQUEST, MSG_ID_DD_PRE_GEND_MODE_DATA_PUBLISH_OVERRIDE_REQUEST, MSG_ID_DD_POST_GEND_MODE_DATA_PUBLISH_OVERRIDE_REQUEST, + MSG_ID_DD_START_PRE_GEN_DIALYSATE_MODE_OVERRIDE_REQUEST, //65 + MSG_ID_DD_PRE_GEN_DIALYSATE_REQUEST_DATA, #ifdef __PUMPTEST__ MSG_ID_DD_PISTON_PUMP_DATA_PUBLISH_OVERRIDE_REQUEST, MSG_ID_DD_PISTON_PUMP_START_STOP_OVERRIDE_REQUEST, @@ -224,6 +226,8 @@ &testHeaterPWMPeriodOverride, &testDDPreGenDialysateDataPublishIntervalOverride, &testDDPostGenDialysateDataPublishIntervalOverride, + &testDDstartPreGenDialysateOverride, //65 + &handlePreGenDialysateRequestMsg, #ifdef __PUMPTEST__ &testDDPistonPumpControlDataPublishIntervalOverride, &testDDPistonPumpStartStopOverride, Index: firmware/App/Services/TDInterface.c =================================================================== diff -u -r322747d530c1b8205be257557e53dcfe9caad50a -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision 322747d530c1b8205be257557e53dcfe9caad50a) +++ firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -20,6 +20,7 @@ #include "MessagePayloads.h" #include "ModeGenDialysate.h" #include "ModeInitPOST.h" +#include "ModePreGenDialysate.h" #include "ModeStandby.h" #include "OperationModes.h" #include "PersistentAlarm.h" @@ -323,6 +324,49 @@ /*********************************************************************//** * @brief + * The handlePreGenDialysateRequestMsg function handles a pre gen dailysate + * delivery request from TD to perform required self test and priming process. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return TRUE if message is sucessfully parsed, FALSE if not. + *************************************************************************/ +BOOL handlePreGenDialysateRequestMsg( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( PRE_GEN_DIALYSATE_REQ_PAYLOAD_T ) ) + { + PRE_GEN_DIALYSATE_REQ_PAYLOAD_T startPreGenRequest; + DD_OP_MODE_T ddMode = getCurrentOperationMode(); + + memcpy( &startPreGenRequest, message->payload, sizeof( PRE_GEN_DIALYSATE_REQ_PAYLOAD_T ) ); + + // Process the pre-gen dialysate delivery request message + if ( ( DD_MODE_STAN == ddMode ) && ( TRUE == startPreGenRequest.start ) ) + { + // start dialysate generation + result = requestDDPreGenStart(); + } + else if ( DD_MODE_PREG == ddMode ) + { + //TODO : handle transition to post treatment after states defined. + if ( FALSE == startPreGenRequest.start ) + { + // stop dialysate generation by transitioning to standby mode + requestNewOperationMode( DD_MODE_STAN ); + } + result = TRUE; + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DD_2_TD, result ); + + return result; +} + +/*********************************************************************//** + * @brief * The handleDialysateDeliveryRequestMsg function handles a dailysate * delivery request from TD and updates dialysate flowrate, UF rate, * dialysate temperature, dialyzer bypass and concentrate types ( acid @@ -344,7 +388,7 @@ memcpy( &startTxRequest, message->payload, sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ); // Process the dialysate delivery request message - if ( ( DD_MODE_STAN == ddMode ) && ( TRUE == startTxRequest.start ) ) + if ( ( DD_MODE_PREG == ddMode ) && ( TRUE == startTxRequest.start ) ) { // Set dialysate flow rate, UF rate and dialysate temperature setTDDialysateFlowrate( startTxRequest.dialRate ); @@ -356,12 +400,13 @@ setTDDialyzerBypass( startTxRequest.bypassDialyzer ); // start dialysate generation - result = requestDDStart(); + result = requestDDGenDialStart(); } else if ( DD_MODE_GEND == ddMode ) { if ( FALSE == startTxRequest.start ) { + //TODO: Transition to post treatment and then standby. // stop dialysate generation by transitioning to standby mode requestNewOperationMode( DD_MODE_STAN ); } Index: firmware/App/Services/TDInterface.h =================================================================== diff -u -r322747d530c1b8205be257557e53dcfe9caad50a -r724b64673b719eaac10b0c9dd839ad9675274911 --- firmware/App/Services/TDInterface.h (.../TDInterface.h) (revision 322747d530c1b8205be257557e53dcfe9caad50a) +++ firmware/App/Services/TDInterface.h (.../TDInterface.h) (revision 724b64673b719eaac10b0c9dd839ad9675274911) @@ -39,6 +39,7 @@ void execTDInterfaceMonitor( void ); BOOL handleDialysateDeliveryRequestMsg( MESSAGE_T *message ); +BOOL handlePreGenDialysateRequestMsg( MESSAGE_T *message ); void setTDOpMode( U32 opMode, U32 subMode ); void setTDDialysateFlowrate( F32 dialFlowrate );