frmVersion.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace FPER
  9. {
  10. public partial class frmVersion : Form
  11. {
  12. public frmVersion()
  13. {
  14. InitializeComponent();
  15. // cyim 2013.7.12 디자인개선작업 : 시스템정보 - 버전정보 : 기본결과
  16. this.button_Menu_BasicSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  17. }
  18. MDIParent mdi = null;
  19. delegate void deleFormInit();
  20. int glb_boardNo = 1;
  21. private void btnWinClose_Click(object sender, EventArgs e)
  22. {
  23. try
  24. {
  25. this.Close();
  26. }
  27. catch (Exception ex)
  28. {
  29. Util.UErrorMessage(ex, 0, 0);
  30. }
  31. }
  32. public void Form_Init()
  33. {
  34. try
  35. {
  36. }
  37. catch (Exception ex)
  38. {
  39. Util.UErrorMessage(ex, 0, 0);
  40. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  41. }
  42. }
  43. private void frmVersion_Load(object sender, EventArgs e)
  44. {
  45. // cyim 2013.8.1 : 더블버퍼링 적용
  46. SetStyle(ControlStyles.UserPaint, true);
  47. //this.UpdateStyles();
  48. SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  49. //this.UpdateStyles();
  50. SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  51. this.UpdateStyles();
  52. try
  53. {
  54. mdi = (MDIParent)this.MdiParent;
  55. txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
  56. //this.mdi.SelectMenuIndex = 7;
  57. txtUIVersion.Text = Application.ProductVersion;
  58. txtDemonVersion.Text = "";
  59. txtFileVersion.Text = "0.0.0.0";
  60. Grid_init();
  61. this.Cursor = Cursors.WaitCursor;
  62. //완료이벤트
  63. dCommandResponse d = new dCommandResponse(VersionInfoComplete);
  64. //명령생성 및 실행
  65. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, 0, 0, d);
  66. cmd.CommandType = "VI";
  67. cmd.ApplyRange = "A"; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  68. cmd.CommandData = null;
  69. mdi.ui.runCommand(cmd);
  70. }
  71. catch (Exception ex)
  72. {
  73. Util.UErrorMessage(ex, 0, 0);
  74. }
  75. }
  76. private void frmVersion_Activated(object sender, EventArgs e)
  77. {
  78. try
  79. {
  80. //this.mdi.SelectMenuIndex = 7;
  81. }
  82. catch (Exception ex)
  83. {
  84. Util.UErrorMessage(ex, 0, 0);
  85. }
  86. }
  87. private void frmVersion_Disposed(object sender, EventArgs e)
  88. {
  89. //if (mdi.ui.CommResponseReading)
  90. //{
  91. // //MessageBox.Show("응답 대기중입니다.. 잠시만 기다려 주십시요..");
  92. // return;
  93. //}
  94. try
  95. {
  96. //this.mdi.SelectMenuIndex = 0;
  97. }
  98. catch (Exception ex)
  99. {
  100. Util.UErrorMessage(ex, 0, 0);
  101. }
  102. }
  103. //*********************************************************************//
  104. // 버젼정보 완료 응답데이터 이벤트 //
  105. //*********************************************************************//
  106. public void VersionInfoComplete(CmdInfo cmd)
  107. {
  108. try
  109. {
  110. this.Cursor = Cursors.Default;
  111. //에러응답처리
  112. if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_ReadCommandStatus")) // cyim 2015.7.23 NACK 처리 부분 오류
  113. {
  114. return;
  115. }
  116. RCVData_ReadCommandStatus resData2 = (RCVData_ReadCommandStatus)cmd.ResponseData;
  117. string demonVer = string.Format("{0}.{1}.{2}.{3}", resData2.Reply_value1, resData2.Reply_value2, resData2.Reply_value3, resData2.Reply_value4);
  118. txtDemonVersion.Text = demonVer;
  119. }
  120. catch (Exception ex)
  121. {
  122. Util.UErrorMessage(ex, 0, 0);
  123. }
  124. }
  125. //*********************************************************************//
  126. // 버젼정보 완료 응답데이터 이벤트 //
  127. //*********************************************************************//
  128. private void BrdVersionInfoComplete(CmdInfo cmd)
  129. {
  130. try
  131. {
  132. this.Cursor = Cursors.Default;
  133. //에러응답처리
  134. if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_ReadTBoardStatus")) // cyim 2015.7.23 NACK 처리 부분 오류
  135. {
  136. button_end(true);
  137. return;
  138. }
  139. if (cmd != null)
  140. {
  141. TextBox txt = (TextBox)Util.FineControl(tabPage2, string.Format("txtBoardVer_{0}", glb_boardNo));
  142. if (txt != null)
  143. {
  144. RCVData_ReadTBoardStatus res = (RCVData_ReadTBoardStatus)cmd.ResponseData;
  145. txt.Text = string.Format("{0}.{1}", res.TBD_MainVersion, res.TBD_SubVersion);
  146. }
  147. glb_boardNo++;
  148. }
  149. while (glb_boardNo <= 16)
  150. {
  151. TextBox txt = (TextBox)Util.FineControl(tabPage2, string.Format("txtBoardVer_{0}", glb_boardNo));
  152. if (txt != null)
  153. {
  154. if (txt.Enabled)
  155. {
  156. //해당 textbox가 활성화 되었다면 해당 버젼정보를 가져온다.
  157. break;
  158. }
  159. else
  160. {
  161. //다음 textbox를 찾는다.
  162. glb_boardNo++;
  163. }
  164. }
  165. else
  166. {
  167. return;
  168. }
  169. }
  170. }
  171. catch (Exception ex)
  172. {
  173. Util.UErrorMessage(ex, 0, 0);
  174. button_end(true);
  175. //MessageBox.Show(ex.Message);
  176. return;
  177. }
  178. try
  179. {
  180. if (glb_boardNo < 16)
  181. {
  182. CmdInfo cmd2 = new CmdInfo(prt_cmd_define.resd_tbd_state, mdi.myReceiverID);
  183. cmd2.boardNo = glb_boardNo;
  184. dCommandResponse d = new dCommandResponse(BrdVersionInfoComplete); //응답후 이벤트 읽기 명령으로 이동
  185. cmd2.dEvent = d;
  186. this.mdi.ui.runCommand(cmd2);
  187. }
  188. else
  189. {
  190. button_end(true);
  191. }
  192. }
  193. catch (Exception ex)
  194. {
  195. Util.UErrorMessage(ex, 0, 0);
  196. button_end(true);
  197. }
  198. }
  199. private void Grid_init()
  200. {
  201. try
  202. {
  203. if (mdi.ui == null) return;
  204. ReceiverTypeInfo receiverInfo = mdi.ui.MyReceiverTypeInfo;
  205. if (receiverInfo == null) return;
  206. /************************************************************************/
  207. /* 통신보드 화면 초기화 */
  208. /************************************************************************/
  209. BoardTypeInfo[] boardInfos = receiverInfo.MyBoardType; //전체통신보드
  210. if (boardInfos != null)
  211. {
  212. foreach (BoardTypeInfo brd in boardInfos)
  213. {
  214. if (brd != null)
  215. {
  216. if (brd.UseFlag)
  217. {
  218. Label lbl = (Label)Util.FineControl(tabPage2, string.Format("lblBoardID_{0}", brd.BoardNo));
  219. if (lbl != null)
  220. {
  221. lbl.Enabled = true;
  222. }
  223. TextBox txt = (TextBox)Util.FineControl(tabPage2, string.Format("txtBoardVer_{0}", brd.BoardNo));
  224. if (txt != null)
  225. {
  226. txt.Enabled = true;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. /************************************************************************/
  233. }
  234. catch (Exception ex)
  235. {
  236. Util.UErrorMessage(ex, 0, 0);
  237. throw ex;
  238. }
  239. }
  240. private void btnCommRead_Click(object sender, EventArgs e)
  241. {
  242. try
  243. {
  244. //버튼 비활성 설정
  245. button_end(false);
  246. glb_boardNo = 1;
  247. //통신보드 버젼읽기 명령 시작
  248. BrdVersionInfoComplete(null);
  249. }
  250. catch (Exception ex)
  251. {
  252. Util.UErrorMessage(ex, 0, 0);
  253. button_end(true);
  254. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  255. }
  256. }
  257. //화면 마우스 커서 및 버튼 다시 클릭 못하도록 설정 및 해제
  258. private void button_end(Boolean val)
  259. {
  260. try
  261. {
  262. if (val)
  263. {
  264. this.btnCommRead.Enabled = true;
  265. this.Cursor = Cursors.Default;
  266. }
  267. else
  268. {
  269. this.btnCommRead.Enabled = false;
  270. this.Cursor = Cursors.WaitCursor;
  271. }
  272. }
  273. catch (Exception ex)
  274. {
  275. Util.UErrorMessage(ex, 0, 0);
  276. }
  277. }
  278. bool CheckBoardVersion = false;//2010.10.29,k.s.d, check flag.
  279. private void tabPage2_Enter(object sender, EventArgs e)
  280. {//2010.10.29,k.s.d, if tab enter , read board version.
  281. try
  282. {
  283. if (CheckBoardVersion == false)
  284. {
  285. glb_boardNo = 1;
  286. BrdVersionInfoComplete(null);
  287. }
  288. CheckBoardVersion = true;
  289. }
  290. catch (Exception ex)
  291. {
  292. Util.UErrorMessage(ex, 0, 0);
  293. }
  294. }
  295. //
  296. // cyim 2013.7.12 디자인개선작업 : 시스템정보 - 버전정보
  297. //
  298. private void button_Menu_BasicSet_Click(object sender, EventArgs e)
  299. {
  300. button_Menu_Color_Init();
  301. this.tabControl1.SelectTab(0);
  302. this.button_Menu_BasicSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  303. this.panel_Menu.Focus();
  304. }
  305. private void button_Menu_CommBoard_Click(object sender, EventArgs e)
  306. {
  307. button_Menu_Color_Init();
  308. this.tabControl1.SelectTab(1);
  309. this.button_Menu_CommBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
  310. this.panel_Menu.Focus();
  311. }
  312. private void button_Menu_Color_Init()
  313. {
  314. this.button_Menu_BasicSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
  315. this.button_Menu_CommBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
  316. }
  317. }
  318. }