Class SerialWombatBase.AnalogInputPort
Represents a serial wombat analog input port
Assembly: SerialWombat.dll
View Source
public class SerialWombatBase.AnalogInputPort : AnalogPortBase, IAnalogInputPort, IAnalogPort, IPort<IAnalogChannelInfo>, IDisposable, IObservable<IChangeResult<Voltage>>
Inheritance: System.Object
-> Meadow.Hardware.PortBase<Meadow.Hardware.IAnalogChannelInfo>
-> Meadow.Hardware.AnalogPortBase
Implements:
Meadow.Hardware.IAnalogInputPort
, Meadow.Hardware.IAnalogPort
, Meadow.Hardware.IPort<Meadow.Hardware.IAnalogChannelInfo>
, System.IDisposable
, System.IObservable<Meadow.IChangeResult<Meadow.Units.Voltage>>
Properties
Observers
Collection of event Observers for the Updated event
View Source
protected List<IObserver<IChangeResult<Voltage>>> Observers { get; set; }
IsSampling
Is the port sampling
View Source
public bool IsSampling { get; protected set; }
Voltage
Current port voltage
View Source
public Voltage Voltage { get; }
ReferenceVoltage
Port reference voltage
View Source
public Voltage ReferenceVoltage { get; }
SampleCount
The sample count
View Source
public int SampleCount { get; }
UpdateInterval
The update interval
View Source
public TimeSpan UpdateInterval { get; }
VoltageSampleBuffer
The voltage sampling buffer
View Source
public Voltage[] VoltageSampleBuffer { get; }
SampleInterval
The sampling interval
View Source
public TimeSpan SampleInterval { get; }
Methods
Read()
Take a reading
View Source
public Task<Voltage> Read()
Returns
System.Threading.Tasks.Task<Meadow.Units.Voltage>
StartUpdating(TimeSpan?)
Start updating
View Source
public void StartUpdating(TimeSpan? updateInterval = null)
Parameters
Type | Name |
---|---|
System.Nullable<System.TimeSpan> | updateInterval |
StopUpdating()
Stop updating the port
View Source
public void StopUpdating()
RaiseChangedAndNotify(IChangeResult<Voltage>)
Raise change events for subscribers
View Source
protected void RaiseChangedAndNotify(IChangeResult<Voltage> changeResult)
Parameters
Type | Name | Description |
---|---|---|
Meadow.IChangeResult<Meadow.Units.Voltage> | changeResult | The change result with the current sensor data |
Subscribe(IObserver<IChangeResult<Voltage>>)
Subscribe an observer for update events
View Source
public IDisposable Subscribe(IObserver<IChangeResult<Voltage>> observer)
Returns
System.IDisposable
Parameters
Type | Name |
---|---|
System.IObserver<Meadow.IChangeResult<Meadow.Units.Voltage>> | observer |
Events
Updated
Raised when the port voltage value changes
View Source
public event EventHandler<IChangeResult<Voltage>> Updated
Event Type
System.EventHandler<Meadow.IChangeResult<Meadow.Units.Voltage>>
Implements
Meadow.Hardware.IAnalogInputPort
Meadow.Hardware.IAnalogPort
Meadow.Hardware.IPort<Meadow.Hardware.IAnalogChannelInfo>
System.IDisposable
System.IObservable<Meadow.IChangeResult<Meadow.Units.Voltage>>