Пример #1
0
        private void timer_Tick(object sender, EventArgs e)
        {
            computer.Accept(updateVisitor);
            treeView.Invalidate();
            plotPanel.InvalidatePlot();
            systemTray.Redraw();
            if (gadget != null)
            {
                gadget.Redraw();
            }

            if (wmiProvider != null)
            {
                wmiProvider.Update();
            }


            if (logSensors != null && logSensors.Value && delayCount >= 4)
            {
                logger.Log();
            }

            if (delayCount < 4)
            {
                delayCount++;
            }
        }
Пример #2
0
        private void timer_Tick(object sender, EventArgs e)
        {
            computer.Accept(updateVisitor);
            treeView.Invalidate();
            plotPanel.InvalidatePlot();
            systemTray.Redraw();
            if (gadget != null)
            {
                gadget.Redraw();
            }

            if (wmiProvider != null)
            {
                wmiProvider.Update();
            }


            if (logSensors != null && logSensors.Value && delayCount >= 4)
            {
                logger.Log();
            }

            if (delayCount < 4)
            {
                delayCount++;
            }

            if (this.emailNotificationManager.ChechIfNotificationShouldBeSend())
            {
                this.emailNotificationManager.SendReport();
            }
        }
Пример #3
0
        private void timer_Tick(object sender, EventArgs e)
        {
            // Stop the timer. Needed when an update is slower than the interval itself.
            timer.Enabled = false;
            if (firstTick == null)
            {
                firstTick = DateTime.Now;
            }
            computer.Accept(updateVisitor);
            treeView.Invalidate();
            plotPanel.InvalidatePlot();
            systemTray.Redraw();
            if (gadget != null)
            {
                gadget.Redraw();
            }

            if (wmiProvider != null)
            {
                wmiProvider.Update();
            }

            if (logSensors != null && logSensors.Value && DateTime.Now - firstTick >= warmup)
            {
                logger.Log();
            }

            timer.Enabled = true;
        }
        private void run()
        {
            _isRunning = true;
            while (_isRunning)
            {
                _computer.Accept(_visitor);
                _provider.Update();

                if (_sensors != null && _sensors.Count > 0)
                {
                    int calculatedTemp = 0;
                    int highestTemp    = 0;
                    foreach (ISensor sensor in _sensors)
                    {
                        int sensorTemp = (int)sensor.Value;
                        calculatedTemp += (int)sensorTemp;
                        if (sensorTemp > highestTemp)
                        {
                            highestTemp = sensorTemp;
                        }
                    }
                    calculatedTemp = calculatedTemp / _sensors.Count;
                    _hardwareModel.calculatedCPUTemperature = calculatedTemp;
                    _hardwareModel.highestCoreTemp          = highestTemp;

                    //TODO: paramterise temperature override for quiet mode! For now we override at 85°C!
                    if (_hardwareModel.quietModeEnabled && _hardwareModel.highestCoreTemp < 85)
                    {
                        _hardwareModel.calculatedSpeed = _hardwareModel.quietModeSpeed;
                    }
                    else if (_hardwareModel.highestCoreTemp < 85)
                    {
                        _hardwareModel.calculatedSpeed = _linearDataInterpolator.extrapolateSpeedFromTemperature(highestTemp).speed;
                    }
                    else
                    {
                        //When the temp is higher then the max safe override to 100% fan speed!
                        _hardwareModel.calculatedSpeed = 100;
                    }
                }
                else
                {
                    //If no sensors are found, set the calculated and highest temps to -1 and the fan speed to a static 70%
                    _hardwareModel.calculatedCPUTemperature = -1;
                    _hardwareModel.highestCoreTemp          = -1;
                    _hardwareModel.quietModeEnabled         = true;
                    _hardwareModel.calculatedSpeed          = 70;
                }

                _messageHub.Publish(new HardwareModelMessage(this, "update"));
                Thread.Sleep(1000);
            }
        }
        private void Timer_Tick(object sender, EventArgs e)
        {
            treeView.Invalidate();
            _systemTray.Redraw();
            _gadget?.Redraw();
            _wmiProvider?.Update();

            if (!backgroundUpdater.IsBusy)
            {
                backgroundUpdater.RunWorkerAsync();
            }

            RestoreCollapsedNodeState(treeView);
        }
