royo2015 / open-hardware-monitor

Automatically exported from code.google.com/p/open-hardware-monitor
0 stars 0 forks source link

DLL Interfacing #342

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently it's a bit tricky trying to get the information needed from sensors 
when using the DLL.

What makes it difficult is that it's currently designed to let you loop through 
the sensors and display them all. It's a bit more complicated if you're trying 
to find a specific sensor, especially if you're coupling it with information 
retrieved from Windows' WMI classes.

Maybe add some wizardry to the interfacing to allow retrieving of sensor data 
from hardware information at run-time?

^ That probably makes no sense. Let me give some examples:
IHardware hardware = Computer.Hardware.GetHardware(hardwareName, hardwareIndex);
ISensor[] sensors = hardware.Sensors.GetSensors(SensorType);

Original issue reported on code.google.com by CJ.FixTh...@gmail.com on 19 Apr 2012 at 5:15

GoogleCodeExporter commented 9 years ago
I agree here. I would really like to see a easier way to interface with the 
Business layer.

Original comment by ZeroAvia...@gmail.com on 25 Jun 2012 at 7:02

GoogleCodeExporter commented 9 years ago
Well, if you're trying to find a specific device/sensor, below is a method that 
would get the average CPU clock speed from all cores:

//CPU Hardware Index
int CPU_HW_IDX = 0;

//Computer object
Computer cp = new Computer();

//Finds the Hardware index of the Processor
//This can be a method or can be put in your loading sequence
//For this example, we'll be using a method
private void Get_CPU_HW_IDX()
{
    for (int i = 0; i < cp.Hardware.Count(); i++)
    {
        if (cp.Hardware[i].HardwareType.ToString() == "")
        {
            CPU_HW_IDX = i;
        }
    }
}

//Gets Average CPU Clock speed
private double Get_CPUCLKSPD()
{
    int CoreCount = 0;
    int CoreClockSum = 0;

    for (int i = 0; i < cp.Hardware[CPU_HW_IDX].Sensors.Count(); i++)
    {
        if (cp.Hardware[CPU_HW_IDX].Sensors[i].SensorType.ToString() == "Clock" &&
            cp.Hardware[CPU_HW_IDX].Sensors[i].Name != "Bus Speed")
        {
            CoreCount++;
            CoreClockSum = Convert.ToInt32(CoreClockSum + (int)cp.Hardware[CPU_HW_IDX].Sensors[i].Value);
        }
    }

    return ((double)CoreClockSum / (double)CoreCount) / 1000; //Returns value in GHz
}

A "GetHardware" function could be made from this. Hope this helps.

Original comment by ztom...@gmail.com on 3 Oct 2012 at 10:36