use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.
the class LIUSBServerAdapter method startCommThread.
/**
* Start the Communication port thread.
*/
private void startCommThread() {
commThread = new Thread(new Runnable() {
@Override
public void run() {
// received to the output pipe.
if (log.isDebugEnabled()) {
log.debug("Communication Adapter Thread Started");
}
XNetReply r;
BufferedReader bufferedin = new BufferedReader(new InputStreamReader(commAdapter.getInputStream(), java.nio.charset.Charset.forName("UTF-8")));
for (; ; ) {
try {
synchronized (commAdapter) {
r = loadChars(bufferedin);
}
} catch (java.io.IOException e) {
// continue;
// start the process of trying to recover from
// a failed connection.
commAdapter.recover();
// then exit the for loop.
break;
}
if (log.isDebugEnabled()) {
log.debug("Network Adapter Received Reply: " + r.toString());
}
writeReply(r);
}
}
});
commThread.start();
}
use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.
the class LIUSBServerAdapter method startBCastThread.
/**
* Start the Broadcast Port thread.
*/
private void startBCastThread() {
bcastThread = new Thread(new Runnable() {
@Override
public void run() {
// to the output pipe.
if (log.isDebugEnabled()) {
log.debug("Broadcast Adapter Thread Started");
}
XNetReply r;
BufferedReader bufferedin = new BufferedReader(new InputStreamReader(bcastAdapter.getInputStream(), java.nio.charset.Charset.forName("UTF-8")));
for (; ; ) {
try {
synchronized (bcastAdapter) {
r = loadChars(bufferedin);
}
} catch (java.io.IOException e) {
//continue;
// start the process of trying to recover from
// a failed connection.
bcastAdapter.recover();
// then exit the for loop.
break;
}
if (log.isDebugEnabled()) {
log.debug("Network Adapter Received Reply: " + r.toString());
}
// Anything coming through the
r.setUnsolicited();
// broadcast port is an
// unsolicited message.
writeReply(r);
}
}
});
bcastThread.start();
}
use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.
the class Z21XPressNetTunnel method reply.
// Z21Listener interface methods.
/**
* Member function that will be invoked by a z21Interface implementation to
* forward a z21 message from the layout.
*
* @param msg The received z21 message. Note that this same object may be
* presented to multiple users. It should not be modified here.
*/
@Override
public void reply(Z21Reply msg) {
// implementation's input stream.
if (msg.isXPressNetTunnelMessage()) {
XNetReply reply = msg.getXNetReply();
log.debug("Z21 Reply {} forwarded to XPressNet implementation as {}", msg, reply);
for (int i = 0; i < reply.getNumDataElements(); i++) {
try {
outpipe.writeByte(reply.getElement(i));
} catch (java.io.IOException ioe) {
log.error("Error writing XPressNet Reply to XPressNet input stream.");
}
}
}
}
use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.
the class Z21XNetSimulatorAdapter 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;
}
use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.
the class Z21XNetSimulatorAdapter 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;
}
Aggregations