Search in sources :

Example 16 with XNetReply

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

the class Z21XNetSimulatorAdapter 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 17 with XNetReply

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

the class Z21XNetSimulatorAdapter method lanXTurnoutInfoReply.

// create a LAN_X_TURNOUT_INFO reply
private XNetReply lanXTurnoutInfoReply(int FAdr_MSB, int FAdr_LSB, boolean thrown) {
    XNetReply reply = new XNetReply();
    reply.setOpCode(Z21Constants.LAN_X_TURNOUT_INFO);
    reply.setElement(1, FAdr_MSB & 0xff);
    reply.setElement(2, FAdr_LSB & 0xff);
    // the turnout direction.
    reply.setElement(3, thrown ? 0x02 : 0x01);
    // set the parity byte to 0.
    reply.setElement(4, 0x00);
    reply.setParity();
    return reply;
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply)

Example 18 with XNetReply

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

the class Z21XNetSimulatorAdapter method okReply.

// Create an OK XNetReply message
private XNetReply okReply() {
    XNetReply r = new XNetReply();
    r.setOpCode(XNetConstants.LI_MESSAGE_RESPONSE_HEADER);
    r.setElement(1, XNetConstants.LI_MESSAGE_RESPONSE_SEND_SUCCESS);
    // set the parity byte to 0
    r.setElement(2, 0x00);
    r.setParity();
    return r;
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply)

Example 19 with XNetReply

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

the class XNetSimulatorAdapterTest method testGenerateEmergencyStopReply.

@Test
public void testGenerateEmergencyStopReply() {
    XNetSimulatorAdapter a = new XNetSimulatorAdapter();
    // NOTE: this test uses reflection to test a private method.
    java.lang.reflect.Method generateReplyMethod = null;
    try {
        generateReplyMethod = a.getClass().getDeclaredMethod("generateReply", XNetMessage.class);
    } catch (java.lang.NoSuchMethodException nsm) {
        Assert.fail("Could not find method generateReply in XNetSimulatorAdapter class: ");
    }
    // override the default permissions.
    Assert.assertNotNull(generateReplyMethod);
    generateReplyMethod.setAccessible(true);
    try {
        XNetReply r = (XNetReply) generateReplyMethod.invoke(a, new XNetMessage("21 80 A1"));
        Assert.assertEquals("CS Emergency Stop Reply", new XNetReply("61 82 E3"), r);
    } catch (java.lang.IllegalAccessException ite) {
        Assert.fail("could not access method generateReply in XNetSimulatoradapter class");
    } catch (java.lang.reflect.InvocationTargetException ite) {
        Throwable cause = ite.getCause();
        Assert.fail("generateReply execution failed reason: " + cause.getMessage());
    }
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Example 20 with XNetReply

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

the class XNetSimulatorAdapterTest method testEmergencyStopLocoReply.

@Test
public void testEmergencyStopLocoReply() {
    XNetSimulatorAdapter a = new XNetSimulatorAdapter();
    // NOTE: this test uses reflection to test a private method.
    java.lang.reflect.Method generateReplyMethod = null;
    try {
        generateReplyMethod = a.getClass().getDeclaredMethod("generateReply", XNetMessage.class);
    } catch (java.lang.NoSuchMethodException nsm) {
        Assert.fail("Could not find method generateReply in XNetSimulatorAdapter class: ");
    }
    // override the default permissions.
    Assert.assertNotNull(generateReplyMethod);
    generateReplyMethod.setAccessible(true);
    try {
        XNetReply r = (XNetReply) generateReplyMethod.invoke(a, new XNetMessage("92 00 02 90"));
        Assert.assertEquals("CS Emergency Specific Loco (XNetV4) Reply ", new XNetReply("01 04 05"), r);
    } catch (java.lang.IllegalAccessException ite) {
        Assert.fail("could not access method generateReply in XNetSimulatoradapter class");
    } catch (java.lang.reflect.InvocationTargetException ite) {
        Throwable cause = ite.getCause();
        Assert.fail("generateReply execution failed reason: " + cause.getMessage());
    }
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

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