Package jmri.jmris
Class AbstractOperationsServer
- java.lang.Object
-
- jmri.jmris.AbstractOperationsServer
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
SimpleOperationsServer
public abstract class AbstractOperationsServer extends java.lang.Object implements java.beans.PropertyChangeListener
Abstract interface between the JMRI operations and a network connection
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractOperationsServer.TrainListener
-
Field Summary
Fields Modifier and Type Field Description protected LocationManager
lm
protected TrainManager
tm
protected java.util.HashMap<java.lang.String,AbstractOperationsServer.TrainListener>
trains
-
Constructor Summary
Constructors Constructor Description AbstractOperationsServer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addTrainToList(java.lang.String trainId)
java.lang.String
constructTrainCaboose(java.lang.String trainName)
constructs a String containing the caboose on a trainjava.lang.String
constructTrainLeadLoco(java.lang.String trainName)
Constructs a String containing the road and number of lead loco, if there's one assigned to the train.java.lang.String
constructTrainLength(java.lang.String trainName)
constructs a String containing the length of a trainjava.lang.String
constructTrainLocation(java.lang.String trainName)
constructs a String containing the location of a trainjava.lang.String
constructTrainNumberOfCars(java.lang.String trainName)
constructs a String containing the number of cars in a trainjava.lang.String
constructTrainStatus(java.lang.String trainName)
constructs a String containing the status of a trainjava.lang.String
constructTrainWeight(java.lang.String trainName)
constructs a String containing the tonnage of a trainvoid
dispose()
protected AbstractOperationsServer.TrainListener
getListener(java.lang.String trainId)
static boolean
isExactLoationNameEnabled()
abstract void
parseStatus(java.lang.String statusString)
abstract void
propertyChange(java.beans.PropertyChangeEvent e)
protected void
removeTrainFromList(java.lang.String trainId)
abstract void
sendErrorStatus(java.lang.String errorStatus)
abstract void
sendFullStatus(Train train)
sends the full status for a train to a clientabstract void
sendLocationList()
abstract void
sendMessage(java.util.ArrayList<javax.management.Attribute> contents)
abstract void
sendTrainList()
static void
setExactLocationName(boolean enabled)
java.lang.String
setTrainLocation(java.lang.String trainName, java.lang.String locationName)
constructs a String containing the location of a trainjava.lang.String
terminateTrain(java.lang.String trainName)
tells Operations that a train has terminated.
-
-
-
Field Detail
-
tm
protected final TrainManager tm
-
lm
protected final LocationManager lm
-
trains
protected final java.util.HashMap<java.lang.String,AbstractOperationsServer.TrainListener> trains
-
-
Constructor Detail
-
AbstractOperationsServer
public AbstractOperationsServer()
-
-
Method Detail
-
sendTrainList
public abstract void sendTrainList()
-
sendLocationList
public abstract void sendLocationList()
-
constructTrainStatus
public java.lang.String constructTrainStatus(java.lang.String trainName) throws java.io.IOException
constructs a String containing the status of a train- Parameters:
trainName
- is the name of the train. If not found in Operations, an error message is sent to the client.- Returns:
- the train's status as known by Operations
- Throws:
java.io.IOException
- on failure to send an error message to the client
-
constructTrainLocation
public java.lang.String constructTrainLocation(java.lang.String trainName) throws java.io.IOException
constructs a String containing the location of a train- Parameters:
trainName
- is the name of the desired train. If not found in Operations, an error message is sent to the client- Returns:
- the train's location, as known by Operations
- Throws:
java.io.IOException
- on failure to send an error message to the client
-
setTrainLocation
public java.lang.String setTrainLocation(java.lang.String trainName, java.lang.String locationName) throws java.io.IOException
constructs a String containing the location of a train- Parameters:
trainName
- is the name of the desired train. If not found in Operations, an error message is sent to the clientlocationName
- is the name of the desired location.- Returns:
- the train's location, as known by Operations
- Throws:
java.io.IOException
- on failure to send an error message to the client
-
setExactLocationName
public static void setExactLocationName(boolean enabled)
-
isExactLoationNameEnabled
public static boolean isExactLoationNameEnabled()
-
constructTrainLength
public java.lang.String constructTrainLength(java.lang.String trainName) throws java.io.IOException
constructs a String containing the length of a train- Parameters:
trainName
- is the name of the desired train. If not found in Operations, an error message is sent to the client- Returns:
- the train's length, as known by Operations
- Throws:
java.io.IOException
- on failure to send an error message to the client
-
constructTrainWeight
public java.lang.String constructTrainWeight(java.lang.String trainName) throws java.io.IOException
constructs a String containing the tonnage of a train- Parameters:
trainName
- is the name of the desired train. If not found in Operations, an error message is sent to the client- Returns:
- the train's tonnage, as known by Operations
- Throws:
java.io.IOException
- on failure to send an error message to the client
-
constructTrainNumberOfCars
public java.lang.String constructTrainNumberOfCars(java.lang.String trainName) throws java.io.IOException
constructs a String containing the number of cars in a train- Parameters:
trainName
- is the name of the desired train. If not found in Operations, an error message is sent to the client- Returns:
- the number of cars in a train, as known by Operations
- Throws:
java.io.IOException
- on failure to send an error message to the client
-
constructTrainLeadLoco
public java.lang.String constructTrainLeadLoco(java.lang.String trainName) throws java.io.IOException
Constructs a String containing the road and number of lead loco, if there's one assigned to the train.- Parameters:
trainName
- is the name of the desired train. If not found in Operations, an error message is sent to the client- Returns:
- the lead loco
- Throws:
java.io.IOException
- on failure to send an error message to the client
-
constructTrainCaboose
public java.lang.String constructTrainCaboose(java.lang.String trainName) throws java.io.IOException
constructs a String containing the caboose on a train- Parameters:
trainName
- is the name of the desired train. If not found in Operations, an error message is sent to the client- Returns:
- the caboose on a train, as known by Operations
- Throws:
java.io.IOException
- on failure to send an error message to the client
-
terminateTrain
public java.lang.String terminateTrain(java.lang.String trainName) throws java.io.IOException
tells Operations that a train has terminated. If not found in Operations, an error message is sent to the client- Parameters:
trainName
- is the name of the train- Returns:
- the termination String
- Throws:
java.io.IOException
- on failure to send an error message to the client
-
sendFullStatus
public abstract void sendFullStatus(Train train) throws java.io.IOException
sends the full status for a train to a client- Parameters:
train
- is the Train object we are sending information about.- Throws:
java.io.IOException
- on failure to send an error message
-
propertyChange
public abstract void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
addTrainToList
protected void addTrainToList(java.lang.String trainId)
-
removeTrainFromList
protected void removeTrainFromList(java.lang.String trainId)
-
getListener
protected AbstractOperationsServer.TrainListener getListener(java.lang.String trainId)
-
dispose
public void dispose()
-
sendMessage
public abstract void sendMessage(java.util.ArrayList<javax.management.Attribute> contents) throws java.io.IOException
- Throws:
java.io.IOException
-
sendErrorStatus
public abstract void sendErrorStatus(java.lang.String errorStatus) throws java.io.IOException
- Throws:
java.io.IOException
-
parseStatus
public abstract void parseStatus(java.lang.String statusString) throws JmriException, java.io.IOException
- Throws:
JmriException
java.io.IOException
-
-