00001 using System;
00002 using System.Net;
00003
00004 namespace GPRSWeb.SmartDeviceClient.SmartProtocolStack
00005 {
00009 public class StackSettings {
00010 public StackSettings() {
00011 LoadFromReg();
00012 }
00013
00018 private int myDeviceID = -1 ;
00019
00023 public ushort MyDeviceID {
00024 get { if (myDeviceID >= 0) {
00025 return (ushort)myDeviceID;
00026 } else {
00027 throw new ApplicationException("Unable to fetch Device ID for stack - no device ID set");
00028 }
00029 }
00030 set { myDeviceID = value;}
00031 }
00032
00036 public int ClientReceivePortNumber {
00037 get { return 30481; }
00038 }
00039 private int clientRxPortNum;
00040
00044 public int ClientSendFromPortNumber {
00045 get { return 12346; }
00046 }
00047
00051 public int ServerSendFromPortNumber {
00052 get { return 12345; }
00053 }
00054
00058 public int ServerReceivePortNumber {
00059 get { return 30481; }
00060 }
00061 private int serverRxPortNum;
00062
00063 private void LoadFromReg() {
00064
00065 throw new ApplicationException("Registry access code needed in StackSettings");
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 }
00077
00078 private int defaultBDP;
00079 public int DefaultBandwidthDelayProdut {
00080 get {
00081 if (defaultBDP >= 0) {
00082 return defaultBDP;
00083 } else {
00084 throw new ApplicationException("Unable to fetch Default Bandwidth Deplay Product - not set");
00085 }
00086 }
00087 }
00088
00089 private int interAckableTime;
00090 public int InterAckableTime {
00091 get {
00092 if (interAckableTime >= 0) {
00093 return interAckableTime;
00094 } else {
00095 throw new ApplicationException("Unable to fetch InterAckableTime - not set");
00096 }
00097 }
00098 }
00099
00100 private int firstAckableTime;
00101 public int FirstAckableTime {
00102 get {
00103 if (firstAckableTime >= 0) {
00104 return firstAckableTime;
00105 } else {
00106 throw new ApplicationException("Unable to fetch FirstAckableTime - not set");
00107 }
00108 }
00109 }
00110
00111 private int ackArrivalTimeout;
00112 public int AckArrivalTimeout {
00113 get {
00114 if (ackArrivalTimeout >= 0) {
00115 return ackArrivalTimeout;
00116 } else {
00117 throw new ApplicationException("Unable to fetch AckArrivalTimeout- not set");
00118 }
00119 }
00120 }
00121
00122 private string serverIP;
00123 public IPAddress ServerIP {
00124 get {
00125 try {
00126 return IPAddress.Parse(serverIP);
00127 } catch (Exception ex) {
00128 throw new ApplicationException("Unable to fetch Server IP\n\r" + ex.ToString());
00129 }
00130 }
00131 }
00132
00133 private string clientIP;
00134 public IPAddress ClientIP {
00135 get {
00136 try {
00137 return IPAddress.Parse(clientIP);
00138 } catch (Exception ex) {
00139 throw new ApplicationException("Unable to fetch Client IP\n\r" + ex.ToString());
00140 }
00141 }
00142 }
00143
00147 public ushort SERVER_DEVICE_ID {
00148 get { return 0; }
00149 }
00150
00151 }
00152 }