Beispiel #1
0
    public void PowerNetworkUpdate()
    {
        powerSupply.PowerNetworkUpdate();
        ActualVoltage = powerSupply.ActualVoltage;

        BatteryCalculation.PowerNetworkUpdate(this);



        if (ChangeToOff)
        {
            ChangeToOff = false;
            //PassChangeToOff = true;
            //ElectricalSynchronisation.ResistanceChange = true;
            //ElectricalSynchronisation.CurrentChange = true;
            //powerSupply.TurnOffSupply();
            powerSupply.TurnOffSupply();
            BatteryCalculation.TurnOffEverything(this);
            ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
        }

        if (current != Previouscurrent)
        {
            if (Previouscurrent == 0 && !(current <= 0))
            {
                //
            }
            else if (current == 0 && !(Previouscurrent <= 0))
            {
                Logger.Log("FlushSupplyAndUp");
                powerSupply.FlushSupplyAndUp(powerSupply.gameObject);
                //powerSupply.TurnOffSupply();
            }
            powerSupply.SupplyingCurrent = current;
            Previouscurrent = current;
            ElectricalSynchronisation.CurrentChange = true;
        }

        if (Resistance != PreviousResistance)
        {
            if (PreviousResistance == 0 && !(Resistance == 0))
            {
                powerSupply.CanProvideResistance = true;
            }
            else if (Resistance == 0 && !(PreviousResistance <= 0))
            {
                powerSupply.CanProvideResistance = false;
                ElectricityFunctions.CleanConnectedDevices(powerSupply);
            }

            powerSupply.PassedDownResistance = Resistance;
            PreviousResistance = Resistance;
            ElectricalSynchronisation.ResistanceChange = true;
            ElectricalSynchronisation.CurrentChange    = true;
        }
        Logger.Log(CurrentCapacity.ToString() + " < CurrentCapacity", Category.Electrical);
    }
        private CurrentCapacity ParseCurrentCapacityNode(XmlNode xmlNodeCurrentCapacity)
        {
            try
            {
                CurrentCapacity currentCapacity = new CurrentCapacity();

                if (xmlNodeCurrentCapacity.ChildNodes != null)
                {
                    foreach (XmlNode xmlNode in xmlNodeCurrentCapacity.ChildNodes)
                    {
                        switch (xmlNode.Name)
                        {
                        case Tags.RebuiltDate:
                            if (xmlNode.Attributes[Tags.Available] != null)
                            {
                                currentCapacity.availableField = GenericFunctions.ConvertStringToBool(xmlNode.Attributes[Tags.Available].Value);

                                if (currentCapacity.availableField)
                                {
                                    currentCapacity.rebuiltDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText);
                                }
                            }
                            break;

                        case Tags.Basic:
                            currentCapacity.basicField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.Terraces:
                            currentCapacity.terracesField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.Roof:
                            currentCapacity.roofField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.VIP:
                            currentCapacity.vipField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.Total:
                            currentCapacity.totalField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;
                        }
                    }
                }
                return(currentCapacity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
    public void PowerNetworkUpdate()
    {
        RelatedDevice.PowerNetworkUpdate();
        ActualVoltage = RelatedDevice.Data.ActualVoltage;
        BatteryCalculation.PowerNetworkUpdate(this);
        if (ChangeToOff)
        {
            ChangeToOff = false;
            RelatedDevice.TurnOffSupply();
            BatteryCalculation.TurnOffEverything(this);
            ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
        }

        if (current != Previouscurrent)
        {
            if (Previouscurrent == 0 && !(current <= 0))
            {
            }
            else if (current == 0 && !(Previouscurrent <= 0))
            {
                RelatedDevice.FlushSupplyAndUp(RelatedDevice.gameObject);
            }
            RelatedDevice.Data.SupplyingCurrent = current;
            Previouscurrent = current;
            ElectricalSynchronisation.CurrentChange = true;
        }
        if (Resistance != PreviousResistance)
        {
            if (PreviousResistance == 0 && !(Resistance == 0))
            {
                CanProvideResistance.Bool = true;
            }
            else if (Resistance == 0 && !(PreviousResistance <= 0))
            {
                CanProvideResistance.Bool = false;
                ElectricalDataCleanup.CleanConnectedDevices(RelatedDevice);
            }
            PreviousResistance = Resistance;
            ElectricalSynchronisation.ResistanceChange = true;
            ElectricalSynchronisation.CurrentChange    = true;
        }
        Logger.Log(CurrentCapacity.ToString() + " < CurrentCapacity", Category.Electrical);
    }