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) float
avgspeed
(package private) int
dirfn
(package private) double
distance
(package private) float
distanceMeter
(package private) double
distanceOnTrack
(package private) boolean
enabled
(package private) java.util.HashMap<java.lang.String,SoundEvent>
event_list
(package private) boolean
initialized
(package private) boolean
is_muted
(package private) PhysicalLocation
lastPos
(package private) float
lastspeed
(package private) LayoutTrack
nextLayoutTrack
(package private) PhysicalLocation
posToSet
(package private) VSDSound
savedSound
(package private) int
setup_index
(package private) java.util.HashMap<java.lang.String,VSDSound>
sound_list
(package private) PhysicalLocation
startPos
(package private) int
topspeed
(package private) int
topspeed_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 void
disable()
Disable this VSDecoder.void
enable()
Enable this VSDecoder.LocoAddress
getAddress()
Get the currently assigned LocoAddressfloat
getDecoderVolume()
Get the current decoder volume setting for this VSDecoder(package private) double
getDirectionRAD()
(package private) double
getDistance()
EngineSound
getEngineSound()
Get a reference to the EngineSound associated with this VSDecoderjava.util.Collection<SoundEvent>
getEventList()
Get a Collection of SoundEvents associated with this VSDecoderjava.lang.String
getId()
Get the ID (System Name) of this VSDecoder(package private) LayoutTrack
getLastTrack()
(package private) LayoutTrack
getLayoutTrack()
(package private) java.awt.geom.Point2D
getLocation()
(package private) LayoutEditor
getModels()
PhysicalLocation
getPosition()
Get the current x/y/z position in the soundspace of this VSDecoderjava.lang.String
getProfileName()
get the currently selected profile name(package private) double
getReturnDistance()
(package private) LayoutTrack
getReturnLastTrack()
(package private) LayoutTrack
getReturnTrack()
RosterEntry
getRosterEntry()
VSDSound
getSound(java.lang.String name)
Retrieve the VSDSound with the given system nameprotected PhysicalLocation
getTrainPosition(Train t)
Get the physical location of the given Operations Trainjava.lang.String
getVSDFilePath()
Get the current VSD File path for this VSDecoderorg.jdom2.Element
getXml()
Get an XML representation of this VSDecoder Includes a subtree of Elements for all of the associated SoundEvents, Triggers, VSDSounds, etc.boolean
isInitialized()
Check whether this VSDecoder has completed initializationboolean
isMuted()
Is this VSDecoder muted?void
mute(boolean m)
Mute or un-mute this VSDecoder(package private) void
navigate()
void
propertyChange(java.beans.PropertyChangeEvent evt)
Respond to property change events from this VSDecoder's GUIvoid
setAddress(LocoAddress l)
Set this VSDecoder's LocoAddress, and register to follow events from the throttle with this address.void
setDecoderVolume(float decoder_volume)
Set the decoder volume for this VSDecoder(package private) void
setDirectionDEG(double directionDEG)
(package private) void
setDirectionRAD(double directionRAD)
(package private) void
setDistance(double distance)
(package private) void
setLastTrack(LayoutTrack lastTrack)
(package private) void
setLayoutTrack(LayoutTrack layoutTrack)
(package private) void
setLocation(java.awt.geom.Point2D location)
(package private) void
setModels(LayoutEditor models)
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.void
setProfileName(java.lang.String pn)
Set the profile name to the given string(package private) void
setReturnDistance(double returnDistance)
(package private) void
setReturnLastTrack(LayoutTrack returnLastTrack)
(package private) void
setReturnTrack(LayoutTrack returnTrack)
void
setVSDFilePath(java.lang.String p)
Set the VSD File path for this VSDecoder to usevoid
setXml(VSDFile vf, java.lang.String pn)
Build this VSDecoder from an XML representationvoid
shutdown()
Shut down this VSDecoder and all of its associated sounds.protected void
throttlePropertyChange(java.beans.PropertyChangeEvent event)
Handle the details of responding to a PropertyChangeEvent from a throttle.
-
-
-
Field Detail
-
initialized
boolean initialized
-
enabled
boolean enabled
-
dirfn
int dirfn
-
posToSet
PhysicalLocation posToSet
-
lastPos
PhysicalLocation lastPos
-
startPos
PhysicalLocation startPos
-
topspeed
int topspeed
-
topspeed_rev
int topspeed_rev
-
lastspeed
float lastspeed
-
avgspeed
float avgspeed
-
setup_index
int setup_index
-
is_muted
boolean is_muted
-
savedSound
VSDSound savedSound
-
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.HashMap<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.
-
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:
propertyChange
in 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
public void enable()
Enable this VSDecoder.
-
disable
public void disable()
Disable this VSDecoder.
-
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()
-
-