示例#1
0
    /// <summary>
    /// Passes it on to the next cable
    /// </summary>
    public virtual void ResistancyOutput(GameObject SourceInstance)
    {
        float Resistance = ElectricityFunctions.WorkOutResistance(Data.SupplyDependent[SourceInstance.GetInstanceID()].ResistanceComingFrom);

        if (Logall)
        {
            Logger.Log("this > " + this + "ResistancyOutput, Resistance > " + Resistance + " SourceInstance  > " + SourceInstance, Category.Electrical);
        }
        InputOutputFunctions.ResistancyOutput(Resistance, SourceInstance, this);
    }
示例#2
0
 public override void ResistancyOutput(GameObject SourceInstance)
 {
     //Logger.Log (SourceInstance.GetInstanceID().ToString() + " < Receive | is > " + this.gameObject.GetInstanceID().ToString() );
     if (!(SourceInstance == this.gameObject))
     {
         int   SourceInstanceID = SourceInstance.GetInstanceID();
         float Resistance       = ElectricityFunctions.WorkOutResistance(Data.ResistanceComingFrom[SourceInstanceID]);
         InputOutputFunctions.ResistancyOutput(Resistance, SourceInstance, this);
     }
 }
示例#3
0
 public static void DoCurrentloop(HashSet <ElectricalOIinheritance> WorkingOn, GameObject SourceInstance)
 {
     foreach (ElectricalOIinheritance Node in WorkingOn)
     {
         //Logger.Log("yow");
         if (!Node.InData.ElectricityOverride)
         {
             float SupplyingCurrent = 0;
             float Voltage          = Node.Data.CurrentStoreValue * (ElectricityFunctions.WorkOutResistance(Node.Data.ResistanceComingFrom[SourceInstanceID]));
             foreach (KeyValuePair <ElectricalOIinheritance, float> JumpTo in Node.Data.ResistanceComingFrom[SourceInstanceID])
             {
                 if (Voltage > 0)
                 {
                     SupplyingCurrent = (Voltage / JumpTo.Value);
                 }
                 else
                 {
                     SupplyingCurrent = Node.Data.CurrentStoreValue;
                 }
                 if (!(Node.Data.CurrentGoingTo.ContainsKey(SourceInstanceID)))
                 {
                     Node.Data.CurrentGoingTo[SourceInstanceID] = new Dictionary <ElectricalOIinheritance, float>();
                 }
                 Node.Data.CurrentGoingTo[SourceInstanceID][JumpTo.Key] = SupplyingCurrent;
                 if (!JumpTo.Key.InData.ElectricityOverride)
                 {
                     //Logger.Log (tick.ToString () + " <tick " + Current.ToString () + " <Current " + SourceInstance.ToString () + " <SourceInstance " + ComingFrom.ToString () + " <ComingFrom " + Thiswire.ToString () + " <Thiswire ", Category.Electrical);
                     if (!(JumpTo.Key.Data.SourceVoltages.ContainsKey(SourceInstanceID)))
                     {
                         JumpTo.Key.Data.SourceVoltages[SourceInstanceID] = new float();
                     }
                     if (!(JumpTo.Key.Data.CurrentComingFrom.ContainsKey(SourceInstanceID)))
                     {
                         JumpTo.Key.Data.CurrentComingFrom[SourceInstanceID] = new Dictionary <ElectricalOIinheritance, float>();
                     }
                     JumpTo.Key.Data.CurrentComingFrom[SourceInstanceID][Node] = SupplyingCurrent;
                     JumpTo.Key.Data.SourceVoltages[SourceInstanceID]          = SupplyingCurrent * (ElectricityFunctions.WorkOutResistance(JumpTo.Key.Data.ResistanceComingFrom[SourceInstanceID]));
                     CurrentWorkOnNextListADD(JumpTo.Key);
                     JumpTo.Key.Data.CurrentStoreValue = ElectricityFunctions.WorkOutCurrent(JumpTo.Key.Data.CurrentComingFrom[SourceInstanceID]);
                     //JumpTo.Key.ElectricityOutput(ElectricityFunctions.WorkOutCurrent(JumpTo.Key.Data.CurrentComingFrom[SourceInstanceID]), SourceInstance);
                 }
                 else
                 {
                     JumpTo.Key.ElectricityInput(SupplyingCurrent, SourceInstance, Node);
                 }
                 ElectricityFunctions.WorkOutActualNumbers(Node);
             }
         }
         else
         {
             Node.ElectricityOutput(Node.Data.CurrentStoreValue, SourceInstance);
         }
     }
 }
