Table of Contents

Interface IZ21CommandStation

Namespace
Z21.Core
Assembly
Z21.Client.dll

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

IZ21CommandFactory

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

locoAddress ushort
cvAddress ushort
timeout TimeSpan

Returns

Task<byte>

Exceptions

CvOperationTimeoutException

No result arrived within timeout.

CvShortCircuitException

The command station reported a short circuit.

ArgumentOutOfRangeException

timeout is 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

locoAddress ushort
cvAddress ushort
bitPosition byte

The 0-based bit position within the CV (0–7).

timeout TimeSpan

Returns

Task<bool>

Exceptions

CvOperationTimeoutException

No result arrived within timeout.

CvShortCircuitException

The command station reported a short circuit.

ArgumentOutOfRangeException

bitPosition exceeds 7, or timeout is 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

commands IZ21Command[]

Returns

Task

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

locoAddress ushort
cvAddress ushort
value byte
timeout TimeSpan

Returns

Task

Exceptions

CvOperationTimeoutException

The write could not be confirmed within timeout.

CvShortCircuitException

The command station reported a short circuit.

ArgumentOutOfRangeException

timeout is 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

locoAddress ushort
cvAddress ushort
bitPosition byte

The 0-based bit position within the CV (0–7).

bitValue bool
timeout TimeSpan

Returns

Task

Exceptions

CvOperationTimeoutException

The write could not be confirmed within timeout.

CvShortCircuitException

The command station reported a short circuit.

ArgumentOutOfRangeException

bitPosition exceeds 7, or timeout is not a positive, in-range duration.