Search in sources :

Example 1 with OpenLcbCanFrame

use of org.openlcb.can.OpenLcbCanFrame in project JMRI by JMRI.

the class OlcbConfigurationManager method convertFromCan.

static OpenLcbCanFrame convertFromCan(jmri.jmrix.can.CanFrame message) {
    OpenLcbCanFrame fin = new OpenLcbCanFrame(0);
    fin.setHeader(message.getHeader());
    if (message.getNumDataElements() == 0) {
        return fin;
    }
    byte[] data = new byte[message.getNumDataElements()];
    for (int i = 0; i < data.length; ++i) {
        data[i] = (byte) (message.getElement(i) & 0xff);
    }
    fin.setData(data);
    return fin;
}
Also used : OpenLcbCanFrame(org.openlcb.can.OpenLcbCanFrame)

Example 2 with OpenLcbCanFrame

use of org.openlcb.can.OpenLcbCanFrame in project JMRI by JMRI.

the class MonitorPane method frameToMessages.

// see jmri.jmrix.openlcb.OlcbConfigurationManager
java.util.List<Message> frameToMessages(int header, int len, int[] content) {
    OpenLcbCanFrame frame = new OpenLcbCanFrame(header & 0xFFF);
    frame.setHeader(header);
    if (len != 0) {
        byte[] data = new byte[len];
        for (int i = 0; i < data.length; i++) {
            data[i] = (byte) content[i];
        }
        frame.setData(data);
    }
    aliasMap.processFrame(frame);
    java.util.List<Message> list = messageBuilder.processFrame(frame);
    return list;
}
Also used : Message(org.openlcb.Message) CanMessage(jmri.jmrix.can.CanMessage) OpenLcbCanFrame(org.openlcb.can.OpenLcbCanFrame)

Aggregations

OpenLcbCanFrame (org.openlcb.can.OpenLcbCanFrame)2 CanMessage (jmri.jmrix.can.CanMessage)1 Message (org.openlcb.Message)1