Package jmri.jmrit.vsdecoder
Class VSDecoder
- java.lang.Object
-
- jmri.jmrit.vsdecoder.VSDecoder
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener,java.util.EventListener
public class VSDecoder extends java.lang.Object implements java.beans.PropertyChangeListener
Implements a software "decoder" that responds to throttle inputs and generates sounds in responds to them.Each VSDecoder implements exactly one Sound Profile (describes a particular type of locomotive, say, an EMD GP7).
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) intdirfn(package private) doubledistance(package private) floatdistanceMeter(package private) doubledistanceOnTrack(package private) java.util.LinkedHashMap<java.lang.String,SoundEvent>event_list(package private) booleaninitialized(package private) booleanis_muted(package private) PhysicalLocationlastPos(package private) LayoutTracknextLayoutTrack(package private) PhysicalLocationposToSet(package private) intsetup_index(package private) java.util.HashMap<java.lang.String,VSDSound>sound_list(package private) PhysicalLocationstartPos(package private) inttopspeed(package private) inttopspeed_rev
-
Constructor Summary
Constructors Constructor Description VSDecoder(java.lang.String id, java.lang.String name, java.lang.String path)Construct a VSDecoder with the given system name (id), profile name and VSD file pathVSDecoder(VSDConfig cfg)Construct a VSDecoder with the given system name (id) and configuration (config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voiddisable()Disable this VSDecoder.(package private) voidenable()Enable this VSDecoder.LocoAddressgetAddress()Get the currently assigned LocoAddressfloatgetDecoderVolume()Get the current decoder volume setting for this VSDecoder(package private) doublegetDirectionRAD()(package private) doublegetDistance()EngineSoundgetEngineSound()Get a reference to the EngineSound associated with this VSDecoderjava.util.Collection<SoundEvent>getEventList()Get a Collection of SoundEvents associated with this VSDecoderjava.lang.StringgetId()Get the ID (System Name) of this VSDecoder(package private) LayoutTrackgetLastTrack()(package private) LayoutTrackgetLayoutTrack()(package private) java.awt.geom.Point2DgetLocation()(package private) LayoutEditorgetModels()PhysicalLocationgetPosition()Get the current x/y/z position in the soundspace of this VSDecoderjava.lang.StringgetProfileName()get the currently selected profile name(package private) doublegetReturnDistance()(package private) LayoutTrackgetReturnLastTrack()(package private) LayoutTrackgetReturnTrack()RosterEntrygetRosterEntry()VSDSoundgetSound(java.lang.String name)Retrieve the VSDSound with the given system nameprotected PhysicalLocationgetTrainPosition(Train t)Get the physical location of the given Operations Trainjava.lang.StringgetVSDFilePath()Get the current VSD File path for this VSDecoderorg.jdom2.ElementgetXml()Get an XML representation of this VSDecoder Includes a subtree of Elements for all of the associated SoundEvents, Triggers, VSDSounds, etc.(package private) booleanisEnabled()booleanisInitialized()Check whether this VSDecoder has completed initializationbooleanisMuted()Is this VSDecoder muted?voidmute(boolean m)Mute or un-mute this VSDecoder(package private) voidnavigate()voidpropertyChange(java.beans.PropertyChangeEvent evt)Respond to property change events from this VSDecoder's GUIvoidsetAddress(LocoAddress l)Set this VSDecoder's LocoAddress, and register to follow events from the throttle with this address.voidsetDecoderVolume(float decoder_volume)Set the decoder volume for this VSDecoder(package private) voidsetDirectionDEG(double directionDEG)(package private) voidsetDirectionRAD(double directionRAD)(package private) voidsetDistance(double distance)(package private) voidsetLastTrack(LayoutTrack lastTrack)(package private) voidsetLayoutTrack(LayoutTrack layoutTrack)(package private) voidsetLocation(java.awt.geom.Point2D location)(package private) voidsetModels(LayoutEditor models)voidsetPosition(PhysicalLocation p)set the x/y/z position in the soundspace of this VSDecoder Translates the given position to a position relative to the listener for the component VSDSounds.voidsetProfileName(java.lang.String pn)Set the profile name to the given string(package private) voidsetReturnDistance(double returnDistance)(package private) voidsetReturnLastTrack(LayoutTrack returnLastTrack)(package private) voidsetReturnTrack(LayoutTrack returnTrack)(package private) voidsetTunnelState(boolean t)voidsetVSDFilePath(java.lang.String p)Set the VSD File path for this VSDecoder to usevoidsetXml(VSDFile vf, java.lang.String pn)Build this VSDecoder from an XML representationvoidshutdown()Shut down this VSDecoder and all of its associated sounds.protected voidthrottlePropertyChange(java.beans.PropertyChangeEvent event)Handle the details of responding to a PropertyChangeEvent from a throttle.
-
-
-
Field Detail
-
initialized
boolean initialized
-
dirfn
int dirfn
-
posToSet
PhysicalLocation posToSet
-
lastPos
PhysicalLocation lastPos
-
startPos
PhysicalLocation startPos
-
topspeed
int topspeed
-
topspeed_rev
int topspeed_rev
-
setup_index
int setup_index
-
is_muted
boolean is_muted
-
distanceOnTrack
double distanceOnTrack
-
distanceMeter
float distanceMeter
-
distance
double distance
-
nextLayoutTrack
LayoutTrack nextLayoutTrack
-
sound_list
java.util.HashMap<java.lang.String,VSDSound> sound_list
-
event_list
java.util.LinkedHashMap<java.lang.String,SoundEvent> event_list
-
-
Constructor Detail
-
VSDecoder
public VSDecoder(VSDConfig cfg)
Construct a VSDecoder with the given system name (id) and configuration (config)- Parameters:
cfg- (VSDConfig) Configuration
-
VSDecoder
public VSDecoder(java.lang.String id, java.lang.String name, java.lang.String path)
Construct a VSDecoder with the given system name (id), profile name and VSD file path- Parameters:
id- (String) System name for this VSDecodername- (String) Profile namepath- (String) Path to a VSD file to pull the given Profile from
-
-
Method Detail
-
getId
public java.lang.String getId()
Get the ID (System Name) of this VSDecoder- Returns:
- (String) system name of this VSDecoder
-
isInitialized
public boolean isInitialized()
Check whether this VSDecoder has completed initialization- Returns:
- (boolean) true if initialization is complete.
-
setVSDFilePath
public void setVSDFilePath(java.lang.String p)
Set the VSD File path for this VSDecoder to use- Parameters:
p- (String) path to VSD File
-
getVSDFilePath
public java.lang.String getVSDFilePath()
Get the current VSD File path for this VSDecoder- Returns:
- (String) path to VSD file
-
shutdown
public void shutdown()
Shut down this VSDecoder and all of its associated sounds.
-
throttlePropertyChange
protected void throttlePropertyChange(java.beans.PropertyChangeEvent event)
Handle the details of responding to a PropertyChangeEvent from a throttle.- Parameters:
event- (PropertyChangeEvent) Throttle event to respond to
-
setAddress
public void setAddress(LocoAddress l)
Set this VSDecoder's LocoAddress, and register to follow events from the throttle with this address.- Parameters:
l- (LocoAddress) LocoAddress to be followed
-
getAddress
public LocoAddress getAddress()
Get the currently assigned LocoAddress- Returns:
- the currently assigned LocoAddress
-
getRosterEntry
public RosterEntry getRosterEntry()
-
getDecoderVolume
public float getDecoderVolume()
Get the current decoder volume setting for this VSDecoder- Returns:
- (float) volume level (0.0 - 1.0)
-
setDecoderVolume
public void setDecoderVolume(float decoder_volume)
Set the decoder volume for this VSDecoder- Parameters:
decoder_volume- (float) volume level (0.0 - 1.0)
-
isMuted
public boolean isMuted()
Is this VSDecoder muted?- Returns:
- true if muted
-
mute
public void mute(boolean m)
Mute or un-mute this VSDecoder- Parameters:
m- (boolean) true to mute, false to un-mute
-
setPosition
public void setPosition(PhysicalLocation p)
set the x/y/z position in the soundspace of this VSDecoder Translates the given position to a position relative to the listener for the component VSDSounds.The idea is that the user-preference Listener Position (relative to the USER's chosen origin) is always the OpenAL Context's origin.
- Parameters:
p- (PhysicalLocation) location relative to the user's chosen Origin.
-
setTunnelState
void setTunnelState(boolean t)
-
getPosition
public PhysicalLocation getPosition()
Get the current x/y/z position in the soundspace of this VSDecoder- Returns:
- PhysicalLocation location of this VSDecoder
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
Respond to property change events from this VSDecoder's GUI- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener- Parameters:
evt- (PropertyChangeEvent) event to respond to
-
getTrainPosition
protected PhysicalLocation getTrainPosition(Train t)
Get the physical location of the given Operations Train- Parameters:
t- (Train) the Train to interrogate- Returns:
- PhysicalLocation location of the train
-
getSound
public VSDSound getSound(java.lang.String name)
Retrieve the VSDSound with the given system name- Parameters:
name- (String) System name of the requested VSDSound- Returns:
- VSDSound the requested sound
-
setProfileName
public void setProfileName(java.lang.String pn)
Set the profile name to the given string- Parameters:
pn- (String) : name of the profile to set
-
getProfileName
public java.lang.String getProfileName()
get the currently selected profile name- Returns:
- (String) name of the currently selected profile
-
enable
void enable()
Enable this VSDecoder.
-
disable
void disable()
Disable this VSDecoder.
-
isEnabled
boolean isEnabled()
-
getEngineSound
public EngineSound getEngineSound()
Get a reference to the EngineSound associated with this VSDecoder- Returns:
- EngineSound The EngineSound reference for this VSDecoder or null
-
getEventList
public java.util.Collection<SoundEvent> getEventList()
Get a Collection of SoundEvents associated with this VSDecoder- Returns:
- Collection<SoundEvent> collection of SoundEvents
-
getXml
public org.jdom2.Element getXml()
Get an XML representation of this VSDecoder Includes a subtree of Elements for all of the associated SoundEvents, Triggers, VSDSounds, etc.- Returns:
- Element XML Element for this VSDecoder
-
setXml
public void setXml(VSDFile vf, java.lang.String pn)
Build this VSDecoder from an XML representation- Parameters:
vf- (VSDFile) : VSD File to pull the XML frompn- (String) : Parameter Name to find within the VSD File.
-
setLocation
void setLocation(java.awt.geom.Point2D location)
-
getLocation
java.awt.geom.Point2D getLocation()
-
getLastTrack
LayoutTrack getLastTrack()
-
setLastTrack
void setLastTrack(LayoutTrack lastTrack)
-
setLayoutTrack
void setLayoutTrack(LayoutTrack layoutTrack)
-
getLayoutTrack
LayoutTrack getLayoutTrack()
-
setReturnTrack
void setReturnTrack(LayoutTrack returnTrack)
-
getReturnTrack
LayoutTrack getReturnTrack()
-
setReturnLastTrack
void setReturnLastTrack(LayoutTrack returnLastTrack)
-
getReturnLastTrack
LayoutTrack getReturnLastTrack()
-
getDistance
double getDistance()
-
setDistance
void setDistance(double distance)
-
getReturnDistance
double getReturnDistance()
-
setReturnDistance
void setReturnDistance(double returnDistance)
-
getDirectionRAD
double getDirectionRAD()
-
setDirectionRAD
void setDirectionRAD(double directionRAD)
-
setDirectionDEG
void setDirectionDEG(double directionDEG)
-
getModels
LayoutEditor getModels()
-
setModels
void setModels(LayoutEditor models)
-
navigate
void navigate()
-
-