use of jmri.jmrix.lenz.LenzCommandStation in project JMRI by JMRI.
the class LI100XNetProgrammerTest method testReadHighCvSequence.
// this test is the same as the testReadCvSequence test, but
// it checks the sequence for CVs greater than 256, which use
// different XPressNet commands.
public void testReadHighCvSequence() throws JmriException {
// infrastructure objects
XNetInterfaceScaffold t = new XNetInterfaceScaffold(new LenzCommandStation());
jmri.ProgListenerScaffold l = new jmri.ProgListenerScaffold();
LI100XNetProgrammer p = new LI100XNetProgrammer(t) {
@Override
protected synchronized void restartTimer(int delay) {
super.restartTimer(RESTART_TIME);
}
};
// and do the read
p.readCV(300, l);
// check "prog mode" message sent
Assert.assertEquals("mode message sent", 1, t.outbound.size());
Assert.assertEquals("read message contents", "22 19 2C 17", t.outbound.elementAt(0).toString());
// send reply
XNetReply mr1 = new XNetReply();
mr1.setElement(0, 0x61);
mr1.setElement(1, 0x02);
mr1.setElement(2, 0x63);
t.sendTestMessage(mr1);
Assert.assertEquals("inquire message sent", 2, t.outbound.size());
Assert.assertEquals("inquire message contents", "21 10 31", t.outbound.elementAt(1).toString());
// send a result string
XNetReply mr2 = new XNetReply();
mr2.setElement(0, 0x63);
mr2.setElement(1, 0x15);
mr2.setElement(2, 0x2C);
mr2.setElement(3, 0x22);
mr2.setElement(4, 0x78);
t.sendTestMessage(mr2);
// At this point, the LI100 XPressNet programmer
// deviates from the standard XPressNet programmer.
// the LI100 version requests an exit from service
// before sending a result to the registered listeners.
Assert.assertEquals("mode message sent", 3, t.outbound.size());
Assert.assertEquals("exit service mode message contents", "21 81 A0", t.outbound.elementAt(2).toString());
// send reply stating service mode has exited
XNetReply mr3 = new XNetReply();
mr3.setElement(0, 0x61);
mr3.setElement(1, 0x01);
mr3.setElement(2, 0x60);
t.sendTestMessage(mr3);
jmri.util.JUnitUtil.releaseThread(this);
//failure in this test occurs with the next line.
Assert.assertFalse("Receive Called by Programmer", l.getRcvdInvoked() == 0);
Assert.assertEquals("Direct mode received value", 34, l.getRcvdValue());
}
use of jmri.jmrix.lenz.LenzCommandStation in project JMRI by JMRI.
the class Z21XNetThrottleManagerTest method setUp.
// The minimal setup for log4J
@Override
@Before
public void setUp() {
apps.tests.Log4JFixture.setUp();
jmri.util.JUnitUtil.resetInstanceManager();
XNetInterfaceScaffold tc = new XNetInterfaceScaffold(new LenzCommandStation());
tm = new Z21XNetThrottleManager(new XNetSystemConnectionMemo(tc));
}
use of jmri.jmrix.lenz.LenzCommandStation in project JMRI by JMRI.
the class Z21XNetProgrammerTest method testWriteCvSequence.
@Override
public void testWriteCvSequence() throws JmriException {
// infrastructure objects
XNetInterfaceScaffold t = new XNetInterfaceScaffold(new LenzCommandStation());
jmri.ProgListenerScaffold l = new jmri.ProgListenerScaffold();
Z21XNetProgrammer p = new Z21XNetProgrammer(t) {
@Override
protected synchronized void restartTimer(int delay) {
super.restartTimer(RESTART_TIME);
}
};
// and do the write
p.writeCV(29, 34, l);
// check "prog mode" message sent
Assert.assertEquals("mode message sent", 1, t.outbound.size());
Assert.assertEquals("write message contents", "24 12 00 1C 22 08", t.outbound.elementAt(0).toString());
// send reply
XNetReply mr1 = new XNetReply();
mr1.setElement(0, 0x64);
mr1.setElement(1, 0x14);
mr1.setElement(2, 0x00);
mr1.setElement(3, 0x1C);
mr1.setElement(4, 0x22);
mr1.setElement(5, 0x4E);
t.sendTestMessage(mr1);
// At this point, the z21XPressNetProgrammer
// should send a result to the programmer listeners, and
// wait for either the next read/write request or for the
// traffic controller to exit from service mode. We just
// need to wait a few seconds and see that the listener we
// registered earlier received the values we expected.
jmri.util.JUnitUtil.waitFor(() -> {
return l.getRcvdInvoked() != 0;
}, "Receive Called by Programmer");
Assert.assertEquals("Direct mode received value", 34, l.getRcvdValue());
}
use of jmri.jmrix.lenz.LenzCommandStation in project JMRI by JMRI.
the class ZTC611XNetTurnoutManagerTest method testAsAbstractFactory.
@Test
public void testAsAbstractFactory() {
lnis = new XNetInterfaceScaffold(new LenzCommandStation());
// create and register the manager object
ZTC611XNetTurnoutManager l = new ZTC611XNetTurnoutManager(lnis, "X");
jmri.InstanceManager.setTurnoutManager(l);
// ask for a Turnout, and check type
TurnoutManager t = jmri.InstanceManager.turnoutManagerInstance();
Turnout o = t.newTurnout("XT21", "my name");
if (log.isDebugEnabled()) {
log.debug("received turnout value " + o);
}
Assert.assertTrue(null != (ZTC611XNetTurnout) o);
// make sure loaded into tables
if (log.isDebugEnabled()) {
log.debug("by system name: " + t.getBySystemName("XT21"));
}
if (log.isDebugEnabled()) {
log.debug("by user name: " + t.getByUserName("my name"));
}
Assert.assertTrue(null != t.getBySystemName("XT21"));
Assert.assertTrue(null != t.getByUserName("my name"));
}
use of jmri.jmrix.lenz.LenzCommandStation in project JMRI by JMRI.
the class ZTC611XNetTurnoutTest method setUp.
// The minimal setup for log4J
@Override
@Before
public void setUp() {
apps.tests.Log4JFixture.setUp();
// prepare an interface
jmri.util.JUnitUtil.resetInstanceManager();
jmri.util.JUnitUtil.initInternalSensorManager();
lnis = new XNetInterfaceScaffold(new LenzCommandStation());
t = new ZTC611XNetTurnout("XT", 21, lnis);
jmri.InstanceManager.store(new jmri.NamedBeanHandleManager(), jmri.NamedBeanHandleManager.class);
}
Aggregations