Пример #6
0
        public DataProvider()
        {
            _computer = new Computer();
            // enable everything except for GPU which we can't monitor in a service anyway (keyword: session 0 isolation)
            _computer.CPUEnabled = _computer.FanControllerEnabled = _computer.HDDEnabled = _computer.RAMEnabled = _computer.MainboardEnabled = true;
            _computer.Open();

            _wmiProvider = new WmiProvider(_computer);
            _wmiProvider.Update();
            _visitor = new UpdateVisitor();
            // tick once per second
            _timer           = new Timer(1000.0);
            _timer.Elapsed  += updateTick;
            _timer.AutoReset = true;
            _timer.Enabled   = true;
        }
Пример #7
0
        private void timer_Tick(object sender, EventArgs e)
        {
            computer.Accept(updateVisitor);
            treeView.Invalidate();
            plotPanel.Invalidate();
            systemTray.Redraw();
            if (gadget != null)
            {
                gadget.Redraw();
            }

            if (wmiProvider != null)
            {
                wmiProvider.Update();
            }
        }
Пример #8
0
        private void timer_Tick(object sender, EventArgs e)
        {
            computer.Accept(updateVisitor);
            treeView.Invalidate();
            plotPanel.InvalidatePlot();
            systemTray.Redraw();
            if (gadget != null)
            {
                gadget.Redraw();
            }

            if (wmiProvider != null)
            {
                wmiProvider.Update();
            }


            if (logSensors != null)
            {
                if (logSensors.Value && delayCount >= 4)
                {
                    logger.Log();
                }

                if (delayCount < 4)
                {
                    delayCount++;
                }
            }
            else
            {
                logSensors = new UserOption("logSensorsMenuItem", false, logSensorsMenuItem,
                                            settings);

                if (logSensors.Value && delayCount >= 4)
                {
                    logger.Log();
                }

                if (delayCount < 4)
                {
                    delayCount++;
                }
            }
        }
Пример #9
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            _computer.Accept(_updateVisitor);
            treeView.Invalidate();
            _plotPanel.InvalidatePlot();
            _systemTray.Redraw();
            _gadget?.Redraw();
            _wmiProvider?.Update();

            if (_logSensors != null && _logSensors.Value && _delayCount >= 4)
            {
                _logger.Log();
            }

            if (_delayCount < 4)
            {
                _delayCount++;
            }
        }
