Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r2c9bbece8057254f8389c26a818081002fb69a77 -r1e323172095bb1ca6969f65976049c9fbe19c489 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 2c9bbece8057254f8389c26a818081002fb69a77) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) @@ -19,6 +19,7 @@ #include "AlarmMgmt.h" #include "BloodLeak.h" #include "FPGA.h" +#include "NVDataMgmtHDRecords.h" #include "OperationModes.h" #include "SystemCommMessages.h" #include "TaskPriority.h" @@ -81,19 +82,16 @@ 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; +static U32 bloodLeakCurrentSetPointWriteTry = 0; ///< Blood leak current set point write try number. +static HD_BLOOD_LEAK_SENSOR_CAL_RECORD_T bloodLeakCalRecord; ///< Blood leak calibration record structure. - /// Blood leak start up sequence array. static const U08 BLOOD_LEAK_START_UP_SEQUENCE[ BLOOD_LEAK_STARTUP_SEQ_LENGTH ] = { BLOOD_LEAK_RESET_TX_FIFO, BLOOD_LEAK_UART_COMM_ACTIVE_LOW, BLOOD_LEAK_START_COMM_CTRL_U_ASCII, BLOOD_LEAK_UART_COMM_ACTIVE_HIGH, BLOOD_LEAK_UART_COMM_ACTIVE_LOW }; -static const U32 REMOVE_LATER_SET_POINT = 38; // TODO remove this later -static U32 test = 38; - // ********** private function prototypes ********** static BLOOD_LEAK_STATES_T handleBloodLeakStartupState( void ); @@ -148,6 +146,22 @@ *************************************************************************/ void execBloodLeak( void ) { + // Check if there is a new calibration data available + if ( TRUE == isNewCalibrationRecordAvailable() ) + { + // TODO figure out a way to process this data + // TODO for testing only remove + bloodLeakCalRecord.setPoint = 123; + // TODO for testing only remove the top + + U32 length = sizeof( HD_BLOOD_LEAK_SENSOR_CAL_RECORD_T ); + getCalibrationRecord2Driver( CAL_GET_BLOOD_LEAK_SENSOR, (U08*)&bloodLeakCalRecord, length, ALARM_ID_HD_BLOOD_LEAK_INVALID_CAL_RECORD ); + + // Force the state machine to go back to set the set point that has been received from + // the calibration data + bloodLeakState = BLOOD_LEAK_SET_SET_POINT_STATE; + } + if ( getCurrentOperationMode() != MODE_INIT ) { // Execute blood leak state machine @@ -207,6 +221,33 @@ /*********************************************************************//** * @brief + * The execBloodLeakSelfTest function executes the blood leak self-test. + * @details Inputs: none + * @details Outputs: none + * @return blood leak self test results (SELF_TEST_STATUS_T) + *************************************************************************/ +SELF_TEST_STATUS_T execBloodLeakSelfTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + + U32 length = sizeof( HD_BLOOD_LEAK_SENSOR_CAL_RECORD_T ); + ALARM_ID_T alarm = ALARM_ID_HD_BLOOD_LEAK_INVALID_CAL_RECORD; + BOOL calStatus = getCalibrationRecord2Driver( CAL_GET_BLOOD_LEAK_SENSOR, (U08*)&bloodLeakCalRecord, length, alarm ); + + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } + + return result; +} + +/*********************************************************************//** + * @brief * The handleBloodLeakStartupState function handles the startup state of the * of blood leak state machine. * @details Inputs: bloodLeakUARTCmdIndex @@ -255,13 +296,12 @@ U32 bloodLeakSetPoint = (U32)getFPGABloodLeakDetectSetPoint(); - if ( bloodLeakSetPoint != REMOVE_LATER_SET_POINT ) + if ( bloodLeakSetPoint != bloodLeakCalRecord.crc ) { if ( bloodLeakCurrentSetPointWriteTry < BLOOD_LEAK_MAX_SET_POINT_WRITE_TRIALS ) { prepareSetPointSeq(); - bloodLeakUARTCmdIndex = 0; state = BLOOD_LEAK_SET_SET_POINT_STATE; } else @@ -529,7 +569,7 @@ // The set point can be maximum 3 digits and when it is converted to string, the null character // is the extra character at the end of the buffer so it maximum length is 4 bytes. U32 digitCount = 0; - U32 setPoint = test; // TODO make the origin of the number right + U32 setPoint = bloodLeakCalRecord.setPoint; U32 bufferIndex = BLOOD_LEAK_SET_POINT_START_CHAR_INDEX; char tempCharBuffer[ BLOOD_LEAK_SET_POINT_MAX_CHAR_LENGTH ]; memset( tempCharBuffer, 0x0, BLOOD_LEAK_SET_POINT_MAX_CHAR_LENGTH ); @@ -543,8 +583,9 @@ digitCount++; } - // - setPoint = test; + // Set point was divided up for find out the number of digits + // so it is reinstated again for the rest of the calculations + setPoint = bloodLeakCalRecord.crc; // Convert the set point number to the equivalent ASCII number with the unsigned integer data type sprintf( tempCharBuffer, "%u", setPoint ); @@ -571,8 +612,12 @@ bufferIndex++; bloodLeakSetPointSequence[ bufferIndex ] = BLOOD_LEAK_UART_COMM_ACTIVE_LOW; + // Update the sequence length for writing to the sensor bloodLeakSetPointSeqLength = bufferIndex + 1; + + // Get ready for the next write to the sensor + bloodLeakUARTCmdIndex = 0; } /*********************************************************************//** Index: firmware/App/Controllers/BloodLeak.h =================================================================== diff -u -r6982379266891326c9d45aecd7d54ad5c85ea69f -r1e323172095bb1ca6969f65976049c9fbe19c489 --- firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision 6982379266891326c9d45aecd7d54ad5c85ea69f) +++ firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) @@ -61,9 +61,11 @@ void initBloodLeak( void ); void execBloodLeak( void ); void zeroBloodLeak( void ); + +SELF_TEST_STATUS_T execBloodLeakSelfTest( void ); BLOOD_LEAK_STATUS_T getBloodLeakStatus( void ); -SELF_TEST_STATUS_T getBloodLeakSelfTestStatus( void ); +SELF_TEST_STATUS_T getBloodLeakSelfTestStatus( void ); // TODO maybe this should not be self test status and just a boolean? BOOL testSetBloodLeakDataPublishIntervalOverride( U32 value ); BOOL testResetBloodLeakDataPublishIntervalOverride( void ); Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -r2c9bbece8057254f8389c26a818081002fb69a77 -r1e323172095bb1ca6969f65976049c9fbe19c489 --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 2c9bbece8057254f8389c26a818081002fb69a77) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) @@ -458,15 +458,6 @@ hasAlarmBeenRaised = FALSE; rpmAlarmStartTime = 0; } - else - { - // If the alarm has been raised and 24 hours has not elapsed, check if the fans RPM is back in range again - // If the fans RPM is in range again, clear the alarm - if ( FALSE == isFanRPMOutOfRange ) - { - clearAlarmCondition( ALARM_ID_HD_FAN_RPM_OUT_OF_RANGE ); - } - } fansMonitorCounter = 0; } Index: firmware/App/Controllers/Fans.h =================================================================== diff -u -r2c9bbece8057254f8389c26a818081002fb69a77 -r1e323172095bb1ca6969f65976049c9fbe19c489 --- firmware/App/Controllers/Fans.h (.../Fans.h) (revision 2c9bbece8057254f8389c26a818081002fb69a77) +++ firmware/App/Controllers/Fans.h (.../Fans.h) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) @@ -41,7 +41,7 @@ F32 fansDutyCycle; ///< Fans duty cycle F32 fansTargetRPM; ///< Fans target RPM F32 fanInlet1RPM; ///< Fan inlet 1 RPM - U32 rpmAlarmTimeOffset + U32 rpmAlarmTimeOffset; ///< RPM alarm time offset } FANS_DATA_T; void initFans( void ); Index: firmware/App/HDCommon.h =================================================================== diff -u -rc6cf2c60675a7c9e027cc33ff8521a9a545b2b87 -r1e323172095bb1ca6969f65976049c9fbe19c489 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision c6cf2c60675a7c9e027cc33ff8521a9a545b2b87) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) @@ -82,7 +82,7 @@ // #define DISABLE_UI_COMM_TO_ALARM 1 // Disable UI comm timeouts #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 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 Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r57131d8f8cfb3979f5f395d1152c6afd85d1d088 -r1e323172095bb1ca6969f65976049c9fbe19c489 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 57131d8f8cfb3979f5f395d1152c6afd85d1d088) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) @@ -20,6 +20,7 @@ #include "Accel.h" #include "AlarmLamp.h" #include "BloodFlow.h" +#include "BloodLeak.h" #include "Buttons.h" #include "Compatible.h" #include "CPLD.h" @@ -189,6 +190,11 @@ postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_BLOOD_LEAK: + testStatus = execBloodLeakSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + case POST_STATE_VALVES: testStatus = execValvesSelfTest(); postState = handlePOSTStatus( testStatus );