Beispiel #1
0
    private void UpdateScreenDisplay()
    {
        if (LocalAPC.State != APC.APCState.Dead)
        {
            OffOverlayColor.SetValueServer(Color.clear);
            Logger.LogTrace("Updating APC display", Category.NetUI);
            // Display the electrical values using engineering notation
            string voltage = LocalAPC.Voltage.ToEngineering("V");
            string current = LocalAPC.Current.ToEngineering("A");
            string power   = (LocalAPC.Voltage * LocalAPC.Current).ToEngineering("W");
            ElectricalValues.SetValueServer($"{voltage}\n{current}\n{power}");
            StatusText.SetValueServer(LocalAPC.State.ToString());
            ChargePercentage.SetValueServer(CalculateChargePercentage());
            // State specific updates
            switch (LocalAPC.State)
            {
            case APC.APCState.Full:
                BackgroundColor.SetValueServer(fullBackground);
                UpdateForegroundColours(fullForeground);
                ChargeBar.SetValueServer("100");
                break;

            case APC.APCState.Charging:
                BackgroundColor.SetValueServer(chargingBackground);
                UpdateForegroundColours(chargingForeground);
                AnimateChargeBar();
                break;

            case APC.APCState.Critical:
                BackgroundColor.SetValueServer(criticalBackground);
                UpdateForegroundColours(criticalForeground);
                ChargeBar.SetValueServer("0");
                break;
            }
        }
        else
        {
            BackgroundColor.SetValueServer(Color.clear);             // Also changing the background since it bleeds through on the edges
            OffOverlayColor.SetValueServer(Color.black);
        }
    }