Search in sources :

Example 6 with Z21Reply

use of jmri.jmrix.roco.z21.Z21Reply in project JMRI by JMRI.

the class Z21SimulatorAdapter method getZ21SerialNumberReply.

private Z21Reply getZ21SerialNumberReply() {
    Z21Reply reply = new Z21Reply();
    reply.setLength(0x0008);
    reply.setOpCode(0x0010);
    reply.setElement(4, 0x00);
    reply.setElement(5, 0x00);
    reply.setElement(6, 0x00);
    reply.setElement(7, 0x00);
    return reply;
}
Also used : Z21Reply(jmri.jmrix.roco.z21.Z21Reply)

Example 7 with Z21Reply

use of jmri.jmrix.roco.z21.Z21Reply in project JMRI by JMRI.

the class Z21SimulatorAdapter method getZ21RailComDataChangedReply.

private Z21Reply getZ21RailComDataChangedReply() {
    Z21Reply reply = new Z21Reply();
    reply.setOpCode(0x0088);
    reply.setLength(0x0004);
    int offset = 4;
    for (int i = 0; i < xnetadapter.locoCount; i++) {
        // byte 5, LocoAddress msb.
        reply.setElement(offset++, xnetadapter.locoData[i].getAddressMsb());
        // byte 6, LocoAddress lsb.
        reply.setElement(offset++, xnetadapter.locoData[i].getAddressLsb());
        // bytes 7-10,32 bit reception counter.
        reply.setElement(offset++, 0x00);
        reply.setElement(offset++, 0x00);
        reply.setElement(offset++, 0x00);
        reply.setElement(offset++, 0x01);
        // bytes 11-14,32 bit error counter.
        reply.setElement(offset++, 0x00);
        reply.setElement(offset++, 0x00);
        reply.setElement(offset++, 0x00);
        reply.setElement(offset++, 0x00);
        //currently reserved.Speed in firmware<=1.12
        reply.setElement(offset++, xnetadapter.locoData[i].getSpeed());
        //currently reserved.Options in firmware<=1.12
        reply.setElement(offset++, 0x00);
        //currently reserved.Temp in firmware<=1.12
        reply.setElement(offset++, 0x00);
        reply.setLength(0xffff & offset);
    }
    log.debug("output {} offset: {}", reply.toString(), offset);
    return reply;
}
Also used : Z21Reply(jmri.jmrix.roco.z21.Z21Reply)

Example 8 with Z21Reply

use of jmri.jmrix.roco.z21.Z21Reply in project JMRI by JMRI.

the class Z21SimulatorAdapter method getZ21BroadCastFlagsReply.

private Z21Reply getZ21BroadCastFlagsReply() {
    Z21Reply reply = new Z21Reply();
    reply.setLength(0x0008);
    reply.setOpCode(0x0051);
    reply.setElement(4, flags[0]);
    reply.setElement(5, flags[1]);
    reply.setElement(6, flags[2]);
    reply.setElement(7, flags[3]);
    return reply;
}
Also used : Z21Reply(jmri.jmrix.roco.z21.Z21Reply)

Example 9 with Z21Reply

use of jmri.jmrix.roco.z21.Z21Reply in project JMRI by JMRI.

the class Z21SimulatorAdapterTest method RailComDataChangedReply.

@Test
public void RailComDataChangedReply() {
    // NOTE: this test uses reflection to test a private method.
    java.lang.reflect.Method getZ21RailComDataChangedReplyMethod = null;
    try {
        getZ21RailComDataChangedReplyMethod = a.getClass().getDeclaredMethod("getZ21RailComDataChangedReply");
    } catch (java.lang.NoSuchMethodException nsm) {
        Assert.fail("Could not find method getZ21RailComDataChagnedReply in Z21SimulatorAdapter class: ");
    }
    // override the default permissions.
    Assert.assertNotNull(getZ21RailComDataChangedReplyMethod);
    getZ21RailComDataChangedReplyMethod.setAccessible(true);
    try {
        Z21Reply z = (Z21Reply) getZ21RailComDataChangedReplyMethod.invoke(a);
        Assert.assertEquals("Empty Railcom Report", "04 00 88 00", z.toString());
    } catch (java.lang.IllegalAccessException iae) {
        Assert.fail("Could not access method getZ21RailComDataChangedReply in Z21SimulatorAdapter class");
    } catch (java.lang.reflect.InvocationTargetException ite) {
        Throwable cause = ite.getCause();
        Assert.fail("getZ21RailComDataChangedReply  executon failed reason: " + cause.getMessage());
    }
}
Also used : Z21Reply(jmri.jmrix.roco.z21.Z21Reply) Test(org.junit.Test)

Aggregations

Z21Reply (jmri.jmrix.roco.z21.Z21Reply)9 DatagramPacket (java.net.DatagramPacket)1 DatagramSocket (java.net.DatagramSocket)1 InetAddress (java.net.InetAddress)1 XNetMessage (jmri.jmrix.lenz.XNetMessage)1 XNetReply (jmri.jmrix.lenz.XNetReply)1 Z21Message (jmri.jmrix.roco.z21.Z21Message)1 Test (org.junit.Test)1