Table of Contents

Interface IAddressCodec

Namespace
Z21.Core.Codecs
Assembly
Z21.Client.dll

Encodes and decodes locomotive and accessory addresses in the Z21 wire representation.

public interface IAddressCodec

Methods

CombineAccessoryAddress(byte, byte)

ushort CombineAccessoryAddress(byte lsb, byte msb)

Parameters

lsb byte
msb byte

Returns

ushort

CombineCvAddress(byte, byte)

Combines the high and low wire bytes of a CV address back into a CV address (0 = CV1).

ushort CombineCvAddress(byte msb, byte lsb)

Parameters

msb byte
lsb byte

Returns

ushort

CombineExtAccessoryAddress(byte, byte)

Maps the RCN-213 RawAddress wire bytes of an extended accessory decoder back to the user-facing address (RawAddress 4 = user address 1).

ushort CombineExtAccessoryAddress(byte lsb, byte msb)

Parameters

lsb byte
msb byte

Returns

ushort

EncodeAccessoryPomAddress(ushort, bool, byte)

Encodes an accessory decoder address for POM commands into the two wire bytes aaaaa / AAAACDDD. When wholeDecoder is true the CV refers to the whole decoder (CDDD = 0000); otherwise C = 1 and DDD = output.

(byte db1, byte db2) EncodeAccessoryPomAddress(ushort decoderAddress, bool wholeDecoder, byte output)

Parameters

decoderAddress ushort
wholeDecoder bool
output byte

Returns

(byte lsb, byte msb)

SplitAccessoryAddress(ushort)

(byte lsb, byte msb) SplitAccessoryAddress(ushort address)

Parameters

address ushort

Returns

(byte lsb, byte msb)

Exceptions

ArgumentOutOfRangeException

Thrown when address is smaller than 1.

SplitAddressBigEndian(ushort)

Splits an address into its big-endian wire bytes (most-significant byte first), as used by the LAN_GET/SET_LOCOMODE and LAN_GET/SET_TURNOUTMODE settings commands.

(byte msb, byte lsb) SplitAddressBigEndian(ushort address)

Parameters

address ushort

Returns

(byte lsb, byte msb)

SplitCvAddress(ushort)

Splits a CV address (0 = CV1) into its high and low wire bytes (no offset applied).

(byte msb, byte lsb) SplitCvAddress(ushort cvAddress)

Parameters

cvAddress ushort

Returns

(byte lsb, byte msb)

SplitExtAccessoryAddress(ushort)

Maps a user-facing extended accessory address (1-based) to its RCN-213 RawAddress wire bytes (user address 1 = RawAddress 4).

(byte lsb, byte msb) SplitExtAccessoryAddress(ushort address)

Parameters

address ushort

Returns

(byte lsb, byte msb)

Exceptions

ArgumentOutOfRangeException

Thrown when address is smaller than 1.

SplitLocoAddress(ushort)

(byte lsb, byte msb) SplitLocoAddress(ushort address)

Parameters

address ushort

Returns

(byte lsb, byte msb)

SplitPomCvAddress(ushort)

Splits a CV address (0 = CV1) for a POM (main-track) command into the two high MM option bits (folded into the DB3 option byte) and the CVAdr_LSB wire byte. POM addresses CVs through a 10-bit field, so only CV addresses 0..1023 (CV1..CV1024) are representable.

(byte cvHighBits, byte cvLsb) SplitPomCvAddress(ushort cvAddress)

Parameters

cvAddress ushort

Returns

(byte lsb, byte msb)

Exceptions

ArgumentOutOfRangeException

Thrown when cvAddress exceeds 1023.