PageRenderTime 53ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/wsu/tools/XMonitor/Config/OasisConstants.java

https://github.com/tyll/tinyos-2.x-contrib
Java | 245 lines | 168 code | 22 blank | 55 comment | 14 complexity | e4e2cc75016db0bc7ed0dd66a092c6b1 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, BSD-3-Clause, LGPL-2.1
  1. package Config;
  2. import java.util.*;
  3. //Note: need to be consistent with :
  4. //OASIS_ROOT/system/OasisType.h
  5. public class OasisConstants {
  6. public static int RPC_MAX_BUFFER = 200;
  7. public static String DATASTREAM_XML_DIR;
  8. //Path Constants
  9. // 2007-08-10 10:13:02 ray-
  10. // change to unix format for both Cygwin and Linux
  11. public OasisConstants() {
  12. try {
  13. Properties env = getEnvironment();
  14. String myEnvVar;
  15. //System.out.println(env);
  16. //8/29/2008 Andy
  17. if (env == null) {
  18. myEnvVar = "/opt/oasis";
  19. //myEnvVar="E:/YXGDOC/Buz/workspace/svn/oasis";
  20. myEnvVar = "oasis";
  21. } else {
  22. myEnvVar = (String) env.get("OASIS_ROOT");
  23. //myEnvVar="E:/YXGDOC/Buz/workspace/svn/oasis";
  24. //myEnvVar = "oasis";
  25. }
  26. //8/29/2008 end
  27. //System.out.println(myEnvVar);
  28. String cygwinHome = "c:/tinyos/cygwin";
  29. String read = "";
  30. StringTokenizer tokenizer = new StringTokenizer(myEnvVar, "/");
  31. if (myEnvVar.indexOf("cygdrive") != -1) {
  32. myEnvVar = "";
  33. while (tokenizer.hasMoreTokens()) {
  34. read = tokenizer.nextToken();
  35. if (!read.equals("cygdrive")) {
  36. myEnvVar += read + "/";
  37. }
  38. }
  39. OasisConstants.OASIS_HOME = myEnvVar.substring(0, 1) + ":" + myEnvVar.substring(1);
  40. // System.out.println("a"+OasisConstants.OASIS_HOME );
  41. } else {
  42. OasisConstants.OASIS_HOME = cygwinHome + myEnvVar + "/";
  43. //xiaogang test
  44. OasisConstants.OASIS_HOME = myEnvVar + "/";
  45. // System.out.println("b"+OasisConstants.OASIS_HOME );
  46. }
  47. // OasisConstants.OASIS_HOME="./";
  48. // String prefix = "tools/com/oasis";
  49. //System.out.println(OasisConstants.OASIS_HOME + " " + OASIS_HOME);
  50. OasisConstants.DefaultPath = OasisConstants.OASIS_HOME + "apps";
  51. OasisConstants.IconFile = OasisConstants.OASIS_HOME + "images/wsu.gif";
  52. OasisConstants.ToolsPath = OasisConstants.OASIS_HOME + "tools";
  53. OasisConstants.LogPath = OasisConstants.OASIS_HOME + "Log";
  54. OasisConstants.ConfigPath = OasisConstants.OASIS_HOME + "Config";
  55. OasisConstants.XMLPath = OASIS_HOME + "apps/OasisApp/build/imote2";
  56. OasisConstants.rpcxmlpath = OASIS_HOME + "apps/MyApp/build/telosw";
  57. OasisConstants.EventLogger = OASIS_HOME + "tools/event.log";
  58. OasisConstants.RPCLogger = OASIS_HOME + "tools/rpc.log";
  59. OasisConstants.SFLogger = OASIS_HOME + "tools/sf.log";
  60. OasisConstants.SimServerEventLogger = OASIS_HOME + "/tools/sim.log";
  61. OasisConstants.DATASTREAM_XML_PATH = OASIS_HOME + "/DXM_DataStream/dxmstream_data.xml";
  62. OasisConstants.DATASTREAM_XML_DIR = OASIS_HOME + "/DXM_DataStream";
  63. OasisConstants.RES = OASIS_HOME + "images";
  64. } catch (Exception ex) {
  65. ex.printStackTrace();
  66. }
  67. }
  68. public Properties getEnvironment() throws java.io.IOException {
  69. try {
  70. Properties env = new Properties();
  71. String OS = System.getProperty("os.name").toLowerCase();
  72. // System.out.println(OS);
  73. if (OS.indexOf("windows 9") > -1) {
  74. env.load(Runtime.getRuntime().exec("command.com /c set").getInputStream());
  75. } else if ((OS.indexOf("nt") > -1) || (OS.indexOf("windows 2000") > -1) || (OS.indexOf("windows xp") > -1)) {
  76. // thanks to JuanFran for the xp fix!
  77. env.load(Runtime.getRuntime().exec("cmd.exe /c set").getInputStream());
  78. } else {
  79. // our last hope, we assume Unix (thanks to H. Ware for the fix)
  80. env.load(Runtime.getRuntime().exec("env").getInputStream());
  81. }
  82. System.out.println(env.getProperty("TOS_PLATFORMS"));
  83. return env;
  84. } catch (Exception ex) {
  85. System.out.println("not get environment");
  86. }
  87. return null;
  88. }
  89. public static String OASIS_HOME = "";
  90. public static boolean DEBUG=false;
  91. // -ray
  92. public static String EventLogger = OASIS_HOME + "/tools/event.log";
  93. public static String RPCLogger = OASIS_HOME + "/tools/rpc.log";
  94. public static String SFLogger = OASIS_HOME + "/tools/sf.log";
  95. public static String SimServerEventLogger = OASIS_HOME + "/tools/sim.log";
  96. public static String DefaultPath = OASIS_HOME + "/apps";
  97. public static String IconFile = OASIS_HOME + "/tools/com/oasis/images/wsu.gif";
  98. public static String ToolsPath = OASIS_HOME + "/tools/com/oasis";
  99. public static String LogPath = OASIS_HOME + "/tools/com/oasis/Log";
  100. public static String ConfigPath = OASIS_HOME + "/tools/com/oasis/Config";
  101. public static String XMLPath = OASIS_HOME + "/apps/OasisApp/build/imote2";
  102. public static String rpcxmlpath = OASIS_HOME + "/apps/MyApp/build/telosw";
  103. public static String DATASTREAM_XML_PATH = OASIS_HOME + "/DXM_DataStream/dxmstream_data.xml";
  104. public static String RES = OASIS_HOME + "/tools/com/oasis/images";
  105. //General constants
  106. public static final short UART_ADDRESS = 0x007e;
  107. public static final int MAX_SIZE_READING = 100; //size of data in DataMsg
  108. public static final int ALL_NODES = 0xffff;
  109. public static final int ROOT_ID = 0;
  110. public static final int BASE_ID = 0;
  111. public static int MAX_LOCATION_INFO_SEND = 5;
  112. public static final int UNKNOWN_ID = 65535;
  113. /*Andy use interval to calculate rate
  114. //Data gathering rate (ms)
  115. public static final int SEISMIC_DATA_RATE = 9*50;
  116. public static final int INFRASONIC_DATA_RATE = 17*50;
  117. public static final int LIGHTNING_DATA_RATE = 141*50;
  118. public static final int GPS_DATA_RATE = 1001*50;
  119. */
  120. //Drain:
  121. // public static int TOS_UART_ADDR = 0x7e;
  122. // public static int DEFAULT_MOTE_ID = 0xfffe;
  123. public static int BCAST_ID = 0xffff;
  124. public static int MAX_VALUE_DATA = 0xffff;
  125. public static int MIN_VALUE_DATA = 0;
  126. public static int RSSI_TIMEOUT = 5;
  127. public static int TOSMSG_DATA_OFFSET = 8;
  128. //Standard OasisType
  129. public static final int AM_NETWORKMSG = 129;
  130. public static final int AM_TIMESYNCMSG = 0xAA;
  131. public static final int AM_ROUTEBEACONMSG = 130;
  132. public static final int AM_NEIGHBORBEACONMSG = 131;
  133. public static final int AM_CASCTRLMSG = 132;
  134. public static final int AM_RPCCASTMSG = 133; //YFH: temp ID for NetworkMsg
  135. public static final int AM_RDTMSG = 115;
  136. public static final int AM_UNKNOWN = 65535;
  137. //Network_Msg types
  138. public static final int NW_DATA = 1;
  139. public static final int NW_SNMS = 2;
  140. public static final int NW_RPCR = 3; //YFH: temp
  141. public static final int NW_RPCC = 4; //YFH: temp
  142. public static final int NW_RSSI = 10; //Andy
  143. public static final int NW_ESCAPE = 11; //Andy
  144. public static final int NW_ALERT = 12; //Andy
  145. public static final int NW_BEACONMSG = 250; //xiaogang
  146. public static final int NW_UNKNOWN = 65535;
  147. // Network layer destination addresses for non-unicast
  148. public static final int ADDR_SINK = 0xfd;
  149. public static final int ADDR_MCAST = 0xfe;
  150. public static final int ADDR_BCAST = 0xff;
  151. public static final int ADDR_UNKNOWN = 65535;
  152. //App Type
  153. public static final int TYPE_DATA_UNKNOWN = -1;
  154. public static final int TYPE_LIGHTNING = 0;
  155. public static final int TYPE_LIGHTNING_EXTRA = 2;
  156. public static final int TYPE_RSSI = 20;
  157. public static final int TYPE_ESCAPEGUIDE = 21;
  158. public static final int TYPE_ALERT = 22;
  159. public static final int TYPE_OTHER = 30;
  160. public static final int EDGE_MULTIHOP = 1;
  161. public static final int EDGE_ESCAPE = 2;
  162. public static final int TYPE_UNKNOWN = 65535;
  163. //public static final int TYPE_DATA_SEISMIC = 0;
  164. //public static final int TYPE_DATA_INFRASONIC = 1;
  165. //public static final int TYPE_DATA_LIGHTNING = 2;
  166. //public static final int TYPE_DATA_RSAM = 3;
  167. //public static final int TYPE_DATA_GPS = 8;
  168. public static final int TYPE_SNMS_EVENT = 11;
  169. public static final int TYPE_SNMS_RPCCOMMAND = 12;
  170. public static final int TYPE_SNMS_RPCRESPONSE = 13;
  171. public static final int TYPE_SNMS_CODE = 14;
  172. //Timer Type
  173. public static final int RTC_TIME = 0;
  174. public static final int PC_TIME = 1;
  175. //Event Type
  176. public static final int EVENT_TYPE_ALL = 0; // used to set filter for all event types
  177. public static final int EVENT_TYPE_SNMS = 1;
  178. public static final int EVENT_TYPE_SENSING = 2;
  179. public static final int EVENT_TYPE_MIDDLEWARE = 3;
  180. public static final int EVENT_TYPE_ROUTING = 4;
  181. public static final int EVENT_TYPE_MAC = 5;
  182. public static final int EVENT_TYPE_DATAMANAGE = 6;
  183. public static final int EVENT_TYPE_SEISMICEVENT = 7;
  184. //Event Level
  185. public static final int EVENT_LEVEL_URGENT = 0; //go through filter guaranteed
  186. public static final int EVENT_LEVEL_HIGH = 1;
  187. public static final int EVENT_LEVEL_MEDIUM = 2;
  188. public static final int EVENT_LEVEL_LOW = 3;
  189. /** RPC */
  190. // RPC response error code
  191. public static final int RPC_SUCCESS = 0; /* packet contains return values */
  192. public static final int RPC_GARBAGE_ARGS = 1; /* can't decode arguments */
  193. public static final int RPC_RESPONSE_TOO_LARGE = 2; /* can we check for this at compile time? */
  194. public static final int RPC_PROCEDURE_UNAVAIL = 3;
  195. public static final int RPC_SYSTEM_ERR = 4;
  196. public static final int RPC_WRONG_XML_FILE = 5;
  197. // RPC constants
  198. public static final int RPC_RESPONSE_DESIRED = 1; /* 1: require response; 0: no response needed */
  199. //8/5/2007 For Cascade
  200. public static final int MAX_CMD_RECORD_NUM = 10;
  201. public static final int TYPE_CASCADES_NODATA = 17;
  202. public static final int TYPE_CASCADES_ACK = 18;
  203. public static final int TYPE_CASCADES_REQ = 19;
  204. /** Rawdata */
  205. public static final int TOS_MSG_HEADER_LEN = 10;
  206. public static final int MAX_FILTER_NODE_NUM = 100;
  207. public static final int MAX_FILTER_TYPE_NUM = 10;
  208. public static final int MSG_BUFFER_SIZE = 256;
  209. public static final int ANY_TYPE_MSG = -1;
  210. //Define the type of received message
  211. public static final int NORM = 0;
  212. public static final int MISS = 1;
  213. public static final int DUP = 2;
  214. public static final int MAX_NODE_NUM = 1000;
  215. public static final int RESET_PERIOD = 200; //max seqNo = 256
  216. /** Oscope */
  217. public static final int OSCOPE_REFRESH_RATE = 3; //num of recvd msgs
  218. //YYY:8/24/2007
  219. /** Debugging Flags */
  220. public static final boolean RPC_DEBUG = false;
  221. //endian
  222. public static boolean BIG = false;
  223. }