frmProgress.cs 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  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.Diagnostics; // 2010.10.28, k.s.d, for debug funtion.
  9. namespace FPER
  10. {
  11. public partial class frmProgress : Form
  12. {
  13. private CmdInfo commandinfo; //명령정보
  14. private SocketUI socketUI; //명령받는곳
  15. private Boolean complete = false; // 완료여부
  16. private controlWriteDevType[] devTypes; //연동타입차단을위해
  17. private RepeaterDeviceTypeInfo[] repinfo; //중계기설정정보-설정쓰기를 위해
  18. private BoardTypeInfo[] brdinfos; //통신보드차단명령을 위해
  19. private ReceiverConfigVo configVoChg; //환경정보변경 명령을 위해 --변경된 데이터
  20. private ReceiverConfigVo configVoMy; //환경정보변경 명령을 위해 --원래 데이터
  21. private ReceiverTypeInfo configReceiverPoint; //전체 수신기 데이터
  22. bool configReceiverPointAllWrite = false; //전체수신기 데이터 쓰기 여부
  23. public ReceiverConfigVo ConfigVoMy { set { this.configVoMy = value; } }
  24. public CmdInfo Commandinfo { get { return this.commandinfo; } set { this.commandinfo = value; } }
  25. public SocketUI ui { get { return this.socketUI; } set { this.socketUI = value; } }
  26. public int download_type = 0;// 2010.10.28, k.s.d, only one click device linkage change support value .
  27. // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  28. public MDIParent mdi = null;
  29. public frmProgress(MDIParent pMdi)
  30. {
  31. InitializeComponent();
  32. mdi = pMdi;
  33. }
  34. private void frmProgress_Load(object sender, EventArgs e)
  35. {
  36. try
  37. {
  38. progressBar1.Value = 0;
  39. btnOK.Enabled = false;
  40. //명령별 작업진행
  41. progress_Run();
  42. }
  43. catch (Exception ex)
  44. {
  45. Util.UErrorMessage(ex, 0, 0);
  46. }
  47. }
  48. public void SetLinkageCut()// 2010.10.28, k.s.d, only one click device linkage change support .
  49. {
  50. try
  51. {
  52. this.Cursor = Cursors.WaitCursor;
  53. //lblDescription.Text = "연동타입차단명령";
  54. progressBar1.Maximum = 100;
  55. progressBar1.Value += 1;
  56. progressBar1.Refresh();
  57. btnOK.Visible = false;//2010.10.29,k.s.d, ok button unvisible.
  58. lblDescription.Visible = false;
  59. // progressBar1.Visible = false;
  60. listView1.Visible = false;
  61. ProgressLabel.Visible = true;
  62. //이벤트정의
  63. dCommandResponse d = new dCommandResponse(command_complete);
  64. this.commandinfo.dEvent = d;
  65. this.commandinfo.CommId = 1;
  66. this.commandinfo.loopNo = 0;
  67. //명령 생성
  68. ui.runCommand(this.commandinfo);
  69. progressBar1.Value = 50;
  70. //string actionMsg = commandinfo.Status == 0 ? "해제" : "설정";
  71. ////Device_Type_Name
  72. //actionMsg = commandinfo.Status == 1 ? "정지" : "연동";//2010.11.12,k.s.d, display message bug fix( 정지 <-> 연동 )
  73. //DacDeviceConfig dacDeviceConfig = new DacDeviceConfig();
  74. //string deviceTypeName = dacDeviceConfig.Device_Type_Name(code_InOutType.Output, string.Format("O{0}", commandinfo.SubType));
  75. //string thisLog = String.Format("{0} 연동타입 {1}명령", deviceTypeName, actionMsg);
  76. //ListViewLogAdd(thisLog + ": 진행중" );
  77. progressBar1.Refresh();
  78. }
  79. catch (Exception ex)
  80. {
  81. Util.UErrorMessage(ex, 0, 0);
  82. this.Cursor = Cursors.Default;
  83. }
  84. }
  85. //작업시작
  86. private void progress_Run()
  87. {
  88. try
  89. {
  90. if (this.commandinfo == null) return;
  91. progressBar1.Value = 0;
  92. listView1.Items.Clear();
  93. this.Show();
  94. if (!ui.Connected)
  95. {
  96. MessageBox.Show("통신상태를 확인하세요..", Application.ProductName);
  97. this.Close();
  98. return;
  99. }
  100. if (download_type != 0)// 2010.10.28, k.s.d, only one click device linkage change support .
  101. {
  102. this.SetLinkageCut();
  103. return;
  104. }
  105. switch (this.commandinfo.Command)
  106. {
  107. //중계기 Unit 에 정보 쓰기
  108. case prt_cmd_define.write_repeater_info_unit:
  109. this.Text = "중계기 정보 UNIT 쓰기중.....";
  110. lblDescription.Text = "중계기 정보 UNIT 쓰기";
  111. if (this.commandinfo.boardNo > 0)
  112. {
  113. progressBar1.Maximum = 127;
  114. if (this.commandinfo.CommandData != null)
  115. {
  116. //중계기 쓰기 정보를 저장한다.. commanddata를 재사용하므로
  117. this.repinfo = (RepeaterDeviceTypeInfo[])this.commandinfo.CommandData;
  118. //중계기 Unit 에 정보 쓰기---시작
  119. repeater_info_unit_write_progress();
  120. }
  121. else
  122. {
  123. MessageBox.Show("데이터가 유효하지 않습니다.. 설정데이터를 알수 없습니다.");
  124. //완료
  125. CompleteProgress();
  126. }
  127. }
  128. else
  129. {
  130. this.Text = "중계기 정보 UNIT 전체 쓰기중.....";
  131. lblDescription.Text = "중계기 정보 UNIT 전체 쓰기";
  132. progressBar1.Maximum = 16 * 2 * 127;
  133. //전체수신기 쓰기를 한다고 저장.
  134. this.configReceiverPointAllWrite = true;
  135. //전체 수신기 데이터를 DB에서 읽어온다..
  136. //수신기 설정정보 CLASS 생성 - DB에서 설정정보를 읽어와 저장한다..
  137. UIReceiverInfo cfg = new UIReceiverInfo(this.commandinfo.receiverID);
  138. this.configReceiverPoint = cfg.ReadAll_ReceiverTypeInfo(mdi);
  139. this.commandinfo.CommandData = null;
  140. this.commandinfo.boardNo = 1;
  141. this.commandinfo.loopNo = 0;
  142. this.commandinfo.repeaterNo = 0; //시작시 중계기 번호를 증가시키므로 0 으로 초기화
  143. //보드존재유무
  144. bool runBoardIdOK = false;
  145. while (!runBoardIdOK)
  146. {
  147. BoardTypeInfo brdinfo = this.configReceiverPoint.Get_RepeaterType(this.commandinfo.boardNo); //통신보드savBoardID의 설정값
  148. if (brdinfo != null)
  149. {
  150. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  151. if (this.commandinfo.loopNo == 0)
  152. {
  153. this.repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
  154. }
  155. else if (this.commandinfo.loopNo == 1)
  156. {
  157. this.repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
  158. }
  159. else if (this.commandinfo.loopNo == 2)
  160. {
  161. this.repinfo = brdinfo.Loop2_RepeaterType; //통신보드 + Loop2 + 127개 중계기 설정값
  162. }
  163. else if (this.commandinfo.loopNo == 3)
  164. {
  165. this.repinfo = brdinfo.Loop3_RepeaterType; //통신보드 + Loop3 + 127개 중계기 설정값
  166. }
  167. runBoardIdOK = true;
  168. }
  169. }
  170. if (runBoardIdOK)
  171. {
  172. //중계기 Unit 에 정보 전체 쓰기---시작
  173. repeater_info_unit_all_write_progress();
  174. }
  175. else
  176. {
  177. MessageBox.Show("설정된 통신보드가 없습니다..");
  178. //완료
  179. CompleteProgress();
  180. }
  181. }
  182. break;
  183. case prt_cmd_define.read_command_status:
  184. switch (this.commandinfo.CommandType)
  185. {
  186. //차단명령
  187. case "DC":
  188. {
  189. this.Text = "차단설정 명령중..";
  190. if (this.commandinfo.CommandData != null)
  191. {
  192. if (this.commandinfo.ApplyRange.Equals("L")) //Loop16개 차단시
  193. {
  194. lblDescription.Text = "계통차단명령";
  195. this.brdinfos = (BoardTypeInfo[])this.commandinfo.CommandData;
  196. progressBar1.Maximum = this.brdinfos.Length;
  197. }
  198. else if (this.commandinfo.ApplyRange.Equals("R")) //중계기 차단시
  199. {
  200. lblDescription.Text = "중계기차단명령";
  201. this.repinfo = (RepeaterDeviceTypeInfo[])this.commandinfo.CommandData;
  202. progressBar1.Maximum = this.repinfo.Length;
  203. }
  204. else if (this.commandinfo.ApplyRange.Equals("A")) //연동타입 차단시
  205. {
  206. lblDescription.Text = "연동타입차단명령";
  207. this.devTypes = (controlWriteDevType[])this.commandinfo.CommandData;
  208. progressBar1.Maximum = this.devTypes.Length;
  209. }
  210. else if (this.commandinfo.ApplyRange.Equals("I")) //입력회로 차단시
  211. {
  212. lblDescription.Text = "입력회로 차단명령";
  213. progressBar1.Maximum = 2;
  214. }
  215. else if (this.commandinfo.ApplyRange.Equals("O")) //출력회로 차단시
  216. {
  217. lblDescription.Text = "출력회로 차단명령";
  218. progressBar1.Maximum = 2;
  219. }
  220. cut_flag_progress();
  221. }
  222. else
  223. {
  224. MessageBox.Show("데이터가 유효하지 않습니다.. 설정데이터를 알수 없습니다.");
  225. //완료
  226. CompleteProgress();
  227. }
  228. break;
  229. }
  230. //환경정보변경
  231. case "CS":
  232. {
  233. progressBar1.Maximum = 4;
  234. this.Text = "환경설정 변경중..";
  235. lblDescription.Text = "환경설정 변경명령";
  236. if (this.commandinfo.CommandData != null)
  237. {
  238. this.configVoChg = (ReceiverConfigVo)this.commandinfo.CommandData;
  239. config_change_progress();
  240. }
  241. else
  242. {
  243. MessageBox.Show("데이터가 유효하지 않습니다.. 설정데이터를 알수 없습니다.");
  244. //완료
  245. CompleteProgress();
  246. }
  247. break;
  248. }
  249. default:
  250. lblDescription.Text = "알수없는명령";
  251. break;
  252. }
  253. break;
  254. default:
  255. break;
  256. }
  257. this.Refresh();
  258. }
  259. catch (Exception ex)
  260. {
  261. Util.UErrorMessage(ex, 0, 0);
  262. //MessageBox.Show(ex.Message, Application.ProductName);
  263. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  264. }
  265. }
  266. //환경설정변경 진행
  267. private void config_change_progress()
  268. {
  269. try
  270. {
  271. //명령 생성 여부
  272. bool runCommandOK = false;
  273. progressBar1.Value += 1;
  274. progressBar1.Refresh();
  275. //이벤트정의
  276. dCommandResponse d = new dCommandResponse(command_complete);
  277. this.commandinfo.dEvent = d;
  278. if (this.configVoChg.Fire_accumulation_mode != this.configVoMy.Fire_accumulation_mode)
  279. {
  280. //축적모드 변경 명령
  281. bool mode = this.configVoChg.Fire_accumulation_mode;
  282. this.commandinfo.SubType = "A";
  283. this.commandinfo.Status = mode ? 1 : 0;
  284. this.configVoMy.Fire_accumulation_mode = mode;
  285. //명령 생성
  286. runCommandOK = true;
  287. ui.runCommand(this.commandinfo);
  288. return;
  289. }
  290. //축적모드일경우만 시간을 보냄
  291. if (this.configVoChg.Fire_accumulation_mode && this.configVoChg.Fire_accumulation_time != this.configVoMy.Fire_accumulation_time)
  292. {
  293. //축적시간 변경 명령
  294. this.commandinfo.SubType = "T";
  295. this.commandinfo.Status = this.configVoChg.Fire_accumulation_time;
  296. this.configVoMy.Fire_accumulation_time = this.configVoChg.Fire_accumulation_time;
  297. //명령 생성
  298. runCommandOK = true;
  299. ui.runCommand(this.commandinfo);
  300. return;
  301. }
  302. if (this.configVoChg.Fire_process_mode != this.configVoMy.Fire_process_mode)
  303. {
  304. //화재모드 변경 명령
  305. bool mode = this.configVoChg.Fire_process_mode;
  306. this.commandinfo.SubType = "F";
  307. this.commandinfo.Status = mode ? 1 : 0;
  308. this.configVoMy.Fire_process_mode = mode;
  309. //명령 생성
  310. runCommandOK = true;
  311. ui.runCommand(this.commandinfo);
  312. return;
  313. }
  314. //지구경종모드 없음
  315. //생성한 명령이 없으므로 종료
  316. if (!runCommandOK) CompleteProgress();
  317. }
  318. catch (Exception ex)
  319. {
  320. Util.UErrorMessage(ex, 0, 0);
  321. }
  322. }
  323. // 차단설정 진행
  324. private void cut_flag_progress()
  325. {
  326. try
  327. {
  328. //명령 생성 여부
  329. bool runCommandOK = false;
  330. progressBar1.Value += 1;
  331. progressBar1.Refresh();
  332. //이벤트정의
  333. dCommandResponse d = new dCommandResponse(command_complete);
  334. this.commandinfo.dEvent = d;
  335. switch (this.commandinfo.ApplyRange) //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  336. {
  337. case "A"://연동타입차단
  338. {
  339. foreach (controlWriteDevType devtp in this.devTypes)
  340. {
  341. if (devtp.ChangeFlag)
  342. {
  343. this.commandinfo.CommId = 1;
  344. this.commandinfo.loopNo = 0;
  345. this.commandinfo.Status = devtp.Use_flag ? 0 : 1; //k.s.d 20101022, devtp.Use_flag ? 1 : 0; -> devtp.Use_flag ? 0 : 1; with jys(ub).
  346. this.commandinfo.SubType = devtp.Dev_type.Substring(1); //연동출력타입1자리
  347. devtp.ChangeFlagReset();
  348. //명령 생성
  349. runCommandOK = true;
  350. ui.runCommand(this.commandinfo);
  351. break;
  352. }
  353. }
  354. if (!runCommandOK) CompleteProgress();
  355. break;
  356. }
  357. case "C": break;
  358. case "B": break; //
  359. case "L": //Loop
  360. {
  361. // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  362. int boardID_init = 0;
  363. int boardID_cnt = 0;
  364. // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다
  365. if (mdi.ReceiverModel == "IFC3300")
  366. {
  367. boardID_init = 0;
  368. boardID_cnt = 65;
  369. }
  370. else
  371. {
  372. boardID_init = 0;
  373. boardID_cnt = 16;
  374. }
  375. for (int i = boardID_init; i < boardID_cnt; i++) // cyim 2016.11.03 : 통신보드(중계반)는 최대 64
  376. {
  377. if (this.brdinfos[i] != null)
  378. {
  379. if (this.brdinfos[i].Loop0CutFlagChange)
  380. {
  381. this.commandinfo.boardNo = i + 1;
  382. this.commandinfo.loopNo = 0;
  383. this.commandinfo.Status = this.brdinfos[i].Loop0CutFlag ? 0 : 1; //k.s.d 20120102, 1 : 0; -> 0 : 1; with jys(ub).
  384. this.brdinfos[i].Loop0CutFlagChangeReset();
  385. //명령 생성
  386. runCommandOK = true;
  387. ui.runCommand(this.commandinfo);
  388. break;
  389. }
  390. else if (this.brdinfos[i].Loop1CutFlagChange)
  391. {
  392. this.commandinfo.boardNo = i + 1;
  393. this.commandinfo.loopNo = 1;
  394. this.commandinfo.Status = this.brdinfos[i].Loop1CutFlag ? 0 : 1;//k.s.d 20120102, 1 : 0; -> 0 : 1; with jys(ub).
  395. this.brdinfos[i].Loop1CutFlagChangeReset();
  396. //명령 생성
  397. runCommandOK = true;
  398. ui.runCommand(this.commandinfo);
  399. break;
  400. }
  401. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  402. else if (this.brdinfos[i].Loop2CutFlagChange)
  403. {
  404. this.commandinfo.boardNo = i + 1;
  405. this.commandinfo.loopNo = 2;
  406. this.commandinfo.Status = this.brdinfos[i].Loop2CutFlag ? 0 : 1;
  407. this.brdinfos[i].Loop2CutFlagChangeReset();
  408. //명령 생성
  409. runCommandOK = true;
  410. ui.runCommand(this.commandinfo);
  411. break;
  412. }
  413. else if (this.brdinfos[i].Loop3CutFlagChange)
  414. {
  415. this.commandinfo.boardNo = i + 1;
  416. this.commandinfo.loopNo = 3;
  417. this.commandinfo.Status = this.brdinfos[i].Loop3CutFlag ? 0 : 1;
  418. this.brdinfos[i].Loop3CutFlagChangeReset();
  419. //명령 생성
  420. runCommandOK = true;
  421. ui.runCommand(this.commandinfo);
  422. break;
  423. }
  424. }
  425. }
  426. if (!runCommandOK) CompleteProgress();
  427. break;
  428. }
  429. case "R": //중계기
  430. {
  431. for (int i = 0; i < this.repinfo.Length; i++)
  432. {
  433. if (this.repinfo[i] != null)
  434. {
  435. if (this.repinfo[i].CutFlagChange)
  436. {
  437. this.commandinfo.repeaterNo = this.repinfo[i].RepeaterNo;
  438. this.commandinfo.Status = this.repinfo[i].CutFlag ? 0 : 1;//k.s.d 20120102, 1 : 0; -> 0 : 1; with jys(ub).
  439. this.repinfo[i].CutFlagChangeReset();
  440. //명령 생성
  441. runCommandOK = true;
  442. ui.runCommand(this.commandinfo);
  443. break;
  444. }
  445. }
  446. }
  447. if (!runCommandOK) CompleteProgress();
  448. break;
  449. }
  450. case "D": break;
  451. case "I":
  452. if (this.commandinfo.CommandData.ToString().Equals("CUTCOMMAND"))
  453. {
  454. this.commandinfo.CommandData = "COMPLETE";
  455. //명령 생성
  456. runCommandOK = true;
  457. ui.runCommand(this.commandinfo);
  458. }
  459. if (!runCommandOK) CompleteProgress();
  460. break;
  461. case "O":
  462. if (this.commandinfo.CommandData.ToString().Equals("CUTCOMMAND"))
  463. {
  464. this.commandinfo.CommandData = "COMPLETE";
  465. //명령 생성
  466. runCommandOK = true;
  467. ui.runCommand(this.commandinfo);
  468. }
  469. if (!runCommandOK) CompleteProgress();
  470. break;
  471. default: break;
  472. }
  473. }
  474. catch (Exception ex)
  475. {
  476. Util.UErrorMessage(ex, 0, 0);
  477. }
  478. }
  479. //중계기 Unit 에 정보 쓰기--시작
  480. private void repeater_info_unit_write_progress()
  481. {
  482. try
  483. {
  484. //중계기정보쓰기 명령
  485. dCommandResponse d = new dCommandResponse(command_complete);
  486. this.commandinfo.dEvent = d;
  487. //다음중계기로 중계기번호를 증가시킨다.
  488. int repeaterNo = this.commandinfo.repeaterNo + 1;
  489. if (repeaterNo <= 127)
  490. {
  491. progressBar1.Value += 1;
  492. progressBar1.Refresh();
  493. int repeaterType = 0;
  494. bool CutFlag = false;
  495. bool FireResetFlag = false;
  496. if (repinfo[repeaterNo - 1] != null)
  497. {
  498. if (repinfo[repeaterNo - 1].UseFlag)
  499. {
  500. // cyim 2015.6.8 아날로그 감지기 연동 추가
  501. //repeaterType = repinfo[repeaterNo - 1].RepeaterType == "A" ? 1 : 2;
  502. // '1' = A : 2X2
  503. // '2' = B : 4X4
  504. // '4' = C : 아날로그연감지기
  505. // '5' = D : 아날로그열감지기
  506. if (repinfo[repeaterNo - 1].RepeaterType == "A")
  507. repeaterType = 1;
  508. else if (repinfo[repeaterNo - 1].RepeaterType == "B")
  509. repeaterType = 2;
  510. else if (repinfo[repeaterNo - 1].RepeaterType == "C")
  511. repeaterType = 4;
  512. else if (repinfo[repeaterNo - 1].RepeaterType == "D")
  513. repeaterType = 5;
  514. CutFlag = repinfo[repeaterNo - 1].CutFlag;
  515. FireResetFlag = repinfo[repeaterNo - 1].FireResetFlag;
  516. }
  517. else
  518. {
  519. repeaterType = 0;
  520. CutFlag = false;
  521. FireResetFlag = false;
  522. }
  523. }
  524. //중계기설정정보 저장
  525. this.commandinfo.repeaterNo = repeaterNo;
  526. //this.commandinfo.setRepeaterInfo(repeaterNo, repeaterType);
  527. RepeaterData data = new RepeaterData((byte)repeaterNo);
  528. data.Set_Info_Data(CutFlag, FireResetFlag, false, false, repeaterType);
  529. this.commandinfo.CommandData = data;
  530. //명령보냄
  531. ui.runCommand(this.commandinfo);
  532. }
  533. else
  534. {
  535. //완료
  536. CompleteProgress();
  537. }
  538. }
  539. catch (Exception ex)
  540. {
  541. Util.UErrorMessage(ex, 0, 0);
  542. }
  543. }
  544. //중계기 Unit 에 정보 전체 쓰기--시작
  545. private void repeater_info_unit_all_write_progress()
  546. {
  547. try
  548. {
  549. //명령 생성 여부
  550. bool runCommandOK = false;
  551. //보드존재유무
  552. bool runBoardIdOK = true;
  553. while (!runCommandOK)
  554. {
  555. //중계기정보쓰기 명령
  556. dCommandResponse d = new dCommandResponse(command_complete);
  557. this.commandinfo.dEvent = d;
  558. //다음중계기로 중계기번호를 증가시킨다.
  559. int repeaterNo = this.commandinfo.repeaterNo + 1;
  560. int loopNo = this.commandinfo.loopNo;
  561. int boardId = this.commandinfo.boardNo;
  562. if (repeaterNo > 127)
  563. {
  564. repeaterNo = 1;
  565. runBoardIdOK = false;
  566. while (!runBoardIdOK)
  567. {
  568. ++loopNo;
  569. if (loopNo > 1)
  570. {
  571. loopNo = 0;
  572. ++boardId;
  573. // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  574. int boardID_cnt = 0;
  575. // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다
  576. if (mdi.ReceiverModel == "IFC3300")
  577. {
  578. boardID_cnt = 64;
  579. }
  580. else
  581. {
  582. boardID_cnt = 16;
  583. }
  584. // cyim 2016.11.03 : 통신보드(중계반)는 최대 64
  585. if (boardId > boardID_cnt)
  586. {
  587. runBoardIdOK = false;
  588. //완료
  589. CompleteProgress();
  590. return;
  591. }
  592. }
  593. BoardTypeInfo brdinfo = this.configReceiverPoint.Get_RepeaterType(boardId); //통신보드savBoardID의 설정값
  594. if (brdinfo != null)
  595. {
  596. runBoardIdOK = true;
  597. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  598. if (loopNo == 0)
  599. {
  600. this.repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
  601. }
  602. else if (loopNo == 1)
  603. {
  604. this.repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
  605. }
  606. else if (loopNo == 2)
  607. {
  608. this.repinfo = brdinfo.Loop2_RepeaterType; //통신보드 + Loop2 + 127개 중계기 설정값
  609. }
  610. else if (loopNo == 3)
  611. {
  612. this.repinfo = brdinfo.Loop3_RepeaterType; //통신보드 + Loop3 + 127개 중계기 설정값
  613. }
  614. }
  615. }
  616. }
  617. progressBar1.Value += 1;
  618. progressBar1.Refresh();
  619. //중계기설정정보 저장
  620. this.commandinfo.repeaterNo = repeaterNo;
  621. //this.commandinfo.setRepeaterInfo(repeaterNo, repeaterType);
  622. this.commandinfo.boardNo = boardId;
  623. this.commandinfo.loopNo = loopNo;
  624. int repeaterType = 0;
  625. bool CutFlag = false;
  626. bool FireResetFlag = false;
  627. if (this.repinfo[repeaterNo - 1] != null)
  628. {
  629. if (this.repinfo[repeaterNo - 1].UseFlag)
  630. {
  631. //repeaterType = this.repinfo[repeaterNo - 1].RepeaterType == "A" ? 1 : 2;
  632. // cyim 2015.6.8 아날로그 감지기 연동 추가
  633. // '1' = A : 2X2
  634. // '2' = B : 4X4
  635. // '4' = C : 아날로그연감지기
  636. // '5' = D : 아날로그열감지기
  637. if (repinfo[repeaterNo - 1].RepeaterType == "A")
  638. repeaterType = 1;
  639. else if (repinfo[repeaterNo - 1].RepeaterType == "B")
  640. repeaterType = 2;
  641. else if (repinfo[repeaterNo - 1].RepeaterType == "C")
  642. repeaterType = 4;
  643. else if (repinfo[repeaterNo - 1].RepeaterType == "D")
  644. repeaterType = 5;
  645. CutFlag = this.repinfo[repeaterNo - 1].CutFlag;
  646. FireResetFlag = repinfo[repeaterNo - 1].FireResetFlag;
  647. }
  648. else
  649. {
  650. repeaterType = 0;
  651. CutFlag = false;
  652. FireResetFlag = false;
  653. }
  654. }
  655. runCommandOK = true;
  656. RepeaterData data = new RepeaterData((byte)repeaterNo);
  657. data.Set_Info_Data(CutFlag, FireResetFlag, false, false, repeaterType);
  658. this.commandinfo.CommandData = data;
  659. //명령보냄
  660. ui.runCommand(this.commandinfo);
  661. break;
  662. }
  663. //RepeaterData data = new RepeaterData((byte)repeaterNo);
  664. //data.Set_Info_Data(CutFlag, false, false, false, repeaterType);
  665. //this.commandinfo.CommandData = data;
  666. ////명령보냄
  667. //ui.runCommand(this.commandinfo);
  668. }
  669. catch (Exception ex)
  670. {
  671. Util.UErrorMessage(ex, 0, 0);
  672. }
  673. }
  674. //명령 쓰기 완료--종료.
  675. public void command_complete(CmdInfo resInfo)
  676. {
  677. try
  678. {
  679. if (this.complete) return;
  680. switch (this.commandinfo.Command)
  681. {
  682. //중계기 Unit 에 정보 쓰기
  683. case prt_cmd_define.write_repeater_info_unit:
  684. {
  685. if (this.configReceiverPointAllWrite)
  686. {
  687. /***********************************************/
  688. /* 전체쓰기 */
  689. /***********************************************/
  690. String thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} UNIT 정보 쓰기", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo);
  691. lblDescription.Text = thisLog;
  692. if (resInfo.ErrResponse)
  693. {
  694. ListViewLogAdd(thisLog + ":" + resInfo.ErrMessage);
  695. Application.DoEvents();
  696. }
  697. else
  698. {
  699. ListViewLogAdd(thisLog + ": 완료");
  700. }
  701. //다시 진행으로 보내줌
  702. repeater_info_unit_all_write_progress();
  703. /***********************************************/
  704. }
  705. else
  706. {
  707. /***********************************************/
  708. /* Loop쓰기 */
  709. /***********************************************/
  710. String thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} UNIT 정보 쓰기", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo);
  711. lblDescription.Text = thisLog;
  712. if (resInfo.ErrResponse)
  713. {
  714. ListViewLogAdd(thisLog + ":" + resInfo.ErrMessage);
  715. Application.DoEvents();
  716. }
  717. else
  718. {
  719. ListViewLogAdd(thisLog + ": 완료");
  720. }
  721. //다시 진행으로 보내줌
  722. repeater_info_unit_write_progress();
  723. /***********************************************/
  724. }
  725. break;
  726. }
  727. case prt_cmd_define.read_command_status:
  728. {
  729. switch (this.commandinfo.CommandType)
  730. {
  731. case "DC":
  732. {
  733. this.Text = "차단설정 명령중..";
  734. string actionMsg = resInfo.Status == 0 ? "설정" : "해제";
  735. String thisLog = "차단설정 명령";
  736. if (this.commandinfo.ApplyRange.Equals("L")) //Loop16개 차단시
  737. {
  738. thisLog = String.Format("통신보드#{0} 계통#{1} 차단{2}명령", resInfo.boardNo, resInfo.loopNo, actionMsg);
  739. }
  740. else if (this.commandinfo.ApplyRange.Equals("R")) //중계기 차단시
  741. {
  742. thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} 차단{3}명령", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo, actionMsg);
  743. }
  744. else if (this.commandinfo.ApplyRange.Equals("I")) //입력회로 차단시
  745. {
  746. thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} 입력회로#{3} 차단{4}명령", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo, resInfo.DeviceId, actionMsg);
  747. }
  748. else if (this.commandinfo.ApplyRange.Equals("O")) //출력회로 차단시
  749. {
  750. thisLog = String.Format("통신보드#{0} 계통#{1} 중계기#{2} 출력회로#{3} 차단{4}명령", resInfo.boardNo, resInfo.loopNo, resInfo.repeaterNo, resInfo.DeviceId, actionMsg);
  751. }
  752. else if (this.commandinfo.ApplyRange.Equals("A")) //연동타입 차단시
  753. {
  754. //Device_Type_Name
  755. actionMsg = resInfo.Status == 1 ? "정지" : "연동";//2010.11.12,k.s.d, display message bug fix( 정지 <-> 연동 )
  756. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(resInfo.receiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  757. string deviceTypeName = dacDeviceConfig.Device_Type_Name(code_InOutType.Output, string.Format("O{0}", resInfo.SubType));
  758. thisLog = String.Format("{0} 연동타입 {1}명령", deviceTypeName, actionMsg);
  759. }
  760. lblDescription.Text = thisLog;
  761. if (resInfo.ErrResponse)
  762. {
  763. ListViewLogAdd(thisLog + ":" + resInfo.ErrMessage);
  764. Application.DoEvents();
  765. }
  766. else
  767. {
  768. ListViewLogAdd(thisLog + ": 완료");
  769. }
  770. //다시 진행으로 보내줌
  771. if (download_type != 0)// 2010.10.28, k.s.d, only one click device linkage change support .
  772. {
  773. CompleteProgress(true, 1000);
  774. }
  775. else
  776. {
  777. cut_flag_progress();
  778. }
  779. break;
  780. }
  781. //환경정보변경
  782. case "CS":
  783. {
  784. this.Text = "환경설정 변경중..";
  785. String thisLog = "알수없음.";
  786. switch (resInfo.SubType)
  787. {
  788. case "A": thisLog = "축적모드 변경"; break;
  789. case "T": thisLog = "축적시간 변경"; break;
  790. case "F": thisLog = "화재모드 변경"; break;
  791. case "S": thisLog = "지구음향모드 변경"; break;//2010.11.12,k.s.d, 지구경종 -> 지구음향
  792. }
  793. lblDescription.Text = thisLog;
  794. if (resInfo.ErrResponse)
  795. {
  796. ListViewLogAdd(thisLog + ":" + resInfo.ErrMessage);
  797. Application.DoEvents();
  798. }
  799. else
  800. {
  801. ListViewLogAdd(thisLog + ": 완료");
  802. }
  803. //다시 진행으로 보내줌
  804. config_change_progress();
  805. break;
  806. }
  807. default: break;
  808. }
  809. break;
  810. }
  811. }
  812. }
  813. catch (Exception ex)
  814. {
  815. Util.UErrorMessage(ex, 0, 0);
  816. }
  817. }
  818. private void CompleteProgress()
  819. {
  820. try
  821. {
  822. this.complete = true;
  823. progressBar1.Value = progressBar1.Maximum;
  824. btnOK.Enabled = true;
  825. }
  826. catch (Exception ex)
  827. {
  828. Util.UErrorMessage(ex, 0, 0);
  829. }
  830. }
  831. private void btnOK_Click(object sender, EventArgs e)
  832. {
  833. try
  834. {
  835. this.Close();
  836. }
  837. catch (Exception ex)
  838. {
  839. Util.UErrorMessage(ex, 0, 0);
  840. }
  841. }
  842. private void ListViewLogAdd(String msg)
  843. {
  844. try
  845. {
  846. int cnt = listView1.Items.Count;
  847. ListViewItem item = new ListViewItem(Convert.ToString(cnt + 1));
  848. item.SubItems.Add(msg);
  849. listView1.Items.Add(item);
  850. listView1.EnsureVisible(cnt);
  851. }
  852. catch (Exception ex)
  853. {
  854. Util.UErrorMessage(ex, 0, 0);
  855. }
  856. }
  857. private void btnWinClose_Click(object sender, EventArgs e)
  858. {
  859. try
  860. {
  861. this.Close();
  862. }
  863. catch (Exception ex)
  864. {
  865. Util.UErrorMessage(ex, 0, 0);
  866. }
  867. }
  868. private void CompleteProgress(bool closePopup, int time)// 2010.10.28, k.s.d, for self destroy popup.
  869. {
  870. try
  871. {
  872. this.complete = true;
  873. progressBar1.Value = progressBar1.Maximum;
  874. btnOK.Enabled = true;
  875. if (closePopup == true)
  876. {
  877. m_closetime_start = Environment.TickCount;
  878. m_closetime = time;
  879. timer_Close_Tick(null, EventArgs.Empty);
  880. timer_Close.Enabled = true;
  881. }
  882. }
  883. catch (Exception ex)
  884. {
  885. Util.UErrorMessage(ex, 0, 0);
  886. }
  887. }
  888. int m_closetime_start = 0;
  889. int m_closetime = 0;
  890. private void timer_Close_Tick(object sender, EventArgs e)// 2010.10.28, k.s.d, for self destroy popup timer.
  891. {
  892. try
  893. {
  894. //m_closetime;
  895. if (m_closetime_start + m_closetime < Environment.TickCount)
  896. {
  897. this.Cursor = Cursors.Default;
  898. this.Close();
  899. }
  900. }
  901. catch (Exception ex)
  902. {
  903. this.Cursor = Cursors.Default;
  904. Util.UErrorMessage(ex, 0, 0);
  905. }
  906. }
  907. }
  908. }