001package jmri.jmrix.tmcc;
002
003import jmri.util.StringUtil;
004
005/**
006 * Contains the data payload of a TMCC serial reply packet.
007 * <p>
008 * Note that <i>only</i> the payload, not the header or trailer, nor the padding
009 * DLE characters are included. These are added during transmission.
010 *
011 * @author Bob Jacobsen Copyright (C) 2002, 2006
012 */
013public class SerialReply extends jmri.jmrix.AbstractMRReply {
014
015    // create a new one
016    public SerialReply() {
017        super();
018    }
019
020    public SerialReply(String s) {
021        super(s);
022    }
023
024    public SerialReply(SerialReply l) {
025        super(l);
026    }
027
028    @Override
029    public String toString() {
030        StringBuilder s = new StringBuilder("");
031        for (int i = 0; i < getNumDataElements(); i++) {
032            if (i != 0) {
033                s.append(" ");
034            }
035            s.append(StringUtil.twoHexFromInt(getElement(i)));
036        }
037        return s.toString();
038    }
039
040    public int getAsWord() {
041        return (getElement(1) & 0xFF) * 256 + (getElement(2) & 0xFF);
042    }
043
044    @Override
045    protected int skipPrefix(int index) {
046        // doesn't have to do anything
047        return index;
048    }
049
050}