示例#4
0
        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);
        }
示例#5
0
    public void PowerUpdateCurrentChange()
    {
        FlushSupplyAndUp(this.gameObject);

        if (connectedDevices.Count > 0)
        {
            int   InstanceID = this.gameObject.GetInstanceID();
            float Resistance = ElectricityFunctions.WorkOutResistance(Data.ResistanceComingFrom [InstanceID]);
            float Voltage    = Data.SupplyingCurrent * Resistance;
            ElectricityOutput(ElectricalSynchronisation.currentTick, Data.SupplyingCurrent, this.gameObject);
        }
    }
示例#6
0
    public static void PowerUpdateCurrentChange(ModuleSupplyingDevice Supply)
    {
        var sync = ElectricalManager.Instance.electricalSync;

        if (Supply.ControllingNode.Node.InData.Data.SupplyDependent.ContainsKey(Supply.ControllingNode.Node))
        {
            //Logger.Log("PowerUpdateCurrentChange for Supply  > " + Supply.name);
            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);
                    }
                }
            }
        }
        //ELCurrent.Currentloop(Supply.gameObject);

        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);
        }
    }
    public void PowerUpdateCurrentChange()
    {
        //Logger.Log (connections.Count.ToString ());
        FlushSupplyAndUp(this.gameObject);

        if (connectedDevices.Count > 0)
        {
            //Logger.Log ("connectedDevices");
            int   InstanceID = this.gameObject.GetInstanceID();
            float Resistance = ElectricityFunctions.WorkOutResistance(ResistanceComingFrom [InstanceID]);
            //Logger.Log (Resistance.ToString () + " Received resistance", Category.Electrical);
            float Voltage = SupplyingCurrent * Resistance;
            ElectricityOutput(ElectricalSynchronisation.currentTick, SupplyingCurrent, this.gameObject);
        }
    }
示例#8
0
    public override float ModifyElectricityInput(float Current, GameObject SourceInstance, ElectricalOIinheritance ComingFrom)
    {
        int   InstanceID = SourceInstance.GetInstanceID();
        float Resistance = ElectricityFunctions.WorkOutResistance(ControllingNode.Node.Data.SupplyDependent[InstanceID].ResistanceComingFrom);
        float Voltage    = (Current * Resistance);

        //Logger.Log (Voltage.ToString() + " < Voltage " + Resistance.ToString() + " < Resistance"  + Current.ToString() + " < Current");
        Tuple <float, float> Currentandoffcut = TransformerCalculations.ElectricalStageTransformerCalculate(this, Voltage: Voltage, ResistanceModified: Resistance, FromHighSide: HighsideConnections.Contains(ComingFrom.InData.Categorytype));

        if (Currentandoffcut.Item2 > 0)
        {
            ControllingNode.Node.Data.SupplyDependent[InstanceID].CurrentGoingTo[ControllingNode.Node] = Currentandoffcut.Item2;
        }
        return(Currentandoffcut.Item1);
    }
