Syntax
public abstract class AnalogSamplingBase : SamplingSensorBase<Voltage>, IObservable<IChangeResult<Voltage>>, ISamplingSensor<Voltage>, ISensor<Voltage>
Constructors
AnalogSamplingBase(IAnalogInputPort)
Creates a new AnalogObservableBase driver
Declaration
public AnalogSamplingBase(IAnalogInputPort port)
Parameters
Type | Name | Description |
---|---|---|
IAnalogInputPort | port | analog input port |
AnalogSamplingBase(IPin, int, TimeSpan?, Voltage?)
Creates a new AnalogObservableBase driver
Declaration
public AnalogSamplingBase(IPin pin, int sampleCount = 5, TimeSpan? sampleInterval = null, Voltage? voltage = null)
Parameters
Type | Name | Description |
---|---|---|
IPin | pin | AnalogChannel connected to the sensor. |
int | sampleCount | Number of sample to average for a reading |
TimeSpan? | sampleInterval | Time between intervals |
Voltage? | voltage | Max voltage of analog port |
Properties
Voltage
Current voltage
Declaration
public Voltage Voltage { get; protected set; }
Property Value
Type | Description |
---|---|
Voltage |
Methods
ReadSensor()
Convenience method to get the current voltage
Declaration
protected override Task<Voltage> ReadSensor()
Returns
Type | Description |
---|---|
Task<Voltage> | A float value that represents the current voltage |
Overrides
StartUpdating(TimeSpan?)
Starts continuously sampling the sensor.
This method also starts raising Changed
events and IObservable
subscribers getting notified. Use the readIntervalDuration
parameter
to specify how often events and notifications are raised/sent.
Declaration
public override void StartUpdating(TimeSpan? updateInterval)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan? | updateInterval | A |
Overrides
StopUpdating()
Stops sampling the sensor
Declaration
public override void StopUpdating()