Search in sources :

Example 21 with LenzCommandStation

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

the class ZTC640Adapter method configure.

/**
     * set up all of the other objects to operate with a ZTC640 connected to
     * this port
     */
@Override
public void configure() {
    // connect to a packetizing traffic controller
    XNetTrafficController packets = new ZTC640XNetPacketizer(new LenzCommandStation());
    packets.connectPort(this);
    // start operation
    // packets.startThreads();
    this.getSystemConnectionMemo().setXNetTrafficController(packets);
    new XNetInitializationManager(this.getSystemConnectionMemo());
}
Also used : XNetInitializationManager(jmri.jmrix.lenz.XNetInitializationManager) XNetTrafficController(jmri.jmrix.lenz.XNetTrafficController) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation)

Example 22 with LenzCommandStation

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

the class LI100XNetInitializationManagerTest method testCtor.

public void testCtor() {
    // infrastructure objects
    XNetInterfaceScaffold t = new XNetInterfaceScaffold(new LenzCommandStation());
    XNetListenerScaffold l = new XNetListenerScaffold();
    XNetSystemConnectionMemo memo = new XNetSystemConnectionMemo(t);
    LI100XNetInitializationManager m = new LI100XNetInitializationManager(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);
    jmri.util.JUnitAppender.assertWarnMessage("Command Station disconnected, or powered down assuming LZ100/LZV100 V3.x");
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) XNetListenerScaffold(jmri.jmrix.lenz.XNetListenerScaffold) XNetSystemConnectionMemo(jmri.jmrix.lenz.XNetSystemConnectionMemo) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation)

Example 23 with LenzCommandStation

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

the class LI100XNetProgrammerTest method testWriteHighCvSequence.

// this test is the same as the testWriteCvSequence test, but
// it checks the sequence for CVs greater than 255, which use
// different XPressNet commands.
public void testWriteHighCvSequence() 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 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", "23 1D 2C 22 30", 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 24 with LenzCommandStation

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

the class LI100XNetProgrammerTest method testWriteRegisterSequence.

public void testWriteRegisterSequence() 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);
        }
    };
    // set register mode
    p.setMode(DefaultProgrammerManager.REGISTERMODE);
    // and do the write
    p.writeCV(29, 12, l);
    // check "prog mode" message sent
    Assert.assertEquals("read message sent", 1, t.outbound.size());
    Assert.assertEquals("write message contents", "23 12 05 0C 38", 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, 0x10);
    mr2.setElement(2, 0x05);
    mr2.setElement(3, 0x0C);
    mr2.setElement(4, 0x7A);
    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("Register mode received value", 12, l.getRcvdValue());
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) LenzCommandStation(jmri.jmrix.lenz.LenzCommandStation) XNetReply(jmri.jmrix.lenz.XNetReply)

Example 25 with LenzCommandStation

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

the class LI100XNetProgrammerTest method testWriteCvSequence.

public void testWriteCvSequence() 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 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", "23 16 1D 22 0A", 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, 0x14);
    mr2.setElement(2, 0x1D);
    mr2.setElement(3, 0x22);
    mr2.setElement(4, 0x48);
    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)

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