Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r1e323172095bb1ca6969f65976049c9fbe19c489 -r53dd658c22a8e91597304b1aff96fee43b7b8c49 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 53dd658c22a8e91597304b1aff96fee43b7b8c49) @@ -47,7 +47,7 @@ #define BLOOD_LEAK_CARRIAGE_RETURN_ASCII 13 ///< Blood leak set point sequence carriage return character in ASCII. #define BLOOD_LEAK_SET_POINT_SEQ_MAX_LENGTH 7 ///< Blood leak set point sequence maximum length. -#define BLOOD_LEAK_WAIT_2_READ_SET_POINT ( 0.5 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Blood leak wait to read set point in counts. +#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_MAX_SET_POINT_WRITE_TRIALS 3 ///< Blood leak maximum number of trials to write the set point. /// Defined states for the blood leak detector state machine. @@ -149,13 +149,8 @@ // 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 ); + getCalibrationRecord2Driver( GET_CAL_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 @@ -232,7 +227,7 @@ 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 ); + BOOL calStatus = getCalibrationRecord2Driver( GET_CAL_BLOOD_LEAK_SENSOR, (U08*)&bloodLeakCalRecord, length, alarm ); if ( TRUE == calStatus ) { @@ -269,7 +264,7 @@ setFPGABloodLeakUARTControl( (U08)command ); } - if ( bloodLeakUARTCmdIndex > BLOOD_LEAK_STARTUP_SEQ_LENGTH - 1 ) + if ( bloodLeakUARTCmdIndex >= BLOOD_LEAK_STARTUP_SEQ_LENGTH ) { bloodLeakUARTCmdIndex = 0; state = BLOOD_LEAK_CHECK_SET_POINT_STATE; @@ -294,14 +289,14 @@ { BLOOD_LEAK_STATES_T state = BLOOD_LEAK_CHECK_SET_POINT_STATE; - U32 bloodLeakSetPoint = (U32)getFPGABloodLeakDetectSetPoint(); + U16 bloodLeakSetPoint = getFPGABloodLeakDetectSetPoint(); - if ( bloodLeakSetPoint != bloodLeakCalRecord.crc ) + if ( bloodLeakSetPoint != bloodLeakCalRecord.setPoint ) { if ( bloodLeakCurrentSetPointWriteTry < BLOOD_LEAK_MAX_SET_POINT_WRITE_TRIALS ) { prepareSetPointSeq(); - + bloodLeakCurrentSetPointWriteTry++; state = BLOOD_LEAK_SET_SET_POINT_STATE; } else @@ -585,7 +580,7 @@ // 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; + setPoint = bloodLeakCalRecord.setPoint; // Convert the set point number to the equivalent ASCII number with the unsigned integer data type sprintf( tempCharBuffer, "%u", setPoint ); Index: firmware/App/Controllers/BloodLeak.h =================================================================== diff -u -r1e323172095bb1ca6969f65976049c9fbe19c489 -r53dd658c22a8e91597304b1aff96fee43b7b8c49 --- firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) +++ firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision 53dd658c22a8e91597304b1aff96fee43b7b8c49) @@ -65,7 +65,7 @@ SELF_TEST_STATUS_T execBloodLeakSelfTest( void ); BLOOD_LEAK_STATUS_T getBloodLeakStatus( void ); -SELF_TEST_STATUS_T getBloodLeakSelfTestStatus( void ); // TODO maybe this should not be self test status and just a boolean? +SELF_TEST_STATUS_T getBloodLeakSelfTestStatus( void ); BOOL testSetBloodLeakDataPublishIntervalOverride( U32 value ); BOOL testResetBloodLeakDataPublishIntervalOverride( void ); Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -r1e323172095bb1ca6969f65976049c9fbe19c489 -r53dd658c22a8e91597304b1aff96fee43b7b8c49 --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 1e323172095bb1ca6969f65976049c9fbe19c489) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 53dd658c22a8e91597304b1aff96fee43b7b8c49) @@ -51,7 +51,6 @@ #define FANS_MAX_ALLOWED_RPM_OUT_OF_RANGE_INTERVAL ( 3 * MS_PER_SECOND ) ///< Fans max allowed RPM out of range time interval. #define FANS_MAX_ALLOWED_RPM 5500 ///< Fans max allowed RPM value. #define FANS_MIN_ALLOWED_RPM 150 ///< Fans max allowed RPM value. -#define FANS_MONITOR_INTERVAL_COUNT ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Fans monitor time interval in counts. #define FANS_MIN_RPM_OUT_OF_RANGE_TOL 0.25 ///< Fans min RPM out of range tolerance. #define FANS_MAX_RPM_OUT_OF_RANGE_TOL 0.5 ///< Fans max RPM out of range tolerance. @@ -75,7 +74,6 @@ static FANS_EXEC_STATES_T fansExecState = FANS_EXEC_STATE_WAIT_FOR_POST_STATE; ///< Fans exec state. static U32 fansControlCounter = 0; ///< Fans control interval counter. static U32 fansPublishCounter = 0; ///< Fans data publish interval counter. -static U32 fansMonitorCounter = 0; ///< Fans monitor interval counter. static BOOL isPOSTComplete = FALSE; ///< Flag that indicates whether POST is complete or not. static BOOL hasAlarmBeenRaised = FALSE; ///< Flag that indicates whether RPM out of range alarm has been raised once. static OVERRIDE_U32_T rpmAlarmStartTimeOffset = { 0, 0, 0, 0}; ///< RPM out of range alarm start time offset. @@ -105,7 +103,7 @@ * @brief * The initFans function initializes the fans module. * @details Inputs: none - * @details Outputs: fansExecState, fansMonitorCounter, fansControlCounter, + * @details Outputs: fansExecState, fansControlCounter, * fansPublishCounter, isPOSTComplete, hasAlarmBeenRaised, fansStatus, * rpmAlarmStartTime, rpmAlarmStartTimeOffset * @return none @@ -118,7 +116,6 @@ fansExecState = FANS_EXEC_STATE_WAIT_FOR_POST_STATE; fansControlCounter = 0; fansPublishCounter = 0; - fansMonitorCounter = 0; isPOSTComplete = FALSE; hasAlarmBeenRaised = FALSE; rpmAlarmStartTime = 0; @@ -407,60 +404,55 @@ /*********************************************************************//** * @brief * The monitorFans function monitors the fans for RPM. - * @details Inputs: fansMonitorCounter, rpmAlarmStartTimer, hasAlarmBeenRaised - * @details Outputs: fansMonitorCounter, hasAlarmBeenRaised, rpmAlarmStartTimer + * @details Inputs: rpmAlarmStartTimer, hasAlarmBeenRaised + * @details Outputs: hasAlarmBeenRaised, rpmAlarmStartTimer * @return none *************************************************************************/ static void monitorFans( void ) { - if ( ++fansMonitorCounter >= FANS_MONITOR_INTERVAL_COUNT ) + FAN_NAMES_T fan; + BOOL isFanRPMOutOfRange = FALSE; + BOOL isAlarmTriggered = FALSE; + F32 rpm = 0.0; + + // The RPM is expected to be 5500 @ 100% duty cycle + // The nominal RPM = duty cycle * 5500 / 1.0 + // The RPM tolerance is -25% to +50% of the nominal RPM + F32 fansNominalRPM = fansStatus.targetDutyCycle * FANS_MAX_ALLOWED_RPM; + F32 fansMinAllowedRPM = fansNominalRPM - ( fansNominalRPM * FANS_MIN_RPM_OUT_OF_RANGE_TOL ); + F32 fansMaxAllowedRPM = fansNominalRPM + ( fansNominalRPM * FANS_MAX_RPM_OUT_OF_RANGE_TOL ); + + // Loop through the fans and make sure the each of them have RPM in range + for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) { - FAN_NAMES_T fan; - BOOL isFanRPMOutOfRange = FALSE; - BOOL isAlarmTriggered = FALSE; - F32 rpm = 0.0; + rpm = getMeasuredFanRPM( fan ); + isFanRPMOutOfRange |= ( ( rpm < fansMinAllowedRPM ) || ( rpm > fansMaxAllowedRPM ) ? TRUE : FALSE ); + } - // The RPM is expected to be 5500 @ 100% duty cycle - // The nominal RPM = duty cycle * 5500 / 1.0 - // The RPM tolerance is -25% to +50% of the nominal RPM - F32 fansNominalRPM = fansStatus.targetDutyCycle * FANS_MAX_ALLOWED_RPM; - F32 fansMinAllowedRPM = fansNominalRPM - ( fansNominalRPM * FANS_MIN_RPM_OUT_OF_RANGE_TOL ); - F32 fansMaxAllowedRPM = fansNominalRPM + ( fansNominalRPM * FANS_MAX_RPM_OUT_OF_RANGE_TOL ); + if ( FALSE == hasAlarmBeenRaised ) + { + isAlarmTriggered = isPersistentAlarmTriggered( ALARM_ID_HD_FAN_RPM_OUT_OF_RANGE, isFanRPMOutOfRange ); - // Loop through the fans and make sure the each of them have RPM in range - for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) + if ( TRUE == isAlarmTriggered ) { - rpm = getMeasuredFanRPM( fan ); - isFanRPMOutOfRange |= ( ( rpm < fansMinAllowedRPM ) || ( rpm > fansMaxAllowedRPM ) ? TRUE : FALSE ); + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_FAN_RPM_OUT_OF_RANGE, rpm ) + // Set the alarm flag to TRUE + hasAlarmBeenRaised = TRUE; } - - if ( FALSE == hasAlarmBeenRaised ) + // If the alarm has been raised but the start time of the alarm has not been set, set the alarm start timer + if ( ( TRUE == hasAlarmBeenRaised ) && ( 0 == rpmAlarmStartTime ) ) { - isAlarmTriggered = isPersistentAlarmTriggered( ALARM_ID_HD_FAN_RPM_OUT_OF_RANGE, isFanRPMOutOfRange ); - - if ( TRUE == isAlarmTriggered ) - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_FAN_RPM_OUT_OF_RANGE, rpm ) - // Set the alarm flag to TRUE - hasAlarmBeenRaised = TRUE; - } - // If the alarm has been raised but the start time of the alarm has not been set, set the alarm start timer - if ( ( TRUE == hasAlarmBeenRaised ) && ( 0 == rpmAlarmStartTime ) ) - { - rpmAlarmStartTime = getMSTimerCount(); - } + rpmAlarmStartTime = getMSTimerCount(); } - // If the alarm has been raised and the alarm has been silent for at least a day, set the flag to FALSE - // This way, if the fans RPM are out of range the alarm will be raised again. This alarm is supposed to be raised - // and remain silent for a defined period of time. - else if ( ( TRUE == hasAlarmBeenRaised ) && ( ( calcTimeSince( rpmAlarmStartTime ) + getRPMAlarmStartTimeOffset() ) >= SECONDS_IN_A_DAY * MS_PER_SECOND ) ) - { - hasAlarmBeenRaised = FALSE; - rpmAlarmStartTime = 0; - } - - fansMonitorCounter = 0; } + // If the alarm has been raised and the alarm has been silent for at least a day, set the flag to FALSE + // This way, if the fans RPM are out of range the alarm will be raised again. This alarm is supposed to be raised + // and remain silent for a defined period of time. + else if ( ( TRUE == hasAlarmBeenRaised ) && ( ( calcTimeSince( rpmAlarmStartTime ) + getRPMAlarmStartTimeOffset() ) >= SECONDS_IN_A_DAY * MS_PER_SECOND ) ) + { + hasAlarmBeenRaised = FALSE; + rpmAlarmStartTime = 0; + } } /*********************************************************************//**