示例#9
0
        public override VIRCurrent ModifyElectricityInput(VIRCurrent Current,
                                                          ElectricalOIinheritance SourceInstance,
                                                          IntrinsicElectronicData ComingFromm)
        {
            float Resistance = ElectricityFunctions.WorkOutResistance(ControllingNode.Node.InData.Data.SupplyDependent[SourceInstance].ResistanceGoingTo);
            var   Voltage    = ElectricityFunctions.WorkOutVoltage(ControllingNode.Node);

            VIRCurrent Currentout =
                TransformerCalculations.ElectricalStageTransformerCalculate(this,
                                                                            Current,
                                                                            Resistance,
                                                                            Voltage,
                                                                            HighsideConnections.Contains(ComingFromm.Categorytype));

            return(Currentout);
        }
    public static void ElectricityInput(int tick, float Current, GameObject SourceInstance, IElectricityIO ComingFrom, IElectricityIO Thiswire)
    {
        //Logger.Log (tick.ToString () + " <tick " + Current.ToString () + " <Current " + SourceInstance.ToString () + " <SourceInstance " + ComingFrom.ToString () + " <ComingFrom " + Thiswire.ToString () + " <Thiswire ", Category.Electrical);
        int SourceInstanceID = SourceInstance.GetInstanceID();

        if (!(Thiswire.Data.SourceVoltages.ContainsKey(SourceInstanceID)))
        {
            Thiswire.Data.SourceVoltages [SourceInstanceID] = new float();
        }
        if (!(Thiswire.Data.CurrentComingFrom.ContainsKey(SourceInstanceID)))
        {
            Thiswire.Data.CurrentComingFrom [SourceInstanceID] = new Dictionary <IElectricityIO, float> ();
        }
        Thiswire.Data.CurrentComingFrom [SourceInstanceID] [ComingFrom] = Current;
        Thiswire.Data.SourceVoltages[SourceInstanceID] = Current * (ElectricityFunctions.WorkOutResistance(Thiswire.Data.ResistanceComingFrom [SourceInstanceID]));
        Thiswire.ElectricityOutput(tick, ElectricityFunctions.WorkOutCurrent(Thiswire.Data.CurrentComingFrom [SourceInstanceID]), SourceInstance);
    }
示例#11
0
    public float ModifyElectricityOutput(int tick, float Current, GameObject SourceInstance)
    {
        int   InstanceID    = SourceInstance.GetInstanceID();
        float ActualCurrent = RelatedDevice.Data.CurrentInWire;
        float Resistance    = ElectricityFunctions.WorkOutResistance(RelatedDevice.Data.ResistanceComingFrom[InstanceID]);
        float Voltage       = (Current * Resistance);
        Tuple <float, float> Currentandoffcut = TransformerCalculations.TransformerCalculate(this, Voltage: Voltage, ResistanceModified: Resistance, ActualCurrent: ActualCurrent);

        if (Currentandoffcut.Item2 > 0)
        {
            if (!(RelatedDevice.Data.CurrentGoingTo.ContainsKey(InstanceID)))
            {
                RelatedDevice.Data.CurrentGoingTo [InstanceID] = new Dictionary <IElectricityIO, float> ();
            }
            RelatedDevice.Data.CurrentGoingTo[InstanceID] [RelatedDevice.GameObject().GetComponent <IElectricityIO>()] = Currentandoffcut.Item2;
        }
        return(Currentandoffcut.Item1);
    }
    public static void ElectricityInput(float Current, GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire)
    {
        //Logger.Log (tick.ToString () + " <tick " + Current.ToString () + " <Current " + SourceInstance.ToString () + " <SourceInstance " + ComingFrom.ToString () + " <ComingFrom " + Thiswire.ToString () + " <Thiswire ", Category.Electrical);
        int SourceInstanceID = SourceInstance.GetInstanceID();

        if (!(Thiswire.Data.SourceVoltages.ContainsKey(SourceInstanceID)))
        {
            Thiswire.Data.SourceVoltages[SourceInstanceID] = new float();
        }
        if (!(Thiswire.Data.CurrentComingFrom.ContainsKey(SourceInstanceID)))
        {
            Thiswire.Data.CurrentComingFrom[SourceInstanceID] = new Dictionary <ElectricalOIinheritance, float>();
        }
        Thiswire.Data.CurrentComingFrom[SourceInstanceID][ComingFrom] = Current;
        Thiswire.Data.SourceVoltages[SourceInstanceID] = Current * (ElectricityFunctions.WorkOutResistance(Thiswire.Data.ResistanceComingFrom[SourceInstanceID]));
        ELCurrent.CurrentWorkOnNextListADD(Thiswire);
        Thiswire.Data.CurrentStoreValue = ElectricityFunctions.WorkOutCurrent(Thiswire.Data.CurrentComingFrom[SourceInstanceID]);
    }
