Search in sources :

Example 46 with XNetReply

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

the class EliteXNetProgrammerTest method testWriteRegisterSequenceString.

public void testWriteRegisterSequenceString() 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 write
    p.writeCV("29", 12, l);
    // check "prog mode" message sent
    Assert.assertEquals("read message sent", 2, 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("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 47 with XNetReply

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

the class EliteXNetTurnoutManagerTest method testEliteXNetMessages.

@Test
public void testEliteXNetMessages() {
    // send messages for 20, 21
    // notify that somebody else changed it...
    XNetReply m1 = new XNetReply();
    m1.setElement(0, 0x42);
    m1.setElement(1, 0x05);
    m1.setElement(2, 0x02);
    m1.setElement(3, 0x45);
    lnis.sendTestMessage(m1);
    // notify that somebody else changed it...
    XNetReply m2 = new XNetReply();
    m2.setElement(0, 0x42);
    m2.setElement(1, 0x05);
    m2.setElement(2, 0x04);
    m2.setElement(3, 0x43);
    lnis.sendTestMessage(m2);
    // try to get turnouts to see if they exist
    Assert.assertTrue(null != l.getBySystemName("XT20"));
    Assert.assertTrue(null != l.getBySystemName("XT21"));
    // check the list
    List<String> testList = new ArrayList<String>(2);
    testList.add("XT20");
    testList.add("XT21");
    Assert.assertEquals("system name list", testList, l.getSystemNameList());
}
Also used : ArrayList(java.util.ArrayList) XNetReply(jmri.jmrix.lenz.XNetReply) Test(org.junit.Test)

Example 48 with XNetReply

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

the class EliteXNetProgrammerTest method testWriteRegisterSequence.

public void testWriteRegisterSequence() 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 write
    p.writeCV(29, 12, l);
    // check "prog mode" message sent
    Assert.assertEquals("read message sent", 2, 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("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 49 with XNetReply

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

the class EliteXNetProgrammerTest method testReadCvSequenceString.

public void testReadCvSequenceString() throws JmriException {
    // infrastructure objects
    XNetInterfaceScaffold t = new XNetInterfaceScaffold(new HornbyEliteCommandStation());
    EliteXNetListenerScaffold l = new EliteXNetListenerScaffold();
    EliteXNetProgrammer p = new EliteXNetProgrammer(t);
    // and do the read
    p.readCV("10", l);
    // check "prog mode" message sent
    Assert.assertEquals("mode message sent", 2, t.outbound.size());
    Assert.assertEquals("read message contents", "22 15 0A 3D", 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 50 with XNetReply

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

the class EliteXNetProgrammerTest method testWriteCvSequence.

public void testWriteCvSequence() 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)

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