Пример #10
0
        /// <summary>
        /// Called when the package is started.
        /// </summary>
        public override void OnStart()
        {
            this.computer = new Computer();
            var updateVisitor = new UpdateVisitor();
            var wmiProvider   = new WmiProvider(computer);

            this.computer.HardwareAdded   += new HardwareEventHandler(computer_HardwareAdded);
            this.computer.HardwareRemoved += new HardwareEventHandler(computer_HardwareRemoved);

            this.computer.Open();

            this.computer.MainboardEnabled     = true;
            this.computer.CPUEnabled           = true;
            this.computer.FanControllerEnabled = true;
            this.computer.GPUEnabled           = true;
            this.computer.HDDEnabled           = true;
            this.computer.MainboardEnabled     = true;
            this.computer.RAMEnabled           = true;

            this.pushHardwareListOnChange = true;
            this.PushHardwaresList();

            while (PackageHost.IsRunning)
            {
                Thread.Sleep(PackageHost.GetSettingValue <int>("Interval"));

                this.computer.Accept(updateVisitor);
                if (wmiProvider != null)
                {
                    wmiProvider.Update();
                }

                foreach (var hardware in computer.Hardware)
                {
                    this.PushHardware(hardware);
                }
            }
        }
        public void SendData(bool hardwareOnly)
        {
            computer.Accept(updateVisitor);

            if (sendSerialData)
            {
                var gpuMaxTemp = Math.Max(
                    (int)MaxTemp(computer, HardwareType.GpuNvidia),
                    (int)MaxTemp(computer, HardwareType.GpuAti)
                    );
                var gpuMaxUsage = Math.Max(
                    (int)UsageInPercent(computer, HardwareType.GpuAti, "GPU Core"),
                    (int)UsageInPercent(computer, HardwareType.GpuNvidia, "GPU Core")
                    );
                var gpuMaxMemory = Math.Max(
                    (int)UsageInPercent(computer, HardwareType.GpuAti, "GPU Memory"),
                    (int)UsageInPercent(computer, HardwareType.GpuNvidia, "GPU Memory")
                    );

                List <float> data = new List <float>
                {
                    (int)MaxTemp(computer, HardwareType.CPU),
                    gpuMaxTemp,
                    (int)MaxTemp(computer, HardwareType.Mainboard),
                    (int)MaxTemp(computer, HardwareType.HDD),
                    (int)UsageInPercent(computer, HardwareType.CPU, "CPU Total"),
                    gpuMaxUsage,
                    (int)UsageInPercent(computer, HardwareType.RAM, "Memory"),
                    gpuMaxMemory
                };

                for (int i = 1; i < 17; i++)
                {
                    data.Add((int)MaxTemp(computer, HardwareType.CPU, $"CPU Core #{i}"));
                    data.Add((int)UsageInPercent(computer, HardwareType.CPU, $"CPU Core #{i}"));
                }

                if (!hardwareOnly)
                {
                    data.AddRange(new float[] {
                        // Right group.
                        settings.GetValue("nMaxFan", 100),
                        settings.GetValue("nMinFan", 20),
                        settings.GetValue("nMaxTemp", 100),
                        settings.GetValue("nMinTemp", 10),

                        // Flags
                        settings.GetValue("chkManualFan", false) ? 1 : 0,
                        settings.GetValue("chkManualColor", false) ? 1 : 0,

                        // Sliders.
                        settings.GetValue("sldManualFan", 50),
                        settings.GetValue("sldManualColor", 500),
                        settings.GetValue("sldLedBrightness", 50),
                        settings.GetValue("sldPlotInterval", 5),

                        settings.GetValue("cboMaxTempSource", 0),
                    });
                }
                ;

                string tmp = string.Join(";", data.Select(T => T.ToString()).ToArray());

                serial.Write(Encoding.ASCII.GetBytes(tmp));
                serial.Write(Encoding.ASCII.GetBytes("E"));
            }

            treeView.Invalidate();
            plotPanel.InvalidatePlot();
            systemTray.Redraw();

            if (gadget != null)
            {
                gadget.Redraw();
            }

            if (wmiProvider != null)
            {
                wmiProvider.Update();
            }

            if (logSensors.Value && delayCount >= 4)
            {
                logger.Log();
            }

            if (delayCount < 4)
            {
                delayCount++;
            }
        }
