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);
}
}
}
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();
}
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);
}
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);
}
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"));
}
Aggregations