Characteristic Locus
Inheritance System.Object ObservableBase<UNIT> > SensorBase<UNIT> > SamplingSensorBase<UNIT> > Gp2d12 > Hcsr04 > Hysrf05 > Mb10x0 > Sfsr02 > AnalogWaterLevel > AnalogJoystick > Alspt19315C > AnalogLightSensor > AnalogSolarGauge > Temt6000 > Capacitive > Fc28 > AnalogTemperature > WindVane
Inherited Members ObservableBase<UNIT>.observers ObservableBase<UNIT>.NotifyObservers(IChangeResult<UNIT>) ObservableBase<UNIT>.Subscribe(IObserver<IChangeResult<UNIT>>) ObservableBase<UNIT>.CreateObserver(Action<IChangeResult<UNIT>>, Nullable<Predicate<IChangeResult<UNIT>>>)
Namespace Meadow.Foundation
Assembly Meadow.Foundation.dll

Syntax

public abstract class SensorBase<UNIT> : ObservableBase<UNIT> where UNIT : struct

Type Parameters

Name Description
UNIT

Fields

samplingLock

Declaration
protected object samplingLock

Field Value

Type Description
System.Object

Properties

Conditions

The last read conditions.

Declaration
public UNIT Conditions { get; protected set; }

Property Value

Type Description
UNIT

IsSampling

Gets a value indicating whether the sensor is currently in a sampling loop. Call StartSampling() to spin up the sampling process.

Declaration
public bool IsSampling { get; protected set; }

Property Value

Type Description
System.Boolean

true if sampling; otherwise, false.

SamplingTokenSource

Declaration
protected CancellationTokenSource? SamplingTokenSource { get; set; }

Property Value

Type Description
System.Nullable<CancellationTokenSource>

UpdateInterval

A TimeSpan that specifies how long to wait between readings. This value influences how often *Updated events are raised and IObservable consumers are notified.

Declaration
public virtual TimeSpan UpdateInterval { get; protected set; }

Property Value

Type Description
TimeSpan

Methods

RaiseEventsAndNotify(IChangeResult<UNIT>)

Declaration
protected virtual void RaiseEventsAndNotify(IChangeResult<UNIT> changeResult)

Parameters

Type Name Description
IChangeResult<UNIT> changeResult

Read()

Convenience method to get the current sensor readings. For frequent reads, use StartSampling() and StopSampling() in conjunction with the SampleBuffer.

Declaration
public virtual Task<UNIT> Read()

Returns

Type Description
Task<UNIT>

ReadSensor()

Declaration
protected abstract Task<UNIT> ReadSensor()

Returns

Type Description
Task<UNIT>

Events

Updated

Declaration
public event EventHandler<IChangeResult<UNIT>> Updated

Event Type

Type Description
EventHandler<IChangeResult<UNIT>>