I'm writing a plugin to read sensor data from the Open Hardware Monitor (OHM) application and am thinking about update efficiency issues. In some cases, there could be a lot of measure's using the same OHM app. I'm wondering what the best way to read/refresh the data from OHM is. The data comes from a windows WMI call. It seems like (no actual measurements) it should be more efficient to read all the sensors in a single call and then have the different measures just read their values from a data structure vs. having a WMI call get made for each sensor.
Some ideas:
- brute force. Make a WMI call for each update() call made to the plugin.
- If I knew what the update interval was for each measure, I could make a WMI call for the shortest one and then just have each update() call return the value that was read at the last update.
- In theory I could have a background thread that updates the sensor values at some interval and the meters would just read from them (this seems unnecessarily complicated).
- Internal update interval. The AdvancedCPU plugin checks it's own internal update clock and only updates values every 0.5 seconds. This seems like the simplest way to improve efficiency - make a single call to read every sensor value at some internal interval.
Any thoughts on the "right" way to do things would be greatly appreciated...
Ted
It is currently April 19th, 2024, 3:52 pm
Best practice for controlling plugin update times?
-
- Posts: 30
- Joined: February 2nd, 2011, 2:19 am
-
- Developer
- Posts: 2872
- Joined: April 17th, 2009, 12:18 pm
Re: Best practice for controlling plugin update times?
In this case, I think an internal update rate makes most sense. Perhaps once per second or maybe even slower is sufficient. If a user wants to improve efficiency, they can change the global Update= and/or add UpdateDivider= to all OHM measures.
I PM'd our local C++ wizard, let's see what he thinks.
I PM'd our local C++ wizard, let's see what he thinks.
-
- Developer
- Posts: 318
- Joined: July 14th, 2009, 5:57 pm
Re: Best practice for controlling plugin update times?
Personally I would go with option 4, the internal update rate, that is the one i was using in something I was working on.
I would be interested to see what spx says though
I would be interested to see what spx says though
+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
Quis custodiet ipsos custodes?
-
- Developer
- Posts: 686
- Joined: August 15th, 2009, 2:41 pm
- Location: Osaka, JPN
Re: Best practice for controlling plugin update times?
I agree "internal update interval", too. It would fit the purpose.
-
- Posts: 30
- Joined: February 2nd, 2011, 2:19 am
Re: Best practice for controlling plugin update times?
OK - Thanks everyone.
Another question (since I have all this developer attention) - how do I include/use STL constructs in a plugin? I'm running VS C++ express 2008. If I build the example plugin, it builds fine. If I add a line:
#include <map>
after the other includes, I get a million errors when trying to build (shown below). I see there are plugins using STL includes but I can't figure out what the difference is between their setup and the example.
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
Another question (since I have all this developer attention) - how do I include/use STL constructs in a plugin? I'm running VS C++ express 2008. If I build the example plugin, it builds fine. If I add a line:
#include <map>
after the other includes, I get a million errors when trying to build (shown below). I see there are plugins using STL includes but I can't figure out what the difference is between their setup and the example.
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
-
- Developer
- Posts: 686
- Joined: August 15th, 2009, 2:41 pm
- Location: Osaka, JPN
Re: Best practice for controlling plugin update times?
Rename filename. (.c to .cpp)TD22057 wrote: Another question (since I have all this developer attention) - how do I include/use STL constructs in a plugin? I'm running VS C++ express 2008. If I build the example plugin, it builds fine. If I add a line:
#include <map>
after the other includes, I get a million errors when trying to build (shown below). I see there are plugins using STL includes but I can't figure out what the difference is between their setup and the example.
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
If file extension is ".c", VC treats as C language file.
-
- Posts: 30
- Joined: February 2nd, 2011, 2:19 am
Re: Best practice for controlling plugin update times?
Thanks. I knew it must be something simple like that.spx wrote: Rename filename. (.c to .cpp)
If file extension is ".c", VC treats as C language file.
Next question: I'm using Update2() since most of sensor value are floating point. I didn't implement a GetString function which from the docs is not necessary. However, when I try to import a skin, it gives me an error saying I need Update or GetString. What's the proper solution? Implement GetString() and convert the Update2 value to a string?
-
- Posts: 30
- Joined: February 2nd, 2011, 2:19 am
Re: Best practice for controlling plugin update times?
Never mind. When I switched it to C++ I forgot to add extern "c" around the exports.
-
- Posts: 30
- Joined: February 2nd, 2011, 2:19 am
Re: Best practice for controlling plugin update times?
Since I'm turning this into a general question thread, here's another one:
What's the best way to report error messages to the user? It's going to be pretty easy for some one using my plugin to misspell a sensor name and they won't get any data back. It would be nice if I could show an error dialog, message, etc when this happens. I have it configured to write something to the log file showing pass/fail, sensor values, etc but that seems like a pain to just debug a simple input problem.
What's the best way to report error messages to the user? It's going to be pretty easy for some one using my plugin to misspell a sensor name and they won't get any data back. It would be nice if I could show an error dialog, message, etc when this happens. I have it configured to write something to the log file showing pass/fail, sensor values, etc but that seems like a pain to just debug a simple input problem.
-
- Developer
- Posts: 2872
- Joined: April 17th, 2009, 12:18 pm
Re: Best practice for controlling plugin update times?
I'd go with a messagebox for erros and LSLog() for others. Something like this: http://code.google.com/p/rainmeter/source/browse/trunk/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp#134