morphyuno / open-hardware-monitor

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

Add documentation and simple samples for the Open Hardware Monitor Library #302

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Would it be possible to port some of the features of this awesome little 
utility to a DLL, i have not found any way for c# to detect my CPU temp, but 
this does it. i just don't want it running all the time D:

Doing this will broaden the audience to developers, and it will provide an 
easier way for you to maintain the GUI separate from the DLL

Original issue reported on code.google.com by Delusion...@gmail.com on 13 Dec 2011 at 10:53

GoogleCodeExporter commented 9 years ago
OHM already uses a DLL. The utility relies on it.

You can call the DLL from your code. See for instance: 
http://code.google.com/p/open-hardware-monitor/issues/detail?id=230

Original comment by pierrehu...@gmail.com on 4 Jan 2012 at 4:09

GoogleCodeExporter commented 9 years ago
The dll is relatively convoluted, and i have no idea how to get the temperature 
of a particular sensor. it seems like you have to keep track of all the sensors 
yourself, which is something i would expect the DLL (API thing) to do.

The snippet you provide is good in the sense that it gets you a report, and 
shows what is 100% needed to get the DLL running, but it doesn't show how to 
control the sensors.

Maybe documentation of the DLL or a simple example (maybe just getting the CPU 
temp) would be useful

Original comment by Delusion...@gmail.com on 7 Jan 2012 at 9:35

GoogleCodeExporter commented 9 years ago
Just take a look at the source code Delusional.

Original comment by Cre...@gmail.com on 11 Jan 2012 at 7:45

GoogleCodeExporter commented 9 years ago
Right now the API of the Open Hardware Monitor Library is not really fixed yet. 
So things might still change in the future, and investing a lot of time to 
document the current state is not really worth it (with the limited resources 
we have on this project).

The GUI project is a detailed example how one could use the library. There are 
also simple examples on how to keep track of the hardware and sensor in there. 
Look for example at the WMI, the gadget or the tray-icon parts of the code.

Some sensors or hardware might not be always available. That's why you need to 
keep track also as a user of the library on what is available. For the CPU 
temperature you can just send in a simple visitor class to search for the CPU 
hardware interface and then store a reference to the IHardware interface and to 
the core sensors (ISensor interface) you want to read. Call .Update() on the 
cpu hardware whenever you want new values and get the values from the sensor 
interface.

Original comment by moel.mich on 11 Jan 2012 at 8:29

GoogleCodeExporter commented 9 years ago
VB.NET - Source Code by Marco Cusano (Retrieve Name of Hardware)

FIRST:
Imports OpenHardwareMonitor
Imports OpenHardwareMonitor.Hardware

SECOND:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'Computer object
    Dim cp As New Computer()
    cp.Open()
    cp.HDDEnabled = True
    cp.RAMEnabled = True
    cp.GPUEnabled = True
    cp.MainboardEnabled = True
    cp.CPUEnabled = True
    '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
    Dim Info As String = ""
    For i As Integer = 0 To cp.Hardware.Count() - 1
        If cp.Hardware(i).HardwareType = HardwareType.Mainboard Then
            Info += " Scheda Madre: " & Trim(cp.Hardware(i).Name)
        End If
        If cp.Hardware(i).HardwareType = HardwareType.CPU Then
            Info += " Processore: " & Trim(cp.Hardware(i).Name)
        End If
        If cp.Hardware(i).HardwareType = HardwareType.GpuNvidia Then
            Info += " Scheda Video: " & Trim(cp.Hardware(i).Name)
        End If
        If cp.Hardware(i).HardwareType = HardwareType.RAM Then
            Info += " RAM: " & Trim(cp.Hardware(i).Name)
        End If
        If cp.Hardware(i).HardwareType = HardwareType.HDD Then
            Info += " HDD: " & Trim(cp.Hardware(i).Name)
        End If
        If cp.Hardware(i).HardwareType = HardwareType.SuperIO Then
            Info += " SuperIO: " & Trim(cp.Hardware(i).Name)
        End If
    Next
    MessageBox.Show(Trim(Info))
End Sub

Original comment by marco.cu...@gmail.com on 27 Jun 2013 at 5:58

GoogleCodeExporter commented 9 years ago
Issue 295 has been merged into this issue.

Original comment by moel.mich on 30 Jun 2013 at 5:45

GoogleCodeExporter commented 9 years ago
If you experience error with line:
For i As Integer = 0 To cp.Hardware.Count() - 1

error: count is not member of system.array

change it to:
For i As Integer = 0 To cp.Hardware.Length - 1

It worked for me.

Original comment by coldkeyb...@gmail.com on 12 Aug 2013 at 4:10

GoogleCodeExporter commented 9 years ago
Hi, The above code works perfect. Could you tell me how to fetch the other 
information like i want to fetch the CPU Temp, Voltage etc?

Original comment by amit.de...@gmail.com on 12 Feb 2014 at 8:40