コード例 #1
0
        public static void TurnOnSupply(ModuleSupplyingDevice supply)
        {
            supply.ControllingNode.Node.InData.Data.ChangeToOff = false;
            var sync = ElectricalManager.Instance.electricalSync;

            sync.AddSupply(supply.ControllingNode, supply.ControllingNode.ApplianceType);
            sync.NUStructureChangeReact.Add(supply.ControllingNode);
            sync.NUResistanceChange.Add(supply.ControllingNode);
            sync.NUCurrentChange.Add(supply.ControllingNode);
        }
コード例 #2
0
        /// <summary>
        /// Called when a Supplying Device is turned off.
        /// </summary>
        /// <param name="supply">The supplying device that is turned off</param>
        public static void TurnOffSupply(ModuleSupplyingDevice supply)
        {
            if (supply.ControllingNode == null)
            {
                Logger.LogError("Supply.ControllingNode == null", Category.Electrical);
                return;
            }

            supply.ControllingNode.Node.InData.Data.ChangeToOff = true;
            ElectricalManager.Instance.electricalSync.NUCurrentChange.Add(supply.ControllingNode);
        }
コード例 #3
0
        public static void PushCurrentDownline(ModuleSupplyingDevice Supply, float FloatCurrent)
        {
            Supply.CurrentSource.current = FloatCurrent;
            var WrapCurrentSource = ElectricalPool.GetWrapCurrent();

            WrapCurrentSource.Current  = Supply.CurrentSource;
            WrapCurrentSource.Strength = 1;
            var VIR = ElectricalPool.GetVIRCurrent();

            VIR.addCurrent(WrapCurrentSource);
            Supply.ControllingNode.Node.InData.ElectricityOutput(VIR,
                                                                 Supply.ControllingNode.Node
                                                                 );
        }
コード例 #4
0
        public static void PowerUpdateCurrentChange(ModuleSupplyingDevice supply)
        {
            var sync = ElectricalManager.Instance.electricalSync;

            if (supply.ControllingNode.Node.InData.Data.SupplyDependent.ContainsKey(supply.ControllingNode.Node))
            {
                supply.ControllingNode.Node.InData.FlushSupplyAndUp(supply.ControllingNode.Node);                 //Needs change

                if (!supply.ControllingNode.Node.InData.Data.ChangeToOff)
                {
                    if (supply.current != 0)
                    {
                        PushCurrentDownline(supply, supply.current);
                    }
                    else if (supply.SupplyingVoltage != 0)
                    {
                        float Current = (supply.SupplyingVoltage) / (supply.InternalResistance
                                                                     + ElectricityFunctions.WorkOutResistance(supply.ControllingNode.Node.InData.Data.SupplyDependent[supply.ControllingNode.Node].ResistanceComingFrom));
                        PushCurrentDownline(supply, Current);
                    }
                    else if (supply.ProducingWatts != 0)
                    {
                        float Current = (float)(Math.Sqrt(supply.ProducingWatts *
                                                          ElectricityFunctions.WorkOutResistance(supply.ControllingNode.Node.InData.Data.SupplyDependent[supply.ControllingNode.Node].ResistanceComingFrom))
                                                / ElectricityFunctions.WorkOutResistance(supply.ControllingNode.Node.InData.Data.SupplyDependent[supply.ControllingNode.Node].ResistanceComingFrom));
                        PushCurrentDownline(supply, Current);
                    }
                }
                else
                {
                    foreach (var connectedDevice in supply.ControllingNode.Node.connectedDevices)
                    {
                        if (sync.ReactiveSuppliesSet.Contains(connectedDevice.Categorytype))
                        {
                            sync.NUCurrentChange.Add(connectedDevice.ControllingDevice);
                        }
                    }
                }
            }

            if (supply.ControllingNode.Node.InData.Data.ChangeToOff)
            {
                supply.ControllingNode.Node.InData.RemoveSupply(supply.ControllingNode.Node);
                supply.ControllingNode.Node.InData.Data.ChangeToOff = false;
                supply.ControllingNode.TurnOffCleanup();

                sync.RemoveSupply(supply.ControllingNode, supply.ControllingNode.Node.InData.Categorytype);
            }
        }
コード例 #5
0
 public static void PowerUpdateStructureChangeReact(ModuleSupplyingDevice supply)
 {
     ElectricalManager.Instance.electricalSync.CircuitSearchLoop(supply.ControllingNode.Node);
 }