示例#1
0
        /// <summary>
        /// Updates the header string data
        /// </summary>
        protected override void UpdateHeaderPanelData()
        {
            double EC       = 0d;
            double maxEC    = 0d;
            double netPower = dataHost.ElectricalData.CurrentConsumption + dataHost.ElectricalData.GetSimulatedElectricalProdution();

            dataHost.ElectricalData.GetElectricalChargeLevels(out EC, out maxEC);

            if (netPower == 0d)
            {
                charging     = false;
                netPowerFlux = String.Format("{0:F2} {1}", Math.Abs(netPower), powerFlowUnits);
                chargeTime   = String.Format("{0}", batteryChargeStable);
            }
            else if (netPower > 0d)
            {
                charging     = true;
                netPowerFlux = String.Format("▲ {0:F2} {1}", Math.Abs(netPower), powerFlowUnits);
                if (HighLogic.LoadedSceneIsFlight)
                {
                    if ((maxEC - EC) < 0.001d)
                    {
                        chargeTime = "0 s";
                    }
                    else
                    {
                        chargeTime = String.Format("{0} {1}", batteryChargeCharging, FormatUtils.FormatTimeString((maxEC - EC) / netPower));
                    }
                }
                else
                {
                    chargeTime = String.Format("{0} {1}", batteryChargeFullCharge, FormatUtils.FormatTimeString(maxEC / netPower));
                }
            }
            else
            {
                charging     = false;
                netPowerFlux = String.Format("<color=#fd6868> ▼ {0:F2} {1}</color>", Math.Abs(netPower), powerFlowUnits);
                if (EC < 0.1d)
                {
                    chargeTime = "0 s";
                }
                else
                {
                    chargeTime = String.Format("{0} in {1}", batteryChargeDepleted, FormatUtils.FormatTimeString(EC / -netPower));
                }
            }

            totalConsumption = String.Format("▼ {0:F2} {1}",
                                             Math.Abs(dataHost.ElectricalData.CurrentConsumption),
                                             powerFlowUnits);
            totalProduction = String.Format("▲ {0:F2} {1}",
                                            Math.Abs(dataHost.ElectricalData.GetSimulatedElectricalProdution()),
                                            powerFlowUnits);
            availableBattery = String.Format("{0:F0} / {1:F0} ({2:F1}%)", EC, maxEC, EC / maxEC * 100d);
        }
示例#2
0
 /// <summary>
 /// Update UI fields and recalculate quantities
 /// </summary>>
 public void Update()
 {
     solarAltitude   = String.Format("{0}{1}", FormatUtils.ToSI(sunRefOrbitHeight * 1000, "F0"), distanceUnits);
     bodyAltitude    = String.Format("{0}{1}", FormatUtils.ToSI(bodyRefOrbitHeight * 1000, "F0"), distanceUnits);
     panelEfficiency = String.Format("{0:F1}%", panelScalar * 100f);
     darkTime        = FormatUtils.FormatTimeString(occlusionTime);
     // Determine scaling constant
     panelScalar   = CalculatePanelScalar();
     occlusionTime = CalculateOcclusionTime();
     electricalView.SolarSimulationScalar = panelScalar;
 }
 /// <summary>
 /// Update UI fields and recalculate quantities
 /// </summary>>
 public void Update()
 {
     if (sunBody != null && selectedBody != null)
     {
         if (selectedBody == sunBody)
         {
             bodyRefOrbitHeight = sunRefOrbitHeight;
         }
     }
     solarAltitude   = String.Format("{0:F0}", sunRefOrbitHeight);
     bodyAltitude    = String.Format("{0:F0}", bodyRefOrbitHeight);
     panelEfficiency = String.Format("{0:F1}%", panelScalar * 100f);
     darkTime        = FormatUtils.FormatTimeString(occlusionTime);
     // Determine scaling constant
     panelScalar   = CalculatePanelScalar();
     occlusionTime = CalculateOcclusionTime();
     electricalView.SolarSimulationScalar = panelScalar;
 }