public void PowerNetworkUpdate()
    {
        RelatedDevice.PowerNetworkUpdate();
        ActualVoltage = RelatedDevice.ActualVoltage;

        BatteryCalculation.PowerNetworkUpdate(this);



        if (ChangeToOff)
        {
            ChangeToOff = false;
            //PassChangeToOff = true;
            //ElectricalSynchronisation.ResistanceChange = true;
            //ElectricalSynchronisation.CurrentChange = true;
            //powerSupply.TurnOffSupply();
            RelatedDevice.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");
                RelatedDevice.FlushSupplyAndUp(RelatedDevice.gameObject);
                //powerSupply.TurnOffSupply();
            }
            RelatedDevice.SupplyingCurrent = current;
            Previouscurrent = current;
            ElectricalSynchronisation.CurrentChange = true;
        }

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

            RelatedDevice.PassedDownResistance = Resistance;
            PreviousResistance = Resistance;
            ElectricalSynchronisation.ResistanceChange = true;
            ElectricalSynchronisation.CurrentChange    = true;
        }
        Logger.Log(CurrentCapacity.ToString() + " < CurrentCapacity", Category.Electrical);
    }
Пример #2
0
 public virtual void UpdateServerState(bool _isOn)
 {
     if (isOn)
     {
         powerSupply.TurnOnSupply();
         PreviousResistance = 0;
         Previouscurrent    = 0;
     }
     else
     {
         powerSupply.TurnOffSupply();
     }
 }