Search in sources :

Example 1 with CanListener

use of jmri.jmrix.can.CanListener 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;
}
Also used : CanInterface(org.openlcb.can.CanInterface) CanListener(jmri.jmrix.can.CanListener) CanReply(jmri.jmrix.can.CanReply) CanMessage(jmri.jmrix.can.CanMessage)

Example 2 with CanListener

use of jmri.jmrix.can.CanListener 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)

Aggregations

CanListener (jmri.jmrix.can.CanListener)2 CanMessage (jmri.jmrix.can.CanMessage)2 CanReply (jmri.jmrix.can.CanReply)2 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