001package jmri;
002
003import java.util.List;
004
005/**
006 * RailCom represents a RailCom enabled decoder that might be fitted to a
007 * specific piece of rolling stock to uniquely identify it.<br>
008 * RailCom is a registered trademark of Lenz GmbH.
009 * <p>
010 * This implementation of RailCom is an extension of @see IdTag and holds the
011 * additional information that can be supplied by the decoder as defined in
012 * RP-9.3.2
013 * <p>
014 * This file is part of JMRI.
015 * <p>
016 * JMRI is free software; you can redistribute it and/or modify it under the
017 * terms of version 2 of the GNU General Public License as published by the Free
018 * Software Foundation. See the "COPYING" file for a copy of this license.
019 * <p>
020 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
022 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
023 *
024 * @author Kevin Dickerson Copyright (C) 2012
025 * @since 2.99.4
026 */
027public interface RailCom extends AddressedIdTag {
028
029    /**
030     * Constant representing that we do not know the address type of the
031     * decoder. This is the initial state of a newly created object before.
032     */
033    public final static int NO_ADDRESS = 0x00;
034
035    /**
036     * Constant representing that the address type reported back is Short.
037     */
038    public final static int SHORT_ADDRESS = 0x02;
039
040    /**
041     * Constant representing that the address type reported back is Long.
042     */
043    public final static int LONG_ADDRESS = 0x04;
044
045    /**
046     * Constant representing that the address type reported back is part of a
047     * Consist.
048     */
049    public final static int CONSIST_ADDRESS = 0x08;
050
051    final public static int ORIENTA = 0x10;
052    final public static int ORIENTB = 0x20;
053
054    /**
055     * Method for a RailCom Reader to set the orientation reported back from a
056     * device
057     *
058     * @param type the orientation to set
059     */
060    public void setOrientation(int type);
061
062    /**
063     * Gets the Orientation of the Rail Com device on the track
064     *
065     * @return current orientation
066     */
067    public int getOrientation();
068
069    /**
070     * Gets the address reported back as a {@link jmri.LocoAddress}.
071     *
072     * @return current DCC loco address
073     * @deprecated since 4.15.4  Use getLocoAddress() instead.
074     */
075    @Deprecated
076    default public DccLocoAddress getDccLocoAddress(){
077       return (DccLocoAddress) getLocoAddress();
078    }
079
080    /**
081     * Method for a RailCom Reader to set the Address type reported back from a
082     * device
083     *
084     * @param type set type of address
085     * @deprecated since 4.15.4  Use {@link jmri.LocoAddress.Protocol} instead.
086     */
087    @Deprecated
088    public void setAddressType(int type);
089
090    /**
091     * Gets the actual type of address reported back by the RailCom device
092     *
093     * @return -1 if not set.
094     * @deprecated since 4.15.4  Use {@link jmri.LocoAddress.Protocol} instead.
095     */
096    @Deprecated
097    public int getAddressType();
098
099    /**
100     * Gets the actual address type as a String.
101     *
102     * @return the address type
103     * @deprecated since 4.15.4  Use {@link jmri.LocoAddress.Protocol} instead.
104     */
105    @Deprecated
106    public String getAddressTypeAsString();
107
108    /**
109     * Method for a RailCom Reader to set the Actual speed reported back from a
110     * device
111     *
112     * @param actualSpeed the speed
113     */
114    public void setActualSpeed(int actualSpeed);
115
116    /**
117     * Gets the actual speed reported by the RailCom device as a representation
118     * 128 speed steps
119     *
120     * @return -1 if not set.
121     */
122    public int getActualSpeed();
123
124    /**
125     * Method for a RailCom Reader to set the Actual Load back from a device.
126     *
127     * @param actualLoad the load
128     */
129    public void setActualLoad(int actualLoad);
130
131    /**
132     * Gets the actual load reported by decoder the RailCom device.
133     *
134     * @return -1 if not set.
135     */
136    public int getActualLoad();
137
138    /**
139     * Method for a RailCom Reader to set the actual temperate reported back
140     * from a device.
141     *
142     * @param actualTemp the temperature
143     */
144    public void setActualTemperature(int actualTemp);
145
146    /**
147     * Gets the actual temperate reported by the RailCom device. Location is
148     * configured in CV876 (RP.9.3.2)
149     *
150     * @return -1 if not set.
151     */
152    public int getActualTemperature();
153
154    /**
155     * Method for a RailCom Reader to set the fuel level reported back from a
156     * device.
157     *
158     * @param fuelLevel the fuel level
159     */
160    public void setFuelLevel(int fuelLevel);
161
162    /**
163     * Method for a RailCom Reader to set the water level reported back from a
164     * device.
165     *
166     * @param waterLevel the water level
167     */
168    public void setWaterLevel(int waterLevel);
169
170    /**
171     * Gets the remaining fuel level as a % Fuel level CV879 (RP.9.3.2)
172     *
173     * @return -1 if not set.
174     */
175    public int getFuelLevel();
176
177    /**
178     * Gets the remaining fuel level as a % Water level CV878 (RP.9.3.2)
179     *
180     * @return -1 if not set.
181     */
182    public int getWaterLevel();
183
184    /**
185     * Method for a RailCom Reader to set the location reported back from a
186     * device.
187     *
188     * @param location the location
189     */
190    public void setLocation(int location);
191
192    /**
193     * Gets the Last Location that the RailCom device was identified in Location
194     * is configured in CV876 (RP.9.3.2)
195     *
196     * @return -1 if not set.
197     */
198    public int getLocation();
199
200    /**
201     * Method for a RailCom Reader to set the routing number reported back from
202     * a device.
203     *
204     * @param routingno the routing number
205     */
206    public void setRoutingNo(int routingno);
207
208    /**
209     * Gets the routing number that the RailCom device wishes to travel. Route
210     * Number is configured in CV874 (RP.9.3.2)
211     *
212     * @return -1 if not set.
213     */
214    public int getRoutingNo();
215
216    /**
217     * Gets the value of a CV reported back from the RailCom device.
218     *
219     * @param cv CV number that the value relates to.
220     * @return the value of the CV, or 0 if none has yet been collected
221     */
222    public int getCV(int cv);
223
224    /**
225     * Sets the value of a CV reported back from the decoder.
226     *
227     * @param cv    CV number that the value relates to.
228     * @param value Value of the CV
229     */
230    public void setCV(int cv, int value);
231
232    /**
233     * Set the CV number of the next expected value to be returned in a RailCom
234     * Packet.
235     *
236     * @param cv the expected CV
237     */
238    public void setExpectedCv(int cv);
239
240    /**
241     * Get the expected CV to be returned in a RailCom Packet.
242     *
243     * @return the expected CV
244     */
245    public int getExpectedCv();
246
247    /**
248     * Set the value of the CV that has been read from the RailCom packet.
249     *
250     * @param value the CV value
251     */
252    public void setCvValue(int value);
253
254    /**
255     * Get a list of the CVs last seen for this RailCom device.
256     *
257     * @return a list of CVs
258     */
259    public List<Integer> getCVList();
260
261}