001package jmri.jmrix.powerline.cm11;
002
003/**
004 * Constants and functions specific to the CM11 interface.
005 *
006 * @author Bob Jacobsen Copyright (C) 2008
007 */
008public class Constants {
009
010    public static final int POLL_REQ = 0x5A;
011    public static final int TIME_REQ_CP11 = 0xA5;
012    public static final int TIME_REQ_CP10 = 0xA6;
013    public static final int MACRO_INITIATED = 0x5B;
014    public static final int MACRO_LOAD = 0xFB;
015    public static final int CHECKSUM_OK = 0x00;
016    public static final int READY_REQ = 0x55;
017    public static final int FILTER_FAIL = 0xF3;
018    public static final int EXT_CMD_HEADER = 0x07;
019
020    public static final int POLL_ACK = 0xC3;
021    public static final int TIMER_DOWNLOAD = 0x9B;
022
023    /**
024     * Pretty-print a header code.
025     *
026     * @param b header byte
027     * @return  formated as text of header byte
028     */
029    public static String formatHeaderByte(int b) {
030        return "Dim: " + ((b >> 3) & 0x1F)
031                + ((b & 0x02) != 0 ? " function" : " address ")
032                + ((b & 0x01) != 0 ? " extended" : " ");
033    }
034
035}