Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r514463982373eb976e4b48a27d0f85f56e014920 -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 514463982373eb976e4b48a27d0f85f56e014920) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -1,19 +1,19 @@ /************************************************************************** -* -* Copyright (c) 2019-2022 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 BloodLeak.c -* -* @author (last) Dara Navaei -* @date (last) 04-Jan-2022 -* -* @author (original) Peman Montazemi -* @date (original) 18-Mar-2021 -* -***************************************************************************/ + * + * Copyright (c) 2019-2022 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 BloodLeak.c + * + * @author (last) Dara Navaei + * @date (last) 04-Jan-2022 + * + * @author (original) Peman Montazemi + * @date (original) 18-Mar-2021 + * + ***************************************************************************/ #include // For sprintf and strlen #include "AlarmMgmt.h" @@ -33,7 +33,7 @@ // ********** private definitions ********** #define BLOOD_LEAK_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the blood leak data is published on the CAN bus. -#define BLOOD_LEAK_TIMEOUT_MS 500 ///< Blood leak detector timeout for zeroing and self-test (15 ms extended edge detection) +#define BLOOD_LEAK_TIMEOUT_MS 2000 ///< Blood leak detector timeout for zeroing and self-test (15 ms extended edge detection) #define BLOOD_LEAK_PERSISTENCE ( 10 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Persistence for blood leak detected alarm. #define BLOOD_LEAK_RESET_TX_FIFO 2 ///< Blood leak reset transmit FIFO command. #define BLOOD_LEAK_START_COMM_CTRL_U_ASCII 21 ///< Blood leak start communication command, ^U (Ctrl-U) in ascii. @@ -52,14 +52,18 @@ #define BLOOD_LEAK_SET_POINT_SEQ_MAX_LENGTH 15 ///< Blood leak set point sequence maximum length. #define BLOOD_LEAK_WAIT_2_READ_SET_POINT ( 1 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Blood leak wait to read set point in counts. +#define BLOOD_LEAK_WAIT_2_READ_CTRL_U ( 1 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Blood leak wait to read control U in counts. #define BLOOD_LEAK_MAX_SET_POINT_WRITE_TRIALS 3 ///< Blood leak maximum number of trials to write the set point. +#define BLOOD_LEAK_MAX_CTRL_U_WRITE_TRIALS 3 ///< Blood leak maximum number of trials to write the control U command. #define BLOOD_LEAK_MIN_WAIT_TIME_2_GET_CAL_MS ( 2 * MS_PER_SECOND ) ///< Blood leak minimum wait time to get calibration in milliseconds. /// Defined states for the blood leak detector state machine. typedef enum BloodLeakStates { - BLOOD_LEAK_START_UP_STATE = 0, ///< Start up state. + BLOOD_LEAK_WAIT_FOR_POST_STATE = 0, ///< Wait for post state. + BLOOD_LEAK_START_UP_STATE, ///< Start up state. + BLOOD_LEAK_CHECK_COMM_STATE, ///< Check communication (Control U) state. BLOOD_LEAK_CHECK_SET_POINT_STATE, ///< Check set point state. BLOOD_LEAK_SET_SET_POINT_STATE, ///< Set set point state. BLOOD_LEAK_INIT_STATE, ///< Init state. @@ -78,6 +82,7 @@ static BOOL bloodLeakZeroRequested = FALSE; ///< Blood leak zero requested flag static U32 bloodLeakZeroStartTime = 0; ///< Blood leak zeroing start time. static U32 bloodLeakSelfTestStartTime = 0; ///< Blood leak self-test start time. +static BOOL bloodLeakIsPOSTComplete; ///< Blood leak is POST complete flag. static U32 bloodLeakPersistenceCtr = 0; ///< Blood leak alarm persistence timer counter. @@ -87,10 +92,11 @@ static U32 bloodLeakUARTCmdIndex = 0; ///< Blood leak UART command index. static U32 bloodLeakSetPointSeqLength = 0; ///< Blood leak set point sequence actual length. static U08 bloodLeakSetPointSequence[ BLOOD_LEAK_SET_POINT_SEQ_MAX_LENGTH ]; ///< Blood leak set point sequence array. -static U32 bloodLeakWait2ReadSetPointCounter = 0; ///< Blood leak wait to read delay counter. -static U32 bloodLeakCurrentSetPointWriteTry = 0; ///< Blood leak current set point write try number. +static U32 bloodLeakWait2ReadResponseCounter; ///< Blood leak wait to read response counter. +static U32 bloodLeakCommandWriteTryCount; ///< Blood leak current set point write try number. static HD_BLOOD_LEAK_SENSOR_CAL_RECORD_T bloodLeakCalRecord; ///< Blood leak calibration record structure. -static U32 bloodLeakGetCalStartTime = 0; ///< Blood leak get calibration start time. +static U32 bloodLeakGetCalStartTime; ///< Blood leak get calibration start time. +static U32 bloodLeakPrevFPGARegisterCount; ///< Blood leak previous FPGA communications counter. /// Blood leak start up sequence array. static const U08 BLOOD_LEAK_START_UP_SEQUENCE[ BLOOD_LEAK_STARTUP_SEQ_LENGTH ] = { BLOOD_LEAK_RESET_TX_FIFO, @@ -102,7 +108,9 @@ // ********** private function prototypes ********** +static BLOOD_LEAK_STATES_T handleBloodLeakWaitForPostState( void ); static BLOOD_LEAK_STATES_T handleBloodLeakStartupState( void ); +static BLOOD_LEAK_STATES_T handleBloodLeakCheckCommState( void ); static BLOOD_LEAK_STATES_T handleBloodLeakCheckSetPointState( void ); static BLOOD_LEAK_STATES_T handleBloodLeakSetSetPointState( void ); static BLOOD_LEAK_STATES_T handleBloodLeakInitState( void ); @@ -119,15 +127,16 @@ * @details Inputs: none * @details Outputs: bloodLeakState, bloodLeakStatus, bloodLeakSelfTestStatus, * bloodLeakZeroRequested, bloodLeakZeroRequested, bloodLeakSelfTestStartTime, - * bloodLeakUARTCmdIndex, bloodLeakSetPointSequence, - * bloodLeakWait2ReadSetPointCounter, bloodLeakDataPublicationTimerCounter, - * bloodLeakCurrentSetPointWriteTry, bloodLeakGetCalStartTime + * bloodLeakUARTCmdIndex, bloodLeakSetPointSequence, bloodLeakPrevFPGARegisterCount + * bloodLeakWait2ReadResponseCounter, bloodLeakDataPublicationTimerCounter, + * bloodLeakCommandWriteTryCount, bloodLeakGetCalStartTime, + * bloodLeakIsPOSTComplete * @return none *************************************************************************/ void initBloodLeak( void ) { bloodLeakDataPublicationTimerCounter = 0; - bloodLeakState = BLOOD_LEAK_START_UP_STATE; + bloodLeakState = BLOOD_LEAK_WAIT_FOR_POST_STATE; bloodLeakStatus.data = BLOOD_LEAK_NOT_DETECTED; bloodLeakStatus.ovInitData = BLOOD_LEAK_NOT_DETECTED; bloodLeakStatus.ovData = BLOOD_LEAK_NOT_DETECTED; @@ -138,9 +147,11 @@ bloodLeakSelfTestStartTime = 0; bloodLeakUARTCmdIndex = 0; bloodLeakSetPointSeqLength = 0; - bloodLeakWait2ReadSetPointCounter = 0; - bloodLeakCurrentSetPointWriteTry = 0; + bloodLeakWait2ReadResponseCounter = 0; + bloodLeakCommandWriteTryCount = 0; bloodLeakGetCalStartTime = getMSTimerCount(); + bloodLeakIsPOSTComplete = FALSE; + bloodLeakPrevFPGARegisterCount = 0; // Set the blood leak set pint sequence to 0 to be initialized memset( bloodLeakSetPointSequence, 0x0, BLOOD_LEAK_SET_POINT_SEQ_MAX_LENGTH ); @@ -179,10 +190,18 @@ // Execute blood leak state machine switch( bloodLeakState ) { + case BLOOD_LEAK_WAIT_FOR_POST_STATE: + bloodLeakState = handleBloodLeakWaitForPostState(); + break; + case BLOOD_LEAK_START_UP_STATE: bloodLeakState = handleBloodLeakStartupState(); break; + case BLOOD_LEAK_CHECK_COMM_STATE: + bloodLeakState = handleBloodLeakCheckCommState(); + break; + case BLOOD_LEAK_CHECK_SET_POINT_STATE: bloodLeakState = handleBloodLeakCheckSetPointState(); break; @@ -249,7 +268,8 @@ if ( TRUE == calStatus ) { - result = SELF_TEST_STATUS_PASSED; + result = SELF_TEST_STATUS_PASSED; + bloodLeakIsPOSTComplete = TRUE; } else { @@ -261,6 +281,29 @@ /*********************************************************************//** * @brief + * The handleBloodLeakWaitForPostState function handles the wait for POST + * state of the of blood leak state machine. + * @details Inputs: bloodLeakIsPOSTComplete, bloodLeakPrevFPGARegisterCount + * @details Outputs: none + * @return next state + *************************************************************************/ +static BLOOD_LEAK_STATES_T handleBloodLeakWaitForPostState( void ) +{ + BLOOD_LEAK_STATES_T state = BLOOD_LEAK_WAIT_FOR_POST_STATE; + + if ( TRUE == bloodLeakIsPOSTComplete ) + { + // Read the value that is in the FPGA counter so it can be used to make sure the blood leak is communicating after + // sending Ctrl U + bloodLeakPrevFPGARegisterCount = getFPGABloodLeakRegisterCounter(); + state = BLOOD_LEAK_START_UP_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleBloodLeakStartupState function handles the startup state of the * of blood leak state machine. * @details Inputs: bloodLeakUARTCmdIndex @@ -287,8 +330,12 @@ // Done with writing all the commands, reset the index and transition if ( bloodLeakUARTCmdIndex >= ( BLOOD_LEAK_STARTUP_SEQ_LENGTH - 1 ) ) { - bloodLeakUARTCmdIndex = 0; - state = BLOOD_LEAK_CHECK_SET_POINT_STATE; + // Wait for the sensor to start communication + if ( ++bloodLeakWait2ReadResponseCounter > BLOOD_LEAK_WAIT_2_READ_CTRL_U ) + { + bloodLeakUARTCmdIndex = 0; + state = BLOOD_LEAK_CHECK_COMM_STATE; + } } else { @@ -300,6 +347,46 @@ /*********************************************************************//** * @brief + * The handleBloodLeakCheckCommState function handles the check communication + * state to ensure the sensor is communicating. + * @details Inputs: bloodLeakCommandWriteTryCount, bloodLeakPrevFPGARegisterCount + * @details Outputs: bloodLeakCommandWriteTryCount, bloodLeakPrevFPGARegisterCount + * @return next state + *************************************************************************/ +static BLOOD_LEAK_STATES_T handleBloodLeakCheckCommState( void ) +{ + BLOOD_LEAK_STATES_T state = BLOOD_LEAK_CHECK_COMM_STATE; + + // Check if the blood leak sensor has started communicating + BOOL isBloodLeakCommunicating = ( bloodLeakPrevFPGARegisterCount != getFPGABloodLeakRegisterCounter() ? TRUE : FALSE ); + + // The sensor is communicating move on + if ( TRUE == isBloodLeakCommunicating ) + { + state = BLOOD_LEAK_CHECK_SET_POINT_STATE; + bloodLeakCommandWriteTryCount = 0; + } + else + { + // If the sensor is not communicating, and the number of writes has not exceeded try again, otherwise alarm + if ( bloodLeakCommandWriteTryCount < BLOOD_LEAK_MAX_CTRL_U_WRITE_TRIALS ) + { + bloodLeakCommandWriteTryCount++; + + bloodLeakPrevFPGARegisterCount = getFPGABloodLeakRegisterCounter(); + state = BLOOD_LEAK_START_UP_STATE; + } + else + { + // TODO alarm. Should we check the BLD communications all the time like in the monitor? + } + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleBloodLeakCheckSetPointState function handles the check set point * state to ensure the set point is set correctly. * @details Inputs: none @@ -313,28 +400,32 @@ U16 bloodLeakSetPoint = getFPGABloodLeakDetectSetPoint(); #ifdef BOARD_WITH_NO_HARDWARE - bloodLeakCalRecord.setPoint = 30; + // In case it is just a bare board, use this value + bloodLeakCalRecord.setPoint = 20; #endif if ( bloodLeakSetPoint != bloodLeakCalRecord.setPoint ) { - if ( bloodLeakCurrentSetPointWriteTry < BLOOD_LEAK_MAX_SET_POINT_WRITE_TRIALS ) + if ( bloodLeakCommandWriteTryCount < BLOOD_LEAK_MAX_SET_POINT_WRITE_TRIALS ) { prepareSetPointSeq(); - bloodLeakCurrentSetPointWriteTry++; + bloodLeakCommandWriteTryCount++; state = BLOOD_LEAK_SET_SET_POINT_STATE; } else { #ifndef IGNORE_BLOOD_LEAK_ALARM - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SENSOR_SET_POINT_SET_FAILURE ); + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) + { + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SENSOR_SET_POINT_SET_FAILURE ); + } #endif } } else { state = BLOOD_LEAK_INIT_STATE; - bloodLeakCurrentSetPointWriteTry = 0; + bloodLeakCommandWriteTryCount = 0; } return state; @@ -373,9 +464,9 @@ } else { - if ( ++bloodLeakWait2ReadSetPointCounter > BLOOD_LEAK_WAIT_2_READ_SET_POINT ) + if ( ++bloodLeakWait2ReadResponseCounter > BLOOD_LEAK_WAIT_2_READ_SET_POINT ) { - bloodLeakWait2ReadSetPointCounter = 0; + bloodLeakWait2ReadResponseCounter = 0; bloodLeakUARTCmdIndex = 0; // Done with writing the set point state = BLOOD_LEAK_CHECK_SET_POINT_STATE; @@ -434,10 +525,13 @@ if ( TRUE == didTimeout( bloodLeakZeroStartTime, BLOOD_LEAK_TIMEOUT_MS ) ) { #ifndef IGNORE_BLOOD_LEAK_ALARM - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_FAULT ); + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) + { + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_FAULT ); + } #endif } - } + } return state; } @@ -454,7 +548,6 @@ { BLOOD_LEAK_STATES_T state = BLOOD_LEAK_SELF_TEST_STATE; -#ifndef IGNORE_BLOOD_LEAK_ALARM if ( SELF_TEST_STATUS_IN_PROGRESS == bloodLeakSelfTestStatus ) { if ( FALSE == noFPGABloodLeakDetected() ) // Faked blood leak caused by independent MCU board @@ -467,7 +560,7 @@ bloodLeakSelfTestStatus = SELF_TEST_STATUS_FAILED; activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SELF_TEST_FAILURE ); - } + } } else { @@ -477,9 +570,6 @@ state = BLOOD_LEAK_NORMAL_STATE; } } -#else - state = BLOOD_LEAK_NORMAL_STATE; -#endif return state; } @@ -512,7 +602,10 @@ { bloodLeakPersistenceCtr = BLOOD_LEAK_PERSISTENCE; #ifndef IGNORE_BLOOD_LEAK_ALARM - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) + { + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + } #endif } } @@ -525,7 +618,10 @@ else { #ifndef IGNORE_BLOOD_LEAK_ALARM - clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) + { + clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + } #endif } } @@ -609,9 +705,9 @@ // Loop through the number of digits and get each ASCII value for ( i = 0; i < digitCount; i++ ) { - // Write the characters - bloodLeakSetPointSequence[ bufferIndex ] = tempCharBuffer[ i ]; - bufferIndex++; + // Write the characters + bloodLeakSetPointSequence[ bufferIndex ] = tempCharBuffer[ i ]; + bufferIndex++; } // After the characters, insert the carriage return into the buffer Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r39c791d03f363ce2c684597080fc8c2f5515976f -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 39c791d03f363ce2c684597080fc8c2f5515976f) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -255,7 +255,6 @@ static BOOL checkVolumeVsSafetyVolume( BOOL stopPump, F32 pctMargin ); static BOOL checkForStall( BOOL stopPump ); static void publishSyringePumpData( void ); -static BOOL processCalibrationData( void ); /*********************************************************************//** * @brief @@ -963,7 +962,8 @@ if ( TRUE == isNewCalibrationRecordAvailable() ) { // Get the new calibration data and check its validity - processCalibrationData(); + getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( HD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), + 0, ALARM_ID_HD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); } S32 encPosition = getFPGASyringePumpEncoderPosition(); @@ -1113,7 +1113,8 @@ { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; - BOOL calStatus = processCalibrationData(); + BOOL calStatus = getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( HD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), + 0, ALARM_ID_HD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); if ( TRUE == calStatus ) { @@ -1884,44 +1885,7 @@ } } -/*********************************************************************//** - * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: forceSensorCalRecord - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; - - // Get the calibration record from NVDataMgmt - HD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T calData = getHDHeparinForceSensorCalibrationRecord(); - - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the heparin force sensors data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.hdHeparinForceSensor.calibrationTime ) - { -#ifndef SKIP_CAL_CHECK - activateAlarmNoData( ALARM_ID_HD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); - status = FALSE; -#endif - } - - // The calibration data was valid, update the local copy - forceSensorCalRecord.hdHeparinForceSensor.fourthOrderCoeff = calData.hdHeparinForceSensor.fourthOrderCoeff; - forceSensorCalRecord.hdHeparinForceSensor.thirdOrderCoeff = calData.hdHeparinForceSensor.thirdOrderCoeff; - forceSensorCalRecord.hdHeparinForceSensor.secondOrderCoeff = calData.hdHeparinForceSensor.secondOrderCoeff; - forceSensorCalRecord.hdHeparinForceSensor.gain = calData.hdHeparinForceSensor.gain; - forceSensorCalRecord.hdHeparinForceSensor.offset = calData.hdHeparinForceSensor.offset; - - return status; -} - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/HDCommon.h =================================================================== diff -u -r596bd7a39e90c4ca7264f463031534373af0b315 -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/HDCommon.h (.../HDCommon.h) (revision 596bd7a39e90c4ca7264f463031534373af0b315) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -37,6 +37,7 @@ // #define RUN_WITHOUT_DG 1 // Run HD w/o DG // #define SIMULATE_UI 1 // Build w/o requirement that UI be there // #define TASK_TIMING_OUTPUT_ENABLED 1 // Re-purposes alarm lamp pins for task timing + // TODO convert the new configuration way #define DISABLE_ALARM_AUDIO 1 // Disable alarm audio // #define SKIP_POST 1 // Skip POST tests - all pass // #define DONT_SKIP_NV_POST 1 // Do not skip NV Data POST @@ -85,14 +86,14 @@ #define DISABLE_WD_AND_SFTY_POST_TESTS 1 // Disable watchdog and safety shutdown POST tests #define DISABLE_ILLEGAL_AIR_TRAP_ALARM 1 // Disable illegal state for air trap alarm #define SKIP_RESERVOIR_ALARMS 1 // Skip reservoir management alarms - #define IGNORE_BLOOD_LEAK_SELF_TEST 1 // Ignore blood leak self test - #define IGNORE_BLOOD_LEAK_ALARM 1 // Ignore blood leak alarm +// #define IGNORE_BLOOD_LEAK_SELF_TEST 1 // Ignore blood leak self test // TODO New config implemented +// #define IGNORE_BLOOD_LEAK_ALARM 1 // Ignore blood leak alarm // TODO New config implemented #define DISABLE_SERVICE_RECORD 1 // Skip Pre-Treatment and get to treatment as soon as possible - #define SKIP_UI_INTERACTION 1 // Skip UI interaction. - #define SKIP_SAMPLE_WATER 1 // Skip pre-treatment sample water - #define SKIP_CONSUMABLE_TESTS 1 // Skip pre-treatment consumable Self-tests + #define SKIP_UI_INTERACTION 1 // Skip UI interaction. // TODO New config implemented + #define SKIP_SAMPLE_WATER 1 // Skip pre-treatment sample water // TODO New config implemented + #define SKIP_CONSUMABLE_TESTS 1 // Skip pre-treatment consumable Self-tests // TODO New config implemented #define SKIP_DRY_SELF_TESTS 1 // Skip pre-treatment dry self-tests #define SKIP_PRIMING 1 // Skip Pre-treatment Prime #define SKIP_WET_SELF_TESTS 1 // Skip Pre-treatment prime wet self-tests Index: firmware/App/Modes/ConsumableSelfTest.c =================================================================== diff -u -r61716bc97ecca8af1ec560333844a8cf602eccb0 -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Modes/ConsumableSelfTest.c (.../ConsumableSelfTest.c) (revision 61716bc97ecca8af1ec560333844a8cf602eccb0) +++ firmware/App/Modes/ConsumableSelfTest.c (.../ConsumableSelfTest.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -18,6 +18,7 @@ #include "ConsumableSelfTest.h" #include "DGInterface.h" #include "ModePreTreat.h" +#include "NVDataMgmt.h" #include "Reservoirs.h" /** @@ -76,14 +77,20 @@ { case CONSUMABLE_SELF_TESTS_INSTALL_STATE: #ifdef SKIP_UI_INTERACTION - consumableInstallConfirmed = TRUE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) != SW_CONFIG_ENABLE_VALUE ) + { + consumableInstallConfirmed = TRUE; + } #endif // TODO: Check for DG straw door status to be open once DG door driver implemented if ( TRUE == consumableInstallConfirmed ) { consumableInstallConfirmed = FALSE; #ifndef SKIP_CONSUMABLE_TESTS - currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_FILL_CMD_STATE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CONSUMABLES_TESTS ) != SW_CONFIG_ENABLE_VALUE ) + { + currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_FILL_CMD_STATE; + } #else currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_COMPLETE_STATE; #endif Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -r24b2fe72608344e67ef37234085d15ad5e4fcc37 -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 24b2fe72608344e67ef37234085d15ad5e4fcc37) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -367,7 +367,10 @@ if ( STATE_CLOSED == getFPGADoorState() ) { #ifdef SKIP_UI_INTERACTION - patientDisconnectionConfirmed = TRUE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) != SW_CONFIG_ENABLE_VALUE ) + { + patientDisconnectionConfirmed = TRUE; + } #endif if ( TRUE == patientDisconnectionConfirmed ) { @@ -410,7 +413,10 @@ HD_POST_TREATMENT_STATE_T state = HD_POST_TREATMENT_DISPOSABLE_REMOVAL_STATE; #ifdef SKIP_UI_INTERACTION - disposableRemovalConfirmed = TRUE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) != SW_CONFIG_ENABLE_VALUE ) + { + disposableRemovalConfirmed = TRUE; + } #endif if ( TRUE == disposableRemovalConfirmed ) Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r61716bc97ecca8af1ec560333844a8cf602eccb0 -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 61716bc97ecca8af1ec560333844a8cf602eccb0) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -199,7 +199,10 @@ { case HD_PRE_TREATMENT_START_STATE: #ifndef SKIP_SAMPLE_WATER - transitionToSampleWater(); + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SAMPLE_WATER ) != SW_CONFIG_ENABLE_VALUE ) + { + transitionToSampleWater(); + } #endif currentPreTreatmentState = HD_PRE_TREATMENT_WATER_SAMPLE_STATE; break; @@ -354,7 +357,10 @@ REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NO_PATIENT_CONNECTION_CONFIRM; #ifdef SKIP_UI_INTERACTION - patientConnectionConfirm = TRUE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) != SW_CONFIG_ENABLE_VALUE ) + { + patientConnectionConfirm = TRUE; + } #endif if ( TRUE == patientConnectionConfirm ) @@ -542,7 +548,8 @@ execSampleWater(); #ifndef SKIP_SAMPLE_WATER - if ( SAMPLE_WATER_COMPLETE_STATE == getSampleWaterState() ) + if ( ( SAMPLE_WATER_COMPLETE_STATE == getSampleWaterState() ) || + ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SAMPLE_WATER ) != SW_CONFIG_ENABLE_VALUE ) ) #endif { cmdDGSampleWater( SAMPLE_WATER_CMD_END ); @@ -647,7 +654,10 @@ HD_PRE_TREATMENT_MODE_STATE_T state = HD_PRE_TREATMENT_CART_INSTALL_STATE; #ifdef SKIP_UI_INTERACTION - confirmInstallRequested = TRUE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) != SW_CONFIG_ENABLE_VALUE ) + { + confirmInstallRequested = TRUE; + } #endif if ( TRUE == confirmInstallRequested ) @@ -763,7 +773,10 @@ execPreTreatmentRecirc(); #ifdef SKIP_UI_INTERACTION - continueToTreatmentRequested = TRUE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) != SW_CONFIG_ENABLE_VALUE ) + { + continueToTreatmentRequested = TRUE; + } #endif if ( TRUE == continueToTreatmentRequested ) Index: firmware/App/Modes/Prime.c =================================================================== diff -u -rb03a3ed91ebe15cfb419e34018f8fe600e744b4b -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Modes/Prime.c (.../Prime.c) (revision b03a3ed91ebe15cfb419e34018f8fe600e744b4b) +++ firmware/App/Modes/Prime.c (.../Prime.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -424,7 +424,10 @@ primeStartTime = getMSTimerCount(); #ifdef SKIP_UI_INTERACTION - primeStartRequested = TRUE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) != SW_CONFIG_ENABLE_VALUE ) + { + primeStartRequested = TRUE; + } #endif if ( TRUE == primeStartRequested ) { Index: firmware/App/Modes/SampleWater.c =================================================================== diff -u -r24b2fe72608344e67ef37234085d15ad5e4fcc37 -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Modes/SampleWater.c (.../SampleWater.c) (revision 24b2fe72608344e67ef37234085d15ad5e4fcc37) +++ firmware/App/Modes/SampleWater.c (.../SampleWater.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -130,7 +130,10 @@ SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED; #ifdef SKIP_SAMPLE_WATER - sampleWaterResult = TRUE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SAMPLE_WATER ) != SW_CONFIG_ENABLE_VALUE ) + { + sampleWaterResult = TRUE; + } #endif if ( TRUE == sampleWaterResult ) { Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -r39c791d03f363ce2c684597080fc8c2f5515976f -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 39c791d03f363ce2c684597080fc8c2f5515976f) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -379,10 +379,15 @@ { case DRY_SELF_TESTS_START_STATE: #ifdef SKIP_DRY_SELF_TESTS - // TODO: Remove once dry self-test is ready to use - currentDrySelfTestsState = DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE; -#else - currentDrySelfTestsState = DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_DRY_SELF_TESTS ) != SW_CONFIG_ENABLE_VALUE ) + { + // TODO: Remove once dry self-test is ready to use + currentDrySelfTestsState = DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE; + } + else + { + currentDrySelfTestsState = DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; + } #endif break; @@ -1032,9 +1037,14 @@ { selfTestsResumeRequested = FALSE; #ifndef SKIP_DRY_SELF_TESTS - state = DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; -#else - state = DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE; + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_DRY_SELF_TESTS ) != SW_CONFIG_ENABLE_VALUE ) + { + state = DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; + } + else + { + state = DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE; + } #endif } @@ -1171,7 +1181,11 @@ if ( ( BUBBLE_NOT_DETECTED == ADABubbleStatus ) && ( BUBBLE_NOT_DETECTED == ADVBubbleStatus ) ) #endif { - zeroBloodLeak(); + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_SELF_TEST ) != SW_CONFIG_ENABLE_VALUE ) + { + zeroBloodLeak(); + } + state = WET_SELF_TESTS_BLOOD_LEAK_DETECTOR_STATE; *result = SELF_TEST_STATUS_PASSED; } @@ -1197,7 +1211,8 @@ { WET_SELF_TESTS_STATE_T state = WET_SELF_TESTS_BLOOD_LEAK_DETECTOR_STATE; - if ( SELF_TEST_STATUS_PASSED == getBloodLeakSelfTestStatus() ) + if ( ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_SELF_TEST ) != SW_CONFIG_ENABLE_VALUE ) || + ( SELF_TEST_STATUS_PASSED == getBloodLeakSelfTestStatus() ) ) { settleStartTime = getMSTimerCount(); state = WET_SELF_TESTS_FIRST_DISPLACEMENT_SETUP_STATE; Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r687dc2717d2f6b128b73526791f08d7176e447e8 -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 687dc2717d2f6b128b73526791f08d7176e447e8) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -73,7 +73,8 @@ static const F32 RESERVOIR_DILUTION_RATIO = MAX_RESERVOIR_DILUTION / ( 1.0 - MAX_RESERVOIR_DILUTION ); ///< Reservoir dilution ratio. -// TODO remove +// TOD remove +// FALSE for reservoir 1 and TRUE for reservoir 2 static BOOL test = TRUE; // TODO remove @@ -584,8 +585,6 @@ DG_RESERVOIR_ID_T inactiveRes = getDGInactiveReservoir(); // TODO test code remove - // This must be TRUE for reservoir 1, and FALSE for reservoir 2 - test = FALSE; //if ( TRUE == test ) { // Signal dialysis sub-mode to capture baseline volume for next reservoir. @@ -596,6 +595,8 @@ // Signal dialysis sub-mode to switch reservoirs signalReservoirsSwitched(); + + test = FALSE; } // TODO test code Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r687dc2717d2f6b128b73526791f08d7176e447e8 -r40f46e196349e3dd730048a354df8bbb2e40407d --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 687dc2717d2f6b128b73526791f08d7176e447e8) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 40f46e196349e3dd730048a354df8bbb2e40407d) @@ -3199,7 +3199,12 @@ void handleHDSerialNumberRequest( void ) { MESSAGE_T msg; - HD_SYSTEM_RECORD_T system = getHDSystemRecord(); + HD_SYSTEM_RECORD_T system; + + // Get the system's record. There are no arrays of system to check and also, raise no alarm since the system record + // has been already checked in POST + getNVRecord2Driver( GET_SYS_RECORD, (U08*)&system, sizeof( HD_SYSTEM_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + U08 *payloadPtr = msg.payload; // Create a message record @@ -3251,7 +3256,10 @@ void handleHDServiceScheduleRequest( MESSAGE_T *message ) { MESSAGE_T msg; - HD_SERVICE_RECORD_T payload = getHDServiceRecord(); + HD_SERVICE_RECORD_T service; + + getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( HD_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + U08 *payloadPtr = msg.payload; // Create a message record @@ -3260,9 +3268,9 @@ msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); // Fill message payload - memcpy( payloadPtr, &payload.lastServiceEpochDate, sizeof( U32 ) ); + memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &payload.serviceIntervalSeconds, sizeof( U32 ) ); + memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED );