public override void PowerUpdateCurrentChange() { if (ControllingNode.Node.InData.Data.SupplyDependent.ContainsKey(ControllingNode.Node)) { if (ControllingNode.Node.InData.Data.SupplyDependent[ControllingNode.Node].ResistanceComingFrom.Count > 0) { if (!(SlowResponse && PullingWatts == 0)) { ControllingNode.Node.InData.FlushSupplyAndUp(ControllingNode.Node); //Room for optimisation CircuitResistance = ElectricityFunctions.WorkOutResistance(ControllingNode.Node.InData.Data.SupplyDependent[ControllingNode.Node].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.InData.FlushSupplyAndUp(ControllingNode.Node); } ControllingNode.Node.InData.Data.SupplyingCurrent = current; Previouscurrent = current; } } } else { CircuitResistance = 999999999999; } } PowerSupplyFunction.PowerUpdateCurrentChange(this); }
public override void PowerUpdateStructureChangeReact() { PowerSupplyFunction.PowerUpdateStructureChangeReact(this); var sync = ElectricalManager.Instance.electricalSync; sync.NUResistanceChange.Add(ControllingNode); sync.NUCurrentChange.Add(ControllingNode); }
public override void PowerUpdateCurrentChange() { if (ControllingNode.Node.InData.Data.SupplyDependent.ContainsKey(ControllingNode.Node)) { if (ControllingNode.Node.InData.Data.SupplyDependent[ControllingNode.Node].ResistanceComingFrom.Count > 0) { if (!(SlowResponse && PullingWatts == 0)) { ControllingNode.Node.InData.FlushSupplyAndUp(ControllingNode.Node); //Room for optimisation CircuitResistance = ElectricityFunctions.WorkOutResistance(ControllingNode.Node.InData.Data.SupplyDependent[ControllingNode.Node].ResistanceComingFrom); // //!! VoltageAtChargePort = ElectricityFunctions.WorkOutVoltageFromConnector(ControllingNode.Node, ResistanceSourceModule.ReactionTo.ConnectingDevice); VoltageAtSupplyPort = ElectricityFunctions.WorkOutVoltageFromConnectors(ControllingNode.Node, ControllingNode.CanConnectTo); if (Cansupport) //Denotes capacity to Provide current { //NOTE This assumes that the voltage will be same on either side if (ToggleCansupport && IsAtVoltageThreshold()) // ToggleCansupport denotes Whether at the current time it is allowed to provide current { if (CurrentCapacity > 0) { var needToPushVoltage = StandardSupplyingVoltage - VoltageAtSupplyPort; current = needToPushVoltage / CircuitResistance; if (current > MaximumCurrentSupport) { current = MaximumCurrentSupport; } PullingWatts = ((current * StandardSupplyingVoltage) * (OutputLevel / 100)); // Should be the same as NeedToPushVoltage + powerSupply.ActualVoltage } } else if (PullingWatts > 0) { //Cleaning up values if it can't supply PullingWatts = 0; current = 0; PullLastDeductedTime = -1; } } if (current != Previouscurrent) { if (current == 0) { ControllingNode.Node.InData.FlushSupplyAndUp(ControllingNode.Node); } ControllingNode.Node.InData.Data.SupplyingCurrent = current; Previouscurrent = current; } } } else { CircuitResistance = MonitoringResistance; } } PowerSupplyFunction.PowerUpdateCurrentChange(this); }
public override void TurnOnSupply() { if (InternalResistance > 0) { foreach (PowerTypeCategory Connecting in ControllingNode.CanConnectTo) { ControllingNode.OverlayInternalResistance(InternalResistance, Connecting); } ElectricalManager.Instance.electricalSync.NUResistanceChange.Add(ControllingNode); } PowerSupplyFunction.TurnOnSupply(this); }
public override void TurnOffSupply() { if (InternalResistance > 0) { foreach (PowerTypeCategory Connecting in ControllingNode.CanConnectTo) { ControllingNode.RestoreResistance(Connecting); } } // On some transitional scenes like the DontDestroyOnLoad scene, we don't have an ElectricalManager. // We should not try to update it in those cases. if (ElectricalManager.Instance?.electricalSync?.NUResistanceChange != null) { ElectricalManager.Instance.electricalSync.NUResistanceChange.Add(ControllingNode); PowerSupplyFunction.TurnOffSupply(this); } }
public override void TurnOffSupply() { isOnForInterface = false; PowerSupplyFunction.TurnOffSupply(this); }
public override void TurnOnSupply() { isOnForInterface = true; PowerSupplyFunction.TurnOnSupply(this); PowerNetworkUpdate(); }
public override void PowerUpdateCurrentChange() { PowerSupplyFunction.PowerUpdateCurrentChange(this); }