Esempio n. 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);
    }
 public void PowerNetworkUpdate()
 {
     powerSupply.PowerNetworkUpdate();
     if (current != Previouscurrent)
     {
         powerSupply.SupplyingCurrent = current;
         Previouscurrent = current;
         ElectricalSynchronisation.CurrentChange = true;
     }
     if (ChangeToOff)
     {
         ChangeToOff = false;
         Logger.Log("Turning off");
         ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
         ElectricalSynchronisation.CurrentChange = true;
         powerSupply.TurnOffSupply();
     }
 }
Esempio n. 3
0
    public void PowerNetworkUpdate()
    {
        powerSupply.PowerNetworkUpdate();
        ActualVoltage = powerSupply.Data.ActualVoltage;
        BatteryCalculation.PowerNetworkUpdate(this);


        if (current != Previouscurrent)
        {
            powerSupply.Data.SupplyingCurrent = current;
            Previouscurrent = current;
            ElectricalSynchronisation.NUCurrentChange.Add(this);
        }

        if (Resistance != PreviousResistance)
        {
            if (PreviousResistance == 0 && !(Resistance == 0))
            {
                resistance.ResistanceAvailable = true;
            }
            else if (Resistance == 0 && !(PreviousResistance <= 0))
            {
                resistance.ResistanceAvailable = false;
                ElectricalSynchronisation.ResistanceChange.Add(this);
            }
            resistance.Ohms    = Resistance;
            PreviousResistance = Resistance;
            foreach (KeyValuePair <IElectricityIO, HashSet <PowerTypeCategory> > Supplie in powerSupply.Data.ResistanceToConnectedDevices)
            {
                if (Supplie.Value.Contains(PowerTypeCategory.StandardCable))
                {
                    ElectricalSynchronisation.ResistanceChange.Add(this);
                    ElectricalSynchronisation.NUCurrentChange.Add(Supplie.Key.InData.ControllingUpdate);
                }
            }
        }
        //Logger.Log (CurrentCapacity.ToString() + " < CurrentCapacity", Category.Electrical);
    }