Search in sources :

Example 6 with XNetReply

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

the class ZTC611XNetTurnoutTest method testXNetTurnoutMsgSequence.

// Test the XNetTurnout message sequence.
@Test
@Override
@Ignore("causes a hang, probably incorrect sequence in test")
public void testXNetTurnoutMsgSequence() {
    t.setFeedbackMode(jmri.Turnout.DIRECT);
    // set closed
    try {
        t.setCommandedState(jmri.Turnout.CLOSED);
    } catch (Exception e) {
        log.error("TO exception: " + e);
    }
    Assert.assertTrue(t.getCommandedState() == jmri.Turnout.CLOSED);
    Assert.assertEquals("on message sent", "52 05 8A DD", lnis.outbound.elementAt(lnis.outbound.size() - 1).toString());
    // notify that the command station received the reply
    XNetReply m = new XNetReply();
    m.setElement(0, 0x42);
    m.setElement(1, 0x05);
    // set CLOSED
    m.setElement(2, 0x04);
    m.setElement(3, 0x43);
    int n = lnis.outbound.size();
    ((jmri.jmrix.lenz.XNetTurnout) t).message(m);
    while (n == lnis.outbound.size()) {
    }
    // busy loop.  Wait for
    // outbound size to change.
    Assert.assertEquals("off message sent", "52 05 80 D7", lnis.outbound.elementAt(n).toString());
    // the turnout will not set its state until it sees an OK message.
    m = new XNetReply();
    m.setElement(0, 0x01);
    m.setElement(1, 0x04);
    m.setElement(2, 0x05);
    n = lnis.outbound.size();
    ((jmri.jmrix.lenz.XNetTurnout) t).message(m);
    while (n == lnis.outbound.size()) {
    }
    // busy loop.  Wait for
    // outbound size to change.
    Assert.assertEquals("off message sent", "52 05 80 D7", lnis.outbound.elementAt(n).toString());
    m = new XNetReply();
    m.setElement(0, 0x01);
    m.setElement(1, 0x04);
    m.setElement(2, 0x05);
    ((jmri.jmrix.lenz.XNetTurnout) t).message(m);
    // no wait here.  The last reply should cause the turnout to
    // set it's state, but it will not cause another reply.
    Assert.assertTrue(t.getKnownState() == jmri.Turnout.CLOSED);
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with XNetReply

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

the class XNetSimulatorAdapter method normalOpsReply.

// Create a "Normal Operations Resumed" message
private XNetReply normalOpsReply() {
    XNetReply r = new XNetReply();
    r.setOpCode(XNetConstants.CS_INFO);
    r.setElement(1, XNetConstants.BC_NORMAL_OPERATIONS);
    // set the parity byte to 0
    r.setElement(2, 0x00);
    r.setParity();
    return r;
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply)

Example 8 with XNetReply

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

the class XNetSimulatorAdapter method notSupportedReply.

// We have a few canned response messages.
// Create an Unsupported XNetReply message
private XNetReply notSupportedReply() {
    XNetReply r = new XNetReply();
    r.setOpCode(XNetConstants.CS_INFO);
    r.setElement(1, XNetConstants.CS_NOT_SUPPORTED);
    // set the parity byte to 0
    r.setElement(2, 0x00);
    r.setParity();
    return r;
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply)

Example 9 with XNetReply

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

the class XNetSimulatorAdapter method csStatusReply.

// Create a reply to a request for the Command Station Status
private XNetReply csStatusReply() {
    XNetReply reply = new XNetReply();
    reply.setOpCode(XNetConstants.CS_REQUEST_RESPONSE);
    reply.setElement(1, XNetConstants.CS_STATUS_RESPONSE);
    reply.setElement(2, csStatus);
    // set the parity byte to 0
    reply.setElement(3, 0x00);
    reply.setParity();
    return reply;
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply)

Example 10 with XNetReply

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

the class XNetSimulatorAdapter method everythingOffReply.

// Create a broadcast "Everything Off" reply
private XNetReply everythingOffReply() {
    XNetReply r = new XNetReply();
    r.setOpCode(XNetConstants.CS_INFO);
    r.setElement(1, XNetConstants.BC_EVERYTHING_OFF);
    // set the parity byte to 0
    r.setElement(2, 0x00);
    r.setParity();
    return r;
}
Also used : 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