Search in sources :

Example 11 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class PaneOpsProgAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isDebugEnabled()) {
        log.debug("Pane programmer requested");
    }
    // create the initial frame that steers
    final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameOpsProgrammerSetup"));
    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(SymbolicProgBundle.getMessage("MenuRoster"), 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 = java.text.MessageFormat.format(SymbolicProgBundle.getMessage("FrameOpsProgrammerTitle"), new Object[] { re.getId() });
            // find the ops-mode programmer
            int address = Integer.parseInt(re.getDccAddress());
            boolean longAddr = re.isLongAddress();
            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.isDebugEnabled()) {
        log.debug("Tab-Programmer 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) JmriJFrame(jmri.util.JmriJFrame) Programmer(jmri.Programmer) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar)

Example 12 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class VSDConfigPanel method storeFile.

protected boolean storeFile(RosterEntry _rosterEntry) {
    log.debug("storeFile starts");
    // We need to create a programmer, a cvTableModel, an iCvTableModel, and a variableTableModel.
    // Doesn't matter which, so we'll use the Global programmer.
    Programmer p = InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer();
    CvTableModel cvModel = new CvTableModel(null, p);
    IndexedCvTableModel iCvModel = new IndexedCvTableModel(null, p);
    VariableTableModel variableModel = new VariableTableModel(null, new String[] { "Name", "Value" }, cvModel, iCvModel);
    // Now, in theory we can call _rosterEntry.writeFile...
    if (_rosterEntry.getFileName() != null) {
        // set the loco file name in the roster entry
        // read, but don't yet process
        _rosterEntry.readFile();
        _rosterEntry.loadCvModel(variableModel, cvModel, iCvModel);
    }
    // id has to be set!
    if (_rosterEntry.getId().equals("")) {
        log.debug("storeFile without a filename; issued dialog");
        return false;
    }
    // if there isn't a filename, store using the id
    _rosterEntry.ensureFilenameExists();
    // create the RosterEntry to its file
    // where to get the models???
    _rosterEntry.writeFile(cvModel, iCvModel, variableModel);
    // mark this as a success
    variableModel.setFileDirty(false);
    // and store an updated roster file
    Roster.getDefault().writeRoster();
    return true;
}
Also used : IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel) CvTableModel(jmri.jmrit.symbolicprog.CvTableModel) VariableTableModel(jmri.jmrit.symbolicprog.VariableTableModel) Programmer(jmri.Programmer) IndexedCvTableModel(jmri.jmrit.symbolicprog.IndexedCvTableModel)

Example 13 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class MultiIndexProgrammerFacadeTest method testWriteReadDoubleIndexed.

public void testWriteReadDoubleIndexed() throws jmri.ProgrammerException, InterruptedException {
    ProgDebugger dp = new ProgDebugger();
    Programmer p = new MultiIndexProgrammerFacade(dp, "81", "82", 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("123.45.46", 12, l);
    waitReply();
    Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
    Assert.assertEquals("index 2 written", 46, dp.getCvVal(82));
    Assert.assertEquals("value written", 12, dp.getCvVal(123));
    dp.clearHasBeenWritten(81);
    dp.clearHasBeenWritten(82);
    p.readCV("123.45.46", l);
    waitReply();
    Assert.assertEquals("read back", 12, readValue);
    Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
    Assert.assertEquals("index 2 written", 46, dp.getCvVal(82));
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 14 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class MultiIndexProgrammerFacadeTest method testWriteReadDoubleIndexedSkip.

public void testWriteReadDoubleIndexedSkip() throws jmri.ProgrammerException, InterruptedException {
    ProgDebugger dp = new ProgDebugger();
    Programmer p = new MultiIndexProgrammerFacade(dp, "81", "82", true, true);
    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("123.45.46", 12, l);
    waitReply();
    Assert.assertEquals("index 1 written", 45, dp.getCvVal(81));
    Assert.assertEquals("index 2 written", 46, dp.getCvVal(82));
    Assert.assertEquals("value written", 12, dp.getCvVal(123));
    dp.clearHasBeenWritten(81);
    dp.clearHasBeenWritten(82);
    p.readCV("123.45.46", l);
    waitReply();
    Assert.assertEquals("read back", 12, readValue);
    Assert.assertTrue("index 1 not written", !dp.hasBeenWritten(81));
    Assert.assertTrue("index 2 not written", !dp.hasBeenWritten(82));
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 15 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class MultiIndexProgrammerFacadeTest method testWriteReadSingleIndexed.

public void testWriteReadSingleIndexed() throws jmri.ProgrammerException, InterruptedException {
    ProgDebugger dp = new ProgDebugger();
    Programmer p = new MultiIndexProgrammerFacade(dp, "81", "82", 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("123.45", 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("123.45", 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)

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