use of jmri.ProgListener in project JMRI by JMRI.
the class MultiIndexProgrammerFacadeTest method testWriteReadDoubleIndexedCvListSkip.
public void testWriteReadDoubleIndexedCvListSkip() 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);
p.readCV("45.46.123", 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));
dp.clearHasBeenWritten(81);
dp.clearHasBeenWritten(82);
p.readCV("45.46.123", 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));
dp.clearHasBeenWritten(81);
dp.clearHasBeenWritten(82);
p.readCV("45.46.123", 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));
// add timeout
p.lastOpTime = p.lastOpTime - 2 * p.maxDelay;
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));
}
use of jmri.ProgListener in project JMRI by JMRI.
the class MultiIndexProgrammerFacadeTest method testWriteReadDirect.
public void testWriteReadDirect() throws jmri.ProgrammerException, InterruptedException {
ProgDebugger dp = new ProgDebugger();
Programmer p = new MultiIndexProgrammerFacade(dp, "81", null, true, 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("4", 12, l);
waitReply();
Assert.assertEquals("target written", 12, dp.getCvVal(4));
Assert.assertTrue("index not written", !dp.hasBeenWritten(81));
p.readCV("4", l);
waitReply();
Assert.assertEquals("read back", 12, readValue);
Assert.assertTrue("index not written", !dp.hasBeenWritten(81));
}
use of jmri.ProgListener in project JMRI by JMRI.
the class TwoIndexTcsProgrammerFacadeTest method testWriteReadTripleIndexed.
public void testWriteReadTripleIndexed() throws jmri.ProgrammerException, InterruptedException {
ProgDebugger dp = new ProgDebugger();
Programmer p = new TwoIndexTcsProgrammerFacade(dp);
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("T3CV.10.20.30", 13, l);
waitReply();
Assert.assertEquals("index 1 written", 10, dp.getCvVal(201));
Assert.assertEquals("value written", 13, dp.getCvVal(202));
Assert.assertEquals("index written to MSB", 20, dp.getCvVal(203));
Assert.assertEquals("index written to LSB", 30, dp.getCvVal(204));
dp.clearHasBeenWritten(201);
dp.resetCv(202, 13);
dp.clearHasBeenWritten(203);
dp.clearHasBeenWritten(204);
p.readCV("T3CV.10.20.30", l);
waitReply();
Assert.assertEquals("index 1 written", 100 + 10, dp.getCvVal(201));
Assert.assertEquals("SI not written, left at start value", 13, dp.getCvVal(202));
Assert.assertEquals("index written to MSB", 20, dp.getCvVal(203));
Assert.assertEquals("index written to LSB", 30, dp.getCvVal(204));
Assert.assertEquals("read back", 13, readValue);
}
use of jmri.ProgListener in project JMRI by JMRI.
the class TwoIndexTcsProgrammerFacadeTest method testWriteReadDoubleIndexed.
public void testWriteReadDoubleIndexed() throws jmri.ProgrammerException, InterruptedException {
ProgDebugger dp = new ProgDebugger();
Programmer p = new TwoIndexTcsProgrammerFacade(dp);
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("T2CV.10.20", 12 * 256 + 13, l);
waitReply();
Assert.assertEquals("index 1 written", 10, dp.getCvVal(201));
Assert.assertEquals("index 2 written", 20, dp.getCvVal(202));
Assert.assertEquals("value MSB written", 12, dp.getCvVal(203));
Assert.assertEquals("value LSB written", 13, dp.getCvVal(204));
dp.clearHasBeenWritten(201);
dp.clearHasBeenWritten(202);
dp.clearHasBeenWritten(203);
dp.clearHasBeenWritten(204);
dp.resetCv(203, 12);
dp.resetCv(204, 20);
p.readCV("T2CV.10.20", l);
waitReply();
Assert.assertEquals("index 1 written", 100 + 10, dp.getCvVal(201));
Assert.assertEquals("index 2 written", 20, dp.getCvVal(202));
// TCS says this is arbitrary, so
Assert.assertEquals("dummy 204 written", 100, dp.getCvVal(204));
// we write the offset value
// We get 100 from the LSB
Assert.assertEquals("read back", 12 * 256 + 100, readValue);
// because we wrote the offset
// and the test Programmer remembers that
}
use of jmri.ProgListener in project JMRI by JMRI.
the class AccessoryOpsModeProgrammerFacadeTest method testWriteDirect.
public void testWriteDirect() throws jmri.ProgrammerException, InterruptedException {
ProgDebugger dp = new ProgDebugger(true, 123);
Programmer p = new AccessoryOpsModeProgrammerFacade(dp, null);
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.assertTrue("target not directly written", !dp.hasBeenWritten(12));
Assert.assertTrue("index not written", !dp.hasBeenWritten(81));
Assert.assertNotNull("packet sent", lastPacket);
}
Aggregations