示例#13
0
    public override float ModifyElectricityOutput(float Current, GameObject SourceInstance)
    {
        int   InstanceID    = SourceInstance.GetInstanceID();
        float ActualCurrent = powerSupply.Data.CurrentInWire;
        float Resistance    = ElectricityFunctions.WorkOutResistance(powerSupply.Data.ResistanceComingFrom[InstanceID]);
        float Voltage       = (Current * Resistance);
        Tuple <float, float> Currentandoffcut = TransformerCalculations.TransformerCalculate(this, Voltage: Voltage, ResistanceModified: Resistance, ActualCurrent: ActualCurrent);

        if (Currentandoffcut.Item2 > 0)
        {
            if (!(powerSupply.Data.CurrentGoingTo.ContainsKey(InstanceID)))
            {
                powerSupply.Data.CurrentGoingTo [InstanceID] = new Dictionary <ElectricalOIinheritance, float> ();
            }
            powerSupply.Data.CurrentGoingTo[InstanceID] [powerSupply.GameObject().GetComponent <ElectricalOIinheritance>()] = Currentandoffcut.Item2;
        }
        //return(Current);
        return(Currentandoffcut.Item1);
    }
示例#14
0
 public static void DoCurrentloop(HashSet <ElectricalOIinheritance> WorkingOn, GameObject SourceInstance)
 {
     foreach (ElectricalOIinheritance Node in WorkingOn)
     {
         if (!Node.InData.ElectricityOverride)
         {
             ElectricalSynchronisation.OutputSupplyingUsingData = Node.Data.SupplyDependent[SourceInstanceID];
             float SupplyingCurrent = 0;
             float Voltage          = Node.Data.CurrentStoreValue * (ElectricityFunctions.WorkOutResistance(ElectricalSynchronisation.OutputSupplyingUsingData.ResistanceComingFrom));
             foreach (KeyValuePair <ElectricalOIinheritance, float> JumpTo in ElectricalSynchronisation.OutputSupplyingUsingData.ResistanceComingFrom)
             {
                 if (Voltage > 0)
                 {
                     SupplyingCurrent = (Voltage / JumpTo.Value);
                 }
                 else
                 {
                     SupplyingCurrent = Node.Data.CurrentStoreValue;
                 }
                 ElectricalSynchronisation.OutputSupplyingUsingData.CurrentGoingTo[JumpTo.Key] = SupplyingCurrent;
                 if (!JumpTo.Key.InData.ElectricityOverride)
                 {
                     ElectricalSynchronisation.OutputSupplyingUsingData = JumpTo.Key.Data.SupplyDependent[SourceInstanceID];
                     ElectricalSynchronisation.OutputSupplyingUsingData.CurrentComingFrom[Node] = SupplyingCurrent;
                     ElectricalSynchronisation.OutputSupplyingUsingData.SourceVoltages          = SupplyingCurrent * (ElectricityFunctions.WorkOutResistance(ElectricalSynchronisation.OutputSupplyingUsingData.ResistanceComingFrom));
                     //Logger.Log(SupplyingCurrent.ToString() + " <Current " + SourceInstance.ToString() + " <SourceInstance " + Node.ToString() + " <ComingFrom " + JumpTo.ToString() + " <Thiswire ", Category.Electrical);
                     CurrentWorkOnNextListADD(JumpTo.Key);
                     JumpTo.Key.Data.CurrentStoreValue = ElectricityFunctions.WorkOutCurrent(ElectricalSynchronisation.OutputSupplyingUsingData.CurrentComingFrom);
                 }
                 else
                 {
                     JumpTo.Key.ElectricityInput(SupplyingCurrent, SourceInstance, Node);
                 }
             }
         }
         else
         {
             Node.ElectricityOutput(Node.Data.CurrentStoreValue, SourceInstance);
         }
     }
 }
示例#15
0
    public void PowerUpdateCurrentChange()
    {
        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();
    }
示例#16
0
    public static void ElectricityOutput(float Current, GameObject SourceInstance, ElectricalOIinheritance Thiswire)
    {
        int SourceInstanceID = SourceInstance.GetInstanceID();

        ElectricalSynchronisation.OutputSupplyingUsingData = Thiswire.Data.SupplyDependent[SourceInstanceID];
        float SupplyingCurrent = 0;
        float Voltage          = Current * (ElectricityFunctions.WorkOutResistance(ElectricalSynchronisation.OutputSupplyingUsingData.ResistanceComingFrom));

        foreach (KeyValuePair <ElectricalOIinheritance, float> JumpTo in ElectricalSynchronisation.OutputSupplyingUsingData.ResistanceComingFrom)
        {
            if (Voltage > 0)
            {
                SupplyingCurrent = (Voltage / JumpTo.Value);
            }
            else
            {
                SupplyingCurrent = Current;
            }
            ElectricalSynchronisation.OutputSupplyingUsingData.CurrentGoingTo[JumpTo.Key] = SupplyingCurrent;
            JumpTo.Key.ElectricityInput(SupplyingCurrent, SourceInstance, Thiswire);
        }
    }
