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) intalf_version(package private) java.util.HashMap<VSDecoder,Block>currentBlock(package private) booleangeofile_okprotected javax.swing.event.EventListenerListlistenerListstatic intmax_decoderprotected NamedBeanHandleManagernbhm(package private) intnum_setups
-
Constructor Summary
Constructors Constructor Description VSDecoderManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEventListener(VSDManagerListener listener)voidatStart(Block blk)Prepare the start of a VSDecoder on the layoutvoidblockPropertyChange(java.beans.PropertyChangeEvent event)voidcalcNewPosition(VSDecoder d)booleancheckForPossibleStartblock(Block blk)Check if Block is a possible startblock.voiddeleteDecoder(java.lang.String address)Delete a VSDecodervoiddoResume()(package private) voidfireMyEvent(VSDManagerEvent evt)intgetArrayIndex(int number)Get index of a decoder.ListeningSpotgetDefaultListenerLocation()Get the VSD listener location.java.lang.StringgetDefaultListenerName()Get the VSD listener system name.intgetLocoAddr(Block blk)Get the loco address from a BlockintgetMasterVolume()Get the master volume of all VSDecoders.java.lang.StringgetProfilePath(java.lang.String profile)Retrieve the Path for a given Profile name.VSDecodergetVSDecoder(VSDConfig config)Provide or build a VSDecoder based on a provided configuration.VSDecodergetVSDecoderByAddress(java.lang.String sa)Get a VSDecoder by its address.VSDecodergetVSDecoderByID(java.lang.String id)Get a VSDecoder by its Id.java.util.Collection<VSDecoder>getVSDecoderList()Get a list of all VSDecoders.VSDecoderPreferencesgetVSDecoderPreferences()Get a reference to the VSD Preferences.java.util.ArrayList<java.lang.String>getVSDProfileNames()Get a list of all profiles.(package private) voidinitSoundPositionTimer()static VSDecoderManagerinstance()Provide the VSdecoderManager instance.voidloadProfiles(VSDFile vf)voidlocoInBlockRemove(int numb)voidpropertyChange(java.beans.PropertyChangeEvent evt)JmriJFrameprovideManagerFrame()Get the VSD GUI.protected voidregisterBeanListener(Manager<Block> beanManager, java.lang.String sysName)protected voidregisterReporterListener(java.lang.String sysName)protected voidregisterReporterListeners()voidremoveEventListener(VSDManagerListener listener)voidreporterManagerPropertyChange(java.beans.PropertyChangeEvent event)voidreporterPropertyChange(java.beans.PropertyChangeEvent event)voidsetDecoderPositionByAddr(LocoAddress a, PhysicalLocation l)voidsetDecoderPositionByID(java.lang.String id, PhysicalLocation p)voidsetListenerLocation(java.lang.String id, ListeningSpot sp)voidsetMasterVolume(int mv)Set the master volume for all VSDecoders.(package private) voidstopSoundPositionTimer()
-
-
-
Field Detail
-
nbhm
protected NamedBeanHandleManager nbhm
-
currentBlock
java.util.HashMap<VSDecoder,Block> currentBlock
-
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
-
checkForPossibleStartblock
public boolean checkForPossibleStartblock(Block blk)
Check if Block is a possible startblock.- Parameters:
blk- Block to check- Returns:
- true if possible, else false
-
doResume
public void doResume()
-
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:
propertyChangein 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()
-
stopSoundPositionTimer
void stopSoundPositionTimer()
-
calcNewPosition
public void calcNewPosition(VSDecoder d)
-
-