use of jmri.ProgListener in project JMRI by JMRI.
the class MultiIndexProgrammerFacadeTest method testWriteReadDoubleIndexedCvListDelayedSkip.
public void testWriteReadDoubleIndexedCvListDelayedSkip() throws jmri.ProgrammerException, InterruptedException {
ProgDebugger dp = new ProgDebugger();
MultiIndexProgrammerFacade p = new MultiIndexProgrammerFacade(dp, "81", "82", false, true);
ProgListener l = new ProgListener() {
@Override
public void programmingOpReply(int value, int status) {
log.debug("callback value=" + value + " status=" + status);
replied = true;
readValue = value;
}
};
p.writeCV("45.46.123", 12, l);
waitReply();
Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
Assert.assertEquals("index 2 written", 46, dp.getCvVal(82));
Assert.assertEquals("value written", 12, dp.getCvVal(123));
dp.clearHasBeenWritten(81);
dp.clearHasBeenWritten(82);
// pretend too long has elapsed, so should still program
p.lastOpTime = p.lastOpTime - 2 * p.maxDelay;
p.readCV("45.46.123", l);
waitReply();
Assert.assertEquals("read back", 12, readValue);
Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
Assert.assertEquals("index 2 written", 46, dp.getCvVal(82));
}
use of jmri.ProgListener in project JMRI by JMRI.
the class MultiIndexProgrammerFacadeTest method testWriteReadSingleIndexedSkip.
public void testWriteReadSingleIndexedSkip() throws jmri.ProgrammerException, InterruptedException {
ProgDebugger dp = new ProgDebugger();
Programmer p = new MultiIndexProgrammerFacade(dp, "81", "82", true, true);
ProgListener l = new ProgListener() {
@Override
public void programmingOpReply(int value, int status) {
log.debug("callback value=" + value + " status=" + status);
replied = true;
readValue = value;
}
};
p.writeCV("123.45", 12, l);
waitReply();
Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
Assert.assertTrue("index 2 not written", !dp.hasBeenWritten(82));
Assert.assertEquals("value written", 12, dp.getCvVal(123));
dp.clearHasBeenWritten(81);
dp.clearHasBeenWritten(82);
p.readCV("123.45", l);
waitReply();
Assert.assertEquals("read back", 12, readValue);
Assert.assertTrue("index 1 not written", !dp.hasBeenWritten(81));
Assert.assertTrue("index 2 not written", !dp.hasBeenWritten(82));
}
use of jmri.ProgListener in project JMRI by JMRI.
the class OffsetHighCvProgrammerFacadeTest method testWriteReadDirectHighCV.
public void testWriteReadDirectHighCV() throws jmri.ProgrammerException, InterruptedException {
ProgDebugger dp = new ProgDebugger();
dp.setTestReadLimit(1024);
dp.setTestWriteLimit(1024);
Programmer p = new OffsetHighCvProgrammerFacade(dp, "256", "7", "10", "100");
ProgListener l = new ProgListener() {
@Override
public void programmingOpReply(int value, int status) {
log.debug("callback value=" + value + " status=" + status);
replied = true;
readValue = value;
}
};
p.writeCV("258", 12, l);
waitReply();
Assert.assertEquals("target written", 12, dp.getCvVal(258));
Assert.assertTrue("index not written", !dp.hasBeenWritten(7));
p.readCV("258", l);
waitReply();
Assert.assertEquals("read back", 12, readValue);
}
use of jmri.ProgListener in project JMRI by JMRI.
the class OffsetHighCvProgrammerFacadeTest method testWriteReadDirect.
public void testWriteReadDirect() throws jmri.ProgrammerException, InterruptedException {
ProgDebugger dp = new ProgDebugger();
dp.setTestReadLimit(256);
dp.setTestWriteLimit(256);
Programmer p = new OffsetHighCvProgrammerFacade(dp, "256", "7", "10", "100");
ProgListener l = new ProgListener() {
@Override
public void programmingOpReply(int value, int status) {
log.debug("callback value=" + value + " status=" + status);
replied = true;
readValue = value;
}
};
p.writeCV("4", 12, l);
waitReply();
Assert.assertEquals("target written", 12, dp.getCvVal(4));
Assert.assertTrue("index not written", !dp.hasBeenWritten(7));
p.readCV(4, l);
waitReply();
Assert.assertEquals("read back", 12, readValue);
}
use of jmri.ProgListener in project JMRI by JMRI.
the class MultiIndexProgrammerFacadeTest method testWriteReadDoubleIndexedCvList.
public void testWriteReadDoubleIndexedCvList() throws jmri.ProgrammerException, InterruptedException {
ProgDebugger dp = new ProgDebugger();
Programmer p = new MultiIndexProgrammerFacade(dp, "81", "82", false, false);
ProgListener l = new ProgListener() {
@Override
public void programmingOpReply(int value, int status) {
log.debug("callback value=" + value + " status=" + status);
replied = true;
readValue = value;
}
};
p.writeCV("45.46.123", 12, l);
waitReply();
Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
Assert.assertEquals("index 2 written", 46, dp.getCvVal(82));
Assert.assertEquals("value written", 12, dp.getCvVal(123));
dp.clearHasBeenWritten(81);
dp.clearHasBeenWritten(82);
p.readCV("45.46.123", l);
waitReply();
Assert.assertEquals("read back", 12, readValue);
Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
Assert.assertEquals("index 2 written", 46, dp.getCvVal(82));
dp.clearHasBeenWritten(81);
dp.clearHasBeenWritten(82);
p.readCV("45.46.123", l);
waitReply();
Assert.assertEquals("read back", 12, readValue);
Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
Assert.assertEquals("index 2 written", 46, dp.getCvVal(82));
dp.clearHasBeenWritten(81);
dp.clearHasBeenWritten(82);
p.readCV("45.46.123", l);
waitReply();
Assert.assertEquals("read back", 12, readValue);
Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
Assert.assertEquals("index 2 written", 46, dp.getCvVal(82));
}
Aggregations