Index: firmware/App/Modes/ConsumableSelfTest.c =================================================================== diff -u --- firmware/App/Modes/ConsumableSelfTest.c (revision 0) +++ firmware/App/Modes/ConsumableSelfTest.c (revision 936acbb405970a406c8b1f557ea727e7cbf74c94) @@ -0,0 +1,160 @@ +/************************************************************************** +* +* Copyright (c) 2019-2020 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 ConsumableSelfTest.c +* +* @author (last) Quang Nguyen +* @date (last) 05-Mar-2021 +* +* @author (original) Quang Nguyen +* @date (original) 05-Mar-2021 +* +***************************************************************************/ + +#include "ConsumableSelfTest.h" +#include "DGInterface.h" +#include "ModePreTreat.h" + +/** + * @addtogroup ConsumableSelfTest + * @{ + */ + +// ********** private definitions ********** + +// ********** private data ********** + +static CONSUMABLE_SELF_TESTS_STATE_T currentConsumableSelfTestState; +static BOOL confirmConsumableInstallRequested; + +// ********** private function prototypes ********** + +static void handleConsumableSelfTestStopRequest( void ); + +/*********************************************************************//** + * @brief + * The initConsumableSelfTest function initializes the ConsumableSelfTest module. + * @details Inputs: none + * @details Outputs: ConsumableSelfTest module initialized. + * @return none + *************************************************************************/ +void initConsumableSelfTest( void ) +{ + currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_INSTALL_STATE; + confirmConsumableInstallRequested = FALSE; +} + +/*********************************************************************//** + * @brief + * The transitionToConsumableSelfTest function resets anything required before + * the start of consumable self-test. + * @details Inputs: none + * @details Outputs: Consumable self-tests re-initialized. + * @return none + *************************************************************************/ +void transitionToConsumableSelfTest( void ) +{ + initConsumableSelfTest(); +} + +/*********************************************************************//** + * @brief + * The execConsumableSelfTest function executes the consumable self-test + * state machine. + * @details Inputs: currentConsumableSelfTestState + * @details Outputs: currentConsumableSelfTestState + * @return none + *************************************************************************/ +void execConsumableSelfTest( void ) +{ + switch( currentConsumableSelfTestState ) + { + case CONSUMABLE_SELF_TESTS_INSTALL_STATE: + if ( TRUE == confirmConsumableInstallRequested ) + { + confirmConsumableInstallRequested = FALSE; + currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_WATER_QUALITY_CHECK_STATE; + signalStartFillReservoirOne(); + } + break; + + case CONSUMABLE_SELF_TESTS_WATER_QUALITY_CHECK_STATE: + if ( ( DG_MODE_FILL == getDGOpMode() ) && ( DG_FILL_MODE_STATE_BICARB_PUMP_CHECK == getDGSubMode() ) ) + { + currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_BICARB_PUMP_CHECK_STATE; + } + break; + + case CONSUMABLE_SELF_TESTS_BICARB_PUMP_CHECK_STATE: + if ( ( DG_MODE_FILL == getDGOpMode() ) && ( DG_FILL_MODE_STATE_ACID_PUMP_CHECK == getDGSubMode() ) ) + { + currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_BICARB_PUMP_CHECK_STATE; + } + break; + + case CONSUMABLE_SELF_TESTS_ACID_PUMP_CHECK_STATE: + if ( ( DG_MODE_FILL == getDGOpMode() ) && ( DG_FILL_MODE_STATE_DIALYSATE_PRODUCTION == getDGSubMode() ) ) + { + currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_COMPLETE_STATE; + } + break; + + case CONSUMABLE_SELF_TESTS_COMPLETE_STATE: + break; + + default: + break; + } + + // Handle triggered alarm with stop property + handleConsumableSelfTestStopRequest(); +} + +/*********************************************************************//** + * @brief + * The getConsumableSelfTestState function returns the current state of + * consumable self-tests sub-mode. + * @details Inputs: currentConsumableSelfTestState + * @details Outputs: none + * @return current consumable self-tests state + *************************************************************************/ +U32 getConsumableSelfTestState( void ) +{ + return (U32)currentConsumableSelfTestState; +} + +/*********************************************************************//** + * @brief + * The signalUserConfirmConsumableInstall function handles user confirmation of + * consumable installation. + * @details Inputs: none + * @details Outputs: confirmConsumableInstallRequested + * @return TRUE if signal accepted, FALSE if not + *************************************************************************/ +void signalUserConfirmConsumableInstall( void ) +{ + confirmConsumableInstallRequested = TRUE; +} + +/*********************************************************************//** + * @brief + * The handleConsumableSelfTestStopRequest function handles stop request from + * alarm and transition to consumable install state. + * @details Inputs: none + * @details Outputs: none + * @return the next state of consumable self-tests state machine + *************************************************************************/ +static void handleConsumableSelfTestStopRequest( void ) +{ + if ( TRUE == doesAlarmStatusIndicateStop() ) + { + currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_INSTALL_STATE; + cmdStopDGFill(); + } +} + +/**@}*/ Index: firmware/App/Modes/ConsumableSelfTest.h =================================================================== diff -u --- firmware/App/Modes/ConsumableSelfTest.h (revision 0) +++ firmware/App/Modes/ConsumableSelfTest.h (revision 936acbb405970a406c8b1f557ea727e7cbf74c94) @@ -0,0 +1,47 @@ +/************************************************************************** +* +* Copyright (c) 2019-2021 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 ConsumableSelfTest.h +* +* @author (last) Quang Nguyen +* @date (last) 05-Mar-2021 +* +* @author (original) Quang Nguyen +* @date (original) 05-Mar-2021 +* +***************************************************************************/ + +#ifndef __CONSUMABLE_SELF_TEST_H__ +#define __CONSUMABLE_SELF_TEST_CONSUMABLE_H__ + +#include "HDCommon.h" +#include "HDDefs.h" + +/** + * @defgroup ConsumableSelfTest ConsumableSelfTest + * @brief ConsumableSelfTest module. This module handles the user interaction for consumable self-test. + * This module monitors DG while the consumable checks are being executed. + * + * @addtogroup ConsumableSelfTest + * @{ + */ + +// ********** public definitions ********** + +// ********** public function prototypes ********** + +void initConsumableSelfTest( void ); +void transitionToConsumableSelfTest( void ); +void execConsumableSelfTest( void ); + +U32 getConsumableSelfTestState( void ); + +void signalUserConfirmConsumableInstall( void ); + +/**@}*/ + +#endif Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r68f18c1952d37f75f27b7ca45969af2202729bb5 -r936acbb405970a406c8b1f557ea727e7cbf74c94 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 68f18c1952d37f75f27b7ca45969af2202729bb5) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 936acbb405970a406c8b1f557ea727e7cbf74c94) @@ -16,6 +16,7 @@ ***************************************************************************/ #include "AlarmMgmt.h" +#include "ConsumableSelfTest.h" #include "FPGA.h" #include "ModePreTreat.h" #include "OperationModes.h" @@ -59,6 +60,7 @@ static void transitionToPatientConnection( void ); static HD_PRE_TREATMENT_MODE_STATE_T handleWaterSampleState( void ); +static HD_PRE_TREATMENT_MODE_STATE_T handleSelfTestConsumableState( void ); static HD_PRE_TREATMENT_MODE_STATE_T handleSelfTestNoCartState( void ); static HD_PRE_TREATMENT_MODE_STATE_T handleInstallState( void ); static HD_PRE_TREATMENT_MODE_STATE_T handleSelfTestDryState( void ); @@ -80,6 +82,7 @@ patientConnectionConfirm = FALSE; initSampleWater(); + initConsumableSelfTest(); initPrime(); initSelfTests(); @@ -126,6 +129,10 @@ currentPreTreatmentState = handleWaterSampleState(); break; + case HD_PRE_TREATMENT_SELF_TEST_CONSUMABLE_STATE: + currentPreTreatmentState = handleSelfTestConsumableState(); + break; + case HD_PRE_TREATMENT_SELF_TEST_NO_CART_STATE: currentPreTreatmentState = handleSelfTestNoCartState(); break; @@ -337,6 +344,7 @@ preTreatmentData.preTreatmentSubMode = currentPreTreatmentState; preTreatmentData.sampleWaterState = getSampleWaterState(); + preTreatmentData.consumableSelfTestsState = getConsumableSelfTestState(); preTreatmentData.noCartSelfTestsState = getNoCartSelfTestsState(); preTreatmentData.installState = 0; preTreatmentData.drySelfTestsState = getDrySelfTestsState(); @@ -408,10 +416,10 @@ /*********************************************************************//** * @brief - * The handleWaterSampleState function handles patient connection state - * during pre-treatment mode. + * The handleWaterSampleState function handles sample water state during + * pre-treatment mode. * @details Inputs: none - * @details Outputs: requested mode transition to treatment mode + * @details Outputs: executed sample water state machine * @return current state (sub-mode) *************************************************************************/ static HD_PRE_TREATMENT_MODE_STATE_T handleWaterSampleState( void ) @@ -422,9 +430,32 @@ if ( TRUE == isSampleWaterPassed() ) { - state = HD_PRE_TREATMENT_SELF_TEST_NO_CART_STATE; + state = HD_PRE_TREATMENT_SELF_TEST_CONSUMABLE_STATE; cmdStartDG(); cmdSetDGDialysateTargetTemps( 39.0, 37.0 ); + transitionToConsumableSelfTest(); + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSelfTestConsumableState function handles consumable self-test state + * during pre-treatment mode. + * @details Inputs: none + * @details Outputs: executed consumable self-test state machine + * @return current state (sub-mode) + *************************************************************************/ +static HD_PRE_TREATMENT_MODE_STATE_T handleSelfTestConsumableState( void ) +{ + HD_PRE_TREATMENT_MODE_STATE_T state = HD_PRE_TREATMENT_SELF_TEST_CONSUMABLE_STATE; + + execConsumableSelfTest(); + + if ( CONSUMABLE_SELF_TESTS_COMPLETE_STATE == getConsumableSelfTestState() ) + { + state = HD_PRE_TREATMENT_SELF_TEST_NO_CART_STATE; transitionToNoCartSelfTests(); } Index: firmware/App/Modes/ModePreTreat.h =================================================================== diff -u -r68f18c1952d37f75f27b7ca45969af2202729bb5 -r936acbb405970a406c8b1f557ea727e7cbf74c94 --- firmware/App/Modes/ModePreTreat.h (.../ModePreTreat.h) (revision 68f18c1952d37f75f27b7ca45969af2202729bb5) +++ firmware/App/Modes/ModePreTreat.h (.../ModePreTreat.h) (revision 936acbb405970a406c8b1f557ea727e7cbf74c94) @@ -36,6 +36,7 @@ { U32 preTreatmentSubMode; ///< Current pre-treatment sub-mode U32 sampleWaterState; ///< Current sample water state + U32 consumableSelfTestsState; ///< Current consumable sefl-tests state U32 noCartSelfTestsState; ///< Current no cartridge self-tests state U32 installState; ///< Current disposable installation state U32 drySelfTestsState; ///< Current dry self-tests state Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -rd3afa76096a5835e791b1e1b380065c4db3d81a1 -r936acbb405970a406c8b1f557ea727e7cbf74c94 --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision d3afa76096a5835e791b1e1b380065c4db3d81a1) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 936acbb405970a406c8b1f557ea727e7cbf74c94) @@ -11,7 +11,7 @@ * @date (last) 28-Jan-2021 * * @author (original) Quang Nguyen -* @date (original) 28-Jan-2021s +* @date (original) 28-Jan-2021 * ***************************************************************************/ Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rb32dd9e582f74d0ddc106a0d0b1efa8974c08c4d -r936acbb405970a406c8b1f557ea727e7cbf74c94 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision b32dd9e582f74d0ddc106a0d0b1efa8974c08c4d) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 936acbb405970a406c8b1f557ea727e7cbf74c94) @@ -1209,6 +1209,10 @@ handleSampleWaterResult( message ); break; + case MSG_ID_UI_CONSUMABLE_INSTALL_CONFIRM: + handleConsumableInstallConfirm( message ); + break; + case MSG_ID_UI_INSTALLATION_CONFIRM: handleInstallationConfirm( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r2f2419f67d9d458837893fef5cc1b21870021026 -r936acbb405970a406c8b1f557ea727e7cbf74c94 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 2f2419f67d9d458837893fef5cc1b21870021026) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 936acbb405970a406c8b1f557ea727e7cbf74c94) @@ -20,8 +20,9 @@ #include "reg_system.h" #include "Accel.h" -#include "AlarmLamp.h" -#include "Buttons.h" +#include "AlarmLamp.h" +#include "Buttons.h" +#include "ConsumableSelfTest.h" #include "DGInterface.h" #include "FPGA.h" #include "ModePreTreat.h" @@ -546,7 +547,6 @@ return sendUIResponseMsg( MSG_ID_HD_SAMPLE_WATER_CMD_RESPONSE, accepted, reason ); } - /*********************************************************************//** * @brief * The handleSampleWaterCmd function handles a sample water result msg from the UI. @@ -570,6 +570,25 @@ /*********************************************************************//** * @brief + * The handleConsumableInstallConfirm function handles a consumable install + * confirm msg from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleConsumableInstallConfirm( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmConsumableInstall(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); +} + +/*********************************************************************//** + * @brief * The handleInstallationConfirm function handles user confirms disposable * installation msg from the UI. * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r2f2419f67d9d458837893fef5cc1b21870021026 -r936acbb405970a406c8b1f557ea727e7cbf74c94 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 2f2419f67d9d458837893fef5cc1b21870021026) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 936acbb405970a406c8b1f557ea727e7cbf74c94) @@ -167,6 +167,9 @@ // MSG_ID_UI_SAMPLE_WATER_RESULT void handleSampleWaterResult( MESSAGE_T *message ); +// MSG_ID_UI_CONSUMABLE_INSTALL_CONFIRM +void handleConsumableInstallConfirm( MESSAGE_T *message ); + // MSG_ID_UI_INSTALLATION_CONFIRM void handleInstallationConfirm( MESSAGE_T *message );