|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.jmrix.AbstractThrottleManager
public abstract class AbstractThrottleManager
Abstract implementation of a ThrottleManager.
Based on Glen Oberhauser's original LnThrottleManager implementation.
| Nested Class Summary | |
|---|---|
protected static class |
AbstractThrottleManager.Addresses
This subClass, keeps track of which loco address have been requested and by whom, it primarily uses a increment count to keep track of all the the Addresses in use as not all external code will have been refactored over to use the new disposeThrottle. |
(package private) static class |
AbstractThrottleManager.WaitingThrottle
|
| Field Summary | |
|---|---|
protected SystemConnectionMemo |
adapterMemo
|
(package private) static org.slf4j.Logger |
log
|
protected String |
userName
|
| Constructor Summary | |
|---|---|
AbstractThrottleManager()
|
|
AbstractThrottleManager(SystemConnectionMemo memo)
|
|
| Method Summary | |
|---|---|
protected boolean |
addressReleased(DccLocoAddress la,
ThrottleListener l)
|
boolean |
addressStillRequired(DccLocoAddress la)
|
void |
attachListener(BasicRosterEntry re,
PropertyChangeListener p)
|
void |
attachListener(DccLocoAddress la,
BasicRosterEntry re,
PropertyChangeListener p)
|
void |
attachListener(DccLocoAddress la,
PropertyChangeListener p)
Attach a PropertyChangeListener to a specific loco address, where the requesting code does not need or require control over the loco. |
void |
cancelThrottleRequest(BasicRosterEntry re,
ThrottleListener l)
Cancel a request for a throttle. |
void |
cancelThrottleRequest(int address,
boolean isLong,
ThrottleListener l)
Cancel a request for a throttle |
void |
cancelThrottleRequest(int address,
ThrottleListener l)
Cancel a request for a throttle. |
void |
dispatchThrottle(DccThrottle t,
ThrottleListener l)
The throttle listener has finished with the specific Throttle and is is available for reuse/reallocation by somebody else. |
boolean |
disposeThrottle(DccThrottle t,
ThrottleListener l)
Not for general use, see releaseThrottle
and dispatchThrottle. |
void |
failedThrottleRequest(DccLocoAddress address,
String reason)
If the system-specific ThrottleManager has been unable to create the DCC throttle then it needs to be removed from the throttleListeners, otherwise any subsequent request for that address results in the address being reported as already in use, if singleUse is set. |
LocoAddress |
getAddress(String value,
LocoAddress.Protocol protocol)
|
LocoAddress |
getAddress(String value,
String protocol)
Get the object representing a particular address |
LocoAddress.Protocol[] |
getAddressProtocolTypes()
returns an Integer list of different protocols that are supported by system, to include short vs long or DCC vs Selectrix vs Motorola |
String[] |
getAddressTypes()
By default, only DCC in this implementation |
String |
getAddressTypeString(LocoAddress.Protocol prot)
By default, only DCC in this implementation |
LocoAddress.Protocol |
getProtocolFromString(String selection)
Get the integer value representing a protocol |
Object |
getThrottleInfo(DccLocoAddress la,
String item)
Provides a Proxy method to return the SpeedSetting, Direction, Function Settings, of a throttle, where the requesting code has used the attachListener
to only be notified of changes in the throttle and not control it. |
String |
getUserName()
A method to get the Name of the system that the programmer is associated with. |
boolean |
hasDispatchFunction()
Check to see if the Dispatch Button should be enabled or not Default to true, override if necessary |
void |
notifyThrottleKnown(DccThrottle throttle,
LocoAddress addr)
Handle throttle information when it's finally available, e.g. when a new Throttle object has been created. |
void |
releaseThrottle(DccThrottle t,
ThrottleListener l)
The specified Throttle Listener has finished using a given throttle and no longer requires access to it. |
void |
removeListener(DccLocoAddress la,
PropertyChangeListener p)
Remove a PropertyChangeListener to a specific loco address, where the requesting code has used attachListener
to get notification of changes in a throttle. |
boolean |
requestThrottle(BasicRosterEntry re,
ThrottleListener l)
Request a throttle from a given Roster Entry. |
boolean |
requestThrottle(DccLocoAddress la,
BasicRosterEntry re,
ThrottleListener l)
Request a throttle, given a decoder address. |
boolean |
requestThrottle(DccLocoAddress la,
ThrottleListener l)
Request a throttle, given a decoder address. |
boolean |
requestThrottle(int address,
boolean isLongAddress,
ThrottleListener l)
Request a throttle, given a decoder address & whether it is a long or short DCC address. |
boolean |
requestThrottle(int address,
ThrottleListener l)
Request a throttle, given a decoder address. |
void |
requestThrottleSetup(LocoAddress a)
Abstract member to actually do the work of configuring a new throttle, usually via interaction with the DCC system |
abstract void |
requestThrottleSetup(LocoAddress a,
boolean control)
Abstract member to actually do the work of configuring a new throttle, usually via interaction with the DCC system |
protected boolean |
singleUse()
Does this DCC system allow a Throttle (e.g. an address) to be used by only one user at a time? |
int |
supportedSpeedModes()
What speed modes are supported by this system? |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface jmri.ThrottleManager |
|---|
addressTypeUnique, canBeLongAddress, canBeShortAddress |
| Field Detail |
|---|
protected SystemConnectionMemo adapterMemo
protected String userName
static org.slf4j.Logger log
| Constructor Detail |
|---|
public AbstractThrottleManager()
public AbstractThrottleManager(SystemConnectionMemo memo)
| Method Detail |
|---|
public String getUserName()
ThrottleManager
getUserName in interface ThrottleManagerpublic String[] getAddressTypes()
getAddressTypes in interface ThrottleManagerpublic String getAddressTypeString(LocoAddress.Protocol prot)
getAddressTypeString in interface ThrottleManagerpublic LocoAddress.Protocol[] getAddressProtocolTypes()
ThrottleManager
getAddressProtocolTypes in interface ThrottleManager
public LocoAddress getAddress(String value,
LocoAddress.Protocol protocol)
getAddress in interface ThrottleManager
public LocoAddress getAddress(String value,
String protocol)
ThrottleManager
getAddress in interface ThrottleManagervalue - String in format specific to the protocolprotocol - specific protocol string, see the specific throttle manager for values
public LocoAddress.Protocol getProtocolFromString(String selection)
ThrottleManager
getProtocolFromString in interface ThrottleManagerprotected boolean singleUse()
public boolean requestThrottle(BasicRosterEntry re,
ThrottleListener l)
ThrottleManager
requestThrottle in interface ThrottleManagerre - The Roster Entry desired.l - The ThrottleListener awaiting notification of a found throttle.
public boolean requestThrottle(int address,
boolean isLongAddress,
ThrottleListener l)
ThrottleManager
requestThrottle in interface ThrottleManageraddress - The decoder address desired.isLongAddress - True if this is a request for a DCC long (extended) address.l - The ThrottleListener awaiting notification of a found throttle.
public boolean requestThrottle(DccLocoAddress la,
ThrottleListener l)
ThrottleManagerThis is a convenience version of the call, which uses system-specific logic to tell whether the address is a short or long form.
requestThrottle in interface ThrottleManagerla - The decoder address desired.l - The ThrottleListener awaiting notification of a found throttle.
public boolean requestThrottle(DccLocoAddress la,
BasicRosterEntry re,
ThrottleListener l)
requestThrottle in interface ThrottleManagerla - DccLocoAddress of the decoder desired.l - The ThrottleListener awaiting notification of a found throttle.re - The RosterEntry desired.
public boolean requestThrottle(int address,
ThrottleListener l)
This is a convenience version of the call, which uses system-specific logic to tell whether the address is a short or long form.
requestThrottle in interface ThrottleManageraddress - The decoder address desired.l - The ThrottleListener awaiting notification of a found throttle.
public abstract void requestThrottleSetup(LocoAddress a,
boolean control)
public void requestThrottleSetup(LocoAddress a)
public void cancelThrottleRequest(int address,
boolean isLong,
ThrottleListener l)
cancelThrottleRequest in interface ThrottleManageraddress - The decoder address desired.isLong - True if this is a request for a DCC long (extended) address.l - The ThrottleListener cancelling request for a throttle.
public void cancelThrottleRequest(BasicRosterEntry re,
ThrottleListener l)
ThrottleManagerThis is a convenience version of the call, which uses system-specific logic to tell whether the address is a short or long form.
cancelThrottleRequest in interface ThrottleManagerre - The Roster Entry desired.l - The ThrottleListener cancelling request for a throttle.
public void cancelThrottleRequest(int address,
ThrottleListener l)
This is a convenience version of the call, which uses system-specific logic to tell whether the address is a short or long form.
cancelThrottleRequest in interface ThrottleManageraddress - The decoder address desired.l - The ThrottleListener cancelling request for a throttle.
public void failedThrottleRequest(DccLocoAddress address,
String reason)
address - The DCC Loco Address that the request failed on.reason - A text string passed by the ThrottleManae as to why
public void notifyThrottleKnown(DccThrottle throttle,
LocoAddress addr)
This method creates a throttle for all ThrottleListeners of that address and notifies them via the ThrottleListener.notifyThrottleFound method.
public boolean hasDispatchFunction()
hasDispatchFunction in interface ThrottleManagerpublic int supportedSpeedModes()
supportedSpeedModes in interface ThrottleManager
public void attachListener(BasicRosterEntry re,
PropertyChangeListener p)
public void attachListener(DccLocoAddress la,
PropertyChangeListener p)
ThrottleManagerThe propertyChangeListener will be notified if it has been attached to a loco address or not, via a propertyChange notification.
attachListener in interface ThrottleManagerla - - DccLocoAddress of the loco we wish to monitorp - - PropertyChangeListener to attach to the throttle
public void attachListener(DccLocoAddress la,
BasicRosterEntry re,
PropertyChangeListener p)
public void removeListener(DccLocoAddress la,
PropertyChangeListener p)
ThrottleManagerattachListener
to get notification of changes in a throttle.
The propertyChangeListener will be notified if it has been removed via a propertyChange notification.
removeListener in interface ThrottleManagerla - - DccLocoAddress of the loco we wish to monitorp - - PropertyChangeListener to attachremove from the throttlepublic boolean addressStillRequired(DccLocoAddress la)
addressStillRequired in interface ThrottleManager
public void releaseThrottle(DccThrottle t,
ThrottleListener l)
ThrottleManagerAfter releasing the throttle, the manager will perform further checks to see if it is in use by any other listeners or if there are any propertychangelisteners attached. If there are no other uses of the throttle then it is disposed of.
Normally, release ends with a call to dispose.
releaseThrottle in interface ThrottleManagert - Throttle being releasedl - Throttle Listener releasing the throttle
public boolean disposeThrottle(DccThrottle t,
ThrottleListener l)
ThrottleManagerreleaseThrottle
and dispatchThrottle.
Dispose of object when finished it. This will free up hardware resource
Used for handling certain internal error conditions, where the object still exists but hardware is not associated with it.
After this, further usage of this Throttle object will result in a JmriException.
disposeThrottle in interface ThrottleManagert - Throttle being releasedl - Throttle Listener releasing the throttle
public void dispatchThrottle(DccThrottle t,
ThrottleListener l)
ThrottleManagerNormally, dispatch ends with a call to dispose.
dispatchThrottle in interface ThrottleManagert - Throttle being releasedl - Throttle Listener releasing the throttle
protected boolean addressReleased(DccLocoAddress la,
ThrottleListener l)
public Object getThrottleInfo(DccLocoAddress la,
String item)
ThrottleManagerattachListener
to only be notified of changes in the throttle and not control it.
Valid values for item are IsForward SpeedSetting SpeedIncrement SpeedStepMode F0-F28
getThrottleInfo in interface ThrottleManagerla - DccLocoAddress that we wish interrogateitem - A string of the item we wish to know the value of.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||