Search in sources :

Example 26 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class TwoIndexTcsProgrammerFacadeTest method testCvLimit.

public void testCvLimit() {
    ProgDebugger dp = new ProgDebugger();
    dp.setTestReadLimit(1024);
    dp.setTestWriteLimit(1024);
    Programmer p = new TwoIndexTcsProgrammerFacade(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 27 with Programmer

use of jmri.Programmer 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 28 with Programmer

use of jmri.Programmer 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 29 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class DeferringProgrammerManager method getGlobalProgrammer.

@Override
public Programmer getGlobalProgrammer() {
    GlobalProgrammerManager gp = InstanceManager.getNullableDefault(GlobalProgrammerManager.class);
    if (gp == null) {
        log.debug("no defaultGlobal ProgrammerManager, getGlobalProgrammer returns null");
        return null;
    }
    Programmer p = gp.getGlobalProgrammer();
    log.debug("getGlobalProgrammer returns default service-mode programmer of type {} from {}", (p != null ? p.getClass() : "(null)"), gp.getClass());
    return p;
}
Also used : Programmer(jmri.Programmer) AddressedProgrammer(jmri.AddressedProgrammer) GlobalProgrammerManager(jmri.GlobalProgrammerManager)

Example 30 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class AddressedHighCvProgrammerFacadeTest method testWriteReadDirectHighCV.

public void testWriteReadDirectHighCV() throws jmri.ProgrammerException, InterruptedException {
    ProgDebugger dp = new ProgDebugger();
    dp.setTestReadLimit(1024);
    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));
    p.readCV("258", l);
    waitReply();
    Assert.assertEquals("read back", 12, readValue);
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Aggregations

Programmer (jmri.Programmer)63 ProgDebugger (jmri.progdebugger.ProgDebugger)33 ProgListener (jmri.ProgListener)27 JFrame (javax.swing.JFrame)4 JPanel (javax.swing.JPanel)3 ProgrammerException (jmri.ProgrammerException)3 IdentifyLoco (jmri.jmrit.roster.IdentifyLoco)3 PaneOpsProgFrame (jmri.jmrit.symbolicprog.tabbedframe.PaneOpsProgFrame)3 BoxLayout (javax.swing.BoxLayout)2 JLabel (javax.swing.JLabel)2 JMenuBar (javax.swing.JMenuBar)2 AddressedProgrammerManager (jmri.AddressedProgrammerManager)2 GlobalProgrammerManager (jmri.GlobalProgrammerManager)2 DecoderFile (jmri.jmrit.decoderdefn.DecoderFile)2 IdentifyDecoder (jmri.jmrit.decoderdefn.IdentifyDecoder)2 ProgModeSelector (jmri.jmrit.progsupport.ProgModeSelector)2 RosterEntry (jmri.jmrit.roster.RosterEntry)2 CvTableModel (jmri.jmrit.symbolicprog.CvTableModel)2 IndexedCvTableModel (jmri.jmrit.symbolicprog.IndexedCvTableModel)2 KnownLocoSelPane (jmri.jmrit.symbolicprog.KnownLocoSelPane)2