Search in sources :

Example 31 with LenzCommandStation

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

the class Z21XNetPacketizerTest method setUp.

// The minimal setup for log4J
@Before
@Override
public void setUp() {
    apps.tests.Log4JFixture.setUp();
    jmri.util.JUnitUtil.resetInstanceManager();
    LenzCommandStation lcs = new LenzCommandStation();
    tc = new Z21XNetPacketizer(lcs) {

        @Override
        protected void handleTimeout(jmri.jmrix.AbstractMRMessage msg, jmri.jmrix.AbstractMRListener l) {
        }
    };
}
Also used : LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) Before(org.junit.Before)

Example 32 with LenzCommandStation

use of jmri.jmrix.lenz.LenzCommandStation 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 33 with LenzCommandStation

use of jmri.jmrix.lenz.LenzCommandStation 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 34 with LenzCommandStation

use of jmri.jmrix.lenz.LenzCommandStation 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)

Example 35 with LenzCommandStation

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

the class Z21XNetThrottleTest method testCtor.

@Override
@Test(timeout = 1000)
public void testCtor() {
    // infrastructure objects
    XNetInterfaceScaffold tc = new XNetInterfaceScaffold(new LenzCommandStation());
    Z21XNetThrottle t = new Z21XNetThrottle(new XNetSystemConnectionMemo(tc), tc);
    Assert.assertNotNull(t);
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) XNetSystemConnectionMemo(jmri.jmrix.lenz.XNetSystemConnectionMemo) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) Test(org.junit.Test) XNetThrottleTest(jmri.jmrix.lenz.XNetThrottleTest)

Aggregations

LenzCommandStation (jmri.jmrix.lenz.LenzCommandStation)37 XNetInterfaceScaffold (jmri.jmrix.lenz.XNetInterfaceScaffold)26 XNetSystemConnectionMemo (jmri.jmrix.lenz.XNetSystemConnectionMemo)11 XNetReply (jmri.jmrix.lenz.XNetReply)10 XNetTrafficController (jmri.jmrix.lenz.XNetTrafficController)10 XNetInitializationManager (jmri.jmrix.lenz.XNetInitializationManager)8 Test (org.junit.Test)8 Before (org.junit.Before)6 XNetListenerScaffold (jmri.jmrix.lenz.XNetListenerScaffold)3 XNetPacketizer (jmri.jmrix.lenz.XNetPacketizer)3 XNetThrottleTest (jmri.jmrix.lenz.XNetThrottleTest)2 Turnout (jmri.Turnout)1 TurnoutManager (jmri.TurnoutManager)1