NOTE: THIS DOCUMENTATION AND THE CODE IS STILL BEING BUILT. USE AT YOUR OWN RISK, BUT FOR NOW WE SUGGEST YOU AVOID DOWNLOADING THIS.
The WattsUpComponent is a component that interfaces with the WattsUp Pro USB device, This device lets one plug in household things into it (e.g., lamps, fridges, powerbars with many things attached to it, etc.). It measures power use, and returns a variety of readings - the most importnat which is the # of watts being consumed. As a USB devices, one can set the WattsUp Pro to send this data to the computer.
This component is a wrapper around the WattsUp Pro API. In essence, one can set sampling rates and various other options, start sampling the device, and get various readings back as an event. It is implemented as a drag and drop component that allows the programmer to access various properties and events from the Visual Studio Properties window.
Download and Installation
- NOTE: THIS DOCUMENTATION AND THE CODE IS STILL BEING BUILT. USE AT YOUR OWN RISK, BUT FOR NOW WE SUGGEST YOU AVOID DOWNLOADING THIS
- WattsUpComponent-1.0.zip. Download / unzip the WattsUp Component package (includes example).
Properties affecting the sampling rate.
There are four interacting properties that determine how the component will raise events giving you the latest data reading. The InternalSamplingRate determines how often the WattsUpPro returns a sample to the component. The component will then use calculations over these samples to determine when it should raise an event to your program. Next, the SamplingRate is the minimum sampling rate that your program wants the component to return as an event; for example, if its set to (say) 5, it will raise an event every 5 seconds (this assumes that the SamplingRate is greater than the Internal SamplingRate). The WattsThreshold is a threshold where the component compares the current sample against the last sample raised as an event; if it differs by more than the threshold amout, then an event is raised regardless of the SamplingRate. One can turn this thresholding on or off by setting the UseWattsDelta boolean property.
For example, lets say InternalSamplingRate is 1 second, SamplingRate is 5 seconds, and UseWattsDelta is 5. lets also look at around 12 seconds of time. The component will read 12 samples in 12 seconds. The first reading will be raised as an event, and then (if the wattage has not changed by more than 5) the 6th reading and 11th reading. On the other hand, lets say you flipped on a lamp attached to the WattsUp at time 7. The increased wattage use will be more than a threshold, so you will likely get a new event at time 7, and maybe even time 8 as the wattage stabilizes. Thus you can play with these values to give yourself a high sampling rate, but to minimize event processing (and perhaps screen redraws) if there is no significant change detected between readings.
- int InternalSamplingRate
- The interval in seconds that this class should internally sample the WattsUp Pro (between 1 and 3600). That is, if the InternalSamplingRate was set to (say) 1, the component configures the WattsUp Pro to return a new reading to the component every second.
- int SamplingRate
- The interval in seconds that we should raise an event, where we return the most recent reading (between 1 and 3600).
- int myWatttsThreshold
- This threshold will be compared to the difference in watts between the current watt reading and the last watts reading raised as an event.
- bool UseWattsDelta
- Use thresholding if true, and don't use it if false.
- string myPort
- The COM Port that the WattsUp Pro is connected to. While the WattsUp is a USB device, it is configured to appear as a COM Serial Port. You just need to know which port it appears as.
- bool Start()
- Connect to the WattsUp and start recording. Returns true on success, else false
- bool Stop()
- Stop recording of data and disconnect from the WattsUp. Return true if successful.
- string GetReading()
- Read the Watts Up. Returns "" if no reading is available, or if cannot do it. Note that you shouldn't have to do this call as readings are raised as events. I just include it mostly for debugging
- string GetVersion()
- Get the version of WattsUp device. Returns "" if we can't get it. Note that you shouldn't have to do this call as readings are raised as events. I just include it mostly for debugging.
- Event invoked whenever a new reading arrives from the WattsUp.
- The event handler has the form XX_OnWuReading(object sender, WuReadingEventArgs e) .
- More importantly, the e argument will have a property called e.wuData (see below) which gives access to all the data returned by the WattsUp Pro.
- DateTime Time
- double Watts
- string Record
- This is the actual raw data returned by the WattsUp Pro. Included here for debuggin.