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