Interface IZ21CommandStation
The Z21 command station: the protocol-agnostic capabilities plus a Z21-specific raw escape hatch for sending hand-built commands.
public interface IZ21CommandStation : ICommandStation, ILocoControl, IAccessoryControl, ITrackPowerControl, ISystemInfoProvider, IProgrammingControl, IFeedbackControl, IFastClockControl
- Inherited Members
Properties
Commands
Factory for building raw Z21 commands to pass to SendCommandsAsync(params IZ21Command[]).
IZ21CommandFactory Commands { get; }
Property Value
Methods
ReadPomCvAsync(ushort, ushort, TimeSpan)
Reads a CV of a locomotive decoder on the main track (POM), retrying while the decoder does not acknowledge, and returns the value. Requires RailCom; without it (or for an absent decoder) the read can only ever time out. The result is correlated by CV address only — the protocol's POM result carries no loco address — so do not run other CV operations on this station concurrently.
Task<byte> ReadPomCvAsync(ushort locoAddress, ushort cvAddress, TimeSpan timeout)
Parameters
Returns
Exceptions
- CvOperationTimeoutException
No result arrived within
timeout.- CvShortCircuitException
The command station reported a short circuit.
- ArgumentOutOfRangeException
timeoutis not a positive, in-range duration.
ReadPomCvBitAsync(ushort, ushort, byte, TimeSpan)
Reads a single bit of a CV of a locomotive decoder on the main track (POM) by reading the CV byte back (so it requires RailCom) and returning the value of the target bit.
Task<bool> ReadPomCvBitAsync(ushort locoAddress, ushort cvAddress, byte bitPosition, TimeSpan timeout)
Parameters
locoAddressushortcvAddressushortbitPositionbyteThe 0-based bit position within the CV (0–7).
timeoutTimeSpan
Returns
Exceptions
- CvOperationTimeoutException
No result arrived within
timeout.- CvShortCircuitException
The command station reported a short circuit.
- ArgumentOutOfRangeException
bitPositionexceeds 7, ortimeoutis not a positive, in-range duration.
SendCommandsAsync(params IZ21Command[])
Sends one or more raw commands in a single UDP packet.
Task SendCommandsAsync(params IZ21Command[] commands)
Parameters
commandsIZ21Command[]
Returns
WritePomCvAsync(ushort, ushort, byte, TimeSpan)
Writes a CV of a locomotive decoder on the main track (POM). Because a POM write returns no acknowledgement, this verifies by reading the CV back and retrying until the read-back matches the written value (so it requires RailCom). A decoder that never reads back the written value is reported as a timeout. Do not run other CV operations on this station concurrently.
Task WritePomCvAsync(ushort locoAddress, ushort cvAddress, byte value, TimeSpan timeout)
Parameters
Returns
Exceptions
- CvOperationTimeoutException
The write could not be confirmed within
timeout.- CvShortCircuitException
The command station reported a short circuit.
- ArgumentOutOfRangeException
timeoutis not a positive, in-range duration.
WritePomCvBitAsync(ushort, ushort, byte, bool, TimeSpan)
Writes a single bit of a CV of a locomotive decoder on the main track (POM). Because a POM write returns no acknowledgement, this verifies by reading the CV byte back and retrying until the target bit matches the written value (so it requires RailCom). A bit that never reads back is reported as a timeout. Do not run other CV operations on this station concurrently.
Task WritePomCvBitAsync(ushort locoAddress, ushort cvAddress, byte bitPosition, bool bitValue, TimeSpan timeout)
Parameters
locoAddressushortcvAddressushortbitPositionbyteThe 0-based bit position within the CV (0–7).
bitValuebooltimeoutTimeSpan
Returns
Exceptions
- CvOperationTimeoutException
The write could not be confirmed within
timeout.- CvShortCircuitException
The command station reported a short circuit.
- ArgumentOutOfRangeException
bitPositionexceeds 7, ortimeoutis not a positive, in-range duration.