Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -rd4c8e0246e5bc34d1ef6a2e1709647716c84a378 -r84cc99fd5cd997d0a1e024a4e23d0d3880142ffb --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision d4c8e0246e5bc34d1ef6a2e1709647716c84a378) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 84cc99fd5cd997d0a1e024a4e23d0d3880142ffb) @@ -73,13 +73,13 @@ } FAN_STATUS_T; static FAN_STATUS_T fansStatus; ///< Fans status. -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 FANS_EXEC_STATES_T fansExecState; ///< Fans exec state. +static U32 fansControlCounter; ///< Fans control interval counter. static U32 fansPublishCounter; ///< Fans data publish 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 BOOL isPOSTComplete; ///< Flag that indicates whether POST is complete or not. +static BOOL hasAlarmBeenRaised; ///< 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. -static U32 rpmAlarmStartTime = 0; ///< RPM alarm start time. +static U32 rpmAlarmStartTime; ///< RPM alarm start time. /// Temperature to duty cycle conversion slope (duty cycle not in percent) static const F32 SLOPE = ( FANS_MAX_DUTY_CYCLE - FANS_MIN_DUTY_CYCLE ) / ( MAX_ALLOWED_AMBINET_TEMPERATURE - MIN_ALLOWED_AMBIENT_TEMPERATURE ); @@ -125,15 +125,15 @@ rpmAlarmStartTimeOffset.ovData = 0; rpmAlarmStartTimeOffset.ovInitData = 0; rpmAlarmStartTimeOffset.override = 0; + fansStatus.dutyCycle.data = 0.0; + fansStatus.dutyCycle.ovInitData = 0.0; + fansStatus.dutyCycle.ovData = 0.0; + fansStatus.dutyCycle.override = OVERRIDE_RESET; + fansStatus.targetRPM = 0.0; // Initialize the fans for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) { - fansStatus.dutyCycle.data = 0.0; - fansStatus.dutyCycle.ovInitData = 0.0; - fansStatus.dutyCycle.ovData = 0.0; - fansStatus.dutyCycle.override = OVERRIDE_RESET; - fansStatus.targetRPM = 0.0; fansStatus.rpm[ fan ].data = 0.0; fansStatus.rpm[ fan ].ovData = 0.0; fansStatus.rpm[ fan ].ovInitData = 0.0; @@ -457,10 +457,21 @@ // 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 ) ) + else if ( TRUE == hasAlarmBeenRaised ) { - hasAlarmBeenRaised = FALSE; - rpmAlarmStartTime = 0; + // Get the offset time since the last alarm. If the offset time has been overridden, then do not include the time that the alarm was raised first. + // Overrides are used to verify the code so what is sent to the firmware from override is intended to be the actual time so check whether the alarm is + // raised properly or not. Adding the start time of the alarm might cause inaccuracy in the verification process. + // For instance, if 86390 seconds is overridden to make sure the alarm is not raise before 24 hours or 86400, if the rpmAlarmStartTime is added to it + // it might make the time to be greater than 86400 seconds and therefore the alarm is raised again while it is not expected. + U32 offsetTime = getRPMAlarmStartTimeOffset(); + U32 elapsedTime = ( OVERRIDE_KEY == rpmAlarmStartTimeOffset.override ? offsetTime : calcTimeSince( rpmAlarmStartTime ) + offsetTime ); + + if ( elapsedTime >= SECONDS_IN_A_DAY * MS_PER_SECOND ) + { + hasAlarmBeenRaised = FALSE; + rpmAlarmStartTime = 0; + } } } @@ -521,6 +532,8 @@ data.fanInlet1RPM = getMeasuredFanRPM( FAN_INLET_1 ); data.rpmAlarmTimeOffset = getRPMAlarmStartTimeOffset(); + data.remove = calcTimeSince( rpmAlarmStartTime ); + broadcastData( MSG_ID_HD_FANS_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data, sizeof( FANS_DATA_T ) ); fansPublishCounter = 0;