Package jmri.managers
Class DefaultProgrammerManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.managers.DefaultProgrammerManager
-
- All Implemented Interfaces:
AddressedProgrammerManager
,PropertyChangeFirer
,PropertyChangeProvider
,GlobalProgrammerManager
- Direct Known Subclasses:
BiDiBProgrammerManager
,CbusDccProgrammerManager
,Dcc4PcProgrammerManager
,DCCppProgrammerManager
,DebugProgrammerManager
,EasyDccProgrammerManager
,EcosProgrammerManager
,LnProgrammerManager
,MrcProgrammerManager
,Mx1ProgrammerManager
,NceProgrammerManager
,OlcbProgrammerManager
,SprogProgrammerManager
,SRCPProgrammerManager
,TamsProgrammerManager
,XNetProgrammerManager
public class DefaultProgrammerManager extends PropertyChangeSupport implements AddressedProgrammerManager, GlobalProgrammerManager
Provides a very basic implementation of a programmer manager by providing a union of the AddressedProgrammerManager and GlobalProgrammerManager interfaces.This implementation requires a service-mode Programmer at construction time and returns that Programmer for all global programming mode requests. This implementation of AddressedProgrammerManager always returns null for Op Mode, or addressed programmer requests, indicating there is no programmer of that type.
-
-
Field Summary
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description DefaultProgrammerManager()
Constructor when no global programmer is available.DefaultProgrammerManager(Programmer programmer)
Constructor with a programmer.DefaultProgrammerManager(Programmer programmer, SystemConnectionMemo memo)
Constructor with a programmer and associated connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
AddressedProgrammer
getAddressedProgrammer(boolean pLongAddress, int pAddress)
Gain access to a Addressed Mode Programmer without reservation.java.util.List<ProgrammingMode>
getDefaultModes()
Get the list ofProgrammingMode
(generally) supported by Programmers provided by this Manager.Programmer
getGlobalProgrammer()
Gain access to the Global Mode Programmer without reservation.java.lang.String
getUserName()
Provides the human-readable representation for including ProgrammerManagers directly in user interface components, so it should return a user-provided name for this particular one.boolean
isAddressedModePossible()
Convenience method to check whether you'll be able to get an Addressed Mode programmer.boolean
isAddressedModePossible(LocoAddress l)
Convenience method to check whether you'll be able to get an Addressed Mode programmer for a specific addressboolean
isGlobalProgrammerAvailable()
Convenience method to check whether you'll be able to get a Global Mode programmer.void
releaseAddressedProgrammer(AddressedProgrammer p)
Return access to an Addressed Mode Programmer, so that it can be used elsewhere.void
releaseGlobalProgrammer(Programmer p)
Return access to the Global Mode Programmer, so that it can be used elsewhere.AddressedProgrammer
reserveAddressedProgrammer(boolean pLongAddress, int pAddress)
Gain access to a (the) Addressed Mode Programmer, in the process reserving it for yourself.Programmer
reserveGlobalProgrammer()
Gain access to the Global Mode Programmer, in the process reserving it for yourself.java.lang.String
toString()
Provides the human-readable representation for including ProgrammerManagers directly in user interface components, so it should return a user-provided name for this particular one.-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.AddressedProgrammerManager
getAddressedProgrammer, reserveAddressedProgrammer
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Constructor Detail
-
DefaultProgrammerManager
public DefaultProgrammerManager()
Constructor when no global programmer is available.
-
DefaultProgrammerManager
public DefaultProgrammerManager(@CheckForNull Programmer programmer)
Constructor with a programmer.- Parameters:
programmer
- the programmer to use; if null, acts as if no programmer is available
-
DefaultProgrammerManager
public DefaultProgrammerManager(@CheckForNull Programmer programmer, @Nonnull SystemConnectionMemo memo)
Constructor with a programmer and associated connection.- Parameters:
programmer
- the programmer to use; if null, acts as if no programmer is availablememo
- the associated connection
-
-
Method Detail
-
getUserName
public java.lang.String getUserName()
Provides the human-readable representation for including ProgrammerManagers directly in user interface components, so it should return a user-provided name for this particular one.- Specified by:
getUserName
in interfaceAddressedProgrammerManager
- Specified by:
getUserName
in interfaceGlobalProgrammerManager
- Returns:
- the name for the programmer
-
toString
public java.lang.String toString()
Provides the human-readable representation for including ProgrammerManagers directly in user interface components, so it should return a user-provided name for this particular one.- Specified by:
toString
in interfaceAddressedProgrammerManager
- Specified by:
toString
in interfaceGlobalProgrammerManager
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the name for the programmer
-
getGlobalProgrammer
public Programmer getGlobalProgrammer()
Description copied from interface:GlobalProgrammerManager
Gain access to the Global Mode Programmer without reservation.- Specified by:
getGlobalProgrammer
in interfaceGlobalProgrammerManager
- Returns:
- null only if there isn't a Global Mode Programmer available via this Manager.
-
getAddressedProgrammer
public AddressedProgrammer getAddressedProgrammer(boolean pLongAddress, int pAddress)
Description copied from interface:AddressedProgrammerManager
Gain access to a Addressed Mode Programmer without reservation.- Specified by:
getAddressedProgrammer
in interfaceAddressedProgrammerManager
- Parameters:
pLongAddress
- true if this is a long (14 bit) address, else falsepAddress
- specific decoder address to use- Returns:
- null only if there isn't an Ops Mode Programmer in the system
-
reserveGlobalProgrammer
public Programmer reserveGlobalProgrammer()
Description copied from interface:GlobalProgrammerManager
Gain access to the Global Mode Programmer, in the process reserving it for yourself.- Specified by:
reserveGlobalProgrammer
in interfaceGlobalProgrammerManager
- Returns:
- null if the existing Global Mode programmer is in use
-
releaseGlobalProgrammer
public void releaseGlobalProgrammer(@Nonnull Programmer p)
Description copied from interface:GlobalProgrammerManager
Return access to the Global Mode Programmer, so that it can be used elsewhere.- Specified by:
releaseGlobalProgrammer
in interfaceGlobalProgrammerManager
- Parameters:
p
- the Programmer to release
-
reserveAddressedProgrammer
public AddressedProgrammer reserveAddressedProgrammer(boolean pLongAddress, int pAddress)
Description copied from interface:AddressedProgrammerManager
Gain access to a (the) Addressed Mode Programmer, in the process reserving it for yourself.- Specified by:
reserveAddressedProgrammer
in interfaceAddressedProgrammerManager
- Parameters:
pLongAddress
- true if this is a long (14 bit) address, else falsepAddress
- Specific decoder address to use- Returns:
- null if the address is in use by a reserved programmer
-
releaseAddressedProgrammer
public void releaseAddressedProgrammer(@Nonnull AddressedProgrammer p)
Description copied from interface:AddressedProgrammerManager
Return access to an Addressed Mode Programmer, so that it can be used elsewhere.- Specified by:
releaseAddressedProgrammer
in interfaceAddressedProgrammerManager
- Parameters:
p
- the programmer to release
-
isAddressedModePossible
public boolean isAddressedModePossible()
Convenience method to check whether you'll be able to get an Addressed Mode programmer.- Specified by:
isAddressedModePossible
in interfaceAddressedProgrammerManager
- Returns:
- always false in this implementation
-
isAddressedModePossible
public boolean isAddressedModePossible(@Nonnull LocoAddress l)
Convenience method to check whether you'll be able to get an Addressed Mode programmer for a specific address- Specified by:
isAddressedModePossible
in interfaceAddressedProgrammerManager
- Parameters:
l
- the address to get a programmer for- Returns:
- always false in this implementation
-
isGlobalProgrammerAvailable
public boolean isGlobalProgrammerAvailable()
Convenience method to check whether you'll be able to get a Global Mode programmer.- Specified by:
isGlobalProgrammerAvailable
in interfaceGlobalProgrammerManager
- Returns:
- always false in this implementation
-
getDefaultModes
public java.util.List<ProgrammingMode> getDefaultModes()
Get the list ofProgrammingMode
(generally) supported by Programmers provided by this Manager.Use this to enquire about modes before you're ready to request a specific programmer.
If the order is significant, earlier modes are better.
- Specified by:
getDefaultModes
in interfaceAddressedProgrammerManager
- Returns:
- a default list of programming modes that most
AddressedProgrammer
s make available
-
dispose
public void dispose()
-
-