Search in sources :

Example 41 with XNetReply

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

the class Z21XNetSimulatorAdapterTest method testGenerateEmergencyStopReply.

@Test
public void testGenerateEmergencyStopReply() {
    Z21XNetSimulatorAdapter a = new Z21XNetSimulatorAdapter();
    Assert.assertEquals("CS Emergency Stop Reply", new XNetReply("61 82 E3"), a.generateReply(new XNetMessage("21 80 A1")));
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Example 42 with XNetReply

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

the class Z21XNetSimulatorAdapterTest method testGenerateEmergencyStopLocoReply.

@Test
public void testGenerateEmergencyStopLocoReply() {
    Z21XNetSimulatorAdapter a = new Z21XNetSimulatorAdapter();
    Assert.assertEquals("CS Emergeny Stop Specific Loco (XNetV4)", new XNetReply("01 04 05"), a.generateReply(new XNetMessage("92 00 02 90")));
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Example 43 with XNetReply

use of jmri.jmrix.lenz.XNetReply 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 44 with XNetReply

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

the class EliteXNetProgrammerTest method testWriteCvSequenceString.

// Test names ending with "String" are for the new writeCV(String, ...) 
// etc methods.  If you remove the older writeCV(int, ...) tests, 
// you can rename these. Note that not all (int,...) tests may have a 
// String(String, ...) test defined, in which case you should create those.
public void testWriteCvSequenceString() throws JmriException {
    // infrastructure objects
    XNetInterfaceScaffold t = new XNetInterfaceScaffold(new HornbyEliteCommandStation());
    EliteXNetListenerScaffold l = new EliteXNetListenerScaffold();
    EliteXNetProgrammer p = new EliteXNetProgrammer(t);
    // and do the write
    p.writeCV("10", 20, l);
    // check "prog mode" message sent
    Assert.assertEquals("mode message sent", 2, t.outbound.size());
    Assert.assertEquals("write message contents", "23 16 0A 14 2B", 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("enquire message sent", 2, t.outbound.size());
    Assert.assertEquals("enquire message contents", "21 10 31", t.outbound.elementAt(1).toString());
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) XNetReply(jmri.jmrix.lenz.XNetReply)

Example 45 with XNetReply

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

the class EliteXNetProgrammerTest method testReadRegisterSequence.

public void testReadRegisterSequence() throws JmriException {
    // infrastructure objects
    XNetInterfaceScaffold t = new XNetInterfaceScaffold(new HornbyEliteCommandStation());
    EliteXNetListenerScaffold l = new EliteXNetListenerScaffold();
    EliteXNetProgrammer p = new EliteXNetProgrammer(t);
    // set register mode
    p.setMode(DefaultProgrammerManager.REGISTERMODE);
    // and do the read
    p.readCV(29, l);
    // check "prog mode" message sent
    Assert.assertEquals("mode message sent", 2, t.outbound.size());
    Assert.assertEquals("read message contents", "22 11 05 36", 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("enquire message sent", 2, t.outbound.size());
    Assert.assertEquals("enquire message contents", "21 10 31", t.outbound.elementAt(1).toString());
}
Also used : XNetInterfaceScaffold(jmri.jmrix.lenz.XNetInterfaceScaffold) XNetReply(jmri.jmrix.lenz.XNetReply)

Aggregations

XNetReply (jmri.jmrix.lenz.XNetReply)57 XNetInterfaceScaffold (jmri.jmrix.lenz.XNetInterfaceScaffold)18 Test (org.junit.Test)17 XNetMessage (jmri.jmrix.lenz.XNetMessage)14 LenzCommandStation (jmri.jmrix.lenz.LenzCommandStation)10 IOException (java.io.IOException)3 BufferedReader (java.io.BufferedReader)2 InputStreamReader (java.io.InputStreamReader)2 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 Z21Reply (jmri.jmrix.roco.z21.Z21Reply)1