Example #1
0
        public static void ElectricityOutput(VIRCurrent Current,
                                             ElectricalOIinheritance SourceInstance,
                                             IntrinsicElectronicData Thiswire)
        {
            //Logger.Log("4 > " + Current);
            //Logger.Log("poke > " + SourceInstance.InData.Data.SupplyDependent[SourceInstance].ToString());
            var        OutputSupplyingUsingData = Thiswire.Data.SupplyDependent[SourceInstance];
            VIRCurrent SupplyingCurrent         = null;
            float      Divider = (ElectricityFunctions.WorkOutResistance(OutputSupplyingUsingData.ResistanceComingFrom));

            foreach (KeyValuePair <IntrinsicElectronicData, VIRResistances> JumpTo in OutputSupplyingUsingData
                     .ResistanceComingFrom)
            {
                if (OutputSupplyingUsingData.ResistanceComingFrom.Count > 1)
                {
                    SupplyingCurrent = Current.SplitCurrent(Divider / JumpTo.Value.Resistance());
                }
                else
                {
                    SupplyingCurrent = Current;
                }

                OutputSupplyingUsingData.CurrentGoingTo[JumpTo.Key] = SupplyingCurrent;
                if (JumpTo.Key != null && JumpTo.Key.Categorytype != PowerTypeCategory.DeadEndConnection)
                {
                    JumpTo.Key.ElectricityInput(SupplyingCurrent, SourceInstance, Thiswire);
                }
            }
        }
Example #2
0
        public static void ElectricityInput(VIRCurrent current,
                                            ElectricalOIinheritance sourceInstance,
                                            IntrinsicElectronicData comingFrom,
                                            IntrinsicElectronicData thiswire)
        {
            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);
        }
Example #3
0
 public override void ElectricityOutput(VIRCurrent Current,
                                        ElectricalOIinheritance SourceInstance)
 {
     Current = InData.ControllingDevice.ModifyElectricityOutput(Current, SourceInstance);
     if (Logall)
     {
         Logger.Log("this > " + this + "ElectricityOutput, Current > " + Current + " SourceInstance  > " + SourceInstance, Category.Electrical);
     }
     InputOutputFunctions.ElectricityOutput(Current, SourceInstance, InData);
 }
Example #4
0
 /// <summary>
 ///The function for out putting current into other nodes (Basically doing ElectricityInput On another one)
 /// </summary>
 public virtual void ElectricityOutput(VIRCurrent Current,
                                       ElectricalOIinheritance SourceInstance)
 {
     if (Logall)
     {
         Logger.Log("this > " + this
                    + "ElectricityOutput, Current > " + Current
                    + " SourceInstance  > " + SourceInstance, Category.Electrical);
     }
     InputOutputFunctions.ElectricityOutput(Current, SourceInstance, InData);
 }
Example #5
0
 /// <summary>
 ///The function for out putting current into other nodes (Basically doing ElectricityInput On another one)
 /// </summary>
 public virtual void ElectricityOutput(VIRCurrent Current,
                                       ElectricalOIinheritance SourceInstance)
 {
     if (Present != null)
     {
         Present.ElectricityOutput(Current, SourceInstance);
     }
     else
     {
         InputOutputFunctions.ElectricityOutput(Current, SourceInstance, this);
     }
 }
Example #6
0
 /// <summary>
 /// Inputs a current from a device, with the supply
 /// </summary>
 public virtual void ElectricityInput(VIRCurrent Current,
                                      ElectricalOIinheritance SourceInstance,
                                      IntrinsicElectronicData ComingFrom)
 {
     if (Logall)
     {
         Logger.Log("this > " + this
                    + "ElectricityInput, Current > " + Current
                    + " SourceInstance  > " + SourceInstance
                    + " ComingFrom > " + ComingFrom, Category.Electrical);
     }
     InputOutputFunctions.ElectricityInput(Current, SourceInstance, ComingFrom, InData);
 }
Example #7
0
 /// <summary>
 /// Inputs a current from a device, with the supply
 /// </summary>
 public virtual void ElectricityInput(VIRCurrent Current,
                                      ElectricalOIinheritance SourceInstance,
                                      IntrinsicElectronicData ComingFrom)
 {
     if (Present != null)
     {
         Present.ElectricityInput(Current, SourceInstance, ComingFrom);
     }
     else
     {
         InputOutputFunctions.ElectricityInput(Current, SourceInstance, ComingFrom, this);
     }
 }
Example #8
0
 public void addCurrent(VIRCurrent NewWrapCurrent)
 {
     foreach (var inCurrent in NewWrapCurrent.CurrentSources)
     {
         foreach (var wrapCurrent in CurrentSources)
         {
             if (wrapCurrent.Current == inCurrent.Current)
             {
                 //wrapCurrent.CombineCurrent(inCurrent);
                 return;
             }
         }
         CurrentSources.Add(inCurrent);
     }
 }