Package jmri.jmrix
Class ConnectionStatus
- java.lang.Object
-
- jmri.jmrix.ConnectionStatus
-
public class ConnectionStatus extends java.lang.Object
Interface for classes that wish to get notification when the connection to the layout changes.Maintains a single instance, as there is only one set of connections for the running program.
The "system name" referred to here is the human-readable name like "LocoNet 2" which can be obtained from i.e.
SystemConnectionMemo.getUserName(). Not clear whetherConnectionConfig.getConnectionName()is correct. It's not intended to be the prefix from i.e.PortAdapter.getSystemPrefix(). Maybe the right thing is to pass in the SystemConnectionMemo?
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONNECTION_DOWNstatic java.lang.StringCONNECTION_UNKNOWNstatic java.lang.StringCONNECTION_UP(package private) java.beans.PropertyChangeSupportpcs
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnection(java.lang.String systemName, java.lang.String portName)Add a connection with a given name and port name to the portStatus set if not yet present in the set.voidaddPropertyChangeListener(java.beans.PropertyChangeListener l)(package private) static voidclearInstance()protected voidfirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)java.lang.StringgetConnectionState(java.lang.String systemName, java.lang.String portName)Get the status of a communication port with a given name.java.lang.StringgetSystemState(java.lang.String systemName)Get the status of a communication port, based on the system name only.static ConnectionStatusinstance()booleanisConnectionOk(java.lang.String systemName, java.lang.String portName)Confirm status of a communication port is not down.booleanisSystemOk(java.lang.String systemName)Confirm status of a communication port is not down, based on the system name.voidremovePropertyChangeListener(java.beans.PropertyChangeListener l)voidsetConnectionState(java.lang.String systemName, java.lang.String portName, java.lang.String state)Set the connection state of a communication port.
-
-
-
Field Detail
-
CONNECTION_UNKNOWN
public static final java.lang.String CONNECTION_UNKNOWN
- See Also:
- Constant Field Values
-
CONNECTION_UP
public static final java.lang.String CONNECTION_UP
- See Also:
- Constant Field Values
-
CONNECTION_DOWN
public static final java.lang.String CONNECTION_DOWN
- See Also:
- Constant Field Values
-
pcs
java.beans.PropertyChangeSupport pcs
-
-
Method Detail
-
instance
public static ConnectionStatus instance()
-
clearInstance
static void clearInstance()
-
addConnection
public void addConnection(java.lang.String systemName, @Nonnull java.lang.String portName)
Add a connection with a given name and port name to the portStatus set if not yet present in the set.- Parameters:
systemName- human-readable name for system like "LocoNet 2" which can be obtained from i.e.SystemConnectionMemo.getUserName().portName- the port name
-
setConnectionState
public void setConnectionState(java.lang.String systemName, @Nonnull java.lang.String portName, @Nonnull java.lang.String state)
Set the connection state of a communication port.- Parameters:
systemName- human-readable name for system like "LocoNet 2" which can be obtained from i.e.SystemConnectionMemo.getUserName().portName- the port namestate- one of ConnectionStatus.UP, ConnectionStatus.DOWN, or ConnectionStatus.UNKNOWN.
-
getConnectionState
public java.lang.String getConnectionState(java.lang.String systemName, @Nonnull java.lang.String portName)
Get the status of a communication port with a given name.- Parameters:
systemName- human-readable name for system like "LocoNet 2" which can be obtained from i.e.SystemConnectionMemo.getUserName().portName- the port name- Returns:
- the status
-
getSystemState
public java.lang.String getSystemState(@Nonnull java.lang.String systemName)
Get the status of a communication port, based on the system name only.- Parameters:
systemName- human-readable name for system like "LocoNet 2" which can be obtained from i.e.SystemConnectionMemo.getUserName().- Returns:
- the status
-
isConnectionOk
public boolean isConnectionOk(java.lang.String systemName, @Nonnull java.lang.String portName)
Confirm status of a communication port is not down.- Parameters:
systemName- human-readable name for system like "LocoNet 2" which can be obtained from i.e.SystemConnectionMemo.getUserName().portName- the port name- Returns:
- true if port connection is operational or unknown, false if not
-
isSystemOk
public boolean isSystemOk(@Nonnull java.lang.String systemName)
Confirm status of a communication port is not down, based on the system name.- Parameters:
systemName- human-readable name for system like "LocoNet 2" which can be obtained from i.e.SystemConnectionMemo.getUserName().- Returns:
- true if port connection is operational or unknown, false if not. This includes returning true if the connection is not recognized.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
-
firePropertyChange
protected void firePropertyChange(@Nonnull java.lang.String p, java.lang.Object old, java.lang.Object n)
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
-
-