001package jmri.jmrix.sprog; 002 003/** 004 * Constants to represent values seen in SPROG traffic. 005 * 006 * @author Andrew Crosland Copyright (C) 2006 from LnConstants.java 007 */ 008 009public final class SprogConstants { 010 011 /* SPROG mode */ 012 public final static int SPROG = 0; 013 public final static int SPROG_CS = 1; 014 015 // Current SPROG state 016 public enum SprogState { 017 018 NORMAL, SIIBOOTMODE, V4BOOTMODE 019 } 020 021 public enum SprogMode { 022 023 SERVICE, OPS 024 } 025 026 /* The following parameters may be overridden by scripts if the user desires */ 027 /** 028 * Threshold to warn of long delays between DCC packets to the rails. 029 * 030 * Worst case DCC packet transmission time is ~10 ms, which equates to 100 031 * packets/s. Wait for a somewhat arbitrary time before reporting a possible 032 * issue with the system performance. A delay of 50 ms equates to 20 packets/s 033 * if sustained. 034 * 035 * Slower systems such as Raspberry Pi with flash based file systems are 036 * more likely to exhibit longer delays between packets. 037 */ 038 public static int PACKET_DELAY_WARN_THRESHOLD = 50; 039 040 /** 041 * Timeout for command station to wait for reply from hardware. 042 * 043 * Slower systems such as Raspberry Pi with flash based file systems are more 044 * likely to exhibit longer delays. 045 */ 046 public static int CS_REPLY_TIMEOUT = 2500; 047 048 /** 049 * Timeout for traffic controller to wait for reply from hardware. 050 * 051 * Most replies are received from SPROG hardware with a few seconds, but 052 * paged mode programming operations can take considerably longer when 053 * reading a high value from a CV. Therefore we set a very long timeout, 054 * which should longer than the programmer timeout. 055 */ 056 public static int TC_PROG_REPLY_TIMEOUT = 70*1000; 057 public static int TC_OPS_REPLY_TIMEOUT = 200; 058 public static int TC_BOOT_REPLY_TIMEOUT = 200; 059 060 /* The following should be altered only if you know what you are doing */ 061 /* How many times to repeat an accessory or function packet in the S queue */ 062 public final static int S_REPEATS = 1; 063 064 /* How many times to repeat an ops mode programming packet */ 065 public final static int OPS_REPEATS = 3; 066 067 /* Longest packet possible */ 068 public final static int MAX_PACKET_LENGTH = 6; 069 070 /* Slot status */ 071 public final static int SLOT_FREE = 0; 072 public final static int SLOT_IN_USE = 1; 073 074 /* 075 * Maximum number of slots for soft command station 076 * 077 * More slots allows more throttles to be opened but the refresh rate for 078 * each throttle will reduce. 079 * 080 */ 081 /* Default */ 082 public final static int DEFAULT_MAX_SLOTS = 16; 083 084 /* Minimum number of slots */ 085 public final static int MIN_SLOTS = 8; 086 087 /* Maimum number of slots */ 088 public final static int SLOTS_LIMIT = 64; 089 090 /* Number of function buttons on a throttle */ 091 public static int MAX_FUNCTIONS = 32; 092 093 /* various bit masks */ 094 public final static int F8 = 0x100; /* Function 8 bit */ 095 096 public final static int F7 = 0x80; /* Function 7 bit */ 097 098 public final static int F6 = 0x40; /* Function 6 bit */ 099 100 public final static int F5 = 0x20; /* Function 5 bit */ 101 102 public final static int F4 = 0x10; /* Function 4 bit */ 103 104 public final static int F3 = 0x08; /* Function 3 bit */ 105 106 public final static int F2 = 0x04; /* Function 2 bit */ 107 108 public final static int F1 = 0x02; /* Function 1 bit */ 109 110 public final static int F0 = 0x01; /* Function 0 bit */ 111 112 /* Mode word bit masks */ 113 public final static int UNLOCK_BIT = 0x0001; /* Unlock bootloader */ 114 115 public final static int CALC_BIT = 0x0008; /* Add error byte */ 116 117 public final static int POWER_BIT = 0x0010; /* Track power */ 118 119 public final static int ZTC_BIT = 0x0020; /* Old ZTC bit timing */ 120 121 public final static int BLUE_BIT = 0x0040; /* Use direct byte for Blueline */ 122 123 public final static int STEP_MASK = 0x0E00; /* Mask for speed step bits */ 124 125 public final static int STEP14_BIT = 0x0200; 126 public final static int STEP28_BIT = 0x0400; 127 public final static int STEP128_BIT = 0x0800; 128 public final static int LONG_ADD = 0x1000; 129 130 public final static int DEFAULT_I = 996; /* milliAmps */ 131 132 public final static int MAX_ACC_DECODER_JMRI_ADDR = 2044; // copied from DCCppConstants 133 134}