Package jmri.jmrix.dcc4pc
Class Dcc4PcRawDecoder
java.lang.Object
jmri.jmrix.dcc4pc.Dcc4PcRawDecoder
Decodes the Raw RailCom encoding of a DCC4PC RailCom reader (Omnibus
specification section 9.3). Each packet gives one DCC packet the reader saw,
the state of every enabled input and the RailCom bytes each input with
RailCom data received in the cutout that followed.
The encoding is stateful: type 1 packets carry no input states and inherit them from the packet before, and the number of duplicate-flag and length bytes that follow depends on those states. RailCom data may also be sent as "duplicate of the 1st, 2nd or 3rd previous" for an input. The decoder therefore only works on an unbroken stream that starts right after a Reset Encoding State, which sets every input to unoccupied. A Get Data reply may end part way through a packet; the leftover bytes are kept and joined to the next reply.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRailCom bytes for one input.static enumstatic classOne decoded packet. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe reader's output buffer overflowed and packets were lost here.static final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
STATE_UNOCCUPIED
- See Also:
-
STATE_OCCUPIED
- See Also:
-
STATE_ORIENTATION_A
- See Also:
-
STATE_ORIENTATION_B
- See Also:
-
OVERFLOW
The reader's output buffer overflowed and packets were lost here.- See Also:
-
-
Constructor Details
-
Dcc4PcRawDecoder
- Parameters:
enabledInputs- the inputs enabled on the reader, numbered from 1, in ascending order
-
-
Method Details
-
getInputs
- Returns:
- the enabled inputs, numbered from 1, in the order their states are reported
-
reset
Start again as the reader does after a Reset Encoding State: every input unoccupied, no partial packet and no RailCom history. -
decode
Decode a chunk of Get Data reply bytes.- Parameters:
chunk- the reply bytes, each 0-255- Returns:
- every packet completed by this chunk
-