Ejemplo n.º 1
0
        public static void ReleasePower(FogDevice nearestFogDevice, Models.Tuple tuple)
        {
            lock (Lock)
            {
                nearestFogDevice.BusyPower      = nearestFogDevice.BusyPower - (GetRequiredPowerPercentage(tuple, nearestFogDevice));
                nearestFogDevice.AvailablePower = 100 - nearestFogDevice.BusyPower;
                /// PowerUtility.CalcPowerValues

                //var obj = new PowerConsumption()
                //{
                //    PowerValue = nearestFogDevice.BusyPower < 86 ? GetPowerConsumption(86) : GetPowerConsumption(int.Parse(nearestFogDevice.BusyPower.ToString())),
                //    Time = DateTime.Now.ToString("hh:mm:ss.fff tt")
                //};
                Debug.WriteLine("ReleasePower-" + nearestFogDevice.BusyPower);

                var obj = new PowerConsumption()
                {
                    PowerValue = (nearestFogDevice.BusyPower < 1) ? CalcPowerValues("1") : (nearestFogDevice.BusyPower > 100) ? CalcPowerValues("100") : CalcPowerValues(nearestFogDevice.BusyPower.ToString()),
                    Time       = DateTime.Now.ToString("hh:mm:ss.fff tt")
                };

                nearestFogDevice.PowerConsumption.Add(obj);

                //GetRequiredPowerPercentage(tuple, nearestFogDevice)
            }
        }
Ejemplo n.º 2
0
        private static void PowerConsumptionTest(Camera camera, PowerSupplyDevice powerSupply)
        {
            msg = "Input acceptable range in Watts separated by comma ex. min,max: ";
            WriteToScreen(msg);
            var range = Console.ReadLine();

            if (range == null)
            {
                throw new ArgumentNullException(range, "Range cannot be null");
            }

            var lstRange = range.Split(',');

            if (lstRange.Length != 2)
            {
                _consoleLogger.LogError("Invalid Range");
                throw new ArgumentException("Invalid acceptable power consumption range");
            }


            IPowerConsumption powerConsumption = new PowerConsumption(new ConsoleLogger());

//            IPowerConsumption powerConsumption = new PowerConsumption(new FileLogger("C:\\Users\\chimm\\Desktop\\log.txt"));

            camera.PowerConsumption = powerConsumption.PowerConsumptionInWatts(powerSupply);

            var passed = powerConsumption.IsPowerConsumptionWithinRange(Convert.ToDouble(lstRange[0]),
                                                                        Convert.ToDouble(lstRange[1]), camera);

            msg = passed ? "Test Passed!" : "Test Failed";

            WriteToScreen(msg);
        }
Ejemplo n.º 3
0
 public string PersonalToString()
 {
     return("Power consumption: " + PowerConsumption.ToString() + " \n" +
            "Cores: " + CoresCount.ToString() + " \n" +
            "Frequency: " + Frequency.ToString() + " \n" +
            "Chipset: " + Chipset + " \n" +
            "RAM: " + RamAge + ", " + RamFrequency.ToString() + ", " + RamStrings.ToString());
 }
Ejemplo n.º 4
0
 public string PersonalToString()
 {
     return("Power consumption: " + PowerConsumption.ToString() + " \n" +
            "GRAMCount: " + GRAMCount.ToString() + " \n" +
            "GRAMAge: " + GRAMAge.ToString() + " \n" +
            "GPU: " + GPU + " \n" +
            "Interfaces: " + Interfaces + " \n" +
            "PowerType: " + PowerType + " \n");
 }
Ejemplo n.º 5
0
        public DateTime?ApplianceLastUsed()
        {
            foreach (var(value, index) in PowerConsumption.Reverse().Select((v, i) => (v, i)))
            {
                if (value != null && value > 1)
                {
                    return(DateTimeOffset.FromUnixTimeSeconds(Timestamps[Timestamps.Count - index - 1]).DateTime);
                }
            }

            return(null);
        }
Ejemplo n.º 6
0
        //public static List<double> testlist = new List<double>();

        public static void ConsumePower(FogDevice nearestFogDevice, Models.Tuple tuple)
        {
            lock (Lock)
            {
                Debug.WriteLine("RequiredPowerByTuple-" + GetRequiredPowerPercentage(tuple, nearestFogDevice));
                Debug.WriteLine("ConsumePower-" + nearestFogDevice.BusyPower);

                nearestFogDevice.BusyPower      = nearestFogDevice.BusyPower + (GetRequiredPowerPercentage(tuple, nearestFogDevice));
                nearestFogDevice.AvailablePower = 100 - nearestFogDevice.BusyPower;
                var obj = new PowerConsumption()
                {
                    PowerValue = (nearestFogDevice.BusyPower > 100) ?
                                 CalcPowerValues("100") : (nearestFogDevice.BusyPower < 1) ? CalcPowerValues("1") : CalcPowerValues(nearestFogDevice.BusyPower.ToString()),
                    Time = DateTime.Now.ToString("hh:mm:ss.fff tt")
                };
                nearestFogDevice.PowerConsumption.Add(obj); //log busy percentage of fog device

                //GetRequiredPowerPercentage(tuple, nearestFogDevice)
            }
        }
        public void RigConfigBuilderToJSON()
        {
            ConcurrentObservableDictionary <(MinerSWE minerSWE, string version, Coin[] coins), MinerSWAbstract> minerSWs = new ConcurrentObservableDictionary <(MinerSWE minerSWE, string version, Coin[] coins), MinerSWAbstract>();
            ConcurrentObservableDictionary <int, MinerGPU> minerGPUs = new ConcurrentObservableDictionary <int, MinerGPU>();
            PowerConsumption pc = new PowerConsumption(new TimeSpan(0, 1, 0), new Power(1, UnitsNet.Units.PowerUnit.Watt));
            TempAndFan       tf = new TempAndFan()
            {
                Temp = new Temperature(50, UnitsNet.Units.TemperatureUnit.DegreeFahrenheit), FanPct = new Ratio(95.5, UnitsNet.Units.RatioUnit.Percent)
            };

            RigConfig rc = RigConfigBuilder.CreateNew()
                           .AddMinerSWs(minerSWs)
                           .AddMinerGPUs(minerGPUs)
                           .AddPowerConsumption(pc)
                           .AddTempAndFan(tf)
                           .Build();
            var str = JsonConvert.SerializeObject(rc);

            str.Should()
            .NotBeNull();
        }
Ejemplo n.º 8
0
 public async Task ReportConsumptionAsync(PowerConsumption consumption)
 {
     await _hub.Clients.All.SendAsync("ReportConsumption", consumption);
 }
Ejemplo n.º 9
0
 public double CalculateTotalAverage()
 {
     return(PowerConsumption.Average(a => a ?? 0));
 }
Ejemplo n.º 10
0
 public void SetUp()
 {
     _powerConsumption = new PowerConsumption(new ConsoleLogger());
 }
 public PowerConsumptionTestData(PowerConsumption PowerConsumption, string serializedPowerConsumption)
 {
     PowerConsumption           = PowerConsumption ?? throw new ArgumentNullException(nameof(PowerConsumption));
     SerializedPowerConsumption = serializedPowerConsumption ?? throw new ArgumentNullException(nameof(serializedPowerConsumption));
 }