package tools.cansim; import tools.*; /** * Carry and work with a simulated CAN frame. * * Immutable once created. * * @author Bob Jacobsen Copyright 2009 * @version $Revision: 2567 $ */ public class CanFrame implements org.openlcb.can.CanFrame { int header; int[] bytes; public CanFrame(int header) { this.bytes = null; this.header = header; } public CanFrame(int header, int[] bytes) { this(header); if (bytes.length > 8) { throw new IllegalArgumentException("payload too long: "+bytes); } this.bytes = bytes; } public int getHeader() { return header; } public byte[] getData() { byte[] t = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) t[i] = (byte)bytes[i]; return t; } public long bodyAsLong() { long retval = 0; for (int i = 0 ; i