use of jmri.ProgListener in project JMRI by JMRI.
the class BoosterProgPanel method setDurationPushed.
void setDurationPushed() {
getProgrammer();
status.setText(rb.getString("StatusProgramming"));
int val = Integer.parseInt(length.getText()) / 256;
try {
p.writeCV(253, val, new ProgListener() {
@Override
public void programmingOpReply(int value, int retval) {
synchronized (this) {
try {
// needed for booster to reset
wait(1500);
} catch (InterruptedException i) {
}
}
durationPart2();
}
});
} catch (ProgrammerException e) {
status.setText(rb.getString("StatusError") + e);
releaseProgrammer();
}
}
use of jmri.ProgListener in project JMRI by JMRI.
the class ProgDebugger method readCV.
@Override
public void readCV(int CV, ProgListener p) throws ProgrammerException {
final ProgListener m = p;
_lastReadCv = CV;
nOperations++;
int readValue = _nextRead;
// try to get something from hash table
Integer saw = mValues.get(CV);
if (saw != null) {
readValue = saw;
}
log.info("read CV: " + CV + " mode: " + getMode() + " will read " + readValue);
final int returnValue = readValue;
// return a notification via the queue to ensure end
Runnable r = new Runnable() {
int retval = returnValue;
ProgListener l = m;
@Override
public void run() {
// log.debug("read CV reply - start sleep");
// try { Thread.sleep(100); } catch (Exception e) {}
log.debug("read CV reply");
l.programmingOpReply(retval, 0);
}
};
sendReturn(r);
}
use of jmri.ProgListener in project JMRI by JMRI.
the class ProgDebugger method confirmCV.
@Override
public void confirmCV(String CVname, int val, ProgListener p) throws ProgrammerException {
int CV = Integer.parseInt(CVname);
final ProgListener m = p;
nOperations++;
// guess by comparing current value in val to has table
Integer saw = mValues.get(CV);
// what was read
int result;
if (saw != null) {
result = saw;
confirmOK = (result == val);
log.info("confirm CV: " + CV + " mode: " + getMode() + " will return " + result + " pass: " + confirmOK);
} else {
result = -1;
confirmOK = false;
log.info("confirm CV: " + CV + " mode: " + getMode() + " will return -1 pass: false due to no previous value");
}
_lastReadCv = CV;
// return a notification via the queue to ensure end
// final to allow passing to inner class
final int returnResult = result;
Runnable r = new Runnable() {
ProgListener l = m;
int result = returnResult;
@Override
public void run() {
log.debug("read CV reply");
if (confirmOK) {
l.programmingOpReply(result, ProgListener.OK);
} else {
l.programmingOpReply(result, ProgListener.ConfirmFailed);
}
}
};
sendReturn(r);
}
Aggregations