|
Treehopper C# API
|
Polls an IPollable device at a regular rate More...
Public Member Functions | |
| delegate void | NewSensorValueEventHandler (object sender, EventArgs e) |
| The signature of the callback to use with the OnNewSensorValue event More... | |
| Poller (TPollable sensor, int samplePeriod=10, bool usePrecisionTimer=false) | |
| Construct a new Poller for the given sensor More... | |
| void | Dispose () |
| Stops the sampling thread safely and closes resources More... | |
Properties | |
| TPollable | Sensor [get] |
| The underlying sensor that is polled by this instance More... | |
Events | |
| PropertyChangedEventHandler | PropertyChanged |
| Fires whenever the sensor value is updated More... | |
| NewSensorValueEventHandler | OnNewSensorValue |
| Fires whenever the sensor value is updated More... | |
Polls an IPollable device at a regular rate
| TPollable | The IPollable device to poll |
While simple devices (such as temperature sensors) can simply auto-update whenever the relevant properties are read from, it is often useful to continuously update these values on a background thread so that the IPollable device can fire events. This is especially true for GPIO port expanders used as inputs in event-driven programming.
Since this class implements INotifyPropertyChanged, WPF and XAML applications can bind directly to properties of the underlying sensor in this class, and GUI controls will be automatically updated
| TPollable | : | IPollable |
| Poller | ( | TPollable | sensor, |
| int | samplePeriod = 10, |
||
| bool | usePrecisionTimer = false |
||
| ) |
Construct a new Poller for the given sensor
| sensor | The sensor to construct a Poller for |
| samplePeriod | The sample period, in milliseconds, to poll this sensor at |
| usePrecisionTimer | Whether to use a (CPU-heavy) precision timer |
When usePrecisionTimer is set to true, a busy-wait timer will be used. All things considered, this provides for relatively precise timing (even given USB latencies, there is often less than 100 microseconds of jitter), but this will cause dramatic increases in CPU usage. We recommend enabling this only in scenarios where you absolutely need low-jitter sampling.
| delegate void NewSensorValueEventHandler | ( | object | sender, |
| EventArgs | e | ||
| ) |
The signature of the callback to use with the OnNewSensorValue event
| sender | The Poller where this call originated from |
| e | An empty EventArgs |
| void Dispose | ( | ) |
Stops the sampling thread safely and closes resources
|
get |
The underlying sensor that is polled by this instance
| PropertyChangedEventHandler PropertyChanged |
Fires whenever the sensor value is updated
| NewSensorValueEventHandler OnNewSensorValue |
Fires whenever the sensor value is updated