Beispiel #1
0
        public void Example5()
        {
            var stats = new SimpleAverage(new double[] { 2, 2, 5, 7 });

            Assert.Equal(4, stats.Count);
            Assert.Equal(4, stats.Average, 15);
        }
Beispiel #2
0
        public void NoValue()
        {
            var stats = new SimpleAverage();

            Assert.Equal(0, stats.Count);
            Assert.Equal(double.NaN, stats.Average);
        }
Beispiel #3
0
        public void Calculate_zeroPeriods()
        {
            double[] input    = new double[] { 200, 225, 245 };
            double[] forecast = ArrayBased.Join(SimpleAverage.Calculate(input, 0));

            Assert.Equal(input, forecast);
        }
Beispiel #4
0
        public void Example6()
        {
            var stats = new SimpleAverage();

            stats.AddRange(new double[] { 2, 4, 4, 4, 5, 5, 7, 9 });
            Assert.Equal(8, stats.Count);
            Assert.Equal(5, stats.Average, 15);
        }
Beispiel #5
0
        public void OneValue()
        {
            var stats = new SimpleAverage();

            stats.Add(1);
            Assert.Equal(1, stats.Count);
            Assert.Equal(1, stats.Average);
        }
Beispiel #6
0
        public void Example10()
        {
            var stats = new SimpleAverage();

            stats.AddRange(new double[] { -1, 0, 1 });
            Assert.Equal(3, stats.Count);
            Assert.Equal(0, stats.Average, 15);
        }
Beispiel #7
0
        public void Example7()
        {
            var stats = new SimpleAverage();

            stats.AddRange(new double[] { 9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4 });
            Assert.Equal(20, stats.Count);
            Assert.Equal(7, stats.Average, 15);
        }
Beispiel #8
0
        public void Example8()
        {
            var stats = new SimpleAverage();

            stats.AddRange(new double[] { 51.3, 55.6, 49.9, 52.0 });
            Assert.Equal(4, stats.Count);
            Assert.Equal(52.2, stats.Average, 15);
        }
Beispiel #9
0
        public void Calculate_1Period()
        {
            double[] input         = new double[] { 100, 150, 200 };
            double[] forecast      = ArrayBased.Join(SimpleAverage.Calculate(input, 1));
            double[] expectedValue = new double[] { 100, 150, 200, 150 };

            Assert.Equal(expectedValue, forecast);
        }
Beispiel #10
0
        public void Example9()
        {
            var stats = new SimpleAverage();

            stats.AddRange(new double[] { -5, -3, -1, 1, 3 });
            Assert.Equal(5, stats.Count);
            Assert.Equal(-1, stats.Average, 15);
        }
Beispiel #11
0
 public void NoNullCollection()
 {
     Assert.Throws <ArgumentNullException>(delegate {
         var stats = new SimpleAverage(null);
     });
     Assert.Throws <ArgumentNullException>(delegate {
         var stats = new SimpleAverage();
         stats.AddRange(null);
     });
 }
Beispiel #12
0
        public void Example4()
        {
            var stats = new SimpleAverage();

            stats.Add(6);
            stats.Add(2);
            stats.Add(3);
            stats.Add(1);
            Assert.Equal(4, stats.Count);
            Assert.Equal(3, stats.Average, 15);
        }
Beispiel #13
0
        public void Example1()
        {
            var stats = new SimpleAverage();

            stats.Add(4);
            stats.Add(7);
            stats.Add(13);
            stats.Add(16);
            Assert.Equal(4, stats.Count);
            Assert.Equal(10, stats.Average, 15);
        }
Beispiel #14
0
 public void Calculate_negativePeriods()
 {
     double[] input = new double[] { };
     try
     {
         SimpleAverage.Calculate(input, -1);
     }
     catch (NegativePeriodsToCalculate e)
     {
         Assert.Equal(e.Message, NegativePeriodsToCalculate.eMessage);
     }
 }
Beispiel #15
0
        public void NoInfinity()
        {
            var stats = new SimpleAverage();

            Assert.Throws <ArgumentOutOfRangeException>(delegate {
                stats.Add(double.NegativeInfinity);
            });
            Assert.Throws <ArgumentOutOfRangeException>(delegate {
                stats.Add(double.PositiveInfinity);
            });
            Assert.Throws <ArgumentOutOfRangeException>(delegate {
                stats.Add(double.NaN);
            });
        }
            public LimberingUpStage(Vector3 estimatedAxis, Vector3Provider gravProvider, bool AutoStart = true) : base("Limbering up")
            {
                AverageAxis  = new SimpleAverage <Vector3>(estimatedAxis);
                GyroProvider = new Vector3Provider(SensorType.Gyroscope, StopToken);
                GravProvider = gravProvider;
                SetUpProvider(GyroProvider);

                UpDirectionInitial = GravProvider.Vector;

                //Current.RunOnUiThread(() =>
                //{
                //    Current.FindViewById(Resource.Id.vault_notification).Visibility = ViewStates.Visible;
                //    Current.FindViewById(Resource.Id.vault_dial_text).Visibility = ViewStates.Gone;
                //});

                InterimInterval = TimeSpan.FromMilliseconds(20);
                if (AutoStart)
                {
                    Activate(Current.StopToken);
                }
            }
        public MainWindow()
        {
            InitializeComponent();

            _screenUpdateResolution = Settings.Default.ScreenUpdateResolution;
            _samplingResolution     = Settings.Default.SamplingResolution;

            _computer = new Computer();
            _computer.Open();
            _computer.IsCpuEnabled = true;
            _computer.Accept(new SensorVisitor(s => s.ValuesTimeWindow = TimeSpan.FromMinutes(5)));

            // Most reliable way to get base frequency
            var registryKeyCpu = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0", false);
            var baseClockMhz   = registryKeyCpu?.GetValue("~MHz").ToString();

            if (baseClockMhz != null)
            {
                _baseClock = int.Parse(baseClockMhz) / 1000.0f;
            }

            var cpu   = (GenericCpu)_computer.Hardware.First();
            var cpuId = cpu.CpuId[0][0];

            _cpuVendor = cpuId.Vendor;

            // Cases not handled by LHM's CPUID
            var nameBuilder = new StringBuilder();

            nameBuilder.Append(cpuId.Name);
            nameBuilder.Replace("4-Core Processor", string.Empty);
            nameBuilder.Replace("6-Core Processor", string.Empty);
            nameBuilder.Replace("8-Core Processor", string.Empty);
            nameBuilder.Replace("12-Core Processor", string.Empty);
            nameBuilder.Replace("16-Core Processor", string.Empty);
            nameBuilder.Replace("24-Core Processor", string.Empty);
            nameBuilder.Replace("32-Core Processor", string.Empty);

            var name = nameBuilder.ToString();

            if (name.Contains("with Radeon"))
            {
                name = name.Remove(name.LastIndexOf("with Radeon", StringComparison.Ordinal));
            }

            Title += $" - {name.Trim()}";

            // 0x16: Processor Frequency Information Leaf - EBX: Maximum Frequency (in MHz)
            if (cpuId.Data.GetLength(0) >= 0x16)
            {
                var freqData = cpuId.Data[0x16, 1];
                _turboClock = (float)Math.Ceiling((freqData + 100) / 1000.0);
            }

            _timer.Interval  = _samplingResolution;
            _timer.Elapsed  += TimerOnElapsed;
            _timer.AutoReset = false;

            _clockMin     = float.MaxValue;
            _clockMax     = float.MinValue;
            _clockAverage = new SimpleAverage(128);
            _utilAverage  = new SimpleAverage(128);
            _tempAverage  = new SimpleAverage(128);
        }