Example #1
0
    public virtual void PowerUpdateCurrentChange()
    {
        //Logger.Log("PowerUpdateCurrentChange()"+ this);
        if (powerSupply.Data.ResistanceComingFrom.Count > 0)
        {
            powerSupply.FlushSupplyAndUp(powerSupply.gameObject);                                                                                      //Room for optimisation
            CircuitResistance = ElectricityFunctions.WorkOutResistance(powerSupply.Data.ResistanceComingFrom[powerSupply.gameObject.GetInstanceID()]); // //!!
            ActualVoltage     = powerSupply.Data.ActualVoltage;

            BatteryCalculation.PowerUpdateCurrentChange(this);

            if (current != Previouscurrent)
            {
                if (Previouscurrent == 0 && !(current <= 0))
                {
                }
                else if (current == 0 && !(Previouscurrent <= 0))
                {
                    powerSupply.FlushSupplyAndUp(powerSupply.gameObject);
                }
                powerSupply.Data.SupplyingCurrent = current;
                Previouscurrent = current;
            }
        }


        powerSupply.PowerUpdateCurrentChange();
        _PowerUpdateCurrentChange();
    }
    public override void PowerUpdateCurrentChange()
    {
        if (ControllingNode.Node.Data.SupplyDependent[ControllingNode.Node.gameObject.GetInstanceID()].ResistanceComingFrom.Count > 0)
        {
            if (!(SlowResponse && PullingWatts == 0))
            {
                ControllingNode.Node.FlushSupplyAndUp(ControllingNode.Node.gameObject);                                                                                                        //Room for optimisation
                CircuitResistance   = ElectricityFunctions.WorkOutResistance(ControllingNode.Node.Data.SupplyDependent[ControllingNode.Node.gameObject.GetInstanceID()].ResistanceComingFrom); // //!!
                VoltageAtChargePort = ElectricityFunctions.WorkOutVoltageFromConnector(ControllingNode.Node, ResistanceSourceModule.ReactionTo.ConnectingDevice);
                VoltageAtSupplyPort = ElectricityFunctions.WorkOutVoltageFromConnectors(ControllingNode.Node, ControllingNode.CanConnectTo);
                BatteryCalculation.PowerUpdateCurrentChange(this);

                if (current != Previouscurrent)
                {
                    if (Previouscurrent == 0 && !(current <= 0))
                    {
                    }
                    else if (current == 0 && !(Previouscurrent <= 0))
                    {
                        ControllingNode.Node.FlushSupplyAndUp(ControllingNode.Node.gameObject);
                    }
                    ControllingNode.Node.Data.SupplyingCurrent = current;
                    Previouscurrent = current;
                }
            }
        }
        else
        {
            CircuitResistance = 999999999999;
        }
        PowerSupplyFunction.PowerUpdateCurrentChange(this);
    }
    public void PowerUpdateCurrentChange()
    {
        RelatedDevice.FlushSupplyAndUp(RelatedDevice.gameObject);                                                                                  //Room for optimisation
        CircuitResistance = ElectricityFunctions.WorkOutResistance(RelatedDevice.ResistanceComingFrom [RelatedDevice.gameObject.GetInstanceID()]); // //!!
        ActualVoltage     = RelatedDevice.ActualVoltage;

        BatteryCalculation.PowerUpdateCurrentChange(this);


        if (current != Previouscurrent)
        {
            if (Previouscurrent == 0 && !(current <= 0))
            {
                //
            }
            else if (current == 0 && !(Previouscurrent <= 0))
            {
                RelatedDevice.FlushSupplyAndUp(RelatedDevice.gameObject);
                //powerSupply.TurnOffSupply();
            }

            RelatedDevice.SupplyingCurrent = current;
            Previouscurrent = current;
        }
        //if (current > 0) {
        RelatedDevice.PowerUpdateCurrentChange();
        //}
    }
Example #4
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);
    }
Example #5
0
    public virtual void PowerNetworkUpdate()
    {
        powerSupply.PowerNetworkUpdate();
        ActualVoltage = powerSupply.Data.ActualVoltage;
        BatteryCalculation.PowerNetworkUpdate(this);

        if (current != Previouscurrent | SupplyingVoltage != PreviousSupplyingVoltage | InternalResistance != PreviousInternalResistance)
        {
            powerSupply.Data.SupplyingCurrent = current;
            Previouscurrent = current;

            powerSupply.Data.SupplyingVoltage = SupplyingVoltage;
            PreviousSupplyingVoltage          = SupplyingVoltage;

            powerSupply.Data.InternalResistance = InternalResistance;
            PreviousInternalResistance          = InternalResistance;

            ElectricalSynchronisation.NUCurrentChange.Add(this);
        }

        if (Resistance != PreviousResistance)
        {
            if (PreviousResistance == 0 && !(Resistance == 0))
            {
                resistance.ResistanceAvailable = true;
            }
            else if (Resistance == 0 && !(PreviousResistance <= 0))
            {
                resistance.ResistanceAvailable = false;
                ElectricalDataCleanup.CleanConnectedDevices(powerSupply);
            }

            PreviousResistance = Resistance;
            foreach (KeyValuePair <ElectricalOIinheritance, 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 + " < CurrentCapacity", Category.Electrical);
        _PowerNetworkUpdate();
    }
Example #6
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);
    }
Example #7
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)
        {
            RelatedDevice.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;
                ElectricalDataCleanup.CleanConnectedDevices(RelatedDevice);
            }
            PreviousResistance = Resistance;
            foreach (KeyValuePair <IElectricityIO, HashSet <PowerTypeCategory> > Supplie in RelatedDevice.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);
    }
    public override void PowerNetworkUpdate()
    {
        VoltageAtChargePort = ElectricityFunctions.WorkOutVoltageFromConnector(ControllingNode.Node, ResistanceSourceModule.ReactionTo.ConnectingDevice);
        VoltageAtSupplyPort = ElectricityFunctions.WorkOutVoltageFromConnectors(ControllingNode.Node, ControllingNode.CanConnectTo);
        BatteryCalculation.PowerNetworkUpdate(this);
        if (current != Previouscurrent | SupplyingVoltage != PreviousSupplyingVoltage | InternalResistance != PreviousInternalResistance)
        {
            ControllingNode.Node.Data.SupplyingCurrent = current;
            Previouscurrent = current;

            ControllingNode.Node.Data.SupplyingVoltage = SupplyingVoltage;
            PreviousSupplyingVoltage = SupplyingVoltage;

            ControllingNode.Node.Data.InternalResistance = InternalResistance;
            PreviousInternalResistance = InternalResistance;

            ElectricalSynchronisation.NUCurrentChange.Add(ControllingNode);
        }
        //Logger.Log(CurrentCapacity + " < CurrentCapacity" + ControllingNode.Node.InData.Categorytype, Category.Electrical);
    }
Example #9
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);
    }
Example #10
0
 public void TurnOffCleanup()
 {
     BatteryCalculation.TurnOffEverything(this);
     ElectricalSynchronisation.RemoveSupply(this, ApplianceType);
 }