/// <summary> /// PSU Monitoring Helper Function /// </summary> private static void MonitorPsuAlertHelper() { // times execution of each pass. Stopwatch timer = new Stopwatch(); int timeTaken = 0; // determine whether to do efficient PSU ALERT monitoring, or // traditional PSU polling. if (ConfigLoaded.PsuAlertMonitorEnabled) { timer.Start(); PsuAlertSignalResponse psuAlert = ChassisState.PsuAlert.GetPsuAlertSignal(); if (psuAlert.CompletionCode == 0x00) { // check if the global psu alert state needs to be updated. if (psuAlert.PsuAlertActive != ChassisState.PsuAlertActive) { ChassisState.SetPsuAlert(psuAlert.PsuAlertActive); } if (psuAlert.PsuAlertActive) { // Step 1: When in PSU Alert, check and try resolve PSU Alerts. Dictionary <byte, PsuAlertFaultStatus> psuRemediate = PsuInvestigateAndRemediate(); // Step 2: Update Blade DPC, if needed PsuAlertUpdateBladeState(psuRemediate); } else { // Check to poll PSUs at slower polling interval // or wait for pollTimer PsuPollAndRemediate(psuPollTimer, out psuPollTimer); } } else { Tracer.WriteError("MonitorPsuAlert unable to get PsuAlert Signal. Defaulting to polling method. CompletionCode: 0x{0:X2}" + psuAlert.CompletionCode); // Check to poll PSUs at slower polling interval // or wait for pollTimer PsuPollAndRemediate(psuPollTimer, out psuPollTimer); } timeTaken = timer.Elapsed.Seconds; // increment polling timer. psuPollTimer += timeTaken; if (timeTaken < ConfigLoaded.PsuAlertPollInterval) // psu alert poll { // sleep until next pass. Thread.Sleep(TimeSpan.FromSeconds(ConfigLoaded.PsuAlertPollInterval - timeTaken)); } // reset the timer to zero; timer.Restart(); } else { timer.Start(); // check for PSU errors and attempt to resolve PsuInvestigateAndRemediate(); // wait polling interval to expire. timeTaken = timer.Elapsed.Seconds; if (timeTaken < ConfigLoaded.PsuPollInterval) { // sleep before next pass. Thread.Sleep(TimeSpan.FromSeconds(ConfigLoaded.PsuPollInterval - timeTaken)); } // reset the timer to zero; timer.Restart(); } }