001package jmri.jmrix.powerline.simulator;
002
003/**
004 * Constants and functions specific to the Insteon 2412S interface.
005 *
006 * @author Bob Jacobsen Copyright (C) 2008, 2009
007 * @author Ken Cameron Copyright (C) 2010
008 */
009public class Constants {
010
011    private Constants() {} // class only supplies static methods
012
013    public static final int HEAD_STX = 0x02;
014
015    public static final int POLL_REQ_STD = 0x50;
016    public static final int POLL_REQ_EXT = 0x51;
017    public static final int POLL_REQ_X10 = 0x52;
018    public static final int POLL_REQ_BUTTON = 0x54;
019    public static final int POLL_REQ_BUTTON_RESET = 0x55;
020    public static final int FUNCTION_REQ_STD = 0x62;
021    public static final int FUNCTION_REQ_X10 = 0x63;
022
023    public static final int CMD_LIGHT_ON_RAMP = 0x11;
024    public static final int CMD_LIGHT_ON_FAST = 0x12;
025    public static final int CMD_LIGHT_OFF_RAMP = 0x13;
026    public static final int CMD_LIGHT_OFF_FAST = 0x14;
027    public static final int CMD_LIGHT_CHG = 0x21;
028
029    public static final int BUTTON_TAP = 0x02;
030    public static final int BUTTON_HELD = 0x03;
031    public static final int BUTTON_REL = 0x04;
032    public static final int BUTTON_BITS_ID = 0xF0;
033    public static final int BUTTON_BITS_OP = 0x0F;
034
035    public static final int REPLY_ACK = 0x06;
036    public static final int REPLY_NAK = 0x15;
037
038    // flag values
039    public static final int FLAG_BIT_STDEXT = 0x10;
040    public static final int FLAG_STD = 0x00;
041    public static final int FLAG_EXT = 0x10;
042
043    public static final int FLAG_BIT_X10_CMDUNIT = 0x80;
044    public static final int FLAG_X10_RECV_CMD = 0x80;
045    public static final int FLAG_X10_RECV_UNIT = 0x00;
046
047    /**
048     * Pretty-print a header code
049     * @param b value for header
050     * @return  formatted string for type of header
051     */
052    public static String formatHeaderByte(int b) {
053        return "Dim: " + ((b >> 3) & 0x1F)
054                + ((b & 0x02) != 0 ? " function" : " address ")
055                + ((b & 0x01) != 0 ? " extended" : " ");
056    }
057
058}