Search in sources :

Example 56 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class AutoSpeedAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isInfoEnabled()) {
        log.debug("auto speed tool requested");
    }
    // create the initial frame that steers
    final JFrame f = new JFrame("Auto-speed Tool Setup");
    f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
    // add the Roster menu
    JMenuBar menuBar = new JMenuBar();
    // menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
    menuBar.add(new jmri.jmrit.roster.swing.RosterMenu("Roster", jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
    f.setJMenuBar(menuBar);
    // known loco on main track
    JPanel pane1 = new // no ident in ops mode yet
    KnownLocoSelPane(// no ident in ops mode yet
    false) {

        @Override
        protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
            String title = "Set speed info for " + re.getId() + " on main track";
            // find the ops-mode programmer
            int address = Integer.parseInt(re.getDccAddress());
            boolean longAddr = true;
            if (address < 100) {
                longAddr = false;
            }
            Programmer programmer = InstanceManager.getDefault(jmri.ProgrammerManager.class).getAddressedProgrammer(longAddr, address);
            // and created the frame
            JFrame p = new PaneOpsProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", programmer);
            p.pack();
            p.setVisible(true);
            f.setVisible(false);
            f.dispose();
        }
    };
    // load primary frame
    pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    f.getContentPane().add(pane1);
    f.pack();
    if (log.isInfoEnabled()) {
        log.debug("setup created");
    }
    f.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) DecoderFile(jmri.jmrit.decoderdefn.DecoderFile) BoxLayout(javax.swing.BoxLayout) KnownLocoSelPane(jmri.jmrit.symbolicprog.KnownLocoSelPane) PaneOpsProgFrame(jmri.jmrit.symbolicprog.tabbedframe.PaneOpsProgFrame) JFrame(javax.swing.JFrame) Programmer(jmri.Programmer) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar)

Example 57 with Programmer

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

Example 58 with Programmer

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

Example 59 with Programmer

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

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

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