Package jmri.jmrit.vsdecoder
Class VSDecoderManager
- java.lang.Object
-
- jmri.jmrit.vsdecoder.VSDecoderManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
public class VSDecoderManager extends java.lang.Object implements java.beans.PropertyChangeListener
VSDecoderFactory, builds VSDecoders as needed, handles loading from XML if needed.
This file is part of JMRI.JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
alf_version
(package private) java.util.HashMap<VSDecoder,Block>
currentBlock
(package private) boolean
geofile_ok
protected javax.swing.event.EventListenerList
listenerList
static int
max_decoder
protected NamedBeanHandleManager
nbhm
(package private) int
num_setups
java.util.HashMap<Block,LayoutEditor>
possibleStartBlocks
-
Constructor Summary
Constructors Constructor Description VSDecoderManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEventListener(VSDManagerListener listener)
void
atStart(Block blk)
Prepare the start of a VSDecoder on the layoutvoid
blockPropertyChange(java.beans.PropertyChangeEvent event)
void
calcNewPosition(VSDecoder d)
void
deleteDecoder(java.lang.String address)
Delete a VSDecoder(package private) void
fireMyEvent(VSDManagerEvent evt)
int
getArrayIndex(int number)
Get index of a decoder.ListeningSpot
getDefaultListenerLocation()
Get the VSD listener location.java.lang.String
getDefaultListenerName()
Get the VSD listener system name.int
getLocoAddr(Block blk)
Get the loco address from a Blockint
getMasterVolume()
Get the master volume of all VSDecoders.java.lang.String
getProfilePath(java.lang.String profile)
Retrieve the Path for a given Profile name.VSDecoder
getVSDecoder(VSDConfig config)
Provide or build a VSDecoder based on a provided configuration.VSDecoder
getVSDecoderByAddress(java.lang.String sa)
Get a VSDecoder by its address.VSDecoder
getVSDecoderByID(java.lang.String id)
Get a VSDecoder by its Id.java.util.Collection<VSDecoder>
getVSDecoderList()
Get a list of all VSDecoders.VSDecoderPreferences
getVSDecoderPreferences()
Get a reference to the VSD Preferences.java.util.ArrayList<java.lang.String>
getVSDProfileNames()
Get a list of all profiles.(package private) void
initSoundPositionTimer(VSDecoder d)
static VSDecoderManager
instance()
Provide the VSdecoderManager instance.void
loadProfiles(VSDFile vf)
void
locoInBlockRemove(int numb)
void
propertyChange(java.beans.PropertyChangeEvent evt)
JmriJFrame
provideManagerFrame()
Get the VSD GUI.protected void
registerBeanListener(Manager<Block> beanManager, java.lang.String sysName)
protected void
registerReporterListener(java.lang.String sysName)
protected void
registerReporterListeners()
void
removeEventListener(VSDManagerListener listener)
void
reporterManagerPropertyChange(java.beans.PropertyChangeEvent event)
void
reporterPropertyChange(java.beans.PropertyChangeEvent event)
void
setDecoderPositionByAddr(LocoAddress a, PhysicalLocation l)
void
setDecoderPositionByID(java.lang.String id, PhysicalLocation p)
void
setListenerLocation(java.lang.String id, ListeningSpot sp)
void
setMasterVolume(int mv)
Set the master volume for all VSDecoders.(package private) void
startSoundPositionTimer(VSDecoder d)
(package private) void
stopSoundPositionTimer(VSDecoder d)
-
-
-
Field Detail
-
nbhm
protected NamedBeanHandleManager nbhm
-
currentBlock
java.util.HashMap<VSDecoder,Block> currentBlock
-
possibleStartBlocks
public java.util.HashMap<Block,LayoutEditor> possibleStartBlocks
-
listenerList
protected javax.swing.event.EventListenerList listenerList
-
max_decoder
public static final int max_decoder
- See Also:
- Constant Field Values
-
geofile_ok
boolean geofile_ok
-
num_setups
int num_setups
-
alf_version
int alf_version
-
-
Constructor Detail
-
VSDecoderManager
public VSDecoderManager()
-
-
Method Detail
-
instance
public static VSDecoderManager instance()
Provide the VSdecoderManager instance.- Returns:
- the manager
-
getVSDecoderPreferences
public VSDecoderPreferences getVSDecoderPreferences()
Get a reference to the VSD Preferences.- Returns:
- the preferences reference
-
getMasterVolume
public int getMasterVolume()
Get the master volume of all VSDecoders.- Returns:
- the master volume
-
setMasterVolume
public void setMasterVolume(int mv)
Set the master volume for all VSDecoders.- Parameters:
mv
- The new master volume
-
provideManagerFrame
public JmriJFrame provideManagerFrame()
Get the VSD GUI.- Returns:
- the VSD frame
-
getVSDecoder
public VSDecoder getVSDecoder(VSDConfig config)
Provide or build a VSDecoder based on a provided configuration.- Parameters:
config
- previous configuration, not null.- Returns:
- vsdecoder, or null on error.
-
getVSDecoderByID
public VSDecoder getVSDecoderByID(java.lang.String id)
Get a VSDecoder by its Id.- Parameters:
id
- The Id of the VSDecoder- Returns:
- vsdecoder, or null on error.
-
getVSDecoderByAddress
public VSDecoder getVSDecoderByAddress(java.lang.String sa)
Get a VSDecoder by its address.- Parameters:
sa
- The address of the VSDecoder- Returns:
- vsdecoder, or null on error.
-
getVSDProfileNames
public java.util.ArrayList<java.lang.String> getVSDProfileNames()
Get a list of all profiles.- Returns:
- sl The profiles list.
-
getVSDecoderList
public java.util.Collection<VSDecoder> getVSDecoderList()
Get a list of all VSDecoders.- Returns:
- the VSDecoder list.
-
getDefaultListenerName
public java.lang.String getDefaultListenerName()
Get the VSD listener system name.- Returns:
- the system name.
-
getDefaultListenerLocation
public ListeningSpot getDefaultListenerLocation()
Get the VSD listener location.- Returns:
- the location or null.
-
setListenerLocation
public void setListenerLocation(java.lang.String id, ListeningSpot sp)
-
setDecoderPositionByID
public void setDecoderPositionByID(java.lang.String id, PhysicalLocation p)
-
setDecoderPositionByAddr
public void setDecoderPositionByAddr(LocoAddress a, PhysicalLocation l)
-
addEventListener
public void addEventListener(VSDManagerListener listener)
-
removeEventListener
public void removeEventListener(VSDManagerListener listener)
-
fireMyEvent
void fireMyEvent(VSDManagerEvent evt)
-
getProfilePath
public java.lang.String getProfilePath(java.lang.String profile)
Retrieve the Path for a given Profile name.- Parameters:
profile
- the profile to get the path for- Returns:
- the path for the profile
-
registerReporterListener
protected void registerReporterListener(java.lang.String sysName)
-
registerBeanListener
protected void registerBeanListener(Manager<Block> beanManager, java.lang.String sysName)
-
registerReporterListeners
protected void registerReporterListeners()
-
deleteDecoder
public void deleteDecoder(java.lang.String address)
Delete a VSDecoder- Parameters:
address
- The DCC address of the VSDecoder
-
atStart
public void atStart(Block blk)
Prepare the start of a VSDecoder on the layout- Parameters:
blk
- The current Block of the VSDecoder
-
getLocoAddr
public int getLocoAddr(Block blk)
Get the loco address from a Block- Parameters:
blk
- The current Block of the VSDecoder- Returns:
- The number of the loco address
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
blockPropertyChange
public void blockPropertyChange(java.beans.PropertyChangeEvent event)
-
reporterPropertyChange
public void reporterPropertyChange(java.beans.PropertyChangeEvent event)
-
reporterManagerPropertyChange
public void reporterManagerPropertyChange(java.beans.PropertyChangeEvent event)
-
getArrayIndex
public int getArrayIndex(int number)
Get index of a decoder.- Parameters:
number
- The loco address number.- Returns:
- the index of a decoder's loco address number in the array or the length of the array.
-
locoInBlockRemove
public void locoInBlockRemove(int numb)
-
loadProfiles
public void loadProfiles(VSDFile vf)
-
initSoundPositionTimer
void initSoundPositionTimer(VSDecoder d)
-
startSoundPositionTimer
void startSoundPositionTimer(VSDecoder d)
-
stopSoundPositionTimer
void stopSoundPositionTimer(VSDecoder d)
-
calcNewPosition
public void calcNewPosition(VSDecoder d)
-
-