frmControlWrite.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  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. using System.IO;
  9. // cyim 2015.7.13 설비연동 주석 정리
  10. // 설비연동 소스가 너무 주석과 내용이 틀리고 엉망이다. 이전 작업자가 작업한 코드를 모두 정리하고
  11. // 불필요한 코드는 다 제거한다
  12. namespace FPER
  13. {
  14. public partial class frmControlWrite : Form
  15. {
  16. // 설비 연동 창 클래스
  17. MDIParent mdi = null;
  18. controlWriteDevType[] devTypes = null;
  19. delegate void deleFormInit();
  20. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  21. public bool ProcessEnableStatus = false;
  22. // cyim 2015.8.18 주경종정지 기능 추가
  23. public bool InitMainSoundStop = false;
  24. // cyim 2016.12.09 : IFC3300에서는 예비전원버튼 -> 설비전체연동조작버튼
  25. public int InitEquipmentAllOperationStatus = 0;
  26. public System.Windows.Forms.Timer timer = new Timer();
  27. // 생성자
  28. public frmControlWrite(bool MainSoundStop, int EquipmentAllOperationStatus)
  29. {
  30. InitializeComponent();
  31. // 초기화
  32. ProcessEnableStatus = false;
  33. // cyim 2015.8.18 주경종정지 기능 추가 : 만약 수신반에서 주경종 정지 기능을 사용하려고 했다면 화면이 준비되는 순간 마지막에 주경종 정지 명령을 날린다
  34. InitMainSoundStop = MainSoundStop;
  35. // cyim 2016.12.09 : IFC3300에서는 예비전원버튼 -> 설비전체연동조작버튼
  36. InitEquipmentAllOperationStatus = EquipmentAllOperationStatus;
  37. timer.Interval = 3000;
  38. timer.Tick += new EventHandler(timer_Tick);
  39. }
  40. // 창 데이터 초기화 함수
  41. public void Form_Init()
  42. {
  43. try
  44. {
  45. if (this.InvokeRequired)
  46. {
  47. deleFormInit d = new deleFormInit(Form_Init);
  48. this.Invoke(d, new object[] { });
  49. }
  50. else
  51. {
  52. getData();
  53. this.mdi.SetLikageBtnStatus();
  54. }
  55. }
  56. catch (Exception ex)
  57. {
  58. Util.UErrorMessage(ex, 0, 0);
  59. }
  60. }
  61. // 버튼 이미지 로딩 함수
  62. private Image ImgLoad(string path)
  63. {
  64. Image ret = null;
  65. try
  66. {
  67. ret = Image.FromFile(path);
  68. }
  69. catch (Exception e)
  70. {
  71. Util.UErrorMessage(e, 0, 0);
  72. }
  73. return ret;
  74. }
  75. private Image ImageLoadingPanelRed()
  76. {
  77. // cyim : 디자인개선
  78. //return (Image)Properties.Resources.panel_430_52_R;
  79. return (Image)Properties.Resources.버튼_개별정지_420_77;
  80. }
  81. private Image ImageLoadingPanelBlue()
  82. {
  83. // cyim : 디자인 개선
  84. //return (Image)Properties.Resources.panel_430_52_B;
  85. return (Image)Properties.Resources.버튼_개별연동_420_77;
  86. }
  87. private controlWriteDevType findControlDevType(string dev_type)
  88. {
  89. controlWriteDevType devType = null;
  90. try
  91. {
  92. foreach (controlWriteDevType devtp in devTypes)
  93. {
  94. if (devtp.Dev_type.Equals(dev_type))
  95. {
  96. devType = devtp;
  97. break;
  98. }
  99. }
  100. }
  101. catch (Exception ex)
  102. {
  103. Util.UErrorMessage(ex, 0, 0);
  104. }
  105. return devType;
  106. }
  107. private void frmControlWrite_Load(object sender, EventArgs e)
  108. {
  109. // cyim 2013.8.1 : 더블버퍼링 적용
  110. SetStyle(ControlStyles.UserPaint, true);
  111. //this.UpdateStyles();
  112. SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  113. //this.UpdateStyles();
  114. SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  115. this.UpdateStyles();
  116. try
  117. {
  118. mdi = (MDIParent)this.MdiParent;
  119. txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
  120. this.Cursor = Cursors.WaitCursor;
  121. init();
  122. this.Cursor = Cursors.Default;
  123. // cyim 2015.8.18 주경종정지 기능 추가
  124. if (InitMainSoundStop == true)
  125. MainSoundStop();
  126. // cyim 2016.12.09 : IFC3300에서는 예비전원버튼 -> 설비전체연동조작버튼
  127. if (InitEquipmentAllOperationStatus != 0)
  128. timer.Start();
  129. }
  130. catch (Exception ex)
  131. {
  132. Util.UErrorMessage(ex, 0, 0);
  133. }
  134. }
  135. // cyim 2016.12.09 : IFC3300에서는 예비전원버튼 -> 설비전체연동조작버튼
  136. public void timer_Tick(object sender, EventArgs e)
  137. {
  138. // 2초후에 루틴
  139. if (InitEquipmentAllOperationStatus != 0) // 0 Default, 1 : 전체정지, 2 : 전체연동
  140. {
  141. getData();
  142. }
  143. timer.Stop();
  144. }
  145. private void frmControlWrite_Activated(object sender, EventArgs e)
  146. {
  147. try
  148. {
  149. this.mdi.SelectMenuIndex = 1;
  150. }
  151. catch (Exception ex)
  152. {
  153. Util.UErrorMessage(ex, 0, 0);
  154. }
  155. }
  156. private void frmControlWrite_Disposed(object sender, EventArgs e)
  157. {
  158. try
  159. {
  160. // cyim 2016.12.09 : IFC3300에서는 예비전원버튼 -> 설비전체연동조작버튼
  161. timer.Tick -= new EventHandler(timer_Tick);
  162. this.mdi.SelectMenuIndex = 0;
  163. }
  164. catch (Exception ex)
  165. {
  166. Util.UErrorMessage(ex, 0, 0);
  167. }
  168. }
  169. // 데이터 초기화 함수
  170. private void init()
  171. {
  172. this.SetLDeviceTypeConfig();
  173. }
  174. // 설정 데이터 갱신 함수
  175. private void getData()
  176. {
  177. try
  178. {
  179. if (this.InvokeRequired)
  180. {
  181. deleFormInit d = new deleFormInit(getData);
  182. this.Invoke(d, new object[] { });
  183. }
  184. else
  185. {
  186. this.UpdateLDeviceTypeConfig();
  187. }
  188. }
  189. catch (Exception ex)
  190. {
  191. Util.UErrorMessage(ex, 0, 0);
  192. }
  193. }
  194. // 버튼 상태 변경 함수
  195. private void DoChangeBTNSet(Button btnYes, Button btnNo, bool set)
  196. {
  197. try
  198. {
  199. if (set) // 사용
  200. {
  201. btnYes.Enabled = false;
  202. btnNo.Enabled = true;
  203. btnYes.BackColor = Color.Blue;
  204. btnNo.BackColor = Color.Red;
  205. btnYes.ForeColor = Color.White;
  206. btnNo.ForeColor = Color.White;
  207. }
  208. else // 차단
  209. {
  210. btnYes.Enabled = true;
  211. btnNo.Enabled = false;
  212. btnYes.BackColor = Color.Blue;
  213. btnNo.BackColor = Color.Red;
  214. btnYes.ForeColor = Color.White;
  215. btnNo.ForeColor = Color.White;
  216. }
  217. }
  218. catch (Exception ex)
  219. {
  220. Util.UErrorMessage(ex, 0, 0);
  221. }
  222. }
  223. // 종료하기
  224. private void btnWinClose_Click(object sender, EventArgs e)
  225. {
  226. this.Close();
  227. }
  228. //명령 쓰기 완료--종료.
  229. bool lock_cmd = false;
  230. // 설비 연동 상태 갱신 함수
  231. private void DoChangeDeviceLinkage2(object sender, EventArgs e)
  232. {
  233. try
  234. {
  235. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  236. if (ProcessEnableStatus == true || mdi.CommDaemon_ComStatus == false) return;
  237. if (sender is Control)
  238. {
  239. Control Ctl = (Control)sender;
  240. if (Ctl.Tag is CDeviceTypeConfig)
  241. {
  242. if (!lock_cmd)
  243. {
  244. lock_cmd = true;
  245. this.Cursor = Cursors.WaitCursor;
  246. timer_check.Enabled = true;
  247. progress_dot = -2;
  248. progress_end = false;
  249. timer_progress.Enabled = true;
  250. CDeviceTypeConfig dtc = (CDeviceTypeConfig)Ctl.Tag;
  251. string devTypeString = dtc.deviceType;
  252. int Use_flag = (dtc.use ? 1 : 0);
  253. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, 0, 0, null);
  254. cmd.CommandType = "DC";
  255. cmd.ApplyRange = "A"; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  256. cmd.Status = (Use_flag == 0 ? 1 : 0); //사용여부 0-비사용,1-사용
  257. cmd.SubType = devTypeString.Substring(1);
  258. cmd.CommId = 1;
  259. cmd.loopNo = 0;
  260. //명령 생성
  261. dCommandResponse d = new dCommandResponse(command_complete);
  262. cmd.dEvent = d;
  263. // cyim 2015.2.10 설비연동 실행
  264. mdi.CommandLog(MappingStatus.Log, string.Format("설비연동 실행 [{0},{1}]", dtc.deviceName, (cmd.Status == 0 ? "Disable" : "Enable")));
  265. this.mdi.ui.runCommand(cmd);
  266. }
  267. }
  268. }
  269. }
  270. catch (Exception ex)
  271. {
  272. progress_end = true;
  273. lock_cmd = false;
  274. this.Cursor = Cursors.Default;
  275. Util.UErrorMessage(ex, 0, 0);
  276. }
  277. }
  278. // cyim 2015.8.18 주경종정지 기능 추가
  279. public void MainSoundStop()
  280. {
  281. try
  282. {
  283. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  284. if (ProcessEnableStatus == true || mdi.CommDaemon_ComStatus == false) return;
  285. //if (sender is Control)
  286. {
  287. //Control Ctl = (Control)sender;
  288. //if (Ctl.Tag is CDeviceTypeConfig)
  289. {
  290. if (!lock_cmd)
  291. {
  292. lock_cmd = true;
  293. this.Cursor = Cursors.WaitCursor;
  294. timer_check.Enabled = true;
  295. progress_dot = -2;
  296. progress_end = false;
  297. timer_progress.Enabled = true;
  298. //CDeviceTypeConfig dtc = (CDeviceTypeConfig)Ctl.Tag;
  299. //string devTypeString = dtc.deviceType;
  300. string devTypeString = "OA";
  301. //int Use_flag = (dtc.use ? 1 : 0);
  302. int Use_flag = 1; // 무조건 정지
  303. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, 0, 0, null);
  304. cmd.CommandType = "DC";
  305. cmd.ApplyRange = "A"; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  306. cmd.Status = (Use_flag == 0 ? 1 : 0); //사용여부 0-비사용,1-사용
  307. cmd.SubType = devTypeString.Substring(1);
  308. cmd.CommId = 1;
  309. cmd.loopNo = 0;
  310. //명령 생성
  311. dCommandResponse d = new dCommandResponse(command_complete);
  312. cmd.dEvent = d;
  313. // cyim 2015.2.10 설비연동 실행
  314. mdi.CommandLog(MappingStatus.Log, string.Format("설비연동 실행 [{0},{1}]", "주경종"/*dtc.deviceName*/, (cmd.Status == 0 ? "Disable" : "Enable")));
  315. this.mdi.ui.runCommand(cmd);
  316. }
  317. }
  318. }
  319. }
  320. catch (Exception ex)
  321. {
  322. progress_end = true;
  323. lock_cmd = false;
  324. this.Cursor = Cursors.Default;
  325. Util.UErrorMessage(ex, 0, 0);
  326. }
  327. }
  328. // cmd 리턴 받으면 실행 함수
  329. public void command_complete(CmdInfo resInfo)
  330. {
  331. try
  332. {
  333. this.Cursor = Cursors.Default;
  334. timer_check.Enabled = false;
  335. progress_end = true;
  336. getData();
  337. //this.mdi.SetLikageBtnStatus(); // cyim 2015.7.7 속도개선작업 : 설비연동화면 종료할때만 최종 결과를 반영하자 (MDIParent 가 실행될때 이미 시작은 미리 되었음) 통신에서 이렇게 데이타베이스를 가져오지 않아도된다
  338. if (resInfo != null)
  339. {
  340. if (resInfo.ErrResponse)
  341. {
  342. }
  343. else
  344. {
  345. }
  346. }
  347. }
  348. catch (Exception ex)
  349. {
  350. Util.UErrorMessage(ex, 0, 0);
  351. }
  352. }
  353. // 체크 타이머 함수
  354. private void timer_check_Tick(object sender, EventArgs e)
  355. {
  356. this.command_complete(null);
  357. }
  358. int progress_dot = -2;
  359. bool progress_end = false;
  360. // 진행 창 설정 타이머
  361. private void timer_progress_Tick(object sender, EventArgs e)
  362. {
  363. try
  364. {
  365. if (progress_dot == -100)
  366. {
  367. panel_LabelMessage.Visible = false; // cyim 2013.7.31 진행중 팝업창 디자인변경
  368. lbl_message.Visible = false;
  369. timer_progress.Enabled = false;
  370. lock_cmd = false;
  371. }
  372. progress_dot++;
  373. if (progress_dot > 4)
  374. {
  375. progress_dot = 0;
  376. }
  377. if (progress_dot >= 0)
  378. {
  379. panel_LabelMessage.Visible = true; // cyim 2013.7.31 진행중 팝업창 디자인변경
  380. lbl_message.Text = "진 행 중";
  381. lbl_message.Visible = true;
  382. // cyim 2013.7.31 진행중 팝업창 디자인변경
  383. //lbl_message.Width = 450;
  384. //lbl_message.Height = 250;
  385. lbl_message.Text = "진 행 중\n";
  386. // cyim 2013.7.31 진행중 팝업창 디자인변경 : 텍스트 삭제
  387. //if (progress_dot == 0) {
  388. // lbl_message.Text = lbl_message.Text + " ";
  389. //}
  390. //else if (progress_dot == 1) {
  391. // lbl_message.Text = lbl_message.Text + ". ";
  392. //}
  393. //else if (progress_dot == 2) {
  394. // lbl_message.Text = lbl_message.Text + ". . ";
  395. //}
  396. //else if (progress_dot == 3) {
  397. // lbl_message.Text = lbl_message.Text + ". . . ";
  398. //}
  399. //else if (progress_dot == 4) {
  400. // lbl_message.Text = lbl_message.Text + ". . . .";
  401. //}
  402. }
  403. if (progress_end)
  404. {
  405. progress_dot = -100;
  406. }
  407. }
  408. catch (Exception ex)
  409. {
  410. Util.UErrorMessage(ex, 0, 0);
  411. }
  412. }
  413. private void frmControlWrite_FormClosing(object sender, FormClosingEventArgs e)
  414. {
  415. // 창 닫는 함수
  416. this.mdi.SetLikageBtnStatus();
  417. }
  418. List<CDeviceTypeConfig> LDeviceTypeConfig = new List<CDeviceTypeConfig>();
  419. List<Panel> LDeviceTypePanel = new List<Panel>();
  420. // 설비 연동 버튼 설정 함수
  421. void SetDeviceTypePanel()
  422. {
  423. this.LDeviceTypePanel.Clear();
  424. int iPanelGab = 650 / ((LDeviceTypeConfig.Count + 1) / 2);
  425. foreach (CDeviceTypeConfig dtc in this.LDeviceTypeConfig)
  426. {
  427. Panel panel = new Panel();
  428. panel.Parent = this.groupBox1;
  429. panel.Size = new Size(420, 60); // cyim : 디자인개선 (430, 52) -> (420, 60)
  430. int positionX = 0;
  431. int positionY = 0;
  432. if ((this.LDeviceTypePanel.Count + 1) % 2 == 1)
  433. {// 버튼 줄 설정, 왼쪽
  434. positionX = 80; // cyim : 디자인개선 40 -> 80
  435. positionY = 50 + iPanelGab * ((this.LDeviceTypePanel.Count + 1) / 2);
  436. }
  437. else
  438. {// 오른쪽
  439. positionX = 570; // cyim : 디자인개선 530 -> 500
  440. positionY = 50 + iPanelGab * ((this.LDeviceTypePanel.Count) / 2);
  441. }
  442. panel.Location = new Point(positionX, positionY);
  443. panel.BackgroundImage = this.ImageLoadingPanelRed();
  444. Label labelName = new Label();
  445. labelName.Parent = panel;
  446. labelName.AutoSize = true;
  447. labelName.Location = new Point(37, 17); // cyim : 디자인개선 (37, 13) -> (37, 17)
  448. labelName.Font = new Font("굴림", 20F, System.Drawing.FontStyle.Bold);
  449. labelName.BackColor = Color.Transparent;
  450. labelName.ForeColor = Color.White; // cyim : 디자인개선
  451. Label labelStatus = new Label();
  452. labelStatus.Parent = panel;
  453. labelStatus.AutoSize = true;
  454. labelStatus.Location = new Point(304, 17); // cyim : 디자인개선 (311, 13) -> (304, 17)
  455. labelStatus.Font = new Font("굴림", 20F, System.Drawing.FontStyle.Bold);
  456. labelStatus.BackColor = Color.Transparent;
  457. labelStatus.ForeColor = Color.White; // cyim : 디자인개선
  458. panel.MouseClick += new MouseEventHandler(DoChangeDeviceLinkage2);
  459. labelName.MouseClick += new MouseEventHandler(DoChangeDeviceLinkage2);
  460. labelStatus.MouseClick += new MouseEventHandler(DoChangeDeviceLinkage2);
  461. labelName.Text = dtc.deviceName;
  462. panel.BackgroundImage = (dtc.use ? this.ImageLoadingPanelBlue() : this.ImageLoadingPanelRed());
  463. labelStatus.Text = (dtc.use ? "연 동" : "정 지");
  464. panel.Tag = dtc;
  465. labelName.Tag = dtc;
  466. labelStatus.Tag = dtc;
  467. this.LDeviceTypePanel.Add(panel);
  468. }
  469. this.UpdateDeviceTypePanel();
  470. }
  471. // 버튼 갱신 함수
  472. void UpdateDeviceTypePanel()
  473. {
  474. foreach (Panel panel in this.LDeviceTypePanel)
  475. {
  476. CDeviceTypeConfig dtc = (CDeviceTypeConfig)panel.Tag;
  477. Label labelName = (Label)panel.Controls[0];
  478. Label labelStatus = (Label)panel.Controls[1];
  479. if ((labelStatus.Text == "연 동") != dtc.use)
  480. {
  481. panel.BackgroundImage = (dtc.use ? this.ImageLoadingPanelBlue() : this.ImageLoadingPanelRed());
  482. labelStatus.Text = (dtc.use ? "연 동" : "정 지");
  483. }
  484. }
  485. // cyim 2013.10.1 : 화면 갱신
  486. this.Update();
  487. }
  488. // 설비연동 데이터 재설정 함수
  489. int SetLDeviceTypeConfig()
  490. {
  491. this.LDeviceTypeConfig.Clear();
  492. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  493. DataTable dt = dacDeviceConfig.Device_type_Select(code_InOutType.Output, null);
  494. foreach (DataRow dr in dt.Rows)
  495. {
  496. // cyim 2014.11.25 주경종 허용
  497. //if (dr["DEVICE_TYPE"].ToString() != "OA" && dr["SEQ_NO"].ToString() != "0")
  498. if (dr["SEQ_NO"].ToString() != "0")
  499. {
  500. this.LDeviceTypeConfig.Add(new CDeviceTypeConfig(dr["SYMBOL_TYPE"].ToString(), dr["DEVICE_TYPE"].ToString(),
  501. dr["DEVICE_TYPE_NAME"].ToString(), dr["USE_FLAG"].ToString()));
  502. }
  503. }
  504. this.SetDeviceTypePanel();
  505. return this.LDeviceTypeConfig.Count;
  506. }
  507. // 설비 연동 데이터 갱신 함수
  508. int UpdateLDeviceTypeConfig()
  509. {
  510. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  511. DataTable dt = dacDeviceConfig.Device_type_Select(code_InOutType.Output, null);
  512. foreach (DataRow dr in dt.Rows)
  513. {
  514. // cyim 2014.11.25 주경종 허용
  515. //if (dr["DEVICE_TYPE"].ToString() != "OA" && dr["SEQ_NO"].ToString() != "0")
  516. if (dr["SEQ_NO"].ToString() != "0")
  517. {
  518. bool add = true;
  519. foreach (CDeviceTypeConfig cd in this.LDeviceTypeConfig)
  520. {
  521. if (cd.deviceType == dr["DEVICE_TYPE"].ToString())
  522. {
  523. cd.UpdateData(dr["USE_FLAG"].ToString());
  524. add = false;
  525. break;
  526. }
  527. }
  528. if (add)
  529. {
  530. this.LDeviceTypeConfig.Add(new CDeviceTypeConfig(dr["SYMBOL_TYPE"].ToString(), dr["DEVICE_TYPE"].ToString(),
  531. dr["DEVICE_TYPE_NAME"].ToString(), dr["USE_FLAG"].ToString()));
  532. }
  533. }
  534. }
  535. this.UpdateDeviceTypePanel();
  536. return this.LDeviceTypeConfig.Count;
  537. }
  538. // 설비연동 데이터 클래스
  539. class CDeviceTypeConfig
  540. {
  541. public string symbolType = "";
  542. public string deviceType = "";
  543. public string deviceName = "";
  544. public bool use = false;
  545. public CDeviceTypeConfig(string symbolType, string deviceType, string deviceName, string useFlag)
  546. {
  547. this.symbolType = symbolType;
  548. this.deviceType = deviceType;
  549. this.deviceName = deviceName;
  550. this.use = (useFlag == "Y" ? true : false);
  551. }
  552. public void UpdateData(string useFlag)
  553. {
  554. this.use = (useFlag == "Y" ? true : false);
  555. }
  556. }
  557. private int indexDisableDeviceAll = 0;
  558. private int indexEnableDeviceAll = 0;
  559. // 모두 정지 버튼
  560. private void btnDisableAll_Click(object sender, EventArgs e)
  561. {
  562. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  563. if (ProcessEnableStatus == true || mdi.CommDaemon_ComStatus == false) return;
  564. ProcessEnableStatus = true;
  565. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58_black;
  566. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58_black;
  567. try
  568. {
  569. if (this.lock_cmd == false)
  570. {
  571. this.lock_cmd = true;
  572. this.Cursor = Cursors.WaitCursor;
  573. timer_check.Enabled = true;
  574. progress_dot = -2;
  575. progress_end = false;
  576. timer_progress.Enabled = true;
  577. // cyim 2016.12.09 : IFC3300에서는 예비전원버튼 -> 설비전체연동조작버튼
  578. if (mdi.ReceiverModel == "IFC3300")
  579. {
  580. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, 0, 0, null);
  581. cmd.CommandType = "ED";
  582. cmd.ApplyRange = "A"; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  583. cmd.Status = 0; //사용여부 0-비사용,1-사용
  584. cmd.SubType = "B";// strDevice;
  585. cmd.CommId = 1;
  586. cmd.loopNo = 0;
  587. // cyim 2015.2.10 설비연동 모두정지 실행
  588. mdi.CommandLog(MappingStatus.Log, string.Format("설비연동 실행 [모두정지]"));
  589. dCommandResponse d = new dCommandResponse(DisableDeviceAll);//명령 생성
  590. cmd.dEvent = d;
  591. this.mdi.ui.runCommand(cmd);
  592. }
  593. else
  594. {
  595. this.DisableDeviceAll(null);
  596. }
  597. }
  598. else
  599. {
  600. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  601. ProcessEnableStatus = false;
  602. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58;
  603. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58;
  604. }
  605. }
  606. catch (Exception ex)
  607. {
  608. this.Cursor = Cursors.Default;
  609. Util.UErrorMessage(ex, 0, 0);
  610. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  611. this.progress_end = true;
  612. this.lock_cmd = false;
  613. ProcessEnableStatus = false;
  614. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58;
  615. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58;
  616. }
  617. }
  618. // 모드 정지 함수
  619. public void DisableDeviceAll(CmdInfo resInfo)
  620. {
  621. try
  622. {
  623. this.getData();
  624. // 갱신 마지막
  625. if (this.indexDisableDeviceAll >= this.LDeviceTypeConfig.Count)
  626. {
  627. this.Cursor = Cursors.Default;
  628. this.timer_check.Enabled = false;
  629. this.progress_end = true;
  630. lock_cmd = false;
  631. //this.mdi.SetLikageBtnStatus(); // cyim 2015.7.7 속도개선작업 : 설비연동화면 종료할때만 최종 결과를 반영하자 (MDIParent 가 실행될때 이미 시작은 미리 되었음)
  632. this.indexDisableDeviceAll = 0;
  633. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  634. ProcessEnableStatus = false;
  635. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58;
  636. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58;
  637. }
  638. else
  639. {
  640. //start
  641. if (resInfo == null)
  642. {
  643. this.indexDisableDeviceAll = 0;
  644. }
  645. // 갱신 중간
  646. if (this.LDeviceTypeConfig.Count > this.indexDisableDeviceAll)
  647. {
  648. CDeviceTypeConfig devTypeConfig = this.LDeviceTypeConfig[this.indexDisableDeviceAll];
  649. string strDevice = devTypeConfig.deviceType.Substring(1, 1);
  650. this.indexDisableDeviceAll++;
  651. this.DisableDevice(strDevice);
  652. }
  653. }
  654. }
  655. catch (Exception ex)
  656. {
  657. Util.UErrorMessage(ex, 0, 0);
  658. }
  659. }
  660. // 설비 연동 정지 함수
  661. private void DisableDevice(string strDevice)
  662. {
  663. try
  664. {
  665. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, 0, 0, null);
  666. cmd.CommandType = "DC";
  667. cmd.ApplyRange = "A"; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  668. cmd.Status = 0; //사용여부 0-비사용,1-사용
  669. cmd.SubType = strDevice;
  670. cmd.CommId = 1;
  671. cmd.loopNo = 0;
  672. dCommandResponse d = new dCommandResponse(DisableDeviceAll);//명령 생성
  673. cmd.dEvent = d;
  674. this.mdi.ui.runCommand(cmd);
  675. }
  676. catch (Exception ex)
  677. {
  678. Util.UErrorMessage(ex, 0, 0);
  679. }
  680. }
  681. // 모두 연동 버튼
  682. private void btnEnableAll_Click(object sender, EventArgs e)
  683. {
  684. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  685. if (ProcessEnableStatus == true || mdi.CommDaemon_ComStatus == false) return;
  686. ProcessEnableStatus = true;
  687. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58_black;
  688. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58_black;
  689. try
  690. {
  691. if (this.lock_cmd == false)
  692. {
  693. this.lock_cmd = true;
  694. this.Cursor = Cursors.WaitCursor;
  695. timer_check.Enabled = true;
  696. progress_dot = -2;
  697. progress_end = false;
  698. timer_progress.Enabled = true;
  699. // cyim 2016.12.09 : IFC3300에서는 예비전원버튼 -> 설비전체연동조작버튼
  700. if (mdi.ReceiverModel == "IFC3300")
  701. {
  702. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, 0, 0, null);
  703. cmd.CommandType = "ED";
  704. cmd.ApplyRange = "A"; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  705. cmd.Status = 1; //사용여부 0-비사용,1-사용
  706. cmd.SubType = "B";//strDevice;
  707. cmd.CommId = 1;
  708. cmd.loopNo = 0;
  709. // cyim 2015.2.10 설비연동 모두연동 실행
  710. mdi.CommandLog(MappingStatus.Log, string.Format("설비연동 실행 [모두연동]"));
  711. dCommandResponse d = new dCommandResponse(EnableDeviceAll);//명령 생성 EnableDeviceAll_BigReceiver
  712. cmd.dEvent = d;
  713. this.mdi.ui.runCommand(cmd);
  714. }
  715. else
  716. {
  717. this.EnableDeviceAll(null);
  718. }
  719. }
  720. else
  721. {
  722. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  723. ProcessEnableStatus = false;
  724. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58;
  725. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58;
  726. }
  727. }
  728. catch (Exception ex)
  729. {
  730. this.Cursor = Cursors.Default;
  731. Util.UErrorMessage(ex, 0, 0);
  732. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  733. this.progress_end = true;
  734. this.lock_cmd = false;
  735. ProcessEnableStatus = false;
  736. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58;
  737. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58;
  738. }
  739. //Util.UDebugMessage("-btnEnableAll_Click", 0, 0);
  740. }
  741. // 모두 설비 연동 함수
  742. public void EnableDeviceAll(CmdInfo resInfo)
  743. {
  744. try
  745. {
  746. this.getData();
  747. // 갱신 마지막
  748. if (this.indexEnableDeviceAll >= this.LDeviceTypeConfig.Count)
  749. {
  750. this.Cursor = Cursors.Default;
  751. this.timer_check.Enabled = false;
  752. this.progress_end = true;
  753. this.lock_cmd = false;
  754. //this.mdi.SetLikageBtnStatus(); // cyim 2015.7.7 속도개선작업 : 설비연동화면 종료할때만 최종 결과를 반영하자 (MDIParent 가 실행될때 이미 시작은 미리 되었음)
  755. this.indexEnableDeviceAll = 0;
  756. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  757. ProcessEnableStatus = false;
  758. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58;
  759. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58;
  760. }
  761. else
  762. {
  763. //start
  764. if (resInfo == null)
  765. {
  766. this.indexEnableDeviceAll = 0;
  767. }
  768. // 갱신 중간
  769. if (this.LDeviceTypeConfig.Count > this.indexEnableDeviceAll)
  770. {
  771. CDeviceTypeConfig devTypeConfig = this.LDeviceTypeConfig[this.indexEnableDeviceAll];
  772. string strDevice = devTypeConfig.deviceType.Substring(1, 1);
  773. this.indexEnableDeviceAll++;
  774. this.EnableDevice(strDevice);
  775. }
  776. }
  777. }
  778. catch (Exception ex)
  779. {
  780. Util.UErrorMessage(ex, 0, 0);
  781. }
  782. }
  783. // 설비 연동 설정 함수
  784. private void EnableDevice(string strDevice)
  785. {
  786. try
  787. {
  788. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, 0, 0, null);
  789. cmd.CommandType = "DC";
  790. cmd.ApplyRange = "A"; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  791. cmd.Status = 1; //사용여부 0-비사용,1-사용
  792. cmd.SubType = strDevice;
  793. cmd.CommId = 1;
  794. cmd.loopNo = 0;
  795. dCommandResponse d = new dCommandResponse(EnableDeviceAll);//명령 생성
  796. cmd.dEvent = d;
  797. this.mdi.ui.runCommand(cmd);
  798. }
  799. catch (Exception ex)
  800. {
  801. Util.UErrorMessage(ex, 0, 0);
  802. }
  803. }
  804. // cyim 2016.12.09 : IFC3300에서는 예비전원버튼 -> 설비전체연동조작버튼
  805. public void DisableDeviceAll_BigReceiver(CmdInfo resInfo)
  806. {
  807. this.getData();
  808. // 갱신 마지막
  809. if (this.indexDisableDeviceAll >= this.LDeviceTypeConfig.Count)
  810. {
  811. this.Cursor = Cursors.Default;
  812. this.timer_check.Enabled = false;
  813. this.progress_end = true;
  814. lock_cmd = false;
  815. //this.mdi.SetLikageBtnStatus(); // cyim 2015.7.7 속도개선작업 : 설비연동화면 종료할때만 최종 결과를 반영하자 (MDIParent 가 실행될때 이미 시작은 미리 되었음)
  816. this.indexDisableDeviceAll = 0;
  817. // cyim 2015.2.10 설비연동 모두정지 실행
  818. mdi.CommandLog(MappingStatus.Log, string.Format("설비연동 실행 [모두정지]"));
  819. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  820. ProcessEnableStatus = false;
  821. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58;
  822. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58;
  823. }
  824. }
  825. // cyim 2016.12.09 : IFC3300에서는 예비전원버튼 -> 설비전체연동조작버튼
  826. public void EnableDeviceAll_BigReceiver(CmdInfo resInfo)
  827. {
  828. this.getData();
  829. this.Cursor = Cursors.Default;
  830. this.timer_check.Enabled = false;
  831. this.progress_end = true;
  832. this.lock_cmd = false;
  833. //this.mdi.SetLikageBtnStatus(); // cyim 2015.7.7 속도개선작업 : 설비연동화면 종료할때만 최종 결과를 반영하자 (MDIParent 가 실행될때 이미 시작은 미리 되었음)
  834. this.indexEnableDeviceAll = 0;
  835. // cyim 2015.2.10 설비연동 모두연동 실행
  836. mdi.CommandLog(MappingStatus.Log, string.Format("설비연동 실행 [모두연동]"));
  837. // cyim 2015.2.10 설비연동의 경우 실행이 완료되어야 다른 버튼이 눌려진다
  838. ProcessEnableStatus = false;
  839. this.btnEnableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체연동_139_58;
  840. this.btnDisableAll.BackgroundImage = (Image)Properties.Resources.버튼_전체정지_139_58;
  841. }
  842. }
  843. public class controlWriteDevType
  844. {
  845. private string dev_type; //연동타입
  846. private bool use_flag; //사용여부
  847. private bool change_flag; //변경여부
  848. public controlWriteDevType(string dev_type)
  849. {
  850. try
  851. {
  852. this.dev_type = dev_type;
  853. this.use_flag = false;
  854. this.change_flag = false;
  855. }
  856. catch (Exception ex)
  857. {
  858. Util.UErrorMessage(ex, 0, 0);
  859. }
  860. }
  861. public string Dev_type { get { return this.dev_type; } }
  862. public bool Use_flag { get { return this.use_flag; } set { this.use_flag = value; } }
  863. public void ChangeFlagReset()
  864. {
  865. try
  866. {
  867. this.change_flag = false;
  868. }
  869. catch (Exception ex)
  870. {
  871. Util.UErrorMessage(ex, 0, 0);
  872. }
  873. }
  874. public Boolean ChangeFlag
  875. {
  876. get { return this.change_flag; }
  877. set
  878. {
  879. bool use_flag = value;
  880. //차단설정데이터 변경여부를 저장한다.
  881. if (this.use_flag != use_flag) this.change_flag = true;
  882. this.use_flag = value;
  883. }
  884. }
  885. }
  886. }