Class 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.

    • Constructor Detail

      • VSDecoder

        public VSDecoder​(VSDConfig cfg)
        Construct a VSDecoder with the given system name (id) and configuration (config)
        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
        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 Detail

      • getId

        public java.lang.String getId()
        Get the ID (System Name) of this VSDecoder
        (String) system name of this VSDecoder
      • isInitialized

        public boolean isInitialized()
        Check whether this VSDecoder has completed initialization
        (boolean) true if initialization is complete.
      • setVSDFilePath

        public void setVSDFilePath​(java.lang.String p)
        Set the VSD File path for this VSDecoder to use
        p - (String) path to VSD File
      • getVSDFilePath

        public java.lang.String getVSDFilePath()
        Get the current VSD File path for this VSDecoder
        (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.
        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.
        l - (LocoAddress) LocoAddress to be followed
      • getAddress

        public LocoAddress getAddress()
        Get the currently assigned LocoAddress
        the currently assigned LocoAddress
      • getDecoderVolume

        public float getDecoderVolume()
        Get the current decoder volume setting for this VSDecoder
        (float) volume level (0.0 - 1.0)
      • setDecoderVolume

        public void setDecoderVolume​(float decoder_volume)
        Set the decoder volume for this VSDecoder
        decoder_volume - (float) volume level (0.0 - 1.0)
      • isMuted

        public boolean isMuted()
        Is this VSDecoder muted?
        true if muted
      • mute

        public void mute​(boolean m)
        Mute or un-mute this VSDecoder
        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.

        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
        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 interface java.beans.PropertyChangeListener
        evt - (PropertyChangeEvent) event to respond to
      • getTrainPosition

        protected PhysicalLocation getTrainPosition​(Train t)
        Get the physical location of the given Operations Train
        t - (Train) the Train to interrogate
        PhysicalLocation location of the train
      • getSound

        public VSDSound getSound​(java.lang.String name)
        Retrieve the VSDSound with the given system name
        name - (String) System name of the requested VSDSound
        VSDSound the requested sound
      • setProfileName

        public void setProfileName​(java.lang.String pn)
        Set the profile name to the given string
        pn - (String) : name of the profile to set
      • getProfileName

        public java.lang.String getProfileName()
        get the currently selected profile name
        (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
        EngineSound The EngineSound reference for this VSDecoder or null
      • getEventList

        public java.util.Collection<SoundEventgetEventList()
        Get a Collection of SoundEvents associated with this VSDecoder
        Collection<SoundEvent> collection of SoundEvents
      • getXml

        public Element getXml()
        Get an XML representation of this VSDecoder Includes a subtree of Elements for all of the associated SoundEvents, Triggers, VSDSounds, etc.
        Element XML Element for this VSDecoder
      • setXml

        public void setXml​(VSDFile vf,
                           java.lang.String pn)
        Build this VSDecoder from an XML representation
        vf - (VSDFile) : VSD File to pull the XML from
        pn - (String) : Parameter Name to find within the VSD File.
      • setLocation

        void setLocation​(java.awt.geom.Point2D location)