Package jmri.jmrit
Class AbstractIdentify
- java.lang.Object
-
- jmri.jmrit.AbstractIdentify
-
- All Implemented Interfaces:
java.util.EventListener
,ProgListener
- Direct Known Subclasses:
IdentifyDecoder
,IdentifyLoco
public abstract class AbstractIdentify extends java.lang.Object implements ProgListener
Abstract base for common code ofIdentifyLoco
andIdentifyDecoder
, the two classes that use a programmer to match Roster entries to what's on the programming track.This is a class (instead of a
Roster
member function) to simplify use ofProgrammer
callbacks.- See Also:
CombinedLocoSelPane
,NewLocoSelPane
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
cvToRead
(package private) java.lang.String
cvToWrite
(package private) int
lastValue
(package private) boolean
optionalCv
(package private) Programmer
programmer
(package private) int
retry
(package private) static int
RETRY_COUNT
(package private) ProgrammingMode
savedMode
(package private) int
state
State of the internal sequence.-
Fields inherited from interface jmri.ProgListener
CommError, ConfirmFailed, FailedTimeout, NoAck, NoLocoDetected, NotImplemented, OK, ProgrammerBusy, ProgrammingShort, SequenceError, UnknownError, UserAborted
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractIdentify(Programmer p)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
error()
Abstract routine to notify of errors.protected void
identifyDone()
Stop the identification state machine.boolean
isOptionalCv()
Check the current status of theoptionalCv
flag.boolean
isRunning()
To check if running now.void
programmingOpReply(int value, int status)
Internal method to handle the programmer callbacks, e.g. when a CV read request terminates.protected void
readCV(java.lang.String cv)
Read a single CV for the next step.void
setOptionalCv(boolean flag)
Specify whether the next CV read may legitimately fail in some cases.void
start()
Start the identification state machine.protected abstract void
statusUpdate(java.lang.String status)
Update the status field (if any).abstract boolean
test1()
abstract boolean
test2(int value)
abstract boolean
test3(int value)
abstract boolean
test4(int value)
abstract boolean
test5(int value)
abstract boolean
test6(int value)
abstract boolean
test7(int value)
abstract boolean
test8(int value)
abstract boolean
test9(int value)
protected void
writeCV(java.lang.String cv, int value)
Write a single CV for the next step.
-
-
-
Field Detail
-
RETRY_COUNT
static final int RETRY_COUNT
- See Also:
- Constant Field Values
-
programmer
Programmer programmer
-
savedMode
ProgrammingMode savedMode
-
state
int state
State of the internal sequence.
-
retry
int retry
-
lastValue
int lastValue
-
optionalCv
boolean optionalCv
-
cvToRead
java.lang.String cvToRead
-
cvToWrite
java.lang.String cvToWrite
-
-
Constructor Detail
-
AbstractIdentify
protected AbstractIdentify(Programmer p)
-
-
Method Detail
-
test1
public abstract boolean test1()
-
test2
public abstract boolean test2(int value)
-
test3
public abstract boolean test3(int value)
-
test4
public abstract boolean test4(int value)
-
test5
public abstract boolean test5(int value)
-
test6
public abstract boolean test6(int value)
-
test7
public abstract boolean test7(int value)
-
test8
public abstract boolean test8(int value)
-
test9
public abstract boolean test9(int value)
-
statusUpdate
protected abstract void statusUpdate(java.lang.String status)
Update the status field (if any). Invoked with "Done" when the results are in.- Parameters:
status
- the new status
-
start
public void start()
Start the identification state machine.
-
identifyDone
protected void identifyDone()
Stop the identification state machine. This also stops the identification process. Its invoked when a testN returns true; that routine should _not_ have invoked a read or write that will result in a callback.
-
programmingOpReply
public void programmingOpReply(int value, int status)
Internal method to handle the programmer callbacks, e.g. when a CV read request terminates. Each will reduce (if possible) the list of consistent decoders, and starts the next step.- Specified by:
programmingOpReply
in interfaceProgListener
- Parameters:
value
- the value returnedstatus
- the status reported
-
error
protected abstract void error()
Abstract routine to notify of errors.
-
isRunning
public boolean isRunning()
To check if running now.- Returns:
- true if running; false otherwise
-
readCV
protected void readCV(java.lang.String cv)
Read a single CV for the next step.- Parameters:
cv
- the CV to read
-
writeCV
protected void writeCV(java.lang.String cv, int value)
Write a single CV for the next step.- Parameters:
cv
- the CV to writevalue
- to write to the CV
-
isOptionalCv
public boolean isOptionalCv()
Check the current status of theoptionalCv
flag.- If
true
, prevents the next CV read from aborting the identification process. - Always
false
after a successful read.
- Returns:
- the current status of the
optionalCv
flag
- If
-
setOptionalCv
public void setOptionalCv(boolean flag)
Specify whether the next CV read may legitimately fail in some cases.- Parameters:
flag
- Settrue
to indicate that the next read may fail. A successful read will automatically set tofalse
.
-
-