Class OlcbProgrammer
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrix.AbstractProgrammer
-
- jmri.jmrix.openlcb.OlcbProgrammer
-
- All Implemented Interfaces:
AddressedProgrammer
,PropertyChangeFirer
,PropertyChangeProvider
,Disposable
,Programmer
public class OlcbProgrammer extends AbstractProgrammer implements AddressedProgrammer
Provide access to the hardware DCC decoder programming capability.Programmers come in multiple types:
- Global, previously "Service Mode" or on a programming track
- Addressed, previously "Ops Mode" also known as "programming on the main"
- DCC CV programming, on service mode track or on the main
- CBUS Node Variable programmers
- LocoNet System Variable programmers
- LocoNet Op Switch programmers
- etc
You get a Programmer object from a
AddressedProgrammer
, which in turn can be located from theInstanceManager
.Starting in JMRI 3.5.5, the CV addresses are Strings for generality. The methods that use ints for CV addresses will later be deprecated.
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:
- 4.1.1
- See Also:
AddressedProgrammer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
OlcbProgrammer.ProgTrackListener
-
Nested classes/interfaces inherited from interface jmri.Programmer
Programmer.WriteConfirmMode
-
-
Field Summary
Fields Modifier and Type Field Description static int
ERROR_FAILED_VERIFY
static int
ERROR_INVALID_ARGUMENTS
static int
ERROR_INVALID_RESPONSE
static int
ERROR_NO_LOCO
static int
ERROR_NO_RAILCOM
static int
ERROR_PGM_DISABLED
static int
ERROR_PGM_SHORT
static int
ERROR_UNIMPLEMENTED_CMD
static EventID
IS_PROGRAMMINGTRACK_EVENT
(package private) NodeID
nid
static int
SPACE_DCC_CV
-
Fields inherited from class jmri.jmrix.AbstractProgrammer
LONG_TIMEOUT, SHORT_TIMEOUT
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description OlcbProgrammer(OlcbInterface system, boolean isLong, int address)
Creates an addressed programmer for a train node given by a DCC address.OlcbProgrammer(OlcbInterface system, NodeID nid)
Creates a programmer for a given OpenLCB node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
confirmCV(java.lang.String CV, int val, ProgListener p)
Confirm the value of a CV using the specified programming mode.java.lang.String
getAddress()
int
getAddressNumber()
boolean
getLongAddress()
java.util.List<ProgrammingMode>
getSupportedModes()
Get the list ofProgrammingMode
supported by this Programmer.void
readCV(java.lang.String CV, ProgListener p)
Perform a CV read in the system-specific manner, and using the specified programming mode.protected void
timeout()
Internal routine to handle a timeout, should be synchronized!void
writeCV(java.lang.String CV, int val, ProgListener p)
Perform a CV write in the system-specific manner, and using the specified programming mode.-
Methods inherited from class jmri.jmrix.AbstractProgrammer
decodeErrorCode, getBestMode, getCanRead, getCanRead, getCanWrite, getCanWrite, getMode, getWriteConfirmMode, registerFromCV, restartTimer, setMode, startLongTimer, startShortTimer, stopTimer
-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.Programmer
addPropertyChangeListener, decodeErrorCode, dispose, getCanRead, getCanRead, getCanWrite, getCanWrite, getMode, getWriteConfirmMode, notifyProgListenerEnd, readCV, removePropertyChangeListener, setMode
-
-
-
-
Field Detail
-
SPACE_DCC_CV
public static final int SPACE_DCC_CV
- See Also:
- Constant Field Values
-
IS_PROGRAMMINGTRACK_EVENT
public static final EventID IS_PROGRAMMINGTRACK_EVENT
-
ERROR_NO_LOCO
public static final int ERROR_NO_LOCO
- See Also:
- Constant Field Values
-
ERROR_FAILED_VERIFY
public static final int ERROR_FAILED_VERIFY
- See Also:
- Constant Field Values
-
ERROR_NO_RAILCOM
public static final int ERROR_NO_RAILCOM
- See Also:
- Constant Field Values
-
ERROR_INVALID_RESPONSE
public static final int ERROR_INVALID_RESPONSE
- See Also:
- Constant Field Values
-
ERROR_PGM_SHORT
public static final int ERROR_PGM_SHORT
- See Also:
- Constant Field Values
-
ERROR_UNIMPLEMENTED_CMD
public static final int ERROR_UNIMPLEMENTED_CMD
- See Also:
- Constant Field Values
-
ERROR_INVALID_ARGUMENTS
public static final int ERROR_INVALID_ARGUMENTS
- See Also:
- Constant Field Values
-
ERROR_PGM_DISABLED
public static final int ERROR_PGM_DISABLED
- See Also:
- Constant Field Values
-
nid
@CheckForNull NodeID nid
-
-
Constructor Detail
-
OlcbProgrammer
public OlcbProgrammer(OlcbInterface system, @CheckForNull NodeID nid)
Creates a programmer for a given OpenLCB node.- Parameters:
system
- system connection memonid
- the target node to use for DCC CV programming. This can be a train node or a program track node.
-
OlcbProgrammer
public OlcbProgrammer(OlcbInterface system, boolean isLong, int address)
Creates an addressed programmer for a train node given by a DCC address.- Parameters:
system
- system connection memoisLong
- dcc address typeaddress
- dcc address number
-
-
Method Detail
-
getSupportedModes
@Nonnull public java.util.List<ProgrammingMode> getSupportedModes()
Get the list ofProgrammingMode
supported by this Programmer. If the order is significant, earlier modes are better.- Specified by:
getSupportedModes
in interfaceProgrammer
- Specified by:
getSupportedModes
in classAbstractProgrammer
- Returns:
- the list of supported modes or an empty list
-
timeout
protected void timeout()
Internal routine to handle a timeout, should be synchronized!- Specified by:
timeout
in classAbstractProgrammer
-
writeCV
public void writeCV(java.lang.String CV, int val, ProgListener p) throws ProgrammerException
Perform a CV write in the system-specific manner, and using the specified programming mode.Handles a general address space through a String address. Each programmer defines the acceptable formats.
Note that this returns before the write is complete; you have to provide a ProgListener to hear about completion. For simplicity, expect the return to be on the GUI thread.
Exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier)
- Specified by:
writeCV
in interfaceProgrammer
- Specified by:
writeCV
in classAbstractProgrammer
- Parameters:
CV
- the CV to writeval
- the value to writep
- the listener that will be notified of the write- Throws:
ProgrammerException
- if unable to communicate
-
readCV
public void readCV(java.lang.String CV, ProgListener p) throws ProgrammerException
Perform a CV read in the system-specific manner, and using the specified programming mode.Handles a general address space through a String address. Each programmer defines the acceptable formats.
Note that this returns before the write is complete; you have to provide a ProgListener to hear about completion. For simplicity, expect the return to be on the GUI thread.
Exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier)
- Specified by:
readCV
in interfaceProgrammer
- Specified by:
readCV
in classAbstractProgrammer
- Parameters:
CV
- the CV to readp
- the listener that will be notified of the read- Throws:
ProgrammerException
- if unable to communicate
-
confirmCV
public void confirmCV(java.lang.String CV, int val, ProgListener p) throws ProgrammerException
Confirm the value of a CV using the specified programming mode. On some systems, this is faster than a read.Handles a general address space through a String address. Each programmer defines the acceptable formats.
Note that this returns before the write is complete; you have to provide a ProgListener to hear about completion. For simplicity, expect the return to be on the GUI thread.
Exceptions will only be thrown at the start, not during the actual programming sequence. A typical exception would be due to an invalid mode (though that should be prevented earlier)
- Specified by:
confirmCV
in interfaceProgrammer
- Specified by:
confirmCV
in classAbstractProgrammer
- Parameters:
CV
- the CV to confirmval
- the value to confirmp
- the listener that will be notified of the confirmation- Throws:
ProgrammerException
- if unable to communicate
-
getLongAddress
public boolean getLongAddress()
- Specified by:
getLongAddress
in interfaceAddressedProgrammer
-
getAddressNumber
public int getAddressNumber()
- Specified by:
getAddressNumber
in interfaceAddressedProgrammer
-
getAddress
public java.lang.String getAddress()
- Specified by:
getAddress
in interfaceAddressedProgrammer
-
-