Search in sources :

Example 6 with XNetInterfaceScaffold

use of jmri.jmrix.lenz.XNetInterfaceScaffold 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());
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) XNetReply(jmri.jmrix.lenz.XNetReply)

Example 7 with XNetInterfaceScaffold

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

the class EliteXNetSystemConnectionMemoTest method testXNetTrafficControllerSetCtor.

@Test
public void testXNetTrafficControllerSetCtor() {
    // infrastructure objects
    XNetInterfaceScaffold tc = new XNetInterfaceScaffold(new HornbyEliteCommandStation());
    EliteXNetSystemConnectionMemo t = new EliteXNetSystemConnectionMemo();
    Assert.assertNotNull(t);
    // the default constructor does not set the traffic controller
    Assert.assertNull(t.getXNetTrafficController());
    // so we need to do this ourselves.
    t.setXNetTrafficController(tc);
    Assert.assertNotNull(t.getXNetTrafficController());
    // and while we're doing that, we should also set the SystemMemo 
    // parameter in the traffic controller.
    Assert.assertNotNull(tc.getSystemConnectionMemo());
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) Test(org.junit.Test)

Example 8 with XNetInterfaceScaffold

use of jmri.jmrix.lenz.XNetInterfaceScaffold 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));
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) XNetSystemConnectionMemo(jmri.jmrix.lenz.XNetSystemConnectionMemo) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) Before(org.junit.Before)

Example 9 with XNetInterfaceScaffold

use of jmri.jmrix.lenz.XNetInterfaceScaffold 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());
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) XNetReply(jmri.jmrix.lenz.XNetReply)

Example 10 with XNetInterfaceScaffold

use of jmri.jmrix.lenz.XNetInterfaceScaffold 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"));
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) TurnoutManager(jmri.TurnoutManager) Turnout(jmri.Turnout) Test(org.junit.Test)

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