Package jmri
Interface Consist
-
- All Known Implementing Classes:
DccConsist
,EasyDccConsist
,LocoNetConsist
,MqttConsist
,NceConsist
,NmraConsist
,WiFiConsist
,XNetConsist
public interface Consist
Interface for a Consist Object, describing one or more cooperatively-operating locomotives.
This file is part of JMRI.JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ADVANCED_CONSIST
static int
CS_CONSIST
static int
POSITION_LEAD
static int
POSITION_TRAIL
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(DccLocoAddress address, boolean directionNormal)
Add a Locomotive to a Consistvoid
addConsistListener(ConsistListener listener)
Add a listener for consist eventsboolean
contains(DccLocoAddress address)
Does the consist contain the specified locomotive address?void
dispose()
A method for cleaning up the consistDccLocoAddress
getConsistAddress()
Get the Consist Addressjava.lang.String
getConsistID()
Get the text ID associated with the consistjava.util.ArrayList<DccLocoAddress>
getConsistList()
Get a list of the locomotives in the consist.int
getConsistType()
Get the Consist Type.boolean
getLocoDirection(DccLocoAddress address)
Get the relative direction setting for a specific locomotive in the consist.int
getPosition(DccLocoAddress address)
Get the position of a locomotive within the consistjava.lang.String
getRosterId(DccLocoAddress address)
Get the rosterId of a locomotive within the consistboolean
isAddressAllowed(DccLocoAddress address)
Is the specific address allowed?void
remove(DccLocoAddress address)
Remove a Locomotive from this Consistvoid
removeConsistListener(ConsistListener listener)
Remove a listener for consist eventsvoid
restore()
Restore the consist to the command station.void
restore(DccLocoAddress address, boolean directionNormal)
Restore a Locomotive to a Consist, but don't write to the command station.void
reverse()
Reverse the order of the consist and the direction the locomotives are travelingvoid
setConsistID(java.lang.String id)
Set the text ID associated with the consistvoid
setConsistType(int consistType)
Set the Consist Type.void
setPosition(DccLocoAddress address, int position)
Set the position of a locomotive within the consistvoid
setRosterId(DccLocoAddress address, java.lang.String rosterId)
Set the roster entry of a locomotive within the consistint
sizeLimit()
Is there a size limit for this type of consist?
-
-
-
Field Detail
-
ADVANCED_CONSIST
static final int ADVANCED_CONSIST
- See Also:
- Constant Field Values
-
CS_CONSIST
static final int CS_CONSIST
- See Also:
- Constant Field Values
-
POSITION_LEAD
static final int POSITION_LEAD
- See Also:
- Constant Field Values
-
POSITION_TRAIL
static final int POSITION_TRAIL
- See Also:
- Constant Field Values
-
-
Method Detail
-
dispose
void dispose()
A method for cleaning up the consist
-
setConsistType
void setConsistType(int consistType)
Set the Consist Type.- Parameters:
consistType
- the consist type
-
getConsistType
int getConsistType()
Get the Consist Type.- Returns:
- the consist type
-
getConsistAddress
DccLocoAddress getConsistAddress()
Get the Consist Address- Returns:
- the consist address
-
isAddressAllowed
boolean isAddressAllowed(DccLocoAddress address)
Is the specific address allowed? (needed for system specific restrictions)- Parameters:
address
- the address- Returns:
- true if allowed; false otherwise
-
sizeLimit
int sizeLimit()
Is there a size limit for this type of consist?- Returns:
- -1 if no limit; 0 if the Consist Type is not supported; or the total number of usable spaces if the consist has a limit (do not subtract used spaces).
-
getConsistList
java.util.ArrayList<DccLocoAddress> getConsistList()
Get a list of the locomotives in the consist.- Returns:
- the list of addresses
-
contains
boolean contains(DccLocoAddress address)
Does the consist contain the specified locomotive address?- Parameters:
address
- the address to check- Returns:
- true if in consist; false otherwise
-
getLocoDirection
boolean getLocoDirection(DccLocoAddress address)
Get the relative direction setting for a specific locomotive in the consist.- Parameters:
address
- the address to check- Returns:
- true if locomotive is in consist in its normal direction of travel; false otherwise
-
add
void add(DccLocoAddress address, boolean directionNormal)
Add a Locomotive to a Consist- Parameters:
address
- is the Locomotive address to add to the locomotivedirectionNormal
- is True if the locomotive is traveling the same direction as the consist, or false otherwise.
-
restore
void restore(DccLocoAddress address, boolean directionNormal)
Restore a Locomotive to a Consist, but don't write to the command station. This is used for restoring the consist from a file or adding a consist read from the command station.- Parameters:
address
- is the Locomotive address to add to the consistdirectionNormal
- is True if the locomotive is traveling the same direction as the consist, or false otherwise.
-
remove
void remove(DccLocoAddress address)
Remove a Locomotive from this Consist- Parameters:
address
- is the Locomotive address to add to the locomotive
-
setPosition
void setPosition(DccLocoAddress address, int position)
Set the position of a locomotive within the consist- Parameters:
address
- is the Locomotive addressposition
- is a constant representing the position within the consist.
-
getPosition
int getPosition(DccLocoAddress address)
Get the position of a locomotive within the consist- Parameters:
address
- is the Locomotive address of interest- Returns:
- integer equal to jmri.Consist.POSITION_LEAD for the designated lead locomotive. equal to jmri.Consist.POSITION_TRAIL for the designated trailing locomotive. between 1 and 254 for other locomotives in the consist
-
setRosterId
void setRosterId(DccLocoAddress address, java.lang.String rosterId)
Set the roster entry of a locomotive within the consist- Parameters:
address
- is the Locomotive addressrosterId
- is the roster Identifier of the associated roster entry.
-
getRosterId
java.lang.String getRosterId(DccLocoAddress address)
Get the rosterId of a locomotive within the consist- Parameters:
address
- is the Locomotive address of interest- Returns:
- string roster Identifier associated with the given address in the consist. Returns null if no roster entry is associated with this entry.
-
addConsistListener
void addConsistListener(ConsistListener listener)
Add a listener for consist events- Parameters:
listener
- is a consistListener object
-
removeConsistListener
void removeConsistListener(ConsistListener listener)
Remove a listener for consist events- Parameters:
listener
- is a consistListener object
-
setConsistID
void setConsistID(java.lang.String id)
Set the text ID associated with the consist- Parameters:
id
- is a string identifier for the consist
-
getConsistID
java.lang.String getConsistID()
Get the text ID associated with the consist- Returns:
- String identifier for the consist default value is the string Identifier for the consist address.
-
reverse
void reverse()
Reverse the order of the consist and the direction the locomotives are traveling
-
restore
void restore()
Restore the consist to the command station.
-
-