public static bool IsPower() { bool b = true; UpsState State = GetState(); if ((State == UpsState.PowerFailure) || (State == UpsState.BattLow)) { b = false; } return(b); }
public void UpdateUpsStatus() { try { UpsState StateB = State; if (SystemInformation.PowerStatus.BatteryChargeStatus == BatteryChargeStatus.NoSystemBattery) { State = UpsState.ConnectionLost; } else { switch (SystemInformation.PowerStatus.PowerLineStatus) { case PowerLineStatus.Unknown: State = UpsState.Unknown; break; case PowerLineStatus.Online: State = UpsState.PowerBack; break; case PowerLineStatus.Offline: switch (SystemInformation.PowerStatus.BatteryChargeStatus) { case BatteryChargeStatus.High: State = UpsState.PowerFailure; break; case BatteryChargeStatus.Low: case BatteryChargeStatus.Critical: State = UpsState.BattLow; break; default: State = UpsState.UpsFailure; break; } break; default: State = UpsState.UpsFailure; break; } } if (StateB != State) { Trace("SystemUps - Status changed to: " + State.ToString()); } } catch (Exception ex) { LogManager.GetLogger("SystemUps").Error("Exception: ", ex.Message); } }
public static bool IsLowPower() { bool b = false; UpsState State = GetState(); if (State == UpsState.BattLow) { b = true; } return(b); }