Example #1
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);
                        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);
        }
Example #2
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);
        }
 public override void PowerUpdateCurrentChange()
 {
     PowerSupplyFunction.PowerUpdateCurrentChange(this);
 }