294eceece53600c527dcca7ff54b56d744caea04.svn-base 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace FPER
  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)
  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. if (board_id == 0 || board_id > 32)
  36. {
  37. throw new Exception("회로번호가 올바르지 않습니다. [통신보드ID]");
  38. }
  39. if (loop_no != 0 && loop_no != 1)
  40. {
  41. throw new Exception("회로번호가 올바르지 않습니다. [Loop No]");
  42. }
  43. if (repeater_id == 0 || repeater_id > 127)
  44. {
  45. throw new Exception("회로번호가 올바르지 않습니다. [중계기ID]");
  46. }
  47. if (device_id == 0)
  48. {
  49. throw new Exception("회로번호가 올바르지 않습니다. [회로ID]");
  50. }
  51. }
  52. else if (dev_s.Length == 9)
  53. {
  54. this.mskId = dev_s;
  55. this.dev_type = dev_s.Substring(0, 1).ToUpper();
  56. this.inout_type = dev_s.Substring(2, 1).ToUpper();
  57. this.board_id = Util.StrToInt(dev_s.Substring(4, 2), 0);
  58. this.loop_no = 0;
  59. this.repeater_id = 0;
  60. this.device_id = Util.StrToInt(dev_s.Substring(7, 2), 0);
  61. if (dev_type.Equals("I")) comm_id = 3;
  62. if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output))
  63. {
  64. throw new Exception("회로번호가 올바르지 않습니다. [입출력구분]");
  65. }
  66. if (board_id == 0)
  67. {
  68. throw new Exception("회로번호가 올바르지 않습니다. [I/O보드ID]");
  69. }
  70. if (device_id == 0)
  71. {
  72. throw new Exception("회로번호가 올바르지 않습니다. [회로ID]");
  73. }
  74. }
  75. else
  76. {
  77. throw new Exception("회로번호가 올바르지 않습니다.");
  78. }
  79. }
  80. catch (Exception ex)
  81. {
  82. Util.UErrorMessage(ex, 0, 0);
  83. }
  84. }
  85. public MskDeviceIDString(int comm_id, int board_id, int loop_no, int repeater_id, int device_id, string inout_type)
  86. {
  87. try
  88. {
  89. this.comm_id = comm_id;
  90. this.inout_type = inout_type;
  91. this.board_id = board_id;
  92. this.loop_no = loop_no;
  93. this.repeater_id = repeater_id;
  94. this.device_id = device_id;
  95. if (comm_id == 3)
  96. this.dev_type = "I";
  97. else if (comm_id == 1)
  98. this.dev_type = "M";
  99. else if (comm_id == 2)
  100. this.dev_type = "M";
  101. else if (comm_id == 4)
  102. this.dev_type = "키패드";
  103. //if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output))
  104. //{
  105. // return;
  106. // //throw new Exception("회로번호가 올바르지 않습니다. [입출력구분]");
  107. //}
  108. if (this.comm_id == 1 || this.comm_id == 2)
  109. {
  110. if (board_id == 0 || board_id > 32)
  111. {
  112. this.mskId = string.Format("Comm[{0}]", this.comm_id);
  113. }
  114. else
  115. {
  116. if (loop_no != 0 && loop_no != 1)
  117. this.mskId = string.Format("통신보드[{0}]", this.board_id);
  118. else
  119. {
  120. if (repeater_id == 0 || repeater_id > 127)
  121. this.mskId = string.Format("통신보드[{0}]-Loop[{1}]", this.board_id, this.loop_no);
  122. else
  123. {
  124. if (device_id == 0)
  125. this.mskId = string.Format("통신보드[{0}]-Loop[{1}]-중계기[{2}]", this.board_id, this.loop_no, this.repeater_id);
  126. else
  127. {
  128. if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output))
  129. this.mskId = string.Format("통신보드[{0}]-Loop[{1}]-중계기[{2}]-회로[{3}]", this.board_id, this.loop_no, this.repeater_id, this.device_id);
  130. else
  131. {
  132. this.mskId = string.Format("{0}{1}-{2:00}-{3:0}-{4:000}-{5}", this.dev_type, this.inout_type, this.board_id
  133. , this.loop_no, this.repeater_id, this.device_id);
  134. }
  135. }
  136. }
  137. }
  138. }
  139. //if (device_id == 0)
  140. //{
  141. // if (repeater_id == 0 || repeater_id > 127)
  142. // {
  143. // if (loop_no != 0 && loop_no != 1)
  144. // {
  145. // if (board_id == 0 || board_id > 32)
  146. // {
  147. // this.mskId = string.Format("Comm[{0}]", this.comm_id);
  148. // }
  149. // else
  150. // {
  151. // this.mskId = string.Format("통신보드[{0}]", this.board_id);
  152. // }
  153. // }
  154. // else
  155. // {
  156. // this.mskId = string.Format("통신보드[{0}]-Loop[{1}]", this.board_id, this.loop_no);
  157. // }
  158. // }
  159. // else
  160. // {
  161. // this.mskId = string.Format("통신보드[{0}]-Loop[{1}]-중계기[{2}]", this.board_id, this.loop_no, this.repeater_id);
  162. // }
  163. //}
  164. //else
  165. //{
  166. // this.mskId = string.Format("{0}{1}-{2:00}-{3:0}-{4:000}-{5}", this.dev_type, this.inout_type, this.board_id
  167. // , this.loop_no, this.repeater_id, this.device_id);
  168. //}
  169. }
  170. else if (this.comm_id == 3)
  171. {
  172. if (device_id == 0)
  173. {
  174. if (board_id == 0)
  175. {
  176. this.mskId = string.Format("IO보드 Comm[{0}]", this.comm_id);
  177. }
  178. else
  179. {
  180. this.mskId = string.Format("IO보드[{0}]", this.board_id);
  181. }
  182. }
  183. else
  184. {
  185. //I-A-12-##
  186. this.mskId = String.Format("{0}-{1}-{2:00}-{3:00}", this.dev_type, this.inout_type, this.board_id, this.device_id);
  187. }
  188. }
  189. else if (this.comm_id == 4)
  190. {
  191. if (device_id == 0)
  192. {
  193. this.mskId = string.Format("키패드 Comm[{0}]", this.comm_id);
  194. }
  195. else
  196. {
  197. //I-A-12-##
  198. this.mskId = String.Format("키패드 번호[{0}]", this.device_id);
  199. }
  200. }
  201. }
  202. catch (Exception ex)
  203. {
  204. Util.UErrorMessage(ex, 0, 0);
  205. }
  206. }
  207. public int Board_id { get { return this.board_id; } }
  208. public int Comm_id { get { return this.comm_id; } }
  209. public int Loop_no { get { return this.loop_no; } }
  210. public int Repeater_id { get { return this.repeater_id; } }
  211. public int Device_id { get { return this.device_id; } }
  212. public String Inout_type { get { return this.inout_type; } }
  213. public String MskId { get { return this.mskId; } }
  214. }
  215. }