Package jmri.jmrit.withrottle
Class DeviceServer
- java.lang.Object
-
- jmri.jmrit.withrottle.DeviceServer
-
- All Implemented Interfaces:
java.lang.Runnable
,java.util.EventListener
,ControllerInterface
,ThrottleControllerListener
public class DeviceServer extends java.lang.Object implements java.lang.Runnable, ThrottleControllerListener, ControllerInterface
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
deviceName
(package private) java.lang.String
deviceUDID
(package private) java.io.BufferedReader
in
(package private) boolean
isClockDisplayed
(package private) boolean
isRouteAllowed
(package private) boolean
isTrackPowerAllowed
(package private) boolean
isTurnoutAllowed
(package private) java.util.HashMap<java.lang.Character,MultiThrottle>
multiThrottles
(package private) java.lang.String
newLine
(package private) java.io.PrintStream
out
(package private) java.lang.String
railroadName
(package private) ThrottleController
secondThrottleController
(package private) ThrottleController
throttleController
-
Constructor Summary
Constructors Constructor Description DeviceServer(java.net.Socket socket, DeviceManager manager)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDeviceListener(DeviceListener l)
Add a DeviceListenervoid
closeSocket()
void
closeThrottles()
java.lang.String
getCurrentAddressString()
java.lang.String
getCurrentRosterIdString()
Get the Roster ID String.java.lang.String
getName()
java.lang.String
getUDID()
static java.lang.String
getWebServerPort()
static java.lang.String
getWiTVersion()
void
notifyControllerAddressDeclined(ThrottleController tc, DccLocoAddress address, java.lang.String reason)
System has declined the address request, may be an in-use address.void
notifyControllerAddressFound(ThrottleController TC)
void
notifyControllerAddressReleased(ThrottleController TC)
void
removeDeviceListener(DeviceListener l)
Remove a DeviceListenervoid
run()
void
sendAlertMessage(java.lang.String message)
Send an Alert message (simple text string) to this clientvoid
sendInfoMessage(java.lang.String message)
Send an Info message (simple text string) to this clientvoid
sendPacketToDevice(java.lang.String message)
Called by various Controllers to send a string message to a connected device.java.lang.String
sendRoster()
Format a package to be sent to the device for roster list selections.void
startEKG()
void
stopEKG()
-
-
-
Field Detail
-
newLine
java.lang.String newLine
-
in
java.io.BufferedReader in
-
out
java.io.PrintStream out
-
deviceName
java.lang.String deviceName
-
deviceUDID
java.lang.String deviceUDID
-
throttleController
ThrottleController throttleController
-
secondThrottleController
ThrottleController secondThrottleController
-
multiThrottles
java.util.HashMap<java.lang.Character,MultiThrottle> multiThrottles
-
isTrackPowerAllowed
final boolean isTrackPowerAllowed
-
isTurnoutAllowed
final boolean isTurnoutAllowed
-
isRouteAllowed
final boolean isRouteAllowed
-
isClockDisplayed
final boolean isClockDisplayed
-
railroadName
final java.lang.String railroadName
-
-
Constructor Detail
-
DeviceServer
DeviceServer(java.net.Socket socket, DeviceManager manager)
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
closeThrottles
public void closeThrottles()
-
closeSocket
public void closeSocket()
-
startEKG
public void startEKG()
-
stopEKG
public void stopEKG()
-
getUDID
public java.lang.String getUDID()
-
getName
public java.lang.String getName()
-
getCurrentAddressString
public java.lang.String getCurrentAddressString()
-
getCurrentRosterIdString
public java.lang.String getCurrentRosterIdString()
Get the Roster ID String.- Returns:
- roster ID string.
- Since:
- 4.15.4
-
getWiTVersion
public static java.lang.String getWiTVersion()
-
getWebServerPort
public static java.lang.String getWebServerPort()
-
sendPacketToDevice
public void sendPacketToDevice(java.lang.String message)
Called by various Controllers to send a string message to a connected device. Appends a newline to the end.- Specified by:
sendPacketToDevice
in interfaceControllerInterface
- Parameters:
message
- The string to send.
-
sendAlertMessage
public void sendAlertMessage(java.lang.String message)
Send an Alert message (simple text string) to this client- Specified by:
sendAlertMessage
in interfaceControllerInterface
- Parameters:
message
- Format: HMmessage
-
sendInfoMessage
public void sendInfoMessage(java.lang.String message)
Send an Info message (simple text string) to this client- Specified by:
sendInfoMessage
in interfaceControllerInterface
- Parameters:
message
- Format: Hmmessage
-
addDeviceListener
public void addDeviceListener(DeviceListener l)
Add a DeviceListener- Parameters:
l
- handle for listener to add
-
removeDeviceListener
public void removeDeviceListener(DeviceListener l)
Remove a DeviceListener- Parameters:
l
- listener to remove
-
notifyControllerAddressFound
public void notifyControllerAddressFound(ThrottleController TC)
- Specified by:
notifyControllerAddressFound
in interfaceThrottleControllerListener
-
notifyControllerAddressReleased
public void notifyControllerAddressReleased(ThrottleController TC)
- Specified by:
notifyControllerAddressReleased
in interfaceThrottleControllerListener
-
notifyControllerAddressDeclined
public void notifyControllerAddressDeclined(ThrottleController tc, DccLocoAddress address, java.lang.String reason)
System has declined the address request, may be an in-use address. Need to clear the address from the proper multiThrottle.- Specified by:
notifyControllerAddressDeclined
in interfaceThrottleControllerListener
- Parameters:
tc
- The throttle controller that was listening for a response to an address requestaddress
- The address to send a cancel toreason
- The reason the request was declined, to be sent back to client
-
sendRoster
public java.lang.String sendRoster()
Format a package to be sent to the device for roster list selections.- Returns:
- String containing a formatted list of some of each RosterEntry's info. Include a header with the length of the string to be received.
-
-