public float GetGpuUsage() { if (gpu == null || gpuLoad == null) { return(0); } gpu.Update(); if (gpuLoad.Value != null) { return((float)gpuLoad.Value); } return(0); }
private int GetCurrentTemperature(string device) { if (device == "CPU") { try { cpuSensor = wmiSearcher.Get().OfType <ManagementObject>().FirstOrDefault(); int currTemp = (Convert.ToInt32(cpuSensor["CurrentTemperature"]) - 2732) / 10; GC.Collect(); return(currTemp); } catch (ManagementException e) { } } else if (device == "GPU") { try { IHardware hardware = computer.Hardware[1]; hardware.Update(); foreach (ISensor sensor in hardware.Sensors) { if (sensor.SensorType == SensorType.Temperature && sensor.Name == "GPU Core") { return(Convert.ToInt32(sensor.Value)); } } } catch (Exception e) { } } return(0); }
public void VisitHardware(IHardware hardware) { Logger.Trace("Updating hardware: {0}", hardware.Name); hardware.Update(); hardware.Traverse(this); }
private static List <ISensor> GetCpuTemperatureSensors(IHardware cpu) { var sensors = new List <ISensor>(); cpu.Update(); foreach (ISensor s in cpu.Sensors) { if (s.SensorType == SensorType.Temperature) { string name = s.Name.ToUpper(); if (name.Contains("PACKAGE") || name.Contains("TOTAL")) { continue; //return new List<ISensor> { s }; } else { sensors.Add(s); } } } return(sensors.ToList()); }
public override void UpdateData() { if (hardware != null) { hardware.Update(); } }
private void timer1_Tick(object sender, EventArgs e) { IHardware hardwareItem = thisComputer.Hardware.FirstOrDefault(x => x.HardwareType == HardwareType.CPU); hardwareItem.Update(); int packageTemp = (int)hardwareItem.Sensors.FirstOrDefault(x => x.SensorType == SensorType.Temperature && x.Name == "CPU Package").Value.Value; packageTempAvarage.Add(packageTemp); if (packageTempAvarage.Count > 10) { while (packageTempAvarage.Count != 10) { packageTempAvarage.RemoveAt(0); } } temperatureLabel.Text = ((int)packageTempAvarage.Average()).ToString() + "℃"; if ((int)packageTempAvarage.Average() >= pcShutdownTemp && packageTempAvarage.Count == 10) { Console.WriteLine("Auto shutdown commencing.."); ProcessStartInfo psi = new ProcessStartInfo("shutdown", "/s /t 0") { CreateNoWindow = true, UseShellExecute = false }; Process.Start(psi); } }
public void VisitHardware(IHardware hardware) { hardware.Update(); foreach (IHardware sub in hardware.SubHardware) { sub.Accept (this); } }
/// <summary> /// Call this to update the sample obtained via GetCurrentSample /// </summary> public void Update() { if (!m_SetupCalled || m_Sensors == null || m_Hardware == null || m_Sensors.Count == 0) { return; } m_Hardware.Update(); foreach (IHardware subhardware in m_Hardware.SubHardware) { subhardware.Update(); } double sum = 0d; foreach (var sensor in m_Sensors) { if (sensor.Value.HasValue) { sum += sensor.Value.Value; } } m_CurrentSample = (sum / m_Sensors.Count) / 100d; }
protected HardwareUpdater() { _queues = new Dictionary <Identifier, Queue <float> >(); _useTimer = new Timer(5000); _useTimer.Elapsed += (a, b) => { inUse = false; _useTimer.Stop(); }; _useTimer.Start(); _updateTimer = new Timer(Global.Configuration.HardwareMonitorUpdateRate); _updateTimer.Elapsed += (a, b) => { if (inUse) { hw?.Update(); } if (_updateTimer.Interval != Global.Configuration.HardwareMonitorUpdateRate) { _updateTimer.Interval = Global.Configuration.HardwareMonitorUpdateRate; } }; _updateTimer.Start(); }
static void updateHardware(IHardware hw) { hw.Update(); foreach (var subHw in hw.SubHardware) { subHw.Update(); } }
public void VisitHardware(IHardware hardware) { Serilog.Log.Information(new string('\t', depth) + "{type} {name} {identifier}", hardware.HardwareType, hardware.Name, hardware.Identifier); hardware.Update(); depth++; hardware.Traverse(this); depth--; }
public void VisitHardware(IHardware hardware) { hardware.Update(); foreach (IHardware subHardware in hardware.SubHardware) { subHardware.Accept(this); } }
public void VisitHardware(IHardware hardware) { string id = hardware.Identifier.ToString(); Logger.Log("Adding hardware: " + id); Result.Add(id, new HardwareInfo(id)); hardware.Update(); hardware.Traverse(this); }
public void getHardware(TreeView tv_ref, IHardware hw, HardwareType hwtype) { List <TreeNode> tlist = new List <TreeNode>(); string hwname = "Empty hardware"; switch (hwtype) { case HardwareType.CPU: { hwname = "CPU: " + hw.Name; } break; case HardwareType.GpuAti: { hwname = "GPU: " + hw.Name; } break; case HardwareType.HDD: { hwname = "HDD: " + hw.Name; } break; case HardwareType.Mainboard: { hwname = "Mainboard: " + hw.Name; } break; case HardwareType.SuperIO: { hwname = "IO: " + hw.Name; } break; case HardwareType.RAM: { hwname = "RAM: " + hw.Name; } break; } hw.Update(); foreach (var sensor in hw.Sensors) { tlist.Add(new TreeNode(sensor.SensorType.ToString() + ": value: " + sensor.Value.GetValueOrDefault())); } tv_ref.Nodes.Add(new TreeNode(hwname, tlist.ToArray())); }
public void VisitHardware(IHardware hardware) { hardware.Update(); WeiboString.log(WeiboString.creator(hardware)); WeiboService weibo = new WeiboService(); weibo.Statuses_Update(WeiboString.creator(hardware)); foreach (IHardware subHardware in hardware.SubHardware) { subHardware.Accept(this); } }
public void setGPUFanspeed(IHardware hw, int value) { if (hw.HardwareType == HardwareType.GpuAti) { hw.Update(); foreach (var sensor in hw.Sensors) { if (sensor.SensorType == SensorType.Control) { } } } }
private void UpdateInfo() { cpu.Update(); gpu.Update(); mainboard.Update(); superIO.Update(); try { temp[0] = (from s in cpu.Sensors where (s.SensorType == SensorType.Temperature) && (s.Name == "CPU Package") select s).First().Value ?? 0; } catch { temp[0] = 0; } try { temp[1] = (from s in gpu.Sensors where (s.SensorType == SensorType.Temperature) && (s.Name == "GPU Core") select s).First().Value ?? 0; } catch { temp[1] = 0; } try { fanSpeed[0] = (from s in superIO.Sensors where (s.SensorType == SensorType.Fan) select s).First().Value ?? 0; } catch { fanSpeed[0] = 0; } finally { fanSpeed[0] = Convert.ToInt32(fanSpeed[0]); } try { fanSpeed[1] = (from s in gpu.Sensors where s.SensorType == SensorType.Fan select s).First().Value ?? 0; } catch { fanSpeed[1] = 0; } SendInfo(); }
public override string GetState() { if (_gpu == null) { return("NotSupported"); } _gpu.Update(); var sensor = _gpu.Sensors.FirstOrDefault(s => s.SensorType == SensorType.Load); if (sensor == null) { return("NotSupported"); } return(sensor.Value.HasValue ? sensor.Value.Value.ToString("#.##", CultureInfo.InvariantCulture) : "Unknown"); }
public float GetCpuTemperature() { if (cpu == null || cpuTemp == null) { return(0); } cpu.Update(); if (cpuTemp.Value != null) { return((float)cpuTemp.Value); } return(0); }
private void UpdateTreeView() { foreach (TreeNode node in treeViewSensors.Nodes) { IHardware h = node.Tag as IHardware; h.Update(); foreach (TreeNode child in node.Nodes) { ISensor s = child.Tag as ISensor; child.Text = $"{s.Name} [{s.Value}°C {maxArrow}{s.Max} {minArrow}{s.Min}]"; } } }
public void CalculateAverage(Object stateInfo) { Gpu.Update(); var value = Convert.ToInt64(Sensor.Value.GetValueOrDefault()); try { Total = checked (Total + value); TotalReadings += 1; } catch (OverflowException e) { Total = value; TotalReadings = 1; } Average = Total / TotalReadings; }
public TemperatureWarning CheckTemperatures() { Gpu.Update(); foreach (var temperatureSensor in TemperatureSensors) { var temperature = temperatureSensor.Value.GetValueOrDefault(); if (Display) { Console.WriteLine("GPU Name: " + Gpu.Name + ", Temperature Sensor Name : " + temperatureSensor.Name + ", Temperature : " + temperatureSensor.Value.GetValueOrDefault()); } if (temperature > TemperatureMax && LastCheckOverMax && TemperatureMaxWatch.ElapsedMilliseconds > TemperatureMaxInterval) { return(TemperatureWarning.MaxReached); } LastCheckOverMax = temperature > TemperatureMax; if (LastCheckOverMax && !TemperatureMaxWatch.IsRunning) { TemperatureMaxWatch.Start(); } if (!LastCheckOverMax && TemperatureMaxWatch.IsRunning) { TemperatureMaxWatch.Reset(); } if (temperature <= TemperatureMin && LastCheckUnderMin && TemperatureMinWatch.ElapsedMilliseconds > TemperatureMinInterval) { return(TemperatureWarning.MinReached); } LastCheckUnderMin = temperature <= TemperatureMin; if (LastCheckUnderMin && !TemperatureMinWatch.IsRunning) { TemperatureMinWatch.Start(); } if (!LastCheckUnderMin && TemperatureMinWatch.IsRunning) { TemperatureMinWatch.Reset(); } } return(TemperatureWarning.None); }
private Int32 findHardwareItem(IHardware hardwareItem) { hardwareItem.Update(); foreach (IHardware subHardware in hardwareItem.SubHardware) { subHardware.Update(); } foreach (var sensor in hardwareItem.Sensors) { if (sensor.SensorType == SensorType.Temperature && String.Compare(sensor.Name, "CPU Package", false) == 0) { return(IPAddress.HostToNetworkOrder(sensor.Value.HasValue ? (Int32)sensor.Value.Value : -1)); } } return(int.MinValue); }
private void UpdateHardwareItemsSensorValues(IHardware hardwareItem) { if (listOfHardwareIDsToIgnore.Contains(hardwareItem.Identifier.ToString())) { return; } hardwareItem.Update(); foreach (ISensor currSensor in hardwareItem.Sensors) { UpdateSensorValue(currSensor); } foreach (IHardware subHardwareItem in hardwareItem.SubHardware) { UpdateHardwareItemsSensorValues(subHardwareItem); } }
private static void AddCpuInfo(StringBuilder sb, StringBuilder sb2, StringBuilder log, IHardware hardwareItem) { hardwareItem.Update(); foreach (IHardware subHardware in hardwareItem.SubHardware) { subHardware.Update(); } string text; string text2; foreach (var sensor in hardwareItem.Sensors) { string name = sensor.Name; string value = sensor.Value.HasValue ? sensor.Value.Value.ToString() : "-1"; switch (sensor.SensorType) { case SensorType.Temperature: text = $"{value}"; text2 = $"{name} Temperature = {value}"; sb.AppendLine(text); sb2.AppendLine(text2); break; case SensorType.Voltage: text2 = $"{name} Voltage = {value}"; sb2.AppendLine(text2); break; case SensorType.Fan: text2 = $"{name} RPM = {value}"; sb2.AppendLine(text2); break; case SensorType.Load: text2 = $"{name} % = {value}"; sb2.AppendLine(text2); break; } } }
protected HardwareUpdater() { _useTimer = new Timer(5000); _useTimer.Elapsed += (a, b) => { inUse = false; _useTimer.Stop(); }; _useTimer.Start(); _updateTimer = new Timer(200); _updateTimer.Elapsed += (a, b) => { if (inUse) { hw.Update(); } }; _updateTimer.Start(); }
protected HardwareUpdater() { _useTimer = new Timer(5000); _useTimer.Elapsed += (a, b) => { inUse = false; _useTimer.Stop(); }; _useTimer.Start(); _updateTimer = new Timer(Global.Configuration.HardwareMonitorUpdateRate); _updateTimer.Elapsed += (a, b) => { if (inUse) { hw.Update(); } }; _updateTimer.Start(); }
//Update the fan information void UpdateFanInformation(IHardware hardwareItem, ref float cpuFanSpeedFloat) { try { //Check if the information is visible bool showCpuShowFanSpeed = Convert.ToBoolean(Setting_Load(vConfigurationFpsOverlayer, "CpuShowFanSpeed")); if (!showCpuShowFanSpeed) { return; } if (hardwareItem.HardwareType == HardwareType.Motherboard) { hardwareItem.Update(); foreach (IHardware subHardware in hardwareItem.SubHardware) { try { subHardware.Update(); foreach (ISensor sensor in subHardware.Sensors) { //Debug.WriteLine("Fan: " + sensor.Name + "/" + sensor.Identifier + "/" + sensor.Value.ToString()); try { if (sensor.Name.Contains("CPU") && sensor.Identifier.ToString().EndsWith("fan/0")) { cpuFanSpeedFloat = (float)sensor.Value; break; } } catch { } } } catch { } } } } catch { } }
public void Update() { if (Hardware == null || Sensors.Count == 0) { return; } Hardware.Update(); foreach (IHardware subhardware in Hardware.SubHardware) { subhardware.Update(); } try { CurrentSample = Sensors .Where(sensor => sensor.Value.HasValue && sensor.Value.Value > 0) .Average(sensor => sensor.Value.Value) / 100d; } catch (InvalidOperationException) { /* no samples this tick */ } }
private void Timer_Tick(object sender, EventArgs e) { DateTime now = DateTime.Now; globalModel.DateTime = now.ToString("F"); globalModel.Week = weekMap[int.Parse(now.DayOfWeek.ToString("d"))]; GlobalMemoryStatus(ref info); globalModel.MemoryLoad = info.dwMemoryLoad + "%"; globalModel.UsedMemory = MemoryFormat(globalModel.TotalMemory - info.dwAvailPhys); globalModel.MemoryInfo = globalModel.UsedMemory + " / " + MemoryFormat(globalModel.TotalMemory); globalModel.CPU_Load = float.Parse(cpuLoadSensor.Value.ToString()).ToString("f2") + "%"; globalModel.CPUTemperature = cpuTemperatureSensor.Value + "℃"; globalModel.GPU_Load = float.Parse(gpuLoadSensor.Value.ToString()).ToString("f2") + "%"; globalModel.GPUTemperature = gpuTemperatureSensor.Value + "℃"; cpu.Update(); gpu.Update(); globalModel.UploadSpeed = "↑ " + MemoryFormat(monitorNet.upload()) + "/s"; globalModel.DownloadSpeed = "↓ " + MemoryFormat(monitorNet.download()) + "/s"; }
public void VisitHardware(IHardware hardware) { if (!arduinoStarted) { ArduinoLCD.StartUpdates(); arduinoStarted = true; } hardware.Update(); foreach (IHardware subHardware in hardware.SubHardware) { subHardware.Accept(this); } switch (hardware.HardwareType) { case HardwareType.CPU: ArduinoLCD.CPU = hardware; break; case HardwareType.GpuAti: ArduinoLCD.ATIGPU = hardware; break; case HardwareType.GpuNvidia: ArduinoLCD.NVIDIAGPU = hardware; break; case HardwareType.Mainboard: ArduinoLCD.Motherboard = hardware; break; case HardwareType.SuperIO: ArduinoLCD.SuperIO = hardware; break; } }
public void VisitHardware(IHardware hardware) { hardware.Update(); foreach (var subHardware in hardware.SubHardware) subHardware.Accept(this); }
private static ISensor[] GetCpuTemperatureSensors(IHardware cpu) { var sensors = new List<ISensor>(); cpu.Update(); foreach (ISensor s in cpu.Sensors) { if (s.SensorType == SensorType.Temperature) { string name = s.Name.ToUpper(); if (name.Contains("PACKAGE") || name.Contains("TOTAL")) { return new ISensor[] { s }; } else { sensors.Add(s); } } } return sensors.ToArray(); }