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 public static final int HEAD_STX = 0x02; 012 013 public static final int POLL_REQ_STD = 0x50; 014 public static final int POLL_REQ_EXT = 0x51; 015 public static final int POLL_REQ_X10 = 0x52; 016 public static final int POLL_REQ_BUTTON = 0x54; 017 public static final int POLL_REQ_BUTTON_RESET = 0x55; 018 public static final int FUNCTION_REQ_STD = 0x62; 019 public static final int FUNCTION_REQ_X10 = 0x63; 020 021 public static final int CMD_LIGHT_ON_RAMP = 0x11; 022 public static final int CMD_LIGHT_ON_FAST = 0x12; 023 public static final int CMD_LIGHT_OFF_RAMP = 0x13; 024 public static final int CMD_LIGHT_OFF_FAST = 0x14; 025 public static final int CMD_LIGHT_CHG = 0x21; 026 027 public static final int BUTTON_TAP = 0x02; 028 public static final int BUTTON_HELD = 0x03; 029 public static final int BUTTON_REL = 0x04; 030 public static final int BUTTON_BITS_ID = 0xF0; 031 public static final int BUTTON_BITS_OP = 0x0F; 032 033 public static final int REPLY_ACK = 0x06; 034 public static final int REPLY_NAK = 0x15; 035 036 // flag values 037 public static final int FLAG_BIT_STDEXT = 0x10; 038 public static final int FLAG_STD = 0x00; 039 public static final int FLAG_EXT = 0x10; 040 041 public static final int FLAG_BIT_X10_CMDUNIT = 0x80; 042 public static final int FLAG_X10_RECV_CMD = 0x80; 043 public static final int FLAG_X10_RECV_UNIT = 0x00; 044 045 /** 046 * Pretty-print a header code 047 * @param b value for header 048 * @return formated string for type of header 049 */ 050 public static String formatHeaderByte(int b) { 051 return "Dim: " + ((b >> 3) & 0x1F) 052 + ((b & 0x02) != 0 ? " function" : " address ") 053 + ((b & 0x01) != 0 ? " extended" : " "); 054 } 055 056}