use of jmri.jmrix.can.CanReply in project JMRI by JMRI.
the class LoopbackTrafficController method newReply.
// New reply from hardware
@Override
protected AbstractMRReply newReply() {
log.debug("New CanReply created");
CanReply reply = new CanReply();
return reply;
}
use of jmri.jmrix.can.CanReply in project JMRI by JMRI.
the class LawicellTrafficController method decodeFromHardware.
/**
* Make a CanReply from a system-specific reply
*/
@Override
public CanReply decodeFromHardware(AbstractMRReply m) {
if (log.isDebugEnabled()) {
log.debug("Decoding from hardware: '" + m + "'\n");
}
Reply gc = (Reply) m;
CanReply ret = gc.createReply();
if (log.isDebugEnabled()) {
log.debug("Decoded " + gc + " as " + ret);
}
return ret;
}
use of jmri.jmrix.can.CanReply in project JMRI by JMRI.
the class GridConnectReply method createReply.
public CanReply createReply() {
CanReply ret = new CanReply();
if (log.isDebugEnabled()) {
log.debug("createReply converts from [" + this + "]");
}
// basic checks drop out the frame
if (!basicFormatCheck()) {
ret.setHeader(0);
ret.setNumDataElements(0);
return ret;
}
// Is it an Extended frame?
if (isExtended()) {
ret.setExtended(true);
}
// Copy the header
ret.setHeader(getHeader());
// Is it an RTR frame?
if (isRtr()) {
ret.setRtr(true);
}
// Get the data
for (int i = 0; i < getNumBytes(); i++) {
ret.setElement(i, getByte(i));
}
ret.setNumDataElements(getNumBytes());
return ret;
}
use of jmri.jmrix.can.CanReply in project JMRI by JMRI.
the class OlcbConfigurationManager method createOlcbCanInterface.
public static CanInterface createOlcbCanInterface(NodeID nodeID, TrafficController tc) {
final CanInterface olcbIf = new CanInterface(nodeID, frame -> tc.sendCanMessage(convertToCan(frame), null));
tc.addCanListener(new CanListener() {
@Override
public void message(CanMessage m) {
// ignored -- loopback is handled by the olcbInterface.
}
@Override
public void reply(CanReply m) {
if (!m.isExtended() || m.isRtr()) {
return;
}
olcbIf.frameInput().send(convertFromCan(m));
}
});
return olcbIf;
}
use of jmri.jmrix.can.CanReply in project JMRI by JMRI.
the class CbusProgrammerTest method testReadSequence.
public void testReadSequence() throws jmri.ProgrammerException {
TrafficControllerScaffold tc = new TrafficControllerScaffold();
CbusProgrammer p = new CbusProgrammer(3, tc);
reply = false;
rcvdValue = -2;
rcvdStatus = -2;
p.readCV(4, testListener);
Assert.assertEquals("listeners", 0, tc.numListeners());
Assert.assertEquals("sent count", 1, tc.outbound.size());
Assert.assertEquals("content 1", "71 00 03 04", tc.outbound.get(0).toString());
Assert.assertTrue("listener not invoked", !reply);
// pretend reply from CAN
int[] frame = new int[] { 0x97, 0, 3, 5 };
CanReply f = new CanReply(frame);
p.reply(f);
Assert.assertTrue("listener invoked", reply);
Assert.assertEquals("status", 0, rcvdStatus);
Assert.assertEquals("value", 5, rcvdValue);
}
Aggregations