Пример #12
0
        private void timer_Tick(object sender, EventArgs e)
        {
            computer.Accept(updateVisitor);

            {
                string tmp = "";
                tmp += string.Format("GPU: {0}C\r", (int)MaxTemp(computer, HardwareType.GpuAti) + AvgTemp(computer, HardwareType.GpuNvidia));
                tmp += string.Format("CPU: {0}C\r", (int)MaxTemp(computer, HardwareType.CPU));
                tmp += string.Format("Mainboard: {0}C\r", (int)MaxTemp(computer, HardwareType.Mainboard));
                tmp += string.Format("HDD: {0}C\r", (int)MaxTemp(computer, HardwareType.HDD));
                serial.Write(new byte[] { 0 });
                serial.Write(Encoding.ASCII.GetBytes(tmp));
                serial.Write(new byte[] { 1 });


                /*var gpus = computer.Hardware.Where(x => x.HardwareType == HardwareType.GpuAti || x.HardwareType == HardwareType.GpuNvidia).ToArray();
                 * if (gpus.Any())
                 * {
                 *  var gpu = gpus.First();
                 *  var temps = gpu.Sensors.Where(x => x.SensorType == SensorType.Temperature).ToArray();
                 *  if (temps.Any())
                 *  {
                 *      var temp = temps.Average(x => x.Value.Value);
                 *      tmp += string.Format("gpu: {0}C\r", (int)temp);
                 *  }
                 * }
                 *
                 * var cpus = computer.Hardware.Where(x => x.HardwareType == HardwareType.CPU).ToArray();
                 *
                 * if (cpus.Any())
                 * {
                 *  var cpu = cpus.First();
                 *  var temps = cpu.Sensors.Where(x => x.SensorType == SensorType.Temperature).ToArray();
                 *  if (temps.Any())
                 *  {
                 *      var temp = temps.Average(x => x.Value.Value);
                 *      tmp += string.Format("cpu: {0}C\r", (int)temp);
                 *  }
                 * }
                 *
                 * var mainboard = computer.Hardware.Where(x => x.HardwareType == HardwareType.Mainboard).Single();
                 * {
                 *  var temps = mainboard.Sensors.Where(x => x.SensorType == SensorType.Temperature).ToArray();
                 *  if (temps.Any())
                 *  {
                 *      var temp = temps.Average(x => x.Value.Value);
                 *      tmp += string.Format("mainboard: {0}C\r", (int)temp);
                 *  }
                 * }
                 *
                 * var hdds = computer.Hardware.Where(x => x.HardwareType == HardwareType.CPU).ToArray();
                 *
                 * if (hdds.Any())
                 * {
                 *  var cpu = cpus.First();
                 *  var temps = cpu.Sensors.Where(x => x.SensorType == SensorType.Temperature).ToArray();
                 *  if (temps.Any())
                 *  {
                 *      var temp = temps.Average(x => x.Value.Value);
                 *      tmp += string.Format("hdd: {0}C\r", (int)temp);
                 *  }
                 * }*/
            }

            treeView.Invalidate();
            plotPanel.InvalidatePlot();
            systemTray.Redraw();
            if (gadget != null)
            {
                gadget.Redraw();
            }

            if (wmiProvider != null)
            {
                wmiProvider.Update();
            }


            if (logSensors.Value && delayCount >= 4)
            {
                logger.Log();
            }

            if (delayCount < 4)
            {
                delayCount++;
            }
        }
