Class VSDecoder

java.lang.Object
jmri.jmrit.vsdecoder.VSDecoder
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class VSDecoder extends Object implements 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 Details

  • Constructor Details

    • VSDecoder

      public VSDecoder(VSDConfig cfg)
      Construct a VSDecoder with the given system name (id) and configuration (config)
      Parameters:
      cfg - (VSDConfig) Configuration
    • VSDecoder

      public VSDecoder(String id, String name, String path)
      Construct a VSDecoder with the given system name (id), profile name and VSD file path
      Parameters:
      id - (String) System name for this VSDecoder
      name - (String) Profile name
      path - (String) Path to a VSD file to pull the given Profile from
  • Method Details

    • getId

      public 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(String p)
      Set the VSD File path for this VSDecoder to use
      Parameters:
      p - (String) path to VSD File
    • 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

      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

      Get the currently assigned LocoAddress
      Returns:
      the currently assigned LocoAddress
    • 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

      Get the current x/y/z position in the soundspace of this VSDecoder
      Returns:
      PhysicalLocation location of this VSDecoder
    • propertyChange

      Respond to property change events from this VSDecoder's GUI
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      evt - (PropertyChangeEvent) event to respond to
    • getTrainPosition

      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(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(String pn)
      Set the profile name to the given string
      Parameters:
      pn - (String) : name of the profile to set
    • 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

      Get a reference to the EngineSound associated with this VSDecoder
      Returns:
      EngineSound The EngineSound reference for this VSDecoder or null
    • 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, String pn)
      Build this VSDecoder from an XML representation
      Parameters:
      vf - (VSDFile) : VSD File to pull the XML from
      pn - (String) : Parameter Name to find within the VSD File.
    • setLocation

      void setLocation(Point2D location)
    • getLocation

    • getLastTrack

    • setLastTrack

      void setLastTrack(LayoutTrack lastTrack)
    • setLayoutTrack

      void setLayoutTrack(LayoutTrack layoutTrack)
    • getLayoutTrack

    • setReturnTrack

      void setReturnTrack(LayoutTrack returnTrack)
    • getReturnTrack

    • setReturnLastTrack

      void setReturnLastTrack(LayoutTrack returnLastTrack)
    • getReturnLastTrack

    • getDistance

      double getDistance()
    • setDistance

      void setDistance(double distance)
    • getReturnDistance

    • setReturnDistance

      void setReturnDistance(double returnDistance)
    • getDirectionRAD

      double getDirectionRAD()
    • setDirectionRAD

      void setDirectionRAD(double directionRAD)
    • setDirectionDEG

      void setDirectionDEG(double directionDEG)
    • getModels

    • setModels

      void setModels(LayoutEditor models)