Search in sources :

Example 16 with CanReply

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;
}
Also used : CanReply(jmri.jmrix.can.CanReply)

Example 17 with CanReply

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);
}
Also used : LoaderClient(org.openlcb.LoaderClient) MessageBuilder(org.openlcb.can.MessageBuilder) CanListener(jmri.jmrix.can.CanListener) CanReply(jmri.jmrix.can.CanReply) AliasMap(org.openlcb.can.AliasMap) OlcbInterface(org.openlcb.OlcbInterface) CanMessage(jmri.jmrix.can.CanMessage)

Example 18 with CanReply

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;
}
Also used : CanReply(jmri.jmrix.can.CanReply)

Example 19 with CanReply

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;
}
Also used : CanReply(jmri.jmrix.can.CanReply)

Example 20 with CanReply

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));
}
Also used : CanReply(jmri.jmrix.can.CanReply)

Aggregations

CanReply (jmri.jmrix.can.CanReply)28 CanMessage (jmri.jmrix.can.CanMessage)3 CanListener (jmri.jmrix.can.CanListener)2 TrafficControllerScaffold (jmri.jmrix.can.TrafficControllerScaffold)2 AbstractMRReply (jmri.jmrix.AbstractMRReply)1 CanSystemConnectionMemo (jmri.jmrix.can.CanSystemConnectionMemo)1 Test (org.junit.Test)1 LoaderClient (org.openlcb.LoaderClient)1 OlcbInterface (org.openlcb.OlcbInterface)1 AliasMap (org.openlcb.can.AliasMap)1 CanInterface (org.openlcb.can.CanInterface)1 MessageBuilder (org.openlcb.can.MessageBuilder)1