示例#17
0
    public static void ElectricityInput(VIRCurrent Current,
                                        ElectricalOIinheritance SourceInstance,
                                        IntrinsicElectronicData ComingFrom,
                                        IntrinsicElectronicData Thiswire)
    {
        //Logger.Log("ElectricityInput" + Thiswire + "  ComingFrom  > " + ComingFrom);
        //Logger.Log("5 > " + Current + "  Categorytype > " + Thiswire.Categorytype + "  ComingFrom  > " + ComingFrom.Categorytype);
        //Logger.Log("poke > " + SourceInstance.InData.Data.SupplyDependent[SourceInstance].ToString());

        if (Thiswire.Data.SupplyDependent.TryGetValue(SourceInstance, out ElectronicSupplyData supplyDep))
        {
            if (supplyDep.CurrentComingFrom.TryGetValue(ComingFrom, out VIRCurrent currentComFrom))
            {
                currentComFrom.addCurrent(Current);
            }
            else
            {
                supplyDep.CurrentComingFrom[ComingFrom] = Current;
            }

            if (!(supplyDep.ResistanceComingFrom.Count > 0))
            {
                var sync = ElectricalManager.Instance.electricalSync;
                sync.StructureChange = true;
                sync.NUStructureChangeReact.Add(Thiswire.ControllingDevice);
                sync.NUResistanceChange.Add(Thiswire.ControllingDevice);
                sync.NUCurrentChange.Add(Thiswire.ControllingDevice);
                Logger.LogErrorFormat("Resistance isn't initialised on", Category.Electrical);
                return;
            }

            supplyDep.SourceVoltage = (float)Current.Current() *
                                      (ElectricityFunctions.WorkOutResistance(supplyDep.ResistanceComingFrom));
        }

        //ELCurrent.CurrentWorkOnNextListADD(Thiswire);
        Thiswire.ElectricityOutput(Current, SourceInstance);
    }
    public static void ElectricityOutput(float Current, GameObject SourceInstance, ElectricalOIinheritance Thiswire)
    {
        int   SourceInstanceID = SourceInstance.GetInstanceID();
        float SupplyingCurrent = 0;
        float Voltage          = Current * (ElectricityFunctions.WorkOutResistance(Thiswire.Data.ResistanceComingFrom[SourceInstanceID]));

        foreach (KeyValuePair <ElectricalOIinheritance, float> JumpTo in Thiswire.Data.ResistanceComingFrom[SourceInstanceID])
        {
            if (Voltage > 0)
            {
                SupplyingCurrent = (Voltage / JumpTo.Value);
            }
            else
            {
                SupplyingCurrent = Current;
            }
            if (!(Thiswire.Data.CurrentGoingTo.ContainsKey(SourceInstanceID)))
            {
                Thiswire.Data.CurrentGoingTo[SourceInstanceID] = new Dictionary <ElectricalOIinheritance, float>();
            }
            Thiswire.Data.CurrentGoingTo[SourceInstanceID][JumpTo.Key] = SupplyingCurrent;
            JumpTo.Key.ElectricityInput(SupplyingCurrent, SourceInstance, Thiswire);
        }
    }
    public static void PowerUpdateCurrentChange(ModuleSupplyingDevice Supply)
    {
        var sync = ElectricalManager.Instance.electricalSync;

        if (Supply.ControllingNode.Node.InData.Data.SupplyDependent.ContainsKey(Supply.ControllingNode.Node))
        {
            //Logger.Log("PowerUpdateCurrentChange for Supply  > " + Supply.name);
            Supply.ControllingNode.Node.InData.FlushSupplyAndUp(Supply.ControllingNode.Node);             //Needs change

            if (!Supply.ControllingNode.Node.InData.Data.ChangeToOff)
            {
                if (Supply.ControllingNode.Node.InData.Data.SupplyingCurrent != 0)
                {
                    Supply.CurrentSource.current = Supply.ControllingNode.Node.InData.Data.SupplyingCurrent;
                    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);
                }
                else if (Supply.ControllingNode.Node.InData.Data.SupplyingVoltage != 0)
                {
                    float Current = (Supply.SupplyingVoltage) / (Supply.InternalResistance
                                                                 + ElectricityFunctions.WorkOutResistance(Supply.ControllingNode.Node.InData.Data.SupplyDependent[Supply.ControllingNode.Node].ResistanceComingFrom));


                    Supply.CurrentSource.current = Current;
                    var WrapCurrentSource = ElectricalPool.GetWrapCurrent();
                    //Logger.Log("Supply.CurrentSource.current" + Supply.CurrentSource.current);
                    WrapCurrentSource.Current  = Supply.CurrentSource;
                    WrapCurrentSource.Strength = 1;
                    //Logger.Log("2 > " + WrapCurrentSource.Current.current);
                    var VIR = ElectricalPool.GetVIRCurrent();
                    VIR.addCurrent(WrapCurrentSource);

                    //Logger.Log("3 > " + VIR);
                    Supply.ControllingNode.Node.InData.ElectricityOutput(VIR,
                                                                         Supply.ControllingNode.Node
                                                                         );
                    //Logger.Log("END > " + VIR);
                }
            }
            else
            {
                foreach (var connectedDevice in Supply.ControllingNode.Node.connectedDevices)
                {
                    if (sync.ReactiveSuppliesSet.Contains(connectedDevice.Categorytype))
                    {
                        sync.NUCurrentChange.Add(connectedDevice.ControllingDevice);
                    }
                }
            }
        }
        //ELCurrent.Currentloop(Supply.gameObject);

        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.Node.InData.ControllingDevice, Supply.ControllingNode.Node.InData.Categorytype);
        }
    }
