Class Switch<TLine>
A two-state output over any line, with its polarity said once: a relay, an LED, a
solenoid valve, a buzzer. Set(true) asserts it, which drives the line low for
an active-low part, so no call site inverts a level by hand.
public sealed class Switch<TLine> where TLine : IOutputLine
Type Parameters
TLineThe line the part is wired to.
- Inheritance
-
Switch<TLine>
- Inherited Members
Constructors
Switch(TLine, PinPolarity)
Wraps a line, starting deasserted. Nothing is driven until Set(bool).
public Switch(TLine line, PinPolarity polarity)
Parameters
lineTLineThe line the part is wired to.
polarityPinPolarityHow the part is wired.
Properties
IsAsserted
Whether the part was last set on.
public bool IsAsserted { get; }
Property Value
Polarity
How the part is wired.
public PinPolarity Polarity { get; }
Property Value
Methods
Release()
Hands the line back, for a test to read what was driven or a program to reuse it.
public TLine Release()
Returns
- TLine
The line.
Set(bool)
Turns the part on or off, driving whichever level that means for its wiring.
public void Set(bool asserted)
Parameters
assertedbooltrueto turn it on.
Exceptions
- Exception
Whatever the line throws when it cannot be driven.