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;
}
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;
}
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;
}
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());
}
}
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());
}
}
Aggregations