Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r611ac03266421f8c4b7a03b4c1576838216aedb5 -r66dda999c5736ecec046197ff1c843c01f6aecc5 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 611ac03266421f8c4b7a03b4c1576838216aedb5) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 66dda999c5736ecec046197ff1c843c01f6aecc5) @@ -80,6 +80,8 @@ #define BLOOD_LEAK_EMB_MODE_ACTIVE_HIGH_INDEX 4 ///< Blood leak embedded mode active high command index. #define BLOOD_LEAK_EMB_MODE_REQUEST_RX_INDEX 0 ///< Blood leak embedded mode request Rx to read index. #define BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE 10 ///< Blood leak embedded mode command queue maximum size. +#define BLOOD_LEAK_EMB_MODE_ZERO_CMD_RQRD_Q 5 ///< Blood leak embedded mode zero command required queue count. +#define BLOOD_LEAK_EMB_MODE_NUM_OF_RETRIES 3 ///< Blood leak embedded mode number of retries to enqueue. /// Defined states for the blood leak detector state machine. typedef enum BloodLeakStates @@ -163,6 +165,7 @@ static U08 bloodLeakEmbModeCmdQFrontIndex; ///< Blood leak embedded mode command queue front index. static U08 bloodLeakEmbModeCmdQCount; ///< Blood leak embedded mode command queue count. static BOOL bloodLeakEmbModeHasZeroBeenRqustd; ///< Blood leak embedded mode flag to indicate zero has been requested. +static U32 bloodLeakEmbModeCmdEnqueueCount; ///< Blood leak embedded mode command enqueue count. // ********** private function prototypes ********** @@ -184,6 +187,7 @@ static void enqueueEmbModeCmd( U08 cmd ); static U08 dequeueEmbModeCmd( void ); static BOOL isEmbModeCmdQueueEmpty( void ); +static U32 getAvailableEmbModeQueueCount( void ); /*********************************************************************//** * @brief @@ -192,7 +196,7 @@ * @details Outputs: bloodLeakState, bloodLeakStatus, bloodLeakSelfTestStatus, * bloodLeakUARTCmdIndex, bloodLeakSetPointSequence * bloodLeakDataPublicationTimerCounter, bloodLeakEmbModeHasZeroBeenRqustd - * bloodLeakEmbModeSubstate + * bloodLeakEmbModeSubstate, bloodLeakEmbModeCmdEnqueueCount * bloodLeakPersistenceCtr, bloodLeakSignalEmbModeReq, * bloodLeakEmbModeRqstedCmd, bloodLeakEmbModeOpsStartTime, bloodLeakEmbModeRespBuffer, * bloodLeakEmbModeRespIndex, bloodLeakExitNormalRequested, @@ -226,6 +230,7 @@ bloodLeakEmbModeCmdQRearIndex = 0; bloodLeakEmbModeCmdQCount = 0; bloodLeakEmbModeHasZeroBeenRqustd = FALSE; + bloodLeakEmbModeCmdEnqueueCount = 0; // Set the blood leak embedded mode command queue to zero memset( bloodLeakEmbModeCmdQ, 0x0, BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE ); @@ -322,20 +327,33 @@ * @brief * The zeroBloodLeak function requests that the Blood Leak Detector be * zeroed. - * @details Inputs: none - * @details Outputs: bloodLeakCmd.cmdZeroRequested, bloodLeakUARTCmdIndex - * @return none + * @details Inputs: bloodLeakEmbModeCmdEnqueueCount + * @details Outputs: bloodLeakCmd.cmdZeroRequested, bloodLeakUARTCmdIndex, + * bloodLeakEmbModeCmdEnqueueCount + * @return TRUE if the zero commands were successfully queued otherwise, FALSE *************************************************************************/ -void zeroBloodLeak( void ) +BOOL zeroBloodLeak( void ) { - bloodLeakEmbModeHasZeroBeenRqustd = TRUE; + BOOL status = TRUE; - // Enqueue the zero and self test sequence (Z->G->Z->Q->T) - enqueueEmbModeCmd( Z_EMB_MODE_CMD ); - enqueueEmbModeCmd( G_EMB_MODE_CMD ); - enqueueEmbModeCmd( Z_EMB_MODE_CMD ); - enqueueEmbModeCmd( Q_EMB_MODE_CMD ); - enqueueEmbModeCmd( T_EMB_MODE_CMD ); + if ( getAvailableEmbModeQueueCount() >= BLOOD_LEAK_EMB_MODE_ZERO_CMD_RQRD_Q ) + { + status = TRUE; + bloodLeakEmbModeHasZeroBeenRqustd = TRUE; + + // Enqueue the zero and self test sequence (Z->G->Z->Q->T) + enqueueEmbModeCmd( Z_EMB_MODE_CMD ); + enqueueEmbModeCmd( G_EMB_MODE_CMD ); + enqueueEmbModeCmd( Z_EMB_MODE_CMD ); + enqueueEmbModeCmd( Q_EMB_MODE_CMD ); + enqueueEmbModeCmd( T_EMB_MODE_CMD ); + } + else if ( ++bloodLeakEmbModeCmdEnqueueCount > BLOOD_LEAK_EMB_MODE_MAX_NUM_CMD_TRIES ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_BLOOD_LEAK_ENQUEUE_FAILURE ) + } + + return status; } /*********************************************************************//** @@ -401,15 +419,13 @@ } else if ( ( TRUE == bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].isCmdRespRdy ) && ( BLOOD_LEAK_EMB_MODE_FAIL_ASCII == cmdResp ) ) { - if ( bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].commandRetryCount < BLOOD_LEAK_EMB_MODE_MAX_NUM_CMD_TRIES ) + if ( ++bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].commandRetryCount < BLOOD_LEAK_EMB_MODE_MAX_NUM_CMD_TRIES ) { // Enqueue the commands to set the embedded mode and request the set point of the blood leak sensor // Since set point was requested in the init function as well, both are requested here because we have to be // in the embedded mode first enqueueEmbModeCmd( CS_EMB_MODE_CMD ); enqueueEmbModeCmd( D_EMB_MODE_CMD ); - - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].commandRetryCount++; } else { @@ -424,7 +440,8 @@ if ( ( getCurrentOperationMode() != MODE_INIT ) && ( TRUE == isEmbModeReady ) ) { - state = BLOOD_LEAK_CHECK_SET_POINT_STATE; + bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].commandRetryCount = 0; + state = BLOOD_LEAK_CHECK_SET_POINT_STATE; } return state; @@ -446,11 +463,9 @@ if ( ( bloodLeakSetPoint != bloodLeakCalRecord.setPoint ) && ( TRUE == isCommandRespReady ) ) { - if ( bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandRetryCount < BLOOD_LEAK_EMB_MODE_MAX_NUM_CMD_TRIES ) + if ( ++bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandRetryCount < BLOOD_LEAK_EMB_MODE_MAX_NUM_CMD_TRIES ) { enqueueEmbModeCmd( D_EMB_MODE_CMD ); - - bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandRetryCount++; } else { @@ -464,7 +479,8 @@ } else if ( TRUE == isCommandRespReady ) { - state = BLOOD_LEAK_INIT_STATE; + bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandRetryCount = 0; + state = BLOOD_LEAK_INIT_STATE; } return state; @@ -551,13 +567,20 @@ if ( FALSE == hasCmdSqncFailed ) { - bloodLeakSelfTestStatus = SELF_TEST_STATUS_PASSED; - state = BLOOD_LEAK_NORMAL_STATE; + // Done with zero sequence, transition to other states + bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].commandRetryCount = 0; + bloodLeakSelfTestStatus = SELF_TEST_STATUS_PASSED; + state = BLOOD_LEAK_NORMAL_STATE; } else if ( bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].commandRetryCount < BLOOD_LEAK_EMB_MODE_MAX_NUM_CMD_TRIES ) { - // Zero sequence failed, try again - zeroBloodLeak(); + if ( TRUE == zeroBloodLeak() ) + { + // Check if the zero sequence has been successfully enqueued + // If the command retry of one of the commands in the zero sequence failed, it means all of them have failed + // So in this condition only the Z command is checked + bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].commandRetryCount++; + } } else { @@ -1353,7 +1376,20 @@ return isEmpty; } +/*********************************************************************//** + * @brief + * The getAvailableEmbModeQueueCount function returns the available embedded + * mode queue count. + * @details Inputs: bloodLeakEmbModeCmdQCount + * @details Outputs: none + * @return Current available embedded mode queue count + *************************************************************************/ +static U32 getAvailableEmbModeQueueCount( void ) +{ + return BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE - bloodLeakEmbModeCmdQCount; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Controllers/BloodLeak.h =================================================================== diff -u -r4e4ab946c0bc4b668cf5b197c7f841355814ccf5 -r66dda999c5736ecec046197ff1c843c01f6aecc5 --- firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision 4e4ab946c0bc4b668cf5b197c7f841355814ccf5) +++ firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision 66dda999c5736ecec046197ff1c843c01f6aecc5) @@ -61,7 +61,7 @@ void initBloodLeak( void ); void execBloodLeak( void ); void execBloodLeakEmbModeCommand( void ); -void zeroBloodLeak( void ); +BOOL zeroBloodLeak( void ); void exitBloodLeakNormalState( void ); Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 -r66dda999c5736ecec046197ff1c843c01f6aecc5 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 66dda999c5736ecec046197ff1c843c01f6aecc5) @@ -84,7 +84,7 @@ static HD_STANDBY_STATE_T handleStandbyModeDGChemDisininfectInProgressState( void ); static BOOL isDGDisinfectValid( void ); -static BOOL haveHDDGServicesBeenExpired( void ); +static BOOL haveHDDGServicesBeenExpired( REQUEST_REJECT_REASON_CODE_T* rejReason ); static void publishDisinfectData( void ); /*********************************************************************//** @@ -281,9 +281,22 @@ rejReason = REQUEST_REJECT_REASON_BATTERY_IS_NOT_CHARGED; } +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SERVICE_AND_DISINFECT_CHECK ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + // This function checks both HD and DG service records and if any of them has failed, it fills the provided reject reason buffer + haveHDDGServicesBeenExpired( &rejReason ); + + if ( FALSE == isDGDisinfectValid() ) + { + rejReason = REQUEST_REJECT_REASON_DG_DISINFECT_HAS_BEEN_EXPIRED; + } + } + if ( REQUEST_REJECT_REASON_NONE == rejReason ) { - result = TRUE; + result = TRUE; treatStartReqReceived = TRUE; } @@ -529,25 +542,17 @@ { BOOL startTreatment = TRUE; -#ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SERVICE_AND_DISINFECT_CHECK ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - startTreatment = isDGDisinfectValid(); - startTreatment = haveHDDGServicesBeenExpired(); - } - - if ( TRUE == startTreatment ) - { - // Initialize treatment modes before starting a new treatment - initTreatParamsMode(); - initPreTreatmentMode(); - initTreatmentMode(); - initPostTreatmentMode(); - // Start treatment workflow with treatment parameters mode - requestNewOperationMode( MODE_TPAR ); - treatStartReqReceived = FALSE; - } + if ( TRUE == startTreatment ) + { + // Initialize treatment modes before starting a new treatment + initTreatParamsMode(); + initPreTreatmentMode(); + initTreatmentMode(); + initPostTreatmentMode(); + // Start treatment workflow with treatment parameters mode + requestNewOperationMode( MODE_TPAR ); + treatStartReqReceived = FALSE; + } } return state; @@ -827,8 +832,8 @@ ***********************************************************************/ static BOOL isDGDisinfectValid( void ) { - BOOL status = TRUE; DG_SERVICE_AND_USAGE_DATA_T data; + BOOL status = TRUE; getHDVersionDGServiceAndUsageData( &data ); @@ -844,13 +849,11 @@ if ( ( TRUE == hasChemDisBeenExpired ) && ( TRUE == hasHeatDisBeenExpired ) ) { status = FALSE; - activateAlarmNoData( ALARM_ID_DG_DISINFECT_HAS_BEEN_EXPIRED ); } } else { status = FALSE; - activateAlarmNoData( ALARM_ID_DG_DISINFECT_HAS_BEEN_EXPIRED ); } } @@ -863,9 +866,10 @@ * service time is still within the interval or not. * @details Inputs: none * @details Outputs: none + * @param rejReason pointer to the provided reject reason buffer to be send to UI * @return TRUE if the service time is still valid otherwise, FALSE ***********************************************************************/ -static BOOL haveHDDGServicesBeenExpired( void ) +static BOOL haveHDDGServicesBeenExpired( REQUEST_REJECT_REASON_CODE_T* rejReason ) { BOOL status = TRUE; DG_SERVICE_AND_USAGE_DATA_T dgData; @@ -883,13 +887,14 @@ if ( TRUE == hasDGSrvcBeenExpired ) { - status = FALSE; - activateAlarmNoData( ALARM_ID_DG_SERIVCE_TIME_INTERVAL_HAS_ELAPSED ); + status = FALSE; + *rejReason = REQUEST_REJECT_REASON_DG_SERVICE_IS_DUE; } + if ( TRUE == hasHDSrvcBeenExpied ) { - status = FALSE; - activateAlarmNoData( ALARM_ID_HD_SERVICE_TIME_INTERVAL_HAS_ELAPSED ); + status = FALSE; + *rejReason = REQUEST_REJECT_REASON_HD_SERVICE_IS_DUE; } } Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 -r66dda999c5736ecec046197ff1c843c01f6aecc5 --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 66dda999c5736ecec046197ff1c843c01f6aecc5) @@ -1260,22 +1260,21 @@ *************************************************************************/ static WET_SELF_TESTS_STATE_T handleWetSelfTestPrimeCheckState( void ) { - WET_SELF_TESTS_STATE_T state = WET_SELF_TESTS_PRIME_CHECK_STATE; + WET_SELF_TESTS_STATE_T state = WET_SELF_TESTS_PRIME_CHECK_STATE; + BUBBLE_STATUS_T ADVBubbleStatus = getBubbleStatus( ADV ); - BUBBLE_STATUS_T const ADVBubbleStatus = getBubbleStatus( ADV ); - if ( BUBBLE_NOT_DETECTED == ADVBubbleStatus ) { #ifndef _RELEASE_ - // TODO do we need both of these? if ( ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_SELF_TEST ) != SW_CONFIG_ENABLE_VALUE ) && ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SELF_TESTS_AIR_BUBBLE_CHECK ) != SW_CONFIG_ENABLE_VALUE ) ) #endif { - zeroBloodLeak(); + if ( TRUE == zeroBloodLeak() ) + { + state = WET_SELF_TESTS_BLOOD_LEAK_DETECTOR_STATE; + } } - - state = WET_SELF_TESTS_BLOOD_LEAK_DETECTOR_STATE; } else { Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 -r66dda999c5736ecec046197ff1c843c01f6aecc5 --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 66dda999c5736ecec046197ff1c843c01f6aecc5) @@ -172,6 +172,7 @@ SW_FAULT_ID_INVALID_FPGA_SENSOR_GROUP_SELECTED, SW_FAULT_ID_WRITE_USAGE_INFO_TO_NV_FAILURE, SW_FAULT_ID_INVALID_NV_RECORD_SELECTED, + SW_FAULT_ID_BLOOD_LEAK_ENQUEUE_FAILURE, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T;