use of jmri.jmrix.can.CanReply in project JMRI by JMRI.
the class Reply method createReply.
public CanReply createReply() {
// is this just an ACK to e.g. a send?
if (_dataChars[0] != 't' && _dataChars[0] != 'T') {
if (log.isDebugEnabled()) {
log.debug("non-frame reply skipped: " + this);
}
return null;
}
// carries a frame
CanReply ret = new CanReply();
ret.setExtended(isExtended());
// Copy the header
ret.setHeader(getHeader());
// 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 configureManagers.
@Override
public void configureManagers() {
// create our NodeID
getOurNodeID();
// do the connections
tc = adapterMemo.getTrafficController();
olcbCanInterface = createOlcbCanInterface(nodeID, tc);
// create JMRI objects
InstanceManager.setSensorManager(getSensorManager());
InstanceManager.setTurnoutManager(getTurnoutManager());
InstanceManager.setThrottleManager(getThrottleManager());
InstanceManager.setProgrammerManager(getProgrammerManager());
// start alias acquisition
new StartUpHandler().start();
OlcbInterface iface = getInterface();
loaderClient = new LoaderClient(iface.getOutputConnection(), iface.getMemoryConfigurationService(), iface.getDatagramService());
iface.registerMessageListener(loaderClient);
iface.registerMessageListener(new SimpleNodeIdentInfoHandler());
aliasMap = new AliasMap();
tc.addCanListener(new CanListener() {
@Override
public void message(CanMessage m) {
if (!m.isExtended() || m.isRtr()) {
return;
}
aliasMap.processFrame(convertFromCan(m));
}
@Override
public void reply(CanReply m) {
if (!m.isExtended() || m.isRtr()) {
return;
}
aliasMap.processFrame(convertFromCan(m));
}
});
messageBuilder = new MessageBuilder(aliasMap);
}
use of jmri.jmrix.can.CanReply in project JMRI by JMRI.
the class MergTrafficController method decodeFromHardware.
/**
* Make a CanReply from a MergReply reply
*/
@Override
public CanReply decodeFromHardware(AbstractMRReply m) {
log.debug("Decoding from hardware");
MergReply gc = (MergReply) m;
CanReply ret = gc.createReply();
return ret;
}
use of jmri.jmrix.can.CanReply in project JMRI by JMRI.
the class GcTrafficController method decodeFromHardware.
/**
* Make a CanReply from a GridConnect reply
*/
@Override
public CanReply decodeFromHardware(AbstractMRReply m) {
log.debug("Decoding from hardware");
GridConnectReply gc = (GridConnectReply) m;
CanReply ret = gc.createReply();
return ret;
}
use of jmri.jmrix.can.CanReply in project JMRI by JMRI.
the class GridConnectReplyTest method testThreeAlt.
public void testThreeAlt() {
GridConnectReply g = new GridConnectReply(":X0000123R12345678;");
CanReply r = g.createReply();
Assert.assertEquals("extended", true, r.isExtended());
Assert.assertEquals("rtr", true, r.isRtr());
Assert.assertEquals("header", 0x123, r.getHeader());
Assert.assertEquals("num elements", 4, r.getNumDataElements());
Assert.assertEquals("el 0", 0x12, r.getElement(0));
Assert.assertEquals("el 1", 0x34, r.getElement(1));
Assert.assertEquals("el 2", 0x56, r.getElement(2));
Assert.assertEquals("el 3", 0x78, r.getElement(3));
}
Aggregations