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); }
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(); }
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); }