Search in sources :

Example 1 with CanReply

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

Example 2 with CanReply

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

Example 3 with CanReply

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

Example 4 with CanReply

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

Example 5 with CanReply

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

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