001package jmri.jmrix.maple; 002 003/** 004 * Contains the data payload of a serial reply packet. Note that _only_ the 005 * payload, not the header or trailer, nor the padding DLE characters are 006 * included. But it does include addressing characters, etc. 007 * 008 * @author Bob Jacobsen Copyright (C) 2002, 2008 009 */ 010public class SerialReply extends jmri.jmrix.AbstractMRReply { 011 012 // create a new one 013 public SerialReply() { 014 super(); 015 } 016 017 public SerialReply(String s) { 018 super(s); 019 } 020 021 public SerialReply(SerialReply l) { 022 super(l); 023 } 024 025 @Override 026 public String toString() { 027 StringBuilder s = new StringBuilder(""); 028 for (int i = 0; i < getNumDataElements(); i++) { 029 if (i != 0) { 030 s.append(" "); 031 } 032 if (getElement(i) < 16) { 033 s.append("0"); 034 } 035 s.append(Integer.toHexString(getElement(i) & 0xFF)); 036 } 037 return s.toString(); 038 } 039 040 // recognize format 041 public boolean isRcv() { 042 return getElement(0) == 0x02; 043 } 044 045 public int getUA() { 046 int addr = (getElement(1) - '0') * 10 + (getElement(2) - '0'); 047 return addr; 048 } 049 050 @Override 051 protected int skipPrefix(int index) { 052 // doesn't have to do anything 053 return index; 054 } 055 056}