001package jmri.jmrix.rfid.merg.concentrator;
002
003import jmri.jmrix.rfid.RfidProtocol;
004import jmri.jmrix.rfid.RfidReply;
005import jmri.jmrix.rfid.RfidTrafficController;
006
007/**
008 * Contains the data payload of a serial reply packet. Note that it's _only_ the
009 * payload.
010 *
011 * @author Bob Jacobsen Copyright (C) 2002, 2006, 2007, 2008
012 * @author Matthew Harris Copyright (C) 2011
013 * @since 2.11.4
014 */
015public class ConcentratorReply extends RfidReply {
016
017    RfidProtocol pr = null;
018
019    // create a new one
020    public ConcentratorReply(RfidTrafficController tc) {
021        super(tc);
022        this.pr = this.tc.getAdapterMemo().getProtocol();
023        setBinary(true);
024        setUnsolicited();
025    }
026
027    public ConcentratorReply(RfidTrafficController tc, String s) {
028        super(tc, s);
029        this.pr = this.tc.getAdapterMemo().getProtocol();
030        setBinary(true);
031        setUnsolicited();
032    }
033
034    public ConcentratorReply(RfidTrafficController tc, RfidReply l) {
035        super(tc, l);
036        this.pr = this.tc.getAdapterMemo().getProtocol();
037        setBinary(true);
038        setUnsolicited();
039    }
040
041    protected boolean isInRange() {
042        return ((tc.getRange().equals("A-H") && (getElement(0) >= 0x41 || getElement(0) <= 0x48))
043                || (tc.getRange().equals("I-P") && (getElement(0) >= 0x49 || getElement(0) <= 0x50)));
044    }
045
046    protected String getReaderPort() {
047//        if (isInRange())
048        return new StringBuffer().append((char) getElement(0)).toString();
049//        return null;
050    }
051
052    @Override
053    public String toMonitorString() {
054        return pr.toMonitorString(this);
055    }
056
057}