Пример #13
0
        public void timer_Tick(object sender, EventArgs e)
        {
            computer.Accept(updateVisitor);

            {
                /*string tmp = "";
                 * tmp += string.Format("{0};", (int)MaxTemp(computer, HardwareType.GpuAti) + AvgTemp(computer, HardwareType.GpuNvidia));
                 * tmp += string.Format("{0};", (int)MaxTemp(computer, HardwareType.CPU));
                 * tmp += string.Format("{0};", (int)MaxTemp(computer, HardwareType.Mainboard));
                 * tmp += string.Format("{0};", (int)MaxTemp(computer, HardwareType.HDD));
                 * tmp += string.Format("{0};", (int)(UsageInPercent(computer, HardwareType.GpuAti, "GPU Core") + UsageInPercent(computer, HardwareType.GpuNvidia, "GPU Core")));
                 * tmp += string.Format("{0};", (int)UsageInPercent(computer, HardwareType.CPU, "CPU Total"));
                 * tmp += string.Format("{0};", (int)UsageInPercent(computer, HardwareType.RAM, "Memory"));
                 * tmp += string.Format("{0};", (int)UsageInPercent(computer, HardwareType.GpuAti, "GPU Memory") + UsageInPercent(computer, HardwareType.GpuNvidia, "GPU Memory"));*/

                var gpuMaxTemp = Math.Max(
                    (int)MaxTemp(computer, HardwareType.GpuNvidia),
                    (int)MaxTemp(computer, HardwareType.GpuAti)
                    );
                var gpuMaxUsage = Math.Max(
                    (int)UsageInPercent(computer, HardwareType.GpuAti, "GPU Core"),
                    (int)UsageInPercent(computer, HardwareType.GpuNvidia, "GPU Core")
                    );
                var gpuMaxMemory = Math.Max(
                    (int)UsageInPercent(computer, HardwareType.GpuAti, "GPU Memory"),
                    (int)UsageInPercent(computer, HardwareType.GpuNvidia, "GPU Memory")
                    );

                List <float> data = new List <float>
                {
                    (int)MaxTemp(computer, HardwareType.CPU),
                    gpuMaxTemp,
                    (int)MaxTemp(computer, HardwareType.Mainboard),
                    (int)MaxTemp(computer, HardwareType.HDD),
                    (int)UsageInPercent(computer, HardwareType.CPU, "CPU Total"),
                    (int)gpuMaxUsage,
                    (int)UsageInPercent(computer, HardwareType.RAM, "Memory"),
                    (int)gpuMaxMemory,

                    // Right group.
                    settings.GetValue("nMaxFan", 100),
                    settings.GetValue("nMinFan", 20),
                    settings.GetValue("nMaxTemp", 100),
                    settings.GetValue("nMinTemp", 10),

                    // Flags
                    settings.GetValue("chkManualFan", false) ? 1 : 0,
                    settings.GetValue("chkManualColor", false) ? 1 : 0,

                    // Sliders.
                    settings.GetValue("sldManualFan", 50),
                    settings.GetValue("sldManualColor", 500),
                    settings.GetValue("sldLedBrightness", 50),
                    settings.GetValue("sldPlotInterval", 5),

                    settings.GetValue("cboMaxTempSource", 0),
                };

                string tmp = string.Join(";", data.Select(T => T.ToString()).ToArray());

                serial.Write(Encoding.ASCII.GetBytes(tmp));
                serial.Write(Encoding.ASCII.GetBytes("E"));

                /*var gpus = computer.Hardware.Where(x => x.HardwareType == HardwareType.GpuAti || x.HardwareType == HardwareType.GpuNvidia).ToArray();
                 * if (gpus.Any())
                 * {
                 *  var gpu = gpus.First();
                 *  var temps = gpu.Sensors.Where(x => x.SensorType == SensorType.Temperature).ToArray();
                 *  if (temps.Any())
                 *  {
                 *      var temp = temps.Average(x => x.Value.Value);
                 *      tmp += string.Format("gpu: {0}C\r", (int)temp);
                 *  }
                 * }
                 *
                 * var cpus = computer.Hardware.Where(x => x.HardwareType == HardwareType.CPU).ToArray();
                 *
                 * if (cpus.Any())
                 * {
                 *  var cpu = cpus.First();
                 *  var temps = cpu.Sensors.Where(x => x.SensorType == SensorType.Temperature).ToArray();
                 *  if (temps.Any())
                 *  {
                 *      var temp = temps.Average(x => x.Value.Value);
                 *      tmp += string.Format("cpu: {0}C\r", (int)temp);
                 *  }
                 * }
                 *
                 * var mainboard = computer.Hardware.Where(x => x.HardwareType == HardwareType.Mainboard).Single();
                 * {
                 *  var temps = mainboard.Sensors.Where(x => x.SensorType == SensorType.Temperature).ToArray();
                 *  if (temps.Any())
                 *  {
                 *      var temp = temps.Average(x => x.Value.Value);
                 *      tmp += string.Format("mainboard: {0}C\r", (int)temp);
                 *  }
                 * }
                 *
                 * var hdds = computer.Hardware.Where(x => x.HardwareType == HardwareType.CPU).ToArray();
                 *
                 * if (hdds.Any())
                 * {
                 *  var cpu = cpus.First();
                 *  var temps = cpu.Sensors.Where(x => x.SensorType == SensorType.Temperature).ToArray();
                 *  if (temps.Any())
                 *  {
                 *      var temp = temps.Average(x => x.Value.Value);
                 *      tmp += string.Format("hdd: {0}C\r", (int)temp);
                 *  }
                 * }*/
            }

            treeView.Invalidate();
            plotPanel.InvalidatePlot();
            systemTray.Redraw();
            if (gadget != null)
            {
                gadget.Redraw();
            }

            if (wmiProvider != null)
            {
                wmiProvider.Update();
            }

            if (logSensors.Value && delayCount >= 4)
            {
                logger.Log();
            }

            if (delayCount < 4)
            {
                delayCount++;
            }
        }
Пример #14
0
 private void updateTick(Object source, ElapsedEventArgs args)
 {
     _computer.Accept(_visitor);
     _wmiProvider.Update();
 }
Пример #15
0
 private void Update()
 {
     _updateVisitor.VisitHardware(_hardware);
     _wmiProvider.Update();
 }