ae07d802f3837b49365b5137faa82023f659a2ec.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace IControls_FireManager
  5. {
  6. public class MskDeviceIDString
  7. {
  8. String mskId = "";
  9. String dev_type = "M"; //M-중계기,I-IO보드
  10. String inout_type = "I"; //입력회로-I,출력회로-O
  11. int board_id = -1; //통신보드
  12. int comm_id = 1; //1-front,2-back,3-io,4-keypad
  13. int loop_no = -1; //Loop No
  14. int repeater_id = -1; //중계기 ID
  15. int device_id = -1; //회로ID
  16. //MI-##-#-###-# :M(구분 M-중계기,I-입력그룹)I,O(회로구분)-##(보드ID)-#(회로ID)
  17. public MskDeviceIDString(String dev_s, string Receiver_ID)
  18. {
  19. try
  20. {
  21. if (dev_s.Length == 13)
  22. {
  23. this.mskId = dev_s;
  24. this.dev_type = dev_s.Substring(0, 1).ToUpper();
  25. this.inout_type = dev_s.Substring(1, 1).ToUpper();
  26. this.board_id = Util.StrToInt(dev_s.Substring(3, 2), 0);
  27. this.loop_no = Util.StrToInt(dev_s.Substring(6, 1), -1);
  28. this.repeater_id = Util.StrToInt(dev_s.Substring(8, 3), 0);
  29. this.device_id = Util.StrToInt(dev_s.Substring(12, 1), 0);
  30. if (dev_type.Equals("I")) comm_id = 3;
  31. if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output))
  32. {
  33. throw new Exception("회로번호가 올바르지 않습니다. [입출력구분]");
  34. }
  35. // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  36. if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300")
  37. {
  38. if (board_id < 0 || board_id > 68) // cyim 2016.09.12 : 통신보드는 8개(ID : 1~8), 중계반은 60개 (ID : 9 ~ 68), 총 256 계통이다
  39. {
  40. throw new Exception("회로번호가 올바르지 않습니다. [통신보드ID]");
  41. }
  42. if (loop_no < 0 || loop_no > 3) // cyim 2016.09.12 : 루프번호는 0~3
  43. {
  44. throw new Exception("회로번호가 올바르지 않습니다. [Loop No]");
  45. }
  46. }
  47. else
  48. {
  49. if (board_id == 0 || board_id > 32)
  50. {
  51. throw new Exception("회로번호가 올바르지 않습니다. [통신보드ID]");
  52. }
  53. if (loop_no != 0 && loop_no != 1)
  54. {
  55. throw new Exception("회로번호가 올바르지 않습니다. [Loop No]");
  56. }
  57. }
  58. if (repeater_id == 0 || repeater_id > 127)
  59. {
  60. throw new Exception("회로번호가 올바르지 않습니다. [중계기ID]");
  61. }
  62. if (device_id == 0)
  63. {
  64. throw new Exception("회로번호가 올바르지 않습니다. [회로ID]");
  65. }
  66. }
  67. else if (dev_s.Length == 9)
  68. {
  69. this.mskId = dev_s;
  70. this.dev_type = dev_s.Substring(0, 1).ToUpper();
  71. this.inout_type = dev_s.Substring(2, 1).ToUpper();
  72. this.board_id = Util.StrToInt(dev_s.Substring(4, 2), 0);
  73. this.loop_no = 0;
  74. this.repeater_id = 0;
  75. this.device_id = Util.StrToInt(dev_s.Substring(7, 2), 0);
  76. if (dev_type.Equals("I")) comm_id = 3;
  77. if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output))
  78. {
  79. throw new Exception("회로번호가 올바르지 않습니다. [입출력구분]");
  80. }
  81. if (board_id == 0)
  82. {
  83. throw new Exception("회로번호가 올바르지 않습니다. [I/O보드ID]");
  84. }
  85. if (device_id == 0)
  86. {
  87. throw new Exception("회로번호가 올바르지 않습니다. [회로ID]");
  88. }
  89. }
  90. else
  91. {
  92. throw new Exception("회로번호가 올바르지 않습니다.");
  93. }
  94. }
  95. catch (Exception ex)
  96. {
  97. Util.UErrorMessage(ex, 0, 0);
  98. }
  99. }
  100. // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  101. public MskDeviceIDString(int comm_id, int board_id, int loop_no, int repeater_id, int device_id, string inout_type, string Receiver_ID)
  102. {
  103. try
  104. {
  105. this.comm_id = comm_id;
  106. this.inout_type = inout_type;
  107. this.board_id = board_id;
  108. this.loop_no = loop_no;
  109. this.repeater_id = repeater_id;
  110. this.device_id = device_id;
  111. if (comm_id == 3)
  112. this.dev_type = "I";
  113. else if (comm_id == 1)
  114. this.dev_type = "M";
  115. else if (comm_id == 2)
  116. this.dev_type = "M";
  117. else if (comm_id == 4)
  118. this.dev_type = "키패드";
  119. //if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output))
  120. //{
  121. // return;
  122. // //throw new Exception("회로번호가 올바르지 않습니다. [입출력구분]");
  123. //}
  124. if (this.comm_id == 1 || this.comm_id == 2)
  125. {
  126. // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  127. if ((((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300") && (board_id < 0 || board_id > 68)) // cyim 2016.09.12 : 통신보드는 8개(ID : 1~8), 중계반은 60개 (ID : 9 ~ 68), 총 256 계통이다
  128. {
  129. this.mskId = string.Format("Comm[{0}]", this.comm_id);
  130. }
  131. else if ((((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL != "IFC3300") && (board_id == 0 || board_id > 32))
  132. {
  133. this.mskId = string.Format("Comm[{0}]", this.comm_id);
  134. }
  135. else
  136. {
  137. // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경
  138. if ((((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300") && (loop_no < 0 || loop_no > 3)) // cyim 2016.09.12 : 루프번호는 0~3
  139. this.mskId = string.Format("통신보드[{0}]", this.board_id);
  140. else if ((((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL != "IFC3300") && (loop_no != 0 && loop_no != 1))
  141. this.mskId = string.Format("통신보드[{0}]", this.board_id);
  142. else
  143. {
  144. if (repeater_id == 0 || repeater_id > 127)
  145. this.mskId = string.Format("통신보드[{0}]-Loop[{1}]", this.board_id, this.loop_no);
  146. else
  147. {
  148. if (device_id == 0)
  149. this.mskId = string.Format("통신보드[{0}]-Loop[{1}]-중계기[{2}]", this.board_id, this.loop_no, this.repeater_id);
  150. else
  151. {
  152. if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output))
  153. this.mskId = string.Format("통신보드[{0}]-Loop[{1}]-중계기[{2}]-회로[{3}]", this.board_id, this.loop_no, this.repeater_id, this.device_id);
  154. else
  155. {
  156. this.mskId = string.Format("{0}{1}-{2:00}-{3:0}-{4:000}-{5}", this.dev_type, this.inout_type, this.board_id
  157. , this.loop_no, this.repeater_id, this.device_id);
  158. }
  159. }
  160. }
  161. }
  162. }
  163. //if (device_id == 0)
  164. //{
  165. // if (repeater_id == 0 || repeater_id > 127)
  166. // {
  167. // if (loop_no != 0 && loop_no != 1)
  168. // {
  169. // if (board_id == 0 || board_id > 32)
  170. // {
  171. // this.mskId = string.Format("Comm[{0}]", this.comm_id);
  172. // }
  173. // else
  174. // {
  175. // this.mskId = string.Format("통신보드[{0}]", this.board_id);
  176. // }
  177. // }
  178. // else
  179. // {
  180. // this.mskId = string.Format("통신보드[{0}]-Loop[{1}]", this.board_id, this.loop_no);
  181. // }
  182. // }
  183. // else
  184. // {
  185. // this.mskId = string.Format("통신보드[{0}]-Loop[{1}]-중계기[{2}]", this.board_id, this.loop_no, this.repeater_id);
  186. // }
  187. //}
  188. //else
  189. //{
  190. // this.mskId = string.Format("{0}{1}-{2:00}-{3:0}-{4:000}-{5}", this.dev_type, this.inout_type, this.board_id
  191. // , this.loop_no, this.repeater_id, this.device_id);
  192. //}
  193. }
  194. else if (this.comm_id == 3)
  195. {
  196. if (device_id == 0)
  197. {
  198. if (board_id == 0)
  199. {
  200. this.mskId = string.Format("IO보드 Comm[{0}]", this.comm_id);
  201. }
  202. else
  203. {
  204. this.mskId = string.Format("IO보드[{0}]", this.board_id);
  205. }
  206. }
  207. else
  208. {
  209. //I-A-12-##
  210. this.mskId = String.Format("{0}-{1}-{2:00}-{3:00}", this.dev_type, this.inout_type, this.board_id, this.device_id);
  211. }
  212. }
  213. else if (this.comm_id == 4)
  214. {
  215. if (device_id == 0)
  216. {
  217. this.mskId = string.Format("키패드 Comm[{0}]", this.comm_id);
  218. }
  219. else
  220. {
  221. //I-A-12-##
  222. this.mskId = String.Format("키패드 번호[{0}]", this.device_id);
  223. }
  224. }
  225. }
  226. catch (Exception ex)
  227. {
  228. Util.UErrorMessage(ex, 0, 0);
  229. }
  230. }
  231. public int Board_id { get { return this.board_id; } }
  232. public int Comm_id { get { return this.comm_id; } }
  233. public int Loop_no { get { return this.loop_no; } }
  234. public int Repeater_id { get { return this.repeater_id; } }
  235. public int Device_id { get { return this.device_id; } }
  236. public String Inout_type { get { return this.inout_type; } }
  237. public String MskId { get { return this.mskId; } }
  238. }
  239. }