001package jmri; 002 003/** 004 * Interface for generic Locomotive Address. 005 * 006 * Note that this is not DCC-specific. 007 * 008 * 009 * <hr> 010 * This file is part of JMRI. 011 * <p> 012 * JMRI is free software; you can redistribute it and/or modify it under the 013 * terms of version 2 of the GNU General Public License as published by the Free 014 * Software Foundation. See the "COPYING" file for a copy of this license. 015 * <p> 016 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY 017 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 018 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 019 * 020 * @author Bob Jacobsen Copyright (C) 2005 021 */ 022@javax.annotation.concurrent.Immutable 023public interface LocoAddress { 024 025 int getNumber(); 026 027 Protocol getProtocol(); 028 029 enum Protocol { 030 031 DCC_SHORT("dcc_short", "ProtocolDCC_Short"), // NOI18N 032 DCC_LONG("dcc_long", "ProtocolDCC_Long"), // NOI18N 033 DCC("dcc", "ProtocolDCC"), // NOI18N 034 SELECTRIX("selectrix", "ProtocolSelectrix"), // NOI18N 035 MOTOROLA("motorola", "ProtocolMotorola"), // NOI18N 036 MFX("mfx", "ProtocolMFX"), // NOI18N 037 M4("m4", "ProtocolM4"), // NOI18N 038 OPENLCB("openlcb", "ProtocolOpenLCB"), // NOI18N 039 TMCC1("tmcc1", "ProtocolTMCC1"), // NOI18N 040 TMCC2("tmcc2", "ProtocolTMCC2"), // NOI18N 041 LGB("lgb", "ProtocolLGB"); // NOI18N 042 043 Protocol(String shName, String peopleKey) { 044 this.shortName = shName; 045 this.peopleName = Bundle.getMessage(peopleKey); 046 } 047 048 String shortName; 049 String peopleName; 050 051 public String getShortName() { 052 return shortName; 053 } 054 055 public String getPeopleName() { 056 return peopleName; 057 } 058 059 static public Protocol getByShortName(String shName) { 060 for (Protocol p : Protocol.values()) { 061 if (p.shortName.equals(shName)) { 062 return p; 063 } 064 } 065 throw new java.lang.IllegalArgumentException("argument value " + shName + " not valid"); 066 } 067 068 static public Protocol getByPeopleName(String pName) { 069 for (Protocol p : Protocol.values()) { 070 if (p.peopleName.equals(pName)) { 071 return p; 072 } 073 } 074 throw new java.lang.IllegalArgumentException("argument value " + pName + " not valid"); 075 } 076 077 } 078 079}