Search in sources :

Example 31 with ProgDebugger

use of jmri.progdebugger.ProgDebugger in project JMRI by JMRI.

the class VerifyWriteProgrammerFacadeTest method testCvLimit.

public void testCvLimit() {
    ProgDebugger dp = new ProgDebugger();
    dp.setTestReadLimit(1024);
    dp.setTestWriteLimit(1024);
    Programmer p = new VerifyWriteProgrammerFacade(dp);
    Assert.assertTrue("CV limit read OK", p.getCanRead("1024"));
    Assert.assertTrue("CV limit write OK", p.getCanWrite("1024"));
    Assert.assertTrue("CV limit read fail", !p.getCanRead("1025"));
    Assert.assertTrue("CV limit write fail", !p.getCanWrite("1025"));
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger)

Example 32 with ProgDebugger

use of jmri.progdebugger.ProgDebugger 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
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 33 with ProgDebugger

use of jmri.progdebugger.ProgDebugger 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);
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 34 with ProgDebugger

use of jmri.progdebugger.ProgDebugger in project JMRI by JMRI.

the class AddressedHighCvProgrammerFacadeTest method testWriteReadDirectHighCVRightSide.

public void testWriteReadDirectHighCVRightSide() throws jmri.ProgrammerException, InterruptedException {
    ProgDebugger dp = new ProgDebugger();
    dp.setTestReadLimit(256);
    dp.setTestWriteLimit(1024);
    Programmer p = new AddressedHighCvProgrammerFacade(dp, "256", "253", "254", "255", "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 H not written", !dp.hasBeenWritten(253));
    Assert.assertTrue("index L not written", !dp.hasBeenWritten(254));
    Assert.assertTrue("index val not written", !dp.hasBeenWritten(255));
    dp.setTestReadLimit(1024);
    dp.setTestWriteLimit(256);
    p.readCV("258", l);
    waitReply();
    Assert.assertEquals("read back", 12, readValue);
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 35 with ProgDebugger

use of jmri.progdebugger.ProgDebugger in project JMRI by JMRI.

the class AccessoryOpsModeProgrammerFacadeTest method testCvLimit.

public void testCvLimit() {
    ProgDebugger dp = new ProgDebugger(true, 123);
    dp.setTestReadLimit(1024);
    dp.setTestWriteLimit(1024);
    Programmer p = new AccessoryOpsModeProgrammerFacade(dp, null);
    Assert.assertTrue("CV limit read OK", p.getCanRead("1024"));
    Assert.assertTrue("CV limit write OK", p.getCanWrite("1024"));
    Assert.assertTrue("CV limit read fail", !p.getCanRead("1025"));
    Assert.assertTrue("CV limit write fail", !p.getCanWrite("1025"));
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger)

Aggregations

ProgDebugger (jmri.progdebugger.ProgDebugger)40 Programmer (jmri.Programmer)33 ProgListener (jmri.ProgListener)27 JLabel (javax.swing.JLabel)4 Element (org.jdom2.Element)4 DocType (org.jdom2.DocType)2 Document (org.jdom2.Document)2 DefaultProgrammerManager (jmri.managers.DefaultProgrammerManager)1 Before (org.junit.Before)1