Search in sources :

Example 46 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class SimpleProgFrame method readPushed.

// handle the buttons being pushed
public void readPushed(java.awt.event.ActionEvent e) {
    Programmer p = modePane.getProgrammer();
    if (p == null) {
        resultsField.setText(SymbolicProgBundle.getMessage("StateNoProgrammer"));
        readButton.setSelected(false);
    } else {
        if (p.getCanRead()) {
            try {
                resultsField.setText(SymbolicProgBundle.getMessage("StateReading"));
                p.readCV(getNewAddr(), this);
            } catch (jmri.ProgrammerException ex) {
                resultsField.setText("" + ex);
                readButton.setSelected(false);
            }
        } else {
            resultsField.setText(SymbolicProgBundle.getMessage("CantReadThisMode"));
            readButton.setSelected(false);
        }
    }
}
Also used : Programmer(jmri.Programmer)

Example 47 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class NewLocoSelPane method startIdentify.

private void startIdentify() {
    // start identifying a decoder
    final NewLocoSelPane me = this;
    Programmer p = null;
    if (selector != null && selector.isSelected())
        p = selector.getProgrammer();
    if (p == null) {
        log.warn("Selector did not provide a programmer, use default");
        p = jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer();
    }
    IdentifyDecoder id = new IdentifyDecoder(p) {

        private NewLocoSelPane who = me;

        @Override
        protected void done(int mfg, int model, int productID) {
            // if Done, updated the selected decoder
            who.selectDecoder(mfg, model, productID);
        }

        @Override
        protected void message(String m) {
            if (_statusLabel != null) {
                _statusLabel.setText(m);
            }
        }

        @Override
        public void error() {
        }
    };
    id.start();
}
Also used : Programmer(jmri.Programmer) IdentifyDecoder(jmri.jmrit.decoderdefn.IdentifyDecoder)

Example 48 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class AccessoryOpsModeProgrammerFacadeTest method testWriteDirect.

public void testWriteDirect() throws jmri.ProgrammerException, InterruptedException {
    ProgDebugger dp = new ProgDebugger(true, 123);
    Programmer p = new AccessoryOpsModeProgrammerFacade(dp, null);
    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.assertTrue("target not directly written", !dp.hasBeenWritten(12));
    Assert.assertTrue("index not written", !dp.hasBeenWritten(81));
    Assert.assertNotNull("packet sent", lastPacket);
}
Also used : Programmer(jmri.Programmer) ProgDebugger(jmri.progdebugger.ProgDebugger) ProgListener(jmri.ProgListener)

Example 49 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class AddressedHighCvProgrammerFacadeTest method testWriteReadDirectHighCVRightSide.

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

Example 50 with Programmer

use of jmri.Programmer in project JMRI by JMRI.

the class AccessoryOpsModeProgrammerFacadeTest method testCvLimit.

public void testCvLimit() {
    ProgDebugger dp = new ProgDebugger(true, 123);
    dp.setTestReadLimit(1024);
    dp.setTestWriteLimit(1024);
    Programmer p = new AccessoryOpsModeProgrammerFacade(dp, null);
    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)

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