示例#20
0
    public virtual void ResistancyOutput(GameObject SourceInstance)
    {
        float Resistance = ElectricityFunctions.WorkOutResistance(Data.ResistanceComingFrom[SourceInstance.GetInstanceID()]);

        InputOutputFunctions.ResistancyOutput(Resistance, SourceInstance, this);
    }
示例#21
0
 public static void PowerUpdateCurrentChange(IElectricityIO Supply)
 {
     Supply.FlushSupplyAndUp(Supply.GameObject());
     if (Supply.connectedDevices.Count > 0)
     {
         if (Supply.Data.SupplyingCurrent != 0)
         {
             Supply.ElectricityOutput(Supply.Data.SupplyingCurrent, Supply.GameObject());
         }
         else if (Supply.Data.SupplyingVoltage != 0)
         {
             int SourceInstanceID = Supply.GameObject().GetInstanceID();
             Supply.ElectricityOutput((Supply.Data.SupplyingVoltage) / (Supply.Data.InternalResistance + ElectricityFunctions.WorkOutResistance(Supply.Data.ResistanceComingFrom[SourceInstanceID])), Supply.GameObject());
         }
     }
 }
示例#22
0
    public static void ElectricityInput(float Current, GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire)
    {
        //Logger.Log (" <Current " + SourceInstance.ToString () + " <SourceInstance " + ComingFrom.ToString () + " <ComingFrom " + Thiswire.ToString () + " <Thiswire ", Category.Electrical);
        int SourceInstanceID = SourceInstance.GetInstanceID();

        ElectricalSynchronisation.InputSupplyingUsingData = Thiswire.Data.SupplyDependent[SourceInstanceID];
        ElectricalSynchronisation.InputSupplyingUsingData.CurrentComingFrom[ComingFrom] = Current;
        if (!(ElectricalSynchronisation.InputSupplyingUsingData.ResistanceComingFrom.Count > 0))
        {
            ElectricalSynchronisation.StructureChange = true;
            ElectricalSynchronisation.NUStructureChangeReact.Add(Thiswire.InData.ControllingDevice);
            ElectricalSynchronisation.NUResistanceChange.Add(Thiswire.InData.ControllingDevice);
            ElectricalSynchronisation.NUCurrentChange.Add(Thiswire.InData.ControllingDevice);
            //Logger.LogErrorFormat("Resistance isn't initialised on {1}", Category.Electrical, SourceInstance);
            return;
        }
        ElectricalSynchronisation.InputSupplyingUsingData.SourceVoltages = Current * (ElectricityFunctions.WorkOutResistance(ElectricalSynchronisation.InputSupplyingUsingData.ResistanceComingFrom));
        ELCurrent.CurrentWorkOnNextListADD(Thiswire);
        Thiswire.Data.CurrentStoreValue = ElectricityFunctions.WorkOutCurrent(ElectricalSynchronisation.InputSupplyingUsingData.CurrentComingFrom);
    }
