Search in sources :

Example 16 with XNetInterfaceScaffold

use of jmri.jmrix.lenz.XNetInterfaceScaffold in project JMRI by JMRI.

the class Z21XNetTurnoutTest method setUp.

// The minimal setup for log4J
@Before
@Override
public void setUp() {
    apps.tests.Log4JFixture.setUp();
    jmri.util.JUnitUtil.resetInstanceManager();
    // prepare an interface
    lnis = new XNetInterfaceScaffold(new RocoZ21CommandStation());
    t = new Z21XNetTurnout("XT", 21, lnis);
    jmri.InstanceManager.store(new jmri.NamedBeanHandleManager(), jmri.NamedBeanHandleManager.class);
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) Before(org.junit.Before)

Example 17 with XNetInterfaceScaffold

use of jmri.jmrix.lenz.XNetInterfaceScaffold in project JMRI by JMRI.

the class Z21XNetInitializationManagerTest method testCtor.

@Test
public void testCtor() {
    // infrastructure objects
    XNetInterfaceScaffold t = new XNetInterfaceScaffold(new LenzCommandStation());
    XNetListenerScaffold l = new XNetListenerScaffold();
    XNetSystemConnectionMemo memo = new XNetSystemConnectionMemo(t);
    Z21XNetInitializationManager m = new Z21XNetInitializationManager(memo) {

        @Override
        protected int getInitTimeout() {
            // shorten, because this will fail & delay test
            return 50;
        }
    };
    Assert.assertNotNull("exists", t);
    Assert.assertNotNull("exists", l);
    Assert.assertNotNull("exists", m);
    Assert.assertNotNull("exists", memo);
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) XNetListenerScaffold(jmri.jmrix.lenz.XNetListenerScaffold) XNetSystemConnectionMemo(jmri.jmrix.lenz.XNetSystemConnectionMemo) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) Test(org.junit.Test)

Example 18 with XNetInterfaceScaffold

use of jmri.jmrix.lenz.XNetInterfaceScaffold in project JMRI by JMRI.

the class Z21XNetProgrammerTest method testWriteHighCvSequence.

// this test is the same as the testWriteCvSequence test, but
// it checks the sequence for CVs greater than 256, which use 
// different XPressNet commands.
@Override
public void testWriteHighCvSequence() 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(300, 34, l);
    // check "prog mode" message sent
    Assert.assertEquals("mode message sent", 1, t.outbound.size());
    Assert.assertEquals("write message contents", "24 12 01 2B 22 3E", t.outbound.elementAt(0).toString());
    // send reply
    XNetReply mr1 = new XNetReply();
    mr1.setElement(0, 0x64);
    mr1.setElement(1, 0x14);
    mr1.setElement(2, 0x01);
    mr1.setElement(3, 0x2B);
    mr1.setElement(4, 0x22);
    mr1.setElement(5, 0x78);
    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());
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) XNetReply(jmri.jmrix.lenz.XNetReply)

Example 19 with XNetInterfaceScaffold

use of jmri.jmrix.lenz.XNetInterfaceScaffold in project JMRI by JMRI.

the class Z21XNetProgrammerTest method testReadCvSequence.

@Override
public void testReadCvSequence() 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 read
    p.readCV(29, l);
    // check "prog mode" message sent
    Assert.assertEquals("mode message sent", 1, t.outbound.size());
    Assert.assertEquals("read message contents", "23 11 00 1C 2E", 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());
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) XNetReply(jmri.jmrix.lenz.XNetReply)

Example 20 with XNetInterfaceScaffold

use of jmri.jmrix.lenz.XNetInterfaceScaffold in project JMRI by JMRI.

the class Z21XNetProgrammerTest method testReadCvHighSequence.

// this test is the same as the testReadCvSequence test, but
// it checks the sequence for CVs greater than 256, which use 
// different XPressNet commands.
@Override
public void testReadCvHighSequence() 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 read
    p.readCV(300, l);
    // check "prog mode" message sent
    Assert.assertEquals("mode message sent", 1, t.outbound.size());
    Assert.assertEquals("read message contents", "23 11 01 2B 18", t.outbound.elementAt(0).toString());
    // send reply
    XNetReply mr1 = new XNetReply();
    mr1.setElement(0, 0x64);
    mr1.setElement(1, 0x14);
    mr1.setElement(2, 0x01);
    mr1.setElement(3, 0x2B);
    mr1.setElement(4, 0x22);
    mr1.setElement(5, 0x78);
    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());
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) XNetReply(jmri.jmrix.lenz.XNetReply)

Aggregations

XNetInterfaceScaffold (jmri.jmrix.lenz.XNetInterfaceScaffold)46 LenzCommandStation (jmri.jmrix.lenz.LenzCommandStation)26 XNetReply (jmri.jmrix.lenz.XNetReply)18 XNetSystemConnectionMemo (jmri.jmrix.lenz.XNetSystemConnectionMemo)13 Test (org.junit.Test)13 Before (org.junit.Before)10 XNetListenerScaffold (jmri.jmrix.lenz.XNetListenerScaffold)4 Turnout (jmri.Turnout)3 TurnoutManager (jmri.TurnoutManager)3 XNetThrottleTest (jmri.jmrix.lenz.XNetThrottleTest)2