Search in sources :

Example 51 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class AddressedHighCvProgrammerFacadeTest method testCvLimit.

public void testCvLimit() {
    ProgDebugger dp = new ProgDebugger();
    dp.setTestReadLimit(256);
    dp.setTestWriteLimit(256);
    Programmer p = new AddressedHighCvProgrammerFacade(dp, "256", "253", "254", "255", "100");
    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 52 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class AddressedHighCvProgrammerFacadeTest method testWriteReadIndexed.

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

Example 53 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class OffsetHighCvProgrammerFacadeTest method testWriteReadIndexed.

public void testWriteReadIndexed() 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("258", 12, l);
    waitReply();
    Assert.assertTrue("target not written", !dp.hasBeenWritten(258));
    Assert.assertEquals("index written", 20, dp.getCvVal(7));
    Assert.assertEquals("value written", 12, dp.getCvVal(58));
    p.readCV("258", l);
    waitReply();
    Assert.assertEquals("read back", 12, readValue);
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 54 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class ResettingOffsetHighCvProgrammerFacadeTest method testCvLimit.

public void testCvLimit() {
    ProgDebugger dp = new ProgDebugger();
    dp.setTestReadLimit(256);
    dp.setTestWriteLimit(256);
    Programmer p = new ResettingOffsetHighCvProgrammerFacade(dp, "256", "7", "10", "100", "200");
    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 55 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class RosterFrame method startProgrammer.

protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
    if (inStartProgrammer) {
        log.debug("Call to start programmer has been called twice when the first call hasn't opened");
        return;
    }
    if (!checkIfEntrySelected()) {
        return;
    }
    try {
        setCursor(new Cursor(Cursor.WAIT_CURSOR));
        inStartProgrammer = true;
        String title = re.getId();
        JFrame progFrame = null;
        if (edit.isSelected()) {
            progFrame = new PaneProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", null, false) {

                @Override
                protected JPanel getModePane() {
                    return null;
                }
            };
        } else if (service.isSelected()) {
            progFrame = new PaneServiceProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", modePanel.getProgrammer()) {
            };
        } else if (ops.isSelected()) {
            int address = Integer.parseInt(re.getDccAddress());
            boolean longAddr = re.isLongAddress();
            Programmer pProg = InstanceManager.getDefault(AddressedProgrammerManager.class).getAddressedProgrammer(longAddr, address);
            progFrame = new PaneOpsProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", pProg);
        }
        if (progFrame == null) {
            return;
        }
        progFrame.pack();
        progFrame.setVisible(true);
    } finally {
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
    inStartProgrammer = false;
}
Also used : JPanel(javax.swing.JPanel) PaneProgFrame(jmri.jmrit.symbolicprog.tabbedframe.PaneProgFrame) JFrame(javax.swing.JFrame) Programmer(jmri.Programmer) PaneServiceProgFrame(jmri.jmrit.symbolicprog.tabbedframe.PaneServiceProgFrame) AddressedProgrammerManager(jmri.AddressedProgrammerManager) Cursor(java.awt.Cursor) PaneOpsProgFrame(jmri.jmrit.symbolicprog.tabbedframe.PaneOpsProgFrame)

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