Search in sources :

Example 26 with ProgListener

use of jmri.ProgListener in project JMRI by JMRI.

the class MultiIndexProgrammerFacadeTest method testWriteReadSingleIndexedCvLast.

public void testWriteReadSingleIndexedCvLast() 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.123", 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("45.123", l);
    waitReply();
    Assert.assertEquals("read back", 12, readValue);
    Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
    Assert.assertTrue("index 2 not written", !dp.hasBeenWritten(82));
    Assert.assertEquals("index written", 45, dp.getCvVal(81));
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 27 with ProgListener

use of jmri.ProgListener in project JMRI by JMRI.

the class TwoIndexTcsProgrammerFacadeTest method testWriteReadDirect.

public void testWriteReadDirect() 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("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));
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 28 with ProgListener

use of jmri.ProgListener in project JMRI by JMRI.

the class VerifyWriteProgrammerFacadeTest method testWriteReadDirect.

public void testWriteReadDirect() throws jmri.ProgrammerException, InterruptedException {
    readCount = 0;
    ProgDebugger dp = new ProgDebugger() {

        @Override
        public boolean getCanRead(String cv) {
            return false;
        }

        @Override
        public boolean getCanRead() {
            return false;
        }

        @Override
        public void readCV(String cv, ProgListener p) throws ProgrammerException {
            readCount++;
            super.readCV(cv, p);
        }
    };
    Programmer p = new VerifyWriteProgrammerFacade(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("4", 12, l);
    waitReply();
    Assert.assertEquals("target written", 12, dp.getCvVal(4));
    Assert.assertEquals("reads", 0, readCount);
    p.readCV("4", l);
    waitReply();
    Assert.assertEquals("read back", 12, readValue);
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 29 with ProgListener

use of jmri.ProgListener in project JMRI by JMRI.

the class VerifyWriteProgrammerFacadeTest method testWriteReadVerify.

public void testWriteReadVerify() throws jmri.ProgrammerException, InterruptedException {
    readCount = 0;
    ProgDebugger dp = new ProgDebugger() {

        @Override
        public boolean getCanRead(String cv) {
            return true;
        }

        @Override
        public boolean getCanRead() {
            return true;
        }

        @Override
        public void readCV(String cv, ProgListener p) throws ProgrammerException {
            readCount++;
            super.readCV(cv, p);
        }
    };
    Programmer p = new VerifyWriteProgrammerFacade(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("4", 12, l);
    waitReply();
    Assert.assertEquals("target written", 12, dp.getCvVal(4));
    Assert.assertEquals("reads", 1, readCount);
    p.readCV("4", l);
    waitReply();
    Assert.assertEquals("read back", 12, readValue);
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 30 with ProgListener

use of jmri.ProgListener in project JMRI by JMRI.

the class SlotManager method notifyProgListenerEnd.

/**
     * internal method to notify of the final result
     *
     * @param value  The cv value to be returned
     * @param status The error code, if any
     */
protected void notifyProgListenerEnd(int value, int status) {
    // NOI18N
    log.debug("  notifyProgListenerEnd with {}, {} and _usingProgrammer = {}", value, status, _usingProgrammer);
    // (re)start power timer
    restartEndOfProgrammingTimer();
    // and send the reply
    ProgListener p = _usingProgrammer;
    _usingProgrammer = null;
    if (p != null) {
        sendProgrammingReply(p, value, status);
    }
}
Also used : ProgListener(jmri.ProgListener)

Aggregations

ProgListener (jmri.ProgListener)53 Programmer (jmri.Programmer)27 ProgDebugger (jmri.progdebugger.ProgDebugger)27 ProgrammerException (jmri.ProgrammerException)3