Class DefaultRailCom

  • All Implemented Interfaces:
    java.lang.Comparable<NamedBean>, AddressedIdTag, PropertyChangeProvider, IdTag, NamedBean, RailCom, Reportable

    public class DefaultRailCom
    extends DefaultIdTag
    implements RailCom
    Concrete implementation of the RailCom interface.
    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.

    Since:
    2.99.3
    • Field Detail

      • cvValues

        java.util.Hashtable<java.lang.Integer,​java.lang.Integer> cvValues
    • Constructor Detail

      • DefaultRailCom

        public DefaultRailCom​(java.lang.String systemName)
      • DefaultRailCom

        public DefaultRailCom​(java.lang.String systemName,
                              java.lang.String userName)
    • Method Detail

      • setState

        public void setState​(int s)
                      throws JmriException
        Description copied from interface: NamedBean
        Provide generic access to internal state.

        This generally shouldn't be used by Java code; use the class-specific form instead (e.g. setCommandedState in Turnout). This is provided to make scripts access easier to read.

        Specified by:
        setState in interface NamedBean
        Overrides:
        setState in class DefaultIdTag
        Parameters:
        s - the state
        Throws:
        JmriException - general error when setting the state fails
      • getState

        public int getState()
        Description copied from interface: NamedBean
        Provide generic access to internal state.

        This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read.

        Specified by:
        getState in interface NamedBean
        Overrides:
        getState in class DefaultIdTag
        Returns:
        the state
      • setOrientation

        public void setOrientation​(int type)
        Description copied from interface: RailCom
        Method for a RailCom Reader to set the orientation reported back from a device
        Specified by:
        setOrientation in interface RailCom
        Parameters:
        type - the orientation to set
      • getOrientation

        public int getOrientation()
        Description copied from interface: RailCom
        Gets the Orientation of the Rail Com device on the track
        Specified by:
        getOrientation in interface RailCom
        Returns:
        current orientation
      • setActualSpeed

        public void setActualSpeed​(int type)
        Description copied from interface: RailCom
        Method for a RailCom Reader to set the Actual speed reported back from a device
        Specified by:
        setActualSpeed in interface RailCom
        Parameters:
        type - the speed
      • getActualSpeed

        public int getActualSpeed()
        Description copied from interface: RailCom
        Gets the actual speed reported by the RailCom device as a representation 128 speed steps
        Specified by:
        getActualSpeed in interface RailCom
        Returns:
        -1 if not set.
      • setActualLoad

        public void setActualLoad​(int type)
        Description copied from interface: RailCom
        Method for a RailCom Reader to set the Actual Load back from a device.
        Specified by:
        setActualLoad in interface RailCom
        Parameters:
        type - the load
      • getActualLoad

        public int getActualLoad()
        Description copied from interface: RailCom
        Gets the actual load reported by decoder the RailCom device.
        Specified by:
        getActualLoad in interface RailCom
        Returns:
        -1 if not set.
      • setActualTemperature

        public void setActualTemperature​(int type)
        Description copied from interface: RailCom
        Method for a RailCom Reader to set the actual temperate reported back from a device.
        Specified by:
        setActualTemperature in interface RailCom
        Parameters:
        type - the temperature
      • getActualTemperature

        public int getActualTemperature()
        Description copied from interface: RailCom
        Gets the actual temperate reported by the RailCom device. Location is configured in CV876 (RP.9.3.2)
        Specified by:
        getActualTemperature in interface RailCom
        Returns:
        -1 if not set.
      • setWaterLevel

        public void setWaterLevel​(int type)
        Description copied from interface: RailCom
        Method for a RailCom Reader to set the water level reported back from a device.
        Specified by:
        setWaterLevel in interface RailCom
        Parameters:
        type - the water level
      • getWaterLevel

        public int getWaterLevel()
        Description copied from interface: RailCom
        Gets the remaining fuel level as a % Water level CV878 (RP.9.3.2)
        Specified by:
        getWaterLevel in interface RailCom
        Returns:
        -1 if not set.
      • setFuelLevel

        public void setFuelLevel​(int type)
        Description copied from interface: RailCom
        Method for a RailCom Reader to set the fuel level reported back from a device.
        Specified by:
        setFuelLevel in interface RailCom
        Parameters:
        type - the fuel level
      • getFuelLevel

        public int getFuelLevel()
        Description copied from interface: RailCom
        Gets the remaining fuel level as a % Fuel level CV879 (RP.9.3.2)
        Specified by:
        getFuelLevel in interface RailCom
        Returns:
        -1 if not set.
      • setLocation

        public void setLocation​(int type)
        Description copied from interface: RailCom
        Method for a RailCom Reader to set the location reported back from a device.
        Specified by:
        setLocation in interface RailCom
        Parameters:
        type - the location
      • getLocation

        public int getLocation()
        Description copied from interface: RailCom
        Gets the Last Location that the RailCom device was identified in Location is configured in CV876 (RP.9.3.2)
        Specified by:
        getLocation in interface RailCom
        Returns:
        -1 if not set.
      • setRoutingNo

        public void setRoutingNo​(int type)
        Description copied from interface: RailCom
        Method for a RailCom Reader to set the routing number reported back from a device.
        Specified by:
        setRoutingNo in interface RailCom
        Parameters:
        type - the routing number
      • getRoutingNo

        public int getRoutingNo()
        Description copied from interface: RailCom
        Gets the routing number that the RailCom device wishes to travel. Route Number is configured in CV874 (RP.9.3.2)
        Specified by:
        getRoutingNo in interface RailCom
        Returns:
        -1 if not set.
      • setExpectedCv

        public void setExpectedCv​(int cv)
        Description copied from interface: RailCom
        Set the CV number of the next expected value to be returned in a RailCom Packet.
        Specified by:
        setExpectedCv in interface RailCom
        Parameters:
        cv - the expected CV
      • getExpectedCv

        public int getExpectedCv()
        Description copied from interface: RailCom
        Get the expected CV to be returned in a RailCom Packet.
        Specified by:
        getExpectedCv in interface RailCom
        Returns:
        the expected CV
      • setCvValue

        public void setCvValue​(int value)
        Description copied from interface: RailCom
        Set the value of the CV that has been read from the RailCom packet.
        Specified by:
        setCvValue in interface RailCom
        Parameters:
        value - the CV value
      • getCV

        public int getCV​(int cv)
        Description copied from interface: RailCom
        Gets the value of a CV reported back from the RailCom device.
        Specified by:
        getCV in interface RailCom
        Parameters:
        cv - CV number that the value relates to.
        Returns:
        the value of the CV, or 0 if none has yet been collected
      • setCV

        public void setCV​(int cv,
                          int value)
        Description copied from interface: RailCom
        Sets the value of a CV reported back from the decoder.
        Specified by:
        setCV in interface RailCom
        Parameters:
        cv - CV number that the value relates to.
        value - Value of the CV
      • getCVList

        public java.util.List<java.lang.Integer> getCVList()
        Description copied from interface: RailCom
        Get a list of the CVs last seen for this RailCom device.
        Specified by:
        getCVList in interface RailCom
        Returns:
        a list of CVs
      • toReportString

        public java.lang.String toReportString()
        Description copied from class: AbstractIdTag
        The IDTag version of toReportString returns a string consisting of the user name (if defined) or Tag ID followed by the associated list of property values.
        Specified by:
        toReportString in interface Reportable
        Overrides:
        toReportString in class AbstractIdTag
        Returns:
        a report string representing the Object.