示例#23
0
    public static void PowerUpdateCurrentChange(ModuleSupplyingDevice Supply)
    {
        Supply.ControllingNode.Node.FlushSupplyAndUp(Supply.gameObject);
        if (!Supply.ControllingNode.Node.Data.ChangeToOff)
        {
            if (Supply.ControllingNode.Node.Data.SupplyingCurrent != 0)
            {
                Supply.ControllingNode.Node.ElectricityOutput(Supply.ControllingNode.Node.Data.SupplyingCurrent, Supply.ControllingNode.Node.GameObject());
            }
            else if (Supply.ControllingNode.Node.Data.SupplyingVoltage != 0)
            {
                int   SourceInstanceID = Supply.ControllingNode.Node.GameObject().GetInstanceID();
                float Current          = (Supply.SupplyingVoltage) / (Supply.InternalResistance + ElectricityFunctions.WorkOutResistance(Supply.ControllingNode.Node.Data.SupplyDependent[SourceInstanceID].ResistanceComingFrom));
                Supply.ControllingNode.Node.ElectricityOutput(Current, Supply.gameObject);
            }
        }
        else
        {
            foreach (ElectricalOIinheritance connectedDevice in Supply.ControllingNode.Node.connectedDevices)
            {
                if (ElectricalSynchronisation.ReactiveSuppliesSet.Contains(connectedDevice.InData.Categorytype))
                {
                    ElectricalSynchronisation.NUCurrentChange.Add(connectedDevice.InData.ControllingDevice);
                }
            }
        }
        ELCurrent.Currentloop(Supply.gameObject);

        if (Supply.ControllingNode.Node.Data.ChangeToOff)
        {
            Supply.ControllingNode.Node.Data.ChangeToOff = false;
            Supply.ControllingNode.TurnOffCleanup();
            ElectricalSynchronisation.RemoveSupply(Supply.ControllingNode.Node.InData.ControllingDevice, Supply.ControllingNode.Node.InData.Categorytype);
        }
    }
    public static void PowerUpdateCurrentChange(ElectricalOIinheritance Supply)
    {
        Supply.FlushSupplyAndUp(Supply.GameObject());
        if (Supply.connectedDevices.Count > 0)
        {
            if (!Supply.Data.ChangeToOff)
            {
                if (Supply.Data.SupplyingCurrent != 0)
                {
                    Supply.ElectricityOutput(Supply.Data.SupplyingCurrent, Supply.GameObject());
                }
                else if (Supply.Data.SupplyingVoltage != 0)
                {
                    int SourceInstanceID = Supply.GameObject().GetInstanceID();
                    Supply.ElectricityOutput((Supply.Data.SupplyingVoltage) / (Supply.Data.InternalResistance + ElectricityFunctions.WorkOutResistance(Supply.Data.ResistanceComingFrom[SourceInstanceID])), Supply.GameObject());
                }
            }
            else
            {
                foreach (ElectricalOIinheritance connectedDevice in Supply.connectedDevices)
                {
                    ElectricalSynchronisation.NUCurrentChange.Add(connectedDevice.InData.ControllingDevice);
                }
            }
            ELCurrent.Currentloop(Supply.GameObject());
        }

        if (Supply.Data.ChangeToOff)
        {
            Supply.Data.ChangeToOff = false;
            Supply.InData.ControllingDevice.TurnOffCleanup();
            ElectricalSynchronisation.RemoveSupply(Supply.InData.ControllingUpdate, Supply.InData.Categorytype);
        }
    }