001package jmri.implementation; 002 003import jmri.LocoAddress; 004import jmri.RailCom; 005 006/** 007 * Extend AbstractReporter for RailCom reporters 008 * <p> 009 * This class is based on {@link jmri.jmrix.rfid.RfidReporter} 010 * 011 * @author Matthew Harris Copyright (c) 2011 012 * @author Paul Bender Copyright (c) 2016,2019 013 * @since 4.5.4 014 */ 015public abstract class AbstractRailComReporter extends AbstractIdTagReporter { 016 017 public AbstractRailComReporter(String systemName) { 018 super(systemName); 019 } 020 021 public AbstractRailComReporter(String systemName, String userName) { 022 super(systemName, userName); 023 } 024 025 /** 026 * {@inheritDoc} 027 */ 028 @Override 029 public abstract boolean hasExitReports(); 030 031 // Methods to support PhysicalLocationReporter interface 032 033 /** 034 * Get the locomotive address we're reporting about from the current report. 035 * 036 * Note: We ignore the string passed in, because RailCom Reporters don't send 037 * String type reports. 038 * {@inheritDoc} 039 */ 040 @Override 041 public LocoAddress getLocoAddress(String rep) { 042 Object cr = this.getCurrentReport(); 043 if (cr instanceof RailCom) { 044 return ((RailCom) cr).getLocoAddress(); 045 } 046 // not a RailCom report, for example an RFID tag on a CBUS Reporter, or no report 047 return super.getLocoAddress(rep); 048 } 049 050}