10cbb1f7b5f5d0749fadc79dcbdf09a8c7fcaa76.svn-base 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017
  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;
  9. using System.Collections;
  10. using System.Threading;
  11. namespace FPER
  12. {
  13. public partial class frmRepeaterGroup : Form
  14. {
  15. int savBoardID = -1;
  16. int savLoop = -1;
  17. bool BoardGroup_change;
  18. MDIParent mdi;
  19. //FormRepeater FormRepeater = null;
  20. delegate void deleFormInit();
  21. LogFileCreate LFC = new LogFileCreate();
  22. //중계기 읽기를 진행하기 위해
  23. private Thread tRepeaterReadThread;
  24. private int tRepeaterReadThreadStatus = 0;
  25. // cyim 2015.7.2 해쉬테이블로 아날로그 감지기 레벨을 아이디별로 저장해둔다
  26. // 화면에서 보이는 보드,루프번호에 해당하는 아날로그감지기 레벨값 정보를 미리 가져온다
  27. Hashtable AnalogDetecterRepeaterID_Hashtable = new Hashtable();
  28. //화면의 GRIDVIEW 각 셀관련 중계기내용
  29. GridRepeater[] GRIDCELL = new GridRepeater[127];
  30. // 생성자
  31. public frmRepeaterGroup()
  32. {
  33. InitializeComponent();
  34. // 이벤트 핸들러 (디자이너가 아닌 수동으로 등록)
  35. this.FormClosing += new FormClosingEventHandler(frmRepeaterGroup_FormClosing);
  36. }
  37. // cyim 2015.7.6 레벨값 갱신 이벤트 추가
  38. public void _Event_AnalogLevel_Update_SendMessage_Event(MDIParent mdi)
  39. {
  40. // Repeater_ SettingData 를 호출은 반드시 해당 보드아이디와 루프가 변경될때만 호출되므로,
  41. // 직접 해쉬테이블을 갱신하도록 한다
  42. AnalogDetecterRepeaterID_Hashtable = mdi.GetAnalogDetecterRepeaterID(mdi.myReceiverID, savBoardID, savLoop);
  43. }
  44. // 소멸자
  45. public void frmRepeaterGroup_FormClosing(object sender, FormClosingEventArgs e)
  46. {
  47. // cyim 2015.7.6 레벨값 갱신 이벤트 추가 : 해제
  48. mdi.Event.AnalogLevel_Update_SendMessage_Event -= new _Event.AnalogLevel_Update_SendMessage_Handler(_Event_AnalogLevel_Update_SendMessage_Event); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  49. }
  50. // 초기화
  51. public void Form_Init()
  52. {
  53. try
  54. {
  55. if (this.InvokeRequired)
  56. {
  57. deleFormInit d = new deleFormInit(Form_Init);
  58. this.Invoke(d, new object[] { });
  59. }
  60. else
  61. {
  62. Repeater_SettingData();
  63. btnRepeaterAllInfo_Click(btnRepeaterAllInfo, EventArgs.Empty);
  64. }
  65. }
  66. catch (Exception ex)
  67. {
  68. Util.UErrorMessage(ex, 0, 0);
  69. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  70. }
  71. }
  72. bool load = false;
  73. // 초기화
  74. private void frmRepeaterGroup_Load(object sender, EventArgs e)
  75. {
  76. // cyim 2013.8.1 : 더블버퍼링 적용
  77. SetStyle(ControlStyles.UserPaint, true);
  78. //this.UpdateStyles();
  79. SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  80. //this.UpdateStyles();
  81. SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  82. this.UpdateStyles();
  83. try
  84. {
  85. this.Cursor = Cursors.WaitCursor;
  86. mdi = (MDIParent)this.MdiParent;
  87. txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
  88. if (BoardGroup_change)
  89. {
  90. mdi.temptxtBoardID = txtBoardID.Text;
  91. mdi.temptxtLoopNo = txtLoopNo.Text;
  92. BoardGroup_change = false;
  93. }
  94. //DacBoardConfig dacBoardConfig = new DacBoardConfig();
  95. //ArrayList ary = dacBoardConfig.Board_List(mdi.myReceiverID);
  96. //Util.ComboSetting(cboBoardList, ary, null);
  97. load = true;
  98. Repeater_SettingData();
  99. btnRepeaterAllInfo_Click(btnRepeaterAllInfo, EventArgs.Empty);
  100. this.timer_RepeaterAllInfo_BlockRead.Start();
  101. // cyim 2015.7.6 레벨값 갱신 이벤트 추가
  102. mdi.Event.AnalogLevel_Update_SendMessage_Event += new _Event.AnalogLevel_Update_SendMessage_Handler(_Event_AnalogLevel_Update_SendMessage_Event); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  103. // cyim 2015.7.23 NACK 응답이 최대 7.2초가 딜레이됨, 단 기본값은 4초
  104. timer_RepeaterAllInfo_BlockRead_ChangeStart(4000);
  105. }
  106. catch (Exception ex)
  107. {
  108. Util.UErrorMessage(ex, 0, 0);
  109. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  110. }
  111. finally
  112. {
  113. this.Cursor = Cursors.Default;
  114. }
  115. }
  116. private void frmRepeaterGroup_Activated(object sender, EventArgs e)
  117. {
  118. this.mdi.SelectMenuIndex = 3;
  119. }
  120. private void frmRepeaterGroup_Disposed(object sender, EventArgs e)
  121. {
  122. this.mdi.SelectMenuIndex = 0;
  123. }
  124. // 중계기 상태를 조회하기 위한 통신보드, 루프번호를 조회한다 (UI 기준)
  125. public void setBoardId(int boardId, int loopNo)
  126. {
  127. try
  128. {
  129. txtBoardID.Text = String.Format("{0:00}", boardId);
  130. txtLoopNo.Text = String.Format("{0}", loopNo);
  131. BoardGroup_change = true;
  132. }
  133. catch (Exception ex)
  134. {
  135. Util.UErrorMessage(ex, 0, 0);
  136. }
  137. }
  138. //GRID에 중계기 설정 표시
  139. private void Repeater_init()
  140. {
  141. // 중계기 이미지
  142. //imgListRepeaterBack.Images[0];
  143. //0 : 중계기 빈것
  144. //1 : 중계기 차단
  145. //2 : 중계기 에러
  146. //3 : 중계기 없음
  147. try
  148. {
  149. this.dataGridView_Repeater_Main.Columns.Clear();
  150. DataGridViewCellStyle sty = new DataGridViewCellStyle();
  151. sty.Alignment = DataGridViewContentAlignment.MiddleCenter;
  152. for (int col = 0; col < 10; col++)
  153. {
  154. DataGridViewImageColumn imageColumn = new DataGridViewImageColumn();
  155. imageColumn.ImageLayout = DataGridViewImageCellLayout.Normal;
  156. // 처음 기본 바탕이미지는 중계기 빈것으로 대체 (흰색)
  157. imageColumn.Image = imgListRepeaterBack.Images[0];
  158. dataGridView_Repeater_Main.Columns.Add(imageColumn);
  159. dataGridView_Repeater_Main.Columns[col].ReadOnly = true;
  160. dataGridView_Repeater_Main.Columns[col].Resizable = DataGridViewTriState.False;
  161. dataGridView_Repeater_Main.Columns[col].Width = 76;
  162. dataGridView_Repeater_Main.Columns[col].DefaultCellStyle = sty;
  163. }
  164. // 10개의 셀 바탕이미지는 중계기 없음으로 대체 (회색)
  165. Image[] rowData12 = new Image[10] {
  166. imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3] , imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3],
  167. imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3] , imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3]};
  168. try
  169. {
  170. this.dataGridView_Repeater_Main.Rows.Clear();
  171. DataGridViewRowCollection rows = dataGridView_Repeater_Main.Rows;
  172. for (int row = 0; row <= 12; row++)
  173. {
  174. rows.Add(rowData12);
  175. }
  176. }
  177. catch (Exception ex)
  178. {
  179. Util.UErrorMessage(ex, 0, 0);
  180. }
  181. // 셀 단위로 이미지를 셋팅한다
  182. for (int row = 0; row <= 12; row++)
  183. {
  184. for (int col = 1; col <= 10; col++)
  185. {
  186. // no 는 중계기 아이디
  187. int no = row * 10 + col;
  188. if (no <= 127)
  189. {
  190. GRIDCELL[no - 1] = new GridRepeater(dataGridView_Repeater_Main.Rows[row].Cells[col - 1], imgListRepeaterBack, no);
  191. }
  192. }
  193. dataGridView_Repeater_Main.Rows[row].Height = 45;
  194. //REP[no] = new RepeaterDeviceTypeInfo(no);
  195. }
  196. }
  197. catch (Exception ex)
  198. {
  199. Util.UErrorMessage(ex, 0, 0);
  200. throw ex;
  201. }
  202. }
  203. bool ex = false;
  204. //중계기 설정데이터 가져오기
  205. private void Repeater_SettingData()
  206. {
  207. try
  208. {
  209. if (this.InvokeRequired)
  210. {
  211. deleFormInit d = new deleFormInit(Repeater_SettingData);
  212. this.Invoke(d, new object[] { });
  213. }
  214. else
  215. {
  216. //if (cboBoardList.Items.Count < 1 || cboLoopList.Items.Count < 1) { Repeater_init(); return; }
  217. //if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) { Repeater_init(); return; }
  218. //String BoardID = cboBoardList.SelectedItem.ToString();
  219. //String Loop = cboLoopList.SelectedItem.ToString();
  220. ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo;
  221. if (load)
  222. {
  223. if (mdi.temptxtBoardID != null && mdi.temptxtLoopNo != null)
  224. {
  225. int boardid = Convert.ToInt32(mdi.temptxtBoardID);
  226. int tempboard = boardid - 1;
  227. int loopid = Convert.ToInt32(mdi.temptxtLoopNo);
  228. if (Receiverinfo.MyBoardType[tempboard] != null)
  229. {
  230. if (Receiverinfo.MyBoardType[tempboard].UseFlag == true)
  231. {
  232. switch (loopid)
  233. {
  234. case 0:
  235. {
  236. if (Receiverinfo.MyBoardType[tempboard].Loop0UseFlag == true)
  237. {
  238. if (boardid > 9)
  239. {
  240. txtBoardID.Text = boardid.ToString();
  241. mdi.temptxtBoardID = txtBoardID.Text;
  242. }
  243. else
  244. {
  245. txtBoardID.Text = "0" + boardid.ToString();
  246. mdi.temptxtBoardID = boardid.ToString();
  247. }
  248. txtLoopNo.Text = "0";
  249. mdi.temptxtLoopNo = txtLoopNo.Text;
  250. ex = true;
  251. break;
  252. }
  253. ex = false;
  254. break;
  255. }
  256. case 1:
  257. {
  258. if (Receiverinfo.MyBoardType[tempboard].Loop1UseFlag == true)
  259. {
  260. if (boardid > 9)
  261. {
  262. txtBoardID.Text = boardid.ToString();
  263. mdi.temptxtBoardID = txtBoardID.Text;
  264. }
  265. else
  266. {
  267. txtBoardID.Text = "0" + boardid.ToString();
  268. mdi.temptxtBoardID = boardid.ToString();
  269. }
  270. txtLoopNo.Text = "1";
  271. mdi.temptxtLoopNo = txtLoopNo.Text;
  272. ex = true;
  273. break;
  274. }
  275. ex = false;
  276. break;
  277. }
  278. case 2:
  279. {
  280. if (Receiverinfo.MyBoardType[tempboard].Loop2UseFlag == true)
  281. {
  282. if (boardid > 9)
  283. {
  284. txtBoardID.Text = boardid.ToString();
  285. mdi.temptxtBoardID = txtBoardID.Text;
  286. }
  287. else
  288. {
  289. txtBoardID.Text = "0" + boardid.ToString();
  290. mdi.temptxtBoardID = boardid.ToString();
  291. }
  292. txtLoopNo.Text = "2";
  293. mdi.temptxtLoopNo = txtLoopNo.Text;
  294. ex = true;
  295. break;
  296. }
  297. ex = false;
  298. break;
  299. }
  300. case 3:
  301. {
  302. if (Receiverinfo.MyBoardType[tempboard].Loop3UseFlag == true)
  303. {
  304. if (boardid > 9)
  305. {
  306. txtBoardID.Text = boardid.ToString();
  307. mdi.temptxtBoardID = txtBoardID.Text;
  308. }
  309. else
  310. {
  311. txtBoardID.Text = "0" + boardid.ToString();
  312. mdi.temptxtBoardID = boardid.ToString();
  313. }
  314. txtLoopNo.Text = "3";
  315. mdi.temptxtLoopNo = txtLoopNo.Text;
  316. ex = true;
  317. break;
  318. }
  319. ex = false;
  320. break;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. if (!ex)
  327. {
  328. for (var i = 0; i < Receiverinfo.MyBoardType.Length; i++)
  329. {
  330. if (Receiverinfo.MyBoardType[i] != null)
  331. {
  332. if (Receiverinfo.MyBoardType[i].UseFlag == true)
  333. {
  334. if (Receiverinfo.MyBoardType[i].Loop0UseFlag == true || Receiverinfo.MyBoardType[i].Loop1UseFlag == true || Receiverinfo.MyBoardType[i].Loop2UseFlag == true || Receiverinfo.MyBoardType[i].Loop3UseFlag == true)
  335. {
  336. int tempcnt = i + 1;
  337. if (tempcnt > 9)
  338. {
  339. txtBoardID.Text = tempcnt.ToString();
  340. }
  341. else
  342. {
  343. txtBoardID.Text = "0" + tempcnt.ToString();
  344. }
  345. if (Receiverinfo.MyBoardType[i].Loop0UseFlag == true)
  346. {
  347. txtLoopNo.Text = "0";
  348. break;
  349. }
  350. else if (Receiverinfo.MyBoardType[i].Loop1UseFlag == true)
  351. {
  352. txtLoopNo.Text = "1";
  353. break;
  354. }
  355. else if (Receiverinfo.MyBoardType[i].Loop2UseFlag == true)
  356. {
  357. txtLoopNo.Text = "2";
  358. break;
  359. }
  360. else
  361. {
  362. txtLoopNo.Text = "3";
  363. break;
  364. }
  365. }
  366. }
  367. }
  368. }
  369. }
  370. load = false;
  371. }
  372. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  373. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  374. if (txtBoardID.Text.Substring(0, 1) == "0")
  375. {
  376. mdi.temptxtBoardID = txtBoardID.Text.Substring(1, 1);
  377. }
  378. else
  379. {
  380. mdi.temptxtBoardID = txtBoardID.Text;
  381. }
  382. mdi.temptxtLoopNo = txtLoopNo.Text;
  383. if (BoardID == savBoardID && Loop == savLoop) return;
  384. this.Cursor = Cursors.WaitCursor;
  385. // 중계기 상태보기 이미지를 초기화
  386. Repeater_init();
  387. savBoardID = BoardID;
  388. savLoop = Loop;
  389. //수신기설정
  390. //통신보드 savBoardID 의 loop 의 설정값
  391. BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(savBoardID);
  392. RepeaterDeviceTypeInfo[] repinfo;
  393. RepeaterPointUnit[] repdata;
  394. bool LoopCutFlag = false;
  395. // cyim 2015.7.2 해쉬테이블로 아날로그 감지기 레벨을 아이디별로 저장해둔다
  396. // 사전에 가져온 데이타베이스 정보를 토대로 해당 보드, 루프를 따져 아날로그 감지기 정보를 미리 알아낸다
  397. // 이 때 아날로그 감지기라면 레벨값을 따져 현재 상태를 알아내야 한다
  398. AnalogDetecterRepeaterID_Hashtable = mdi.GetAnalogDetecterRepeaterID(mdi.myReceiverID, savBoardID, savLoop);
  399. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  400. // 통신보드의 Loop 정보
  401. if (savLoop == 0)
  402. {
  403. LoopCutFlag = brdinfo.Loop0CutFlag;
  404. repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
  405. repdata = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
  406. }
  407. else if (savLoop == 1)
  408. {
  409. LoopCutFlag = brdinfo.Loop1CutFlag;
  410. repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
  411. repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
  412. }
  413. else if (savLoop == 2)
  414. {
  415. LoopCutFlag = brdinfo.Loop2CutFlag;
  416. repinfo = brdinfo.Loop2_RepeaterType; //통신보드 + Loop2 + 127개 중계기 설정값
  417. repdata = brdinfo.Loop2_RepeaterUnit_Data; //127개 중계기 데이터
  418. }
  419. else if (savLoop == 3)
  420. {
  421. LoopCutFlag = brdinfo.Loop3CutFlag;
  422. repinfo = brdinfo.Loop3_RepeaterType; //통신보드 + Loop3 + 127개 중계기 설정값
  423. repdata = brdinfo.Loop3_RepeaterUnit_Data; //127개 중계기 데이터
  424. }
  425. else
  426. {
  427. LoopCutFlag = brdinfo.Loop0CutFlag;
  428. repinfo = null;
  429. repdata = null;
  430. }
  431. // 차단 정보 (계통)
  432. if (LoopCutFlag)
  433. {
  434. btnRepeaterRecoverCmd.Enabled = false;
  435. btnRepeaterSearchCmd.Enabled = false;
  436. btnInWrite.Enabled = false;
  437. btnOutWrite.Enabled = false;
  438. this.btnRepeaterReset.Enabled = false; // cyim 2015.2.23 계통차단시에는 사용불가
  439. }
  440. else
  441. {
  442. btnRepeaterRecoverCmd.Enabled = true;
  443. btnRepeaterSearchCmd.Enabled = true;
  444. btnInWrite.Enabled = true;
  445. btnOutWrite.Enabled = true;
  446. this.btnRepeaterReset.Enabled = true; // cyim 2015.2.23 계통차단시에는 사용불가
  447. }
  448. // 각 중계기의 정보
  449. for (int i = 0; i < repinfo.Length; i++)//2010.11.22, k.s.d , #127 repeater information don't display bug fix. , for (int i = 0; i < repinfo.Length - 1;i++ )
  450. {
  451. RepeaterDeviceTypeInfo dev = repinfo[i];
  452. GRIDCELL[i].LoopCutFlag = LoopCutFlag;
  453. //if (dev != null)
  454. //{
  455. int RepeaterID = i + 1;
  456. //개별중계기 설정값으로 Grid UI 생성
  457. GRIDCELL[i].Set_DeviceInfo(dev);
  458. //개별중계기 데이터값으로 Grid UI 생성 - 중계기 타입 결정
  459. GRIDCELL[i].Set_DeviceUnit(repdata[RepeaterID - 1]);
  460. //}
  461. }
  462. // 하단은 필요없음
  463. //if (LoopCutFlag)
  464. //{
  465. // //MessageBox.Show(string.Format("해당 계통은 차단설정 중입니다.. 통신보드[{0}] 계통[{1}] 차단설정 해제후 제어하십시요..", savBoardID, savLoop));
  466. //}
  467. }
  468. this.Cursor = Cursors.Default;
  469. }
  470. catch (Exception ex)
  471. {
  472. Util.UErrorMessage(ex, 0, 0);
  473. }
  474. }
  475. void RepeaterInfoRead()
  476. {
  477. try
  478. {
  479. while (tRepeaterReadThreadStatus > 0)
  480. {
  481. if (this.mdi.ui.Connected)
  482. {
  483. try
  484. {
  485. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  486. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  487. if (BoardID == 0)
  488. {
  489. tRepeaterReadThreadStatus = 0;
  490. }
  491. if (Loop != 0 && Loop != 1)
  492. {
  493. tRepeaterReadThreadStatus = 0;
  494. }
  495. tRepeaterReadThreadStatus++;
  496. //중계기 전체 읽기 명령
  497. dCommandResponse d = new dCommandResponse(RepeaterInfoAll);
  498. //명령생성 및 실행
  499. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_repeater_all, mdi.myReceiverID, 1, Loop, BoardID, d);
  500. this.mdi.ui.runCommand(cmd);
  501. if (tRepeaterReadThreadStatus > 4) tRepeaterReadThreadStatus = 0;
  502. }
  503. catch (Exception ex)
  504. {
  505. Util.UErrorMessage(ex, 0, 0);
  506. tRepeaterReadThreadStatus = 0;
  507. }
  508. Thread.Sleep(1000);
  509. }
  510. else
  511. {
  512. tRepeaterReadThreadStatus = 0;
  513. }
  514. }
  515. }
  516. catch (Exception ex)
  517. {
  518. Util.UErrorMessage(ex, 0, 0);
  519. tRepeaterReadThreadStatus = 0;
  520. }
  521. }
  522. //선택셀이 바뀔때마다 해당중계기 설정내용 및 데이터 표시
  523. private void dataGridView1_SelectionChanged(object sender, EventArgs e)
  524. {
  525. try
  526. {
  527. if (dataGridView_Repeater_Main.SelectedCells.Count > 0)
  528. {
  529. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  530. int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
  531. if (no > 127)
  532. {
  533. lblRepeaterID.Text = "";
  534. DeviceStatus(null, null);
  535. return;
  536. }
  537. else
  538. {
  539. lblRepeaterID.Text = String.Format("{0:000} 아이디", no);
  540. if (GRIDCELL[no - 1] != null)
  541. {
  542. lblInfoMessage.Text = GRIDCELL[no - 1].InfoMessage;
  543. //dataGridView2에 데이터 표시
  544. RepeaterDeviceTypeInfo dev = GRIDCELL[no - 1].DeviceInfo;
  545. RepeaterPointUnit unit = GRIDCELL[no - 1].DeviceUnit;
  546. DeviceStatus(dev, unit);
  547. }
  548. else
  549. {
  550. lblRepeaterID.Text = "";
  551. }
  552. }
  553. }
  554. }
  555. catch (Exception ex)
  556. {
  557. Util.UErrorMessage(ex, 0, 0);
  558. }
  559. }
  560. // cyim 2015.2.23 계통차단시에는 사용불가
  561. // 현재 라인이 차단되었는지 알아보는 함수
  562. private bool LoopCut()
  563. {
  564. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  565. ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
  566. BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(BoardID); //통신보드savBoardID의 loop0의 설정값
  567. //RepeaterDeviceTypeInfo[] repinfo;
  568. //RepeaterPointUnit[] repdata;
  569. bool LoopCutFlag = false;
  570. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  571. if (savLoop == 0)
  572. {
  573. LoopCutFlag = brdinfo.Loop0CutFlag;
  574. //repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
  575. //repdata = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
  576. }
  577. else if (savLoop == 1)
  578. {
  579. LoopCutFlag = brdinfo.Loop1CutFlag;
  580. //repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
  581. //repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
  582. }
  583. else if (savLoop == 2)
  584. {
  585. LoopCutFlag = brdinfo.Loop2CutFlag;
  586. //repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop2 + 127개 중계기 설정값
  587. //repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
  588. }
  589. else if (savLoop == 3)
  590. {
  591. LoopCutFlag = brdinfo.Loop3CutFlag;
  592. //repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop3 + 127개 중계기 설정값
  593. //repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
  594. }
  595. return LoopCutFlag;
  596. }
  597. //dataGridView2에 중계기 회로정보 표시
  598. private void DeviceStatus(RepeaterDeviceTypeInfo dt, RepeaterPointUnit unit)
  599. {
  600. try
  601. {
  602. if (dt != null && dt.UseFlag == true)
  603. {
  604. if (dt.RepeaterType.Equals("")
  605. // cyim 2015.2.23 계통차단시에는 사용불가
  606. || LoopCut() == true
  607. // cyim 2015.2.23 중계기차단시에는 사용불가
  608. || dt.CutFlag == true
  609. )
  610. {
  611. btnInWrite.Enabled = false;
  612. btnOutWrite.Enabled = false;
  613. btnRepeaterRecoverCmd.Enabled = false;
  614. btnRepeaterSearchCmd.Enabled = false;
  615. this.btnRepeaterReset.Enabled = false; // cyim 2015.2.23 계통차단시에는 사용불가
  616. }
  617. //else if (dt.CutFlag
  618. else
  619. {
  620. btnInWrite.Enabled = true;
  621. btnOutWrite.Enabled = true;
  622. btnRepeaterRecoverCmd.Enabled = true;
  623. btnRepeaterSearchCmd.Enabled = true;
  624. this.btnRepeaterReset.Enabled = true; // cyim 2015.2.23 계통차단시에는 사용불가
  625. }
  626. // 사용하는 셀 (흰색)
  627. DataGridViewCellStyle sty = new DataGridViewCellStyle();
  628. sty.Alignment = DataGridViewContentAlignment.MiddleCenter;
  629. sty.BackColor = System.Drawing.Color.White;
  630. // 미사용하는 셀 (회색)
  631. DataGridViewCellStyle styGray = new DataGridViewCellStyle();
  632. styGray.Alignment = DataGridViewContentAlignment.MiddleCenter;
  633. styGray.BackColor = System.Drawing.Color.Gray;
  634. styGray.SelectionBackColor = System.Drawing.Color.Gray;
  635. // cyim 2015.6.8 아날로그 감지기 연동 추가 : 타입에 관계없이 동일한 스타일이 적용된다
  636. for (int col = 0; col < 4; col++)
  637. {
  638. dataGridView_Repeater_Sub.Columns[col].ReadOnly = true;
  639. dataGridView_Repeater_Sub.Columns[col].Resizable = DataGridViewTriState.False;
  640. dataGridView_Repeater_Sub.Columns[col].Width = 70;
  641. dataGridView_Repeater_Sub.Columns[col].DefaultCellStyle = sty;
  642. }
  643. //if (dt.RepeaterType.Equals("A"))
  644. //{
  645. // for (int col = 0; col < 4; col++)
  646. // {
  647. // //dataGridView2.Columns.Add(new DataGridViewTextBoxColumn());
  648. // dataGridView_Repeater_Sub.Columns[col].ReadOnly = true;
  649. // dataGridView_Repeater_Sub.Columns[col].Resizable = DataGridViewTriState.False;
  650. // dataGridView_Repeater_Sub.Columns[col].Width = 140;
  651. // dataGridView_Repeater_Sub.Columns[col].DefaultCellStyle = sty;
  652. // }
  653. // //dt.InType3 = "";
  654. // //dt.InType4 = "";
  655. // //dt.OutType3 = "";
  656. // //dt.OutType4 = "";
  657. // // cyim 2015.6.8 아날로그 감지기 연동 추가 : 아래 소스는 필요없음
  658. // //dataGridView_Repeater_Sub.Columns[2].ReadOnly = true;
  659. // //dataGridView_Repeater_Sub.Columns[2].Resizable = DataGridViewTriState.False;
  660. // //dataGridView_Repeater_Sub.Columns[2].Width = 140;
  661. // //dataGridView_Repeater_Sub.Columns[2].DefaultCellStyle = styGray;
  662. // //dataGridView_Repeater_Sub.Columns[3].ReadOnly = true;
  663. // //dataGridView_Repeater_Sub.Columns[3].Resizable = DataGridViewTriState.False;
  664. // //dataGridView_Repeater_Sub.Columns[3].Width = 140;
  665. // //dataGridView_Repeater_Sub.Columns[3].DefaultCellStyle = styGray;
  666. //}
  667. //else if (dt.RepeaterType.Equals("B"))
  668. //{
  669. // for (int col = 0; col < 4; col++)
  670. // {
  671. // //dataGridView2.Columns.Add(new DataGridViewTextBoxColumn());
  672. // dataGridView_Repeater_Sub.Columns[col].ReadOnly = true;
  673. // dataGridView_Repeater_Sub.Columns[col].Resizable = DataGridViewTriState.False;
  674. // dataGridView_Repeater_Sub.Columns[col].Width = 70;
  675. // dataGridView_Repeater_Sub.Columns[col].DefaultCellStyle = sty;
  676. // }
  677. //}
  678. //else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))
  679. //{
  680. // for (int col = 0; col < 1; col++)
  681. // {
  682. // //dataGridView2.Columns.Add(new DataGridViewTextBoxColumn());
  683. // dataGridView_Repeater_Sub.Columns[col].ReadOnly = true;
  684. // dataGridView_Repeater_Sub.Columns[col].Resizable = DataGridViewTriState.False;
  685. // dataGridView_Repeater_Sub.Columns[col].Width = 140;
  686. // dataGridView_Repeater_Sub.Columns[col].DefaultCellStyle = sty;
  687. // }
  688. //}
  689. //회로입력,출력값 표시
  690. if (unit != null)
  691. {
  692. DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;
  693. if (dt != null)
  694. {
  695. if (dt.RepeaterType.Equals("A"))
  696. {
  697. //sdkim , 2011.11.22. bug fix , 2in2out type repeater - null point exception bug.
  698. String[] inData = { DeviceStatusText.InputText(unit.Repeater_Input1,dt.inDeviceTypeInfos[0]),
  699. DeviceStatusText.InputText(unit.Repeater_Input2,dt.inDeviceTypeInfos[1]),
  700. "",
  701. "" };
  702. String[] outData = { DeviceStatusText.OutputText(unit.Repeater_Output1,dt.outDeviceTypeInfos[0]),
  703. DeviceStatusText.OutputText(unit.Repeater_Output2,dt.outDeviceTypeInfos[1]),
  704. "",
  705. "" };
  706. rows2.Clear();
  707. rows2.Add(inData);
  708. rows2.Add(outData);
  709. }
  710. else if (dt.RepeaterType.Equals("B"))
  711. {
  712. String[] inData = { DeviceStatusText.InputText(unit.Repeater_Input1,dt.inDeviceTypeInfos[0]),
  713. DeviceStatusText.InputText(unit.Repeater_Input2,dt.inDeviceTypeInfos[1]),
  714. DeviceStatusText.InputText(unit.Repeater_Input3,dt.inDeviceTypeInfos[2]),
  715. DeviceStatusText.InputText(unit.Repeater_Input4,dt.inDeviceTypeInfos[3]) };
  716. String[] outData = { DeviceStatusText.OutputText(unit.Repeater_Output1,dt.outDeviceTypeInfos[0]),
  717. DeviceStatusText.OutputText(unit.Repeater_Output2,dt.outDeviceTypeInfos[1]),
  718. DeviceStatusText.OutputText(unit.Repeater_Output3,dt.outDeviceTypeInfos[2]),
  719. DeviceStatusText.OutputText(unit.Repeater_Output4,dt.outDeviceTypeInfos[3])};
  720. rows2.Clear();
  721. rows2.Add(inData);
  722. rows2.Add(outData);
  723. }
  724. // cyim 2015.6.8 아날로그 감지기 연동 추가
  725. else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))
  726. {
  727. String[] inData = { DeviceStatusText.InputText(unit.Repeater_Input1, dt.inDeviceTypeInfos[0]) };
  728. String[] outData = { DeviceStatusText.OutputText(unit.Repeater_Output1, dt.outDeviceTypeInfos[0]) };
  729. rows2.Clear();
  730. rows2.Add(inData);
  731. rows2.Add(outData);
  732. }
  733. }
  734. }
  735. else
  736. {
  737. DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;
  738. if (dt != null)
  739. {
  740. rows2.Clear();
  741. // cyim 2014.4.3 : 초기값 수정 1,2,3,4 -> "-"
  742. if (dt.RepeaterType.Equals("A"))
  743. {
  744. String[] inData = { "-", "-", "", "" };
  745. String[] outData = { "-", "-", "", "" };
  746. rows2.Add(inData);
  747. rows2.Add(outData);
  748. }
  749. else if (dt.RepeaterType.Equals("B"))
  750. {
  751. String[] inData = { "-", "-", "-", "-" };
  752. String[] outData = { "-", "-", "-", "-" };
  753. rows2.Add(inData);
  754. rows2.Add(outData);
  755. }
  756. // cyim 2015.6.8 아날로그 감지기 연동 추가
  757. else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))
  758. {
  759. String[] inData = { "-", "", "", "" };
  760. String[] outData = { "-", "", "", "" };
  761. rows2.Add(inData);
  762. rows2.Add(outData);
  763. }
  764. }
  765. }
  766. }
  767. else
  768. {
  769. this.dataGridView_Repeater_Sub.Rows.Clear();
  770. btnInWrite.Enabled = false;
  771. btnOutWrite.Enabled = false;
  772. btnRepeaterRecoverCmd.Enabled = false;
  773. btnRepeaterSearchCmd.Enabled = false;
  774. lblRepeaterID.Text = "";
  775. this.btnRepeaterReset.Enabled = false; // cyim 2015.2.23 계통차단시에는 사용불가
  776. }
  777. }
  778. catch (Exception ex)
  779. {
  780. Util.UErrorMessage(ex, 0, 0);
  781. }
  782. }
  783. private Boolean dtCutFlag(DeviceTypeInfo dtInfo)
  784. {
  785. bool cutFlag = false;
  786. try
  787. {
  788. if (dtInfo != null) cutFlag = dtInfo.CutFlag;
  789. }
  790. catch (Exception ex)
  791. {
  792. Util.UErrorMessage(ex, 0, 0);
  793. }
  794. return cutFlag;
  795. }
  796. /*******************************************
  797. * 중계기정보를 가져오는 통신부분 ---시작
  798. ******************************************/
  799. private void btnRepeaterAllInfo_Click(object sender, EventArgs e)
  800. {
  801. try
  802. {
  803. SocketUI ui = this.mdi.ui;
  804. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  805. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  806. if (BoardID == 0)
  807. {
  808. this.label_Warning.Text = string.Format("통신보드ID를 입력하여 주십시요.");
  809. this.label_Warning.Visible = true;
  810. txtBoardID.Focus();
  811. return;
  812. }
  813. else
  814. if (Loop != 0 && Loop != 1 && Loop != 2 && Loop != 3)
  815. {
  816. this.label_Warning.Text = string.Format("Loop No를 올바르게 입력하여 주십시요.");
  817. this.label_Warning.Visible = true;
  818. txtLoopNo.Focus();
  819. return;
  820. }
  821. else
  822. {
  823. this.label_Warning.Visible = false;
  824. }
  825. button_end(false);//버튼 비활성 설정
  826. dCommandResponse d = new dCommandResponse(RepeaterInfoAll);//중계기 전체 읽기 명령
  827. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_repeater_all, mdi.myReceiverID, 1, Loop, BoardID, d);//명령생성 및 실행
  828. ui.runCommand(cmd);
  829. }
  830. catch (Exception ex)
  831. {
  832. Util.UErrorMessage(ex, 0, 0);
  833. }
  834. }
  835. //화면 마우스 커서 및 버튼 다시 클릭 못하도록 설정 및 해제
  836. private void button_end(Boolean val)
  837. {
  838. try
  839. {
  840. if (val)
  841. {
  842. this.btnRepeaterAllInfo.Enabled = true;
  843. this.Cursor = Cursors.Default;
  844. }
  845. else
  846. {
  847. this.btnRepeaterAllInfo.Enabled = false;
  848. this.Cursor = Cursors.WaitCursor;
  849. }
  850. }
  851. catch (Exception ex)
  852. {
  853. Util.UErrorMessage(ex, 0, 0);
  854. }
  855. }
  856. // cyim 2015.7.23 NACK 응답이 최대 7.2초가 딜레이됨, 단 기본값은 4초
  857. public void timer_RepeaterAllInfo_BlockRead_ChangeStart(int interval)
  858. {
  859. if (timer_RepeaterAllInfo_BlockRead.Interval != interval) // 중간에 주기를 변경하는 경우에만 타이머를 재시작한다
  860. {
  861. timer_RepeaterAllInfo_BlockRead.Stop();
  862. timer_RepeaterAllInfo_BlockRead.Interval = interval;
  863. timer_RepeaterAllInfo_BlockRead.Start();
  864. }
  865. }
  866. //*********************************************************************//
  867. // 중계기 전체읽기 응답데이터 이벤트 //
  868. //*********************************************************************//
  869. public void RepeaterInfoAll(CmdInfo cmd)
  870. {
  871. try
  872. {
  873. if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_ReadRepeaterPointAll")) // cyim 2015.7.23 NACK 처리 부분 오류
  874. {
  875. //에러응답처리
  876. button_end(true);
  877. // cyim 2015.7.23 NACK 응답이 최대 7.2초가 딜레이됨, 단 기본값은 4초
  878. timer_RepeaterAllInfo_BlockRead_ChangeStart(7200);
  879. return;
  880. }
  881. // cyim 2015.7.23 NACK 응답이 최대 7.2초가 딜레이됨, 단 기본값은 4초
  882. timer_RepeaterAllInfo_BlockRead_ChangeStart(4000);
  883. RCVData_ReadRepeaterPointAll ResponseData = (RCVData_ReadRepeaterPointAll)cmd.ResponseData;
  884. RepeaterData[] data = ResponseData.Data;
  885. if (cmd.Command == prt_cmd_define.read_repeater_all || cmd.ResCommand == prt_res_define.read_repeater_all)
  886. {
  887. if (savBoardID == cmd.boardNo && savLoop == cmd.loopNo)
  888. {
  889. ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
  890. BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(savBoardID); //통신보드savBoardID의 loop0의 설정값
  891. RepeaterDeviceTypeInfo[] repinfo;
  892. RepeaterPointUnit[] repdata;
  893. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  894. if (savLoop == 0)
  895. {
  896. repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
  897. repdata = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
  898. }
  899. else if (savLoop == 1)
  900. {
  901. repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
  902. repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
  903. }
  904. else if (savLoop == 2)
  905. {
  906. repinfo = brdinfo.Loop2_RepeaterType; //통신보드 + Loop2 + 127개 중계기 설정값
  907. repdata = brdinfo.Loop2_RepeaterUnit_Data; //127개 중계기 데이터
  908. }
  909. else if (savLoop == 3)
  910. {
  911. repinfo = brdinfo.Loop3_RepeaterType; //통신보드 + Loop3 + 127개 중계기 설정값
  912. repdata = brdinfo.Loop3_RepeaterUnit_Data; //127개 중계기 데이터
  913. }
  914. else
  915. {
  916. repinfo = null;
  917. repdata = null;
  918. }
  919. bool dataChanged = false;
  920. for (int repeaterNo = 0; repeaterNo < data.Length; repeaterNo++)
  921. {
  922. if (repinfo[repeaterNo] != null)
  923. {
  924. // cyim 2015.6.8 아날로그 감지기 연동 추가 : 해당 중계기 아이디가 아날로그 감지기 타입이다
  925. if (repinfo[repeaterNo].RepeaterType.Equals("C") || repinfo[repeaterNo].RepeaterType.Equals("D"))
  926. {
  927. // cyim 2015.7.2 해쉬테이블로 아날로그 감지기 레벨을 아이디별로 저장해둔다
  928. // 해당 중계기의 아날로그 레벨 값을 생성자로 전달한다
  929. AnalogLevel analoglevel = (AnalogLevel)AnalogDetecterRepeaterID_Hashtable[(repeaterNo + 1).ToString()];
  930. if (GRIDCELL[repeaterNo].Unit == null)
  931. {
  932. RepeaterPointUnit newdata = new RepeaterPointUnit(repeaterNo + 1, data[repeaterNo], analoglevel, mdi); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  933. repdata[repeaterNo] = newdata;
  934. GRIDCELL[repeaterNo].Set_DeviceUnit(newdata);
  935. dataChanged = true;
  936. }
  937. else if (GRIDCELL[repeaterNo].UpdateDeviceUnit(data[repeaterNo], analoglevel, mdi)) // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  938. {
  939. dataChanged = true;
  940. }
  941. }
  942. // 일반 중계기 타입이다
  943. else
  944. {
  945. if (GRIDCELL[repeaterNo].Unit == null)
  946. {
  947. RepeaterPointUnit newdata = new RepeaterPointUnit(repeaterNo + 1, data[repeaterNo]);
  948. repdata[repeaterNo] = newdata;
  949. GRIDCELL[repeaterNo].Set_DeviceUnit(newdata);
  950. dataChanged = true;
  951. }
  952. else if (GRIDCELL[repeaterNo].UpdateDeviceUnit(data[repeaterNo]))
  953. {
  954. dataChanged = true;
  955. }
  956. }
  957. }
  958. }
  959. if (dataChanged)
  960. {
  961. dataGridView1_SelectionChanged(dataGridView_Repeater_Main, System.EventArgs.Empty);//선택된 셀의 데이터를 dataGridView2에 표시한다..
  962. }
  963. }
  964. }
  965. button_end(true);//버튼 비활성 해제
  966. }
  967. catch (Exception ex)
  968. {
  969. Util.UErrorMessage(ex, 0, 0);
  970. }
  971. //finally
  972. //{
  973. // button_end(true);//버튼 비활성 해제
  974. //}
  975. }
  976. private void btnInputOpen_Click(object sender, EventArgs e)
  977. {
  978. try
  979. {
  980. InputIDVo vo = new InputIDVo();
  981. vo.ReceiverID = int.Parse(txtThisReceiverID.Text);
  982. vo.CommID = 1;
  983. vo.BoardID = Util.StrToInt(txtBoardID.Text, 0);
  984. vo.LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
  985. IWin32Window window = this;
  986. // cyim 2017.01.12 : 모델에 따라 선택할수 있는 통신보드가 틀리다
  987. frmModalLoopSelect frm = new frmModalLoopSelect(mdi);
  988. frm.InputVo = vo;
  989. frm.ShowDialog(window);
  990. vo = frm.InputVo;
  991. //입력한 코드가 있다면
  992. if (vo.InputOK)
  993. {
  994. txtThisReceiverID.Text = String.Format("{0:00}", vo.ReceiverID);
  995. txtBoardID.Text = String.Format("{0:00}", vo.BoardID);
  996. txtLoopNo.Text = String.Format("{0}", vo.LoopNo);
  997. Repeater_SettingData();
  998. btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty); //중계기정보읽기
  999. }
  1000. }
  1001. catch (Exception ex)
  1002. {
  1003. Util.UErrorMessage(ex, 0, 0);
  1004. }
  1005. }
  1006. private void btnOK_Click(object sender, EventArgs e)
  1007. {
  1008. try
  1009. {
  1010. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1011. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1012. if (BoardID == 0)
  1013. {
  1014. this.label_Warning.Text = string.Format("통신보드ID를 입력하여 주십시요.");
  1015. this.label_Warning.Visible = true;
  1016. //MessageBox.Show("통신보드ID를 입력하여 주십시요.", Application.ProductName);
  1017. txtBoardID.Focus();
  1018. return;
  1019. }
  1020. else
  1021. if (Loop != 0 && Loop != 1 && Loop != 2 && Loop != 3)
  1022. {
  1023. this.label_Warning.Text = string.Format("Loop No를 올바르게 입력하여 주십시요.");
  1024. this.label_Warning.Visible = true;
  1025. //MessageBox.Show("Loop No를 올바르게 입력하여 주십시요.", Application.ProductName);
  1026. txtLoopNo.Focus();
  1027. return;
  1028. }
  1029. else
  1030. {
  1031. this.label_Warning.Visible = false;
  1032. }
  1033. Repeater_SettingData();
  1034. btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty);
  1035. }
  1036. catch (Exception ex)
  1037. {
  1038. Util.UErrorMessage(ex, 0, 0);
  1039. }
  1040. }
  1041. private void btnWinClose_Click(object sender, EventArgs e)
  1042. {
  1043. try
  1044. {
  1045. this.Close();
  1046. }
  1047. catch (Exception ex)
  1048. {
  1049. Util.UErrorMessage(ex, 0, 0);
  1050. }
  1051. }
  1052. private void btnRepeaterRecoverCmd_Click(object sender, EventArgs e)
  1053. {
  1054. try
  1055. {
  1056. if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
  1057. {
  1058. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1059. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1060. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  1061. int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
  1062. if (no <= 127)
  1063. {
  1064. SocketUI ui = this.mdi.ui;
  1065. //완료이벤트
  1066. dCommandResponse d = new dCommandResponse(RepeaterRecoverComplete);
  1067. //명령생성 및 실행
  1068. CmdInfo cmd = new CmdInfo(prt_cmd_define.reset_repeater_unit, mdi.myReceiverID, 1, Loop, BoardID, no, d);
  1069. ui.runCommand(cmd);
  1070. }
  1071. }
  1072. }
  1073. catch (Exception ex)
  1074. {
  1075. Util.UErrorMessage(ex, 0, 0);
  1076. }
  1077. }
  1078. public void RepeaterRecoverComplete(CmdInfo cmd)
  1079. {
  1080. try
  1081. {
  1082. //에러응답처리
  1083. if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_ACK")) // cyim 2015.7.23 NACK 처리 부분 오류
  1084. {
  1085. button_end(true);
  1086. return;
  1087. }
  1088. MessageBox.Show("중계기복구 완료");
  1089. btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty); //중계기 읽기 명령
  1090. }
  1091. catch (Exception ex)
  1092. {
  1093. Util.UErrorMessage(ex, 0, 0);
  1094. }
  1095. }
  1096. //선택셀이 바뀔때마다 해당중계기 설정내용 및 데이터 표시
  1097. private void dataGridView2_SelectionChanged(object sender, EventArgs e)
  1098. {
  1099. try
  1100. {
  1101. txtDeviceTypeName.Text = "";
  1102. txtPositionName.Text = "";
  1103. txtDeviceMemo.Text = "";
  1104. if (dataGridView_Repeater_Main.SelectedCells.Count > 0 && dataGridView_Repeater_Sub.SelectedCells.Count > 0)
  1105. {
  1106. int CommID = 1;
  1107. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1108. int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
  1109. DataGridViewCell repCell = this.dataGridView_Repeater_Main.SelectedCells[0];
  1110. int RepeaterID = (repCell.RowIndex * 10) + repCell.ColumnIndex + 1;
  1111. DataGridViewCell devCell = this.dataGridView_Repeater_Sub.SelectedCells[0];
  1112. string InOut_Type = "I";
  1113. if (devCell.RowIndex > 0) InOut_Type = "O";
  1114. int deviceId = devCell.ColumnIndex + 1;
  1115. //회로설정값
  1116. DacUIProcess dacUIProcess = new DacUIProcess(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1117. DataTable dt2 = dacUIProcess.Device_Select(mdi.myReceiverID, CommID, BoardID, LoopNo, RepeaterID, deviceId, InOut_Type);
  1118. foreach (DataRow dr2 in dt2.Rows)
  1119. {
  1120. txtDeviceTypeName.Text = Util.NullToStr(dr2["DEVICE_TYPE_NAME"]);
  1121. txtPositionName.Text = Util.NullToStr(dr2["POSITION_NAME"]);
  1122. txtDeviceMemo.Text = Util.NullToStr(dr2["DEVICE_NAME"]);
  1123. }
  1124. }
  1125. }
  1126. catch (Exception ex)
  1127. {
  1128. Util.UErrorMessage(ex, 0, 0);
  1129. }
  1130. }
  1131. //중계기검색
  1132. private void btnRepeaterSearchCmd_Click(object sender, EventArgs e)
  1133. {
  1134. try
  1135. {
  1136. if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
  1137. {
  1138. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1139. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1140. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  1141. int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
  1142. if (no <= 127)
  1143. {
  1144. SocketUI ui = this.mdi.ui;
  1145. //완료이벤트
  1146. dCommandResponse d = new dCommandResponse(RepeaterSearchComplete);
  1147. //명령생성 및 실행
  1148. CmdInfo cmd = new CmdInfo(prt_cmd_define.search_repeater_unit, mdi.myReceiverID, 1, Loop, BoardID, no, d);
  1149. ui.runCommand(cmd);
  1150. }
  1151. }
  1152. }
  1153. catch (Exception ex)
  1154. {
  1155. Util.UErrorMessage(ex, 0, 0);
  1156. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1157. }
  1158. }
  1159. //중계기검색완료
  1160. public void RepeaterSearchComplete(CmdInfo cmd)
  1161. {
  1162. //에러응답처리
  1163. if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_SearchRepeaterUNIT")) // cyim 2015.7.23 NACK 처리 부분 오류
  1164. {
  1165. button_end(true);
  1166. return;
  1167. }
  1168. try
  1169. {
  1170. RCVData_SearchRepeaterUNIT unit = (RCVData_SearchRepeaterUNIT)cmd.ResponseData;
  1171. if (unit == null) throw new Exception("중계기 검색에 실패하였습니다. 통신상태 및 중계기 설정을 확인하십시요.");
  1172. if (unit.Data == null) throw new Exception("중계기 검색에 실패하였습니다. 통신상태 및 중계기 설정을 확인하십시요.");
  1173. RepeaterData dat = (RepeaterData)unit.Data;
  1174. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1175. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1176. if (BoardID == cmd.boardNo && cmd.loopNo == Loop)
  1177. {
  1178. int RepeaterID = cmd.repeaterNo;
  1179. RepeaterPointUnit rep = new RepeaterPointUnit(cmd.repeaterNo, dat);
  1180. GRIDCELL[RepeaterID - 1].Set_DeviceUnit(rep); //개별중계기 데이터값으로 Grid UI 생성
  1181. //검색완료여부
  1182. if (rep.RepeaterS == false)
  1183. {
  1184. MessageBox.Show(string.Format("중계기검색 완료. 중계기번호:{0}", RepeaterID));
  1185. }
  1186. else
  1187. {
  1188. MessageBox.Show(string.Format("중계기검색 실패. 중계기번호:{0}", RepeaterID));
  1189. }
  1190. btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty); //중계기 읽기 명령
  1191. }
  1192. }
  1193. catch (Exception ex)
  1194. {
  1195. Util.UErrorMessage(ex, 0, 0);
  1196. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  1197. }
  1198. finally
  1199. {
  1200. //버튼 비활성 해제
  1201. button_end(true);
  1202. }
  1203. }
  1204. private void btnInWrite_Click(object sender, EventArgs e)
  1205. {
  1206. try
  1207. {
  1208. if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
  1209. {
  1210. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1211. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1212. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  1213. int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
  1214. if (no <= 127)
  1215. {
  1216. SocketUI ui = this.mdi.ui;
  1217. //회로
  1218. RepeaterPointUnit unit = GRIDCELL[no - 1].DeviceUnit;
  1219. RepeaterDeviceTypeInfo Info = GRIDCELL[no - 1].DeviceInfo;
  1220. if (Info == null || unit == null)
  1221. {
  1222. MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다..통신상태를 확인하십시요..", Application.ProductName);
  1223. return;
  1224. }
  1225. if (MessageBox.Show("TEST용 회로만 입력쓰기가 가능합니다..그래도 입력쓰기를 하시겠습니까?", Application.ProductName, MessageBoxButtons.OKCancel)
  1226. == DialogResult.OK)
  1227. {
  1228. //int deviceNo = cell2.ColumnIndex + 1;
  1229. InputIDVo vo = new InputIDVo();
  1230. vo.ReceiverID = int.Parse(txtThisReceiverID.Text);
  1231. vo.CommID = 1;
  1232. vo.BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1233. vo.LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
  1234. vo.RepeaterID = no;
  1235. vo.RepeaterType = Info.RepeaterType;
  1236. vo.InoutType = "I";
  1237. InputDeviceStatus[] devData = new InputDeviceStatus[4]{ unit.Repeater_Input1
  1238. ,unit.Repeater_Input2
  1239. ,unit.Repeater_Input3
  1240. ,unit.Repeater_Input4};
  1241. vo.InputUnitData = devData;
  1242. IWin32Window window = this;
  1243. frmModalUnitDataSelect frm = new frmModalUnitDataSelect(Info); // cyim 2015.2.23 회로차단시에는 사용불가
  1244. frm.InputVo = vo;
  1245. frm.ShowDialog(window);
  1246. vo = frm.InputVo;
  1247. //입력한 코드가 있다면
  1248. if (vo.InputOK)
  1249. {
  1250. devData = vo.InputUnitData;
  1251. //회로
  1252. RepeaterData inputdata = new RepeaterData((byte)vo.RepeaterID);
  1253. inputdata.Set_Input_Data((int)devData[3], (int)devData[2], (int)devData[1], (int)devData[0]);
  1254. //완료이벤트
  1255. dCommandResponse d = new dCommandResponse(RepeaterInputWriteComplete);
  1256. //명령생성 및 실행
  1257. CmdInfo cmd = new CmdInfo(prt_cmd_define.write_repeater_input_unit, mdi.myReceiverID, 1, vo.LoopNo, vo.BoardID, vo.RepeaterID, d);
  1258. cmd.CommandData = inputdata;
  1259. ui.runCommand(cmd);
  1260. }
  1261. }
  1262. }
  1263. }
  1264. }
  1265. catch (Exception ex)
  1266. {
  1267. Util.UErrorMessage(ex, 0, 0);
  1268. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1269. }
  1270. }
  1271. //중계기 입력쓰기 완료
  1272. public void RepeaterInputWriteComplete(CmdInfo cmd)
  1273. {
  1274. //에러응답처리
  1275. if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_WriteRepeaterInputUNIT")) // cyim 2015.7.23 NACK 처리 부분 오류
  1276. {
  1277. button_end(true);
  1278. return;
  1279. }
  1280. try
  1281. {
  1282. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1283. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1284. if (BoardID == cmd.boardNo && cmd.loopNo == Loop)
  1285. {
  1286. int RepeaterID = cmd.repeaterNo;
  1287. RCVData_WriteRepeaterInputUNIT ResponseData = (RCVData_WriteRepeaterInputUNIT)cmd.ResponseData;
  1288. RepeaterPointUnit newdata = new RepeaterPointUnit(BoardID, ResponseData.Data);
  1289. //데이터저장
  1290. ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
  1291. BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(BoardID); //통신보드savBoardID의 loop0의 설정값
  1292. RepeaterPointUnit[] repdata;
  1293. if (savLoop == 0)
  1294. {
  1295. repdata = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
  1296. }
  1297. else
  1298. {
  1299. repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
  1300. }
  1301. repdata[RepeaterID - 1] = newdata;
  1302. //각 셀에 중계기 데이터 표시
  1303. GRIDCELL[RepeaterID - 1].Set_DeviceUnit(newdata);
  1304. //dataGridView2에 데이터 표시
  1305. RepeaterDeviceTypeInfo dev = GRIDCELL[RepeaterID - 1].DeviceInfo;
  1306. RepeaterPointUnit unit = GRIDCELL[RepeaterID - 1].DeviceUnit;
  1307. DeviceStatus(dev, unit);
  1308. }
  1309. }
  1310. catch (Exception ex)
  1311. {
  1312. Util.UErrorMessage(ex, 0, 0);
  1313. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  1314. }
  1315. finally
  1316. {
  1317. //버튼 비활성 해제
  1318. button_end(true);
  1319. }
  1320. }
  1321. // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
  1322. //중계기 출력쓰기 완료
  1323. public void RepeaterOutputWriteComplete(CmdInfo cmd)
  1324. {
  1325. //에러응답처리
  1326. if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_WriteRepeaterOutputUNIT")) // cyim 2015.7.23 NACK 처리 부분 오류
  1327. {
  1328. button_end(true);
  1329. return;
  1330. }
  1331. try
  1332. {
  1333. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1334. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1335. if (BoardID == cmd.boardNo && cmd.loopNo == Loop)
  1336. {
  1337. int RepeaterID = cmd.repeaterNo;
  1338. RCVData_WriteRepeaterOutputUNIT ResponseData = (RCVData_WriteRepeaterOutputUNIT)cmd.ResponseData;
  1339. RepeaterPointUnit newdata = new RepeaterPointUnit(BoardID, ResponseData.Data);
  1340. //데이터저장
  1341. ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
  1342. BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(BoardID); //통신보드savBoardID의 loop0의 설정값
  1343. RepeaterPointUnit[] repdata;
  1344. if (savLoop == 0)
  1345. {
  1346. repdata = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
  1347. }
  1348. else if (savLoop == 1)
  1349. {
  1350. repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
  1351. }
  1352. else if (savLoop == 2)
  1353. {
  1354. repdata = brdinfo.Loop2_RepeaterUnit_Data; //127개 중계기 데이터
  1355. }
  1356. else if (savLoop == 3)
  1357. {
  1358. repdata = brdinfo.Loop3_RepeaterUnit_Data; //127개 중계기 데이터
  1359. }
  1360. else
  1361. {
  1362. repdata = null;
  1363. }
  1364. repdata[RepeaterID - 1] = newdata;
  1365. //각 셀에 중계기 데이터 표시
  1366. GRIDCELL[RepeaterID - 1].Set_DeviceUnit(newdata);
  1367. //dataGridView2에 데이터 표시
  1368. RepeaterDeviceTypeInfo dev = GRIDCELL[RepeaterID - 1].DeviceInfo;
  1369. RepeaterPointUnit unit = GRIDCELL[RepeaterID - 1].DeviceUnit;
  1370. DeviceStatus(dev, unit);
  1371. if (this.tRepeaterReadThreadStatus == 1)
  1372. {
  1373. this.tRepeaterReadThread = new Thread(this.RepeaterInfoRead);
  1374. this.tRepeaterReadThreadStatus = 1;
  1375. this.tRepeaterReadThread.Start();
  1376. }
  1377. }
  1378. }
  1379. catch (Exception ex)
  1380. {
  1381. Util.UErrorMessage(ex, 0, 0);
  1382. }
  1383. finally
  1384. {
  1385. //버튼 비활성 해제
  1386. button_end(true);
  1387. }
  1388. }
  1389. // 쓰기버튼
  1390. private void btnOutWrite_Click(object sender, EventArgs e)
  1391. {
  1392. try
  1393. {
  1394. if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
  1395. {
  1396. // 상위에 통신보드 아이디와 채널계통 정보를 가져온다
  1397. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1398. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1399. // 중계기 인덱스
  1400. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  1401. int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
  1402. if (no <= 127)
  1403. {
  1404. SocketUI ui = this.mdi.ui;
  1405. //
  1406. // 회로 정보
  1407. //
  1408. RepeaterPointUnit unit = GRIDCELL[no - 1].DeviceUnit;
  1409. RepeaterDeviceTypeInfo Info = GRIDCELL[no - 1].DeviceInfo;
  1410. if (Info == null || unit == null)
  1411. {
  1412. MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다", Application.ProductName);
  1413. return;
  1414. }
  1415. // cyim 2015.2.23 계통차단시에는 사용불가
  1416. if (LoopCut() == true
  1417. // cyim 2015.2.23 중계기차단시에는 사용불가
  1418. || Info.CutFlag == true)
  1419. {
  1420. MessageBox.Show("차단중에는 사용할수 없습니다", Application.ProductName);
  1421. return;
  1422. }
  1423. // cyim 2015.2.24 통신에러는 쓰기 금지
  1424. if (unit.RepeaterErr == true)
  1425. {
  1426. MessageBox.Show("통신 에러중에는 사용할 수 없습니다", Application.ProductName);
  1427. return;
  1428. }
  1429. //
  1430. // 출력 회로 값 쓰기
  1431. //
  1432. if (MessageBox.Show("실제로 화재 및 설비 연동감지가 될수 있습니다. 그래도 출력쓰기를 하시겠습니까?", Application.ProductName, MessageBoxButtons.OKCancel)
  1433. == DialogResult.OK)
  1434. {
  1435. //
  1436. // 회로 정보를 담는 클래스
  1437. //
  1438. InputIDVo vo = new InputIDVo();
  1439. vo.ReceiverID = int.Parse(txtThisReceiverID.Text);
  1440. vo.CommID = 1;
  1441. vo.BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1442. vo.LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
  1443. vo.RepeaterID = no;
  1444. vo.RepeaterType = Info.RepeaterType;
  1445. vo.InoutType = "O";
  1446. //
  1447. // 출력디바이스 상태 (InputIDVo 전용)
  1448. //
  1449. //출력회로상태값 초기상태(-1),출력없음(0),출력있음(1),차단(3)
  1450. //public enum OutputDeviceStatus { Init = -1, NotWrite = 0, Write = 1, Blocking = 3 }
  1451. OutputDeviceStatus[] devData = new OutputDeviceStatus[4]{
  1452. unit.Repeater_Output1 // NotWrite
  1453. ,unit.Repeater_Output2 // NotWrite
  1454. ,unit.Repeater_Output3 // NotWrite
  1455. ,unit.Repeater_Output4};// NotWrite
  1456. // 출력디바이스 상태 추가
  1457. vo.OutputUnitData = devData;
  1458. //
  1459. // 모달대화상자를 출력
  1460. //
  1461. IWin32Window window = this;
  1462. frmModalUnitDataSelect frm = new frmModalUnitDataSelect(Info); // cyim 2015.2.23 회로차단시에는 사용불가
  1463. frm.InputVo = vo;
  1464. frm.ShowDialog(window);
  1465. vo = frm.InputVo; // 다이얼로그 출력이후 원하는 회로값이 상이함
  1466. // 확인 버튼을 누름 (입력한 코드가 있다면)
  1467. if (vo.InputOK)
  1468. {
  1469. // cyim 2013.9.3 출력쓰기 시도시 테스트 모드로 진입
  1470. this.mdi.SetInputTestMode(true);
  1471. // cyim 2015.2.27 출력 쓰기 사용중
  1472. mdi.CommandLog(MappingStatus.Log, string.Format("출력테스트 실행 CommID:{0},LoopNo:{1},BoardID:{2},RepeaterID:{3},devID:{4}-{5}-{6}-{7}",
  1473. vo.CommID, vo.LoopNo, vo.BoardID, vo.RepeaterID, vo.OutputUnitData[0], vo.OutputUnitData[1], vo.OutputUnitData[2], vo.OutputUnitData[3]));
  1474. // 중계기 데이타
  1475. RepeaterData outputdata = new RepeaterData((byte)vo.RepeaterID);
  1476. devData = vo.OutputUnitData;
  1477. outputdata.Set_Output_Data(
  1478. devData[3] == OutputDeviceStatus.Blocking ? true : false
  1479. , devData[2] == OutputDeviceStatus.Blocking ? true : false
  1480. , devData[1] == OutputDeviceStatus.Blocking ? true : false
  1481. , devData[0] == OutputDeviceStatus.Blocking ? true : false
  1482. , devData[3] == OutputDeviceStatus.Write ? true : false
  1483. , devData[2] == OutputDeviceStatus.Write ? true : false
  1484. , devData[1] == OutputDeviceStatus.Write ? true : false
  1485. , devData[0] == OutputDeviceStatus.Write ? true : false
  1486. );
  1487. //완료이벤트
  1488. dCommandResponse d = new dCommandResponse(RepeaterOutputWriteComplete);
  1489. //명령생성 및 실행
  1490. CmdInfo cmd = new CmdInfo(
  1491. prt_cmd_define.write_repeater_output_unit,
  1492. mdi.myReceiverID, // 수신기 아이디
  1493. 1, // CommID (1-통신보드 3-IO보드 4-KEYPAD 5-비상방송)
  1494. vo.LoopNo, //채널계통
  1495. vo.BoardID, // 통신보드
  1496. vo.RepeaterID, // 중계기 아이디
  1497. d); // 완료이벤트
  1498. cmd.CommandData = outputdata;
  1499. ui.runCommand(cmd);
  1500. //연동으로 인해 출력값이 변경될 수 있으므로 계속 읽는다..
  1501. //this.tRepeaterReadThread = new Thread(this.RepeaterInfoRead);
  1502. this.tRepeaterReadThreadStatus = 1;
  1503. //this.tRepeaterReadThread.Start();
  1504. }
  1505. }
  1506. }
  1507. }
  1508. }
  1509. catch (Exception ex)
  1510. {
  1511. Util.UErrorMessage(ex, 0, 0);
  1512. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1513. }
  1514. }
  1515. private void timer1_Tick(object sender, EventArgs e)
  1516. {
  1517. this.btnRepeaterAllInfo_Click(null, null);
  1518. }
  1519. // 더블 클릭시 입력 강제 테스트 실행
  1520. private void dataGridView2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  1521. {
  1522. try
  1523. {
  1524. // 입력신호 중 1개 선택시에만 동작
  1525. if (this.dataGridView_Repeater_Sub.SelectedCells.Count == 1)
  1526. {
  1527. DataGridViewCell cell = this.dataGridView_Repeater_Sub.SelectedCells[0];
  1528. // 입력 회로 선택시
  1529. if (cell.RowIndex == 0)
  1530. {
  1531. // 상단의 계통검색 UI
  1532. int CommID = 1;
  1533. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1534. int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
  1535. // 상단의 중계기 UI
  1536. DataGridViewCell repCell = this.dataGridView_Repeater_Main.SelectedCells[0];
  1537. int RepeaterID = (repCell.RowIndex * 10) + repCell.ColumnIndex + 1;
  1538. int devID = cell.ColumnIndex + 1;
  1539. // cyim 2015.7.6 아날로그 감지기는 입력테스트 불가
  1540. if (AnalogDetecterRepeaterID_Hashtable.ContainsKey(RepeaterID.ToString()) == true)
  1541. {
  1542. MessageBox.Show("중계기 타입 2*2 혹은 4*4 만 가능합니다", Application.ProductName);
  1543. return;
  1544. }
  1545. // cyim 2014.4.3 입력 강제 시험시에 회로정보가 없는지 확인
  1546. //
  1547. // 회로 정보
  1548. //
  1549. RepeaterPointUnit unit = GRIDCELL[RepeaterID - 1].DeviceUnit;
  1550. RepeaterDeviceTypeInfo Info = GRIDCELL[RepeaterID - 1].DeviceInfo;
  1551. if (Info == null || unit == null)
  1552. {
  1553. MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다", Application.ProductName);
  1554. return;
  1555. }
  1556. // cyim 2015.2.23 회로차단시에는 사용불가
  1557. if (Info.inDeviceTypeInfos[devID - 1].CutFlag == true
  1558. // cyim 2015.2.23 계통차단시에는 사용불가
  1559. || LoopCut() == true
  1560. // cyim 2015.2.23 중계기차단시에는 사용불가
  1561. || Info.CutFlag == true)
  1562. {
  1563. MessageBox.Show("차단중에는 사용할수 없습니다", Application.ProductName);
  1564. return;
  1565. }
  1566. //if (MessageBox.Show(string.Format("cell = {0} {1} {2} {3} {4}", CommID, BoardID, LoopNo, RepeaterID, devID), "", MessageBoxButtons.OKCancel) == DialogResult.OK) {
  1567. if (MessageBox.Show(string.Format("입력 강제 시험을 하겠습니까? 출력 연동이 될수 있습니다"), "입력 시험", MessageBoxButtons.OKCancel) == DialogResult.OK)
  1568. {
  1569. this.mdi.SetInputTestMode(true);
  1570. SocketUI ui = mdi.ui;
  1571. //명령생성 및 실행
  1572. //중계기 설정 데이터를 CmdInfo에 넣어준다..
  1573. CmdInfo cmd = new CmdInfo(
  1574. prt_cmd_define.write_repeater_input_unit,
  1575. mdi.myReceiverID,
  1576. CommID,
  1577. LoopNo,
  1578. BoardID,
  1579. RepeaterID,
  1580. null);
  1581. // cyim 2015.2.27 입력 쓰기 테스트 모드 사용중
  1582. mdi.CommandLog(MappingStatus.Log, string.Format("입력테스트 실행 CommID:{0},LoopNo:{1},BoardID:{2},RepeaterID:{3},devID:{4}", CommID, LoopNo, BoardID, RepeaterID, devID));
  1583. switch (devID)
  1584. {
  1585. case 1:
  1586. {
  1587. cmd.CommandData = (byte)0xFC;
  1588. break;
  1589. }
  1590. case 2:
  1591. {
  1592. cmd.CommandData = (byte)0xF3;
  1593. break;
  1594. }
  1595. case 3:
  1596. {
  1597. cmd.CommandData = (byte)0xCF;
  1598. break;
  1599. }
  1600. case 4:
  1601. {
  1602. cmd.CommandData = (byte)0x3F;
  1603. break;
  1604. }
  1605. }
  1606. ui.runCommand(cmd);
  1607. }
  1608. }
  1609. }
  1610. }
  1611. catch (Exception ex)
  1612. {
  1613. Util.UErrorMessage(ex, 0, 0);
  1614. }
  1615. }
  1616. // cyim 2013.3.13
  1617. // 입력쓰기 테스트 이후 복구 버튼을 눌러서 중계기 별로 복구하도록 명령한다
  1618. // 중계기 복구
  1619. private void btnRepeaterReset_Click(object sender, EventArgs e)
  1620. {
  1621. try
  1622. {
  1623. if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
  1624. {
  1625. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1626. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1627. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  1628. int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
  1629. if (no <= 127)
  1630. {
  1631. //2019-12-10 수정 QA파트 요청
  1632. //if (MessageBox.Show(string.Format("중계기 [" + no + "] 를 복구할까요?"), "중계기 복구", MessageBoxButtons.OKCancel) == DialogResult.OK)
  1633. if (MessageBox.Show(string.Format(Loop + "번 Loop를 복구할까요?"), "중계기 복구", MessageBoxButtons.OKCancel) == DialogResult.OK)
  1634. {
  1635. // MDIParent
  1636. LFC.Log("타입: 수신기 조작 로그, 메세지: 중계기 개별복구 실행");
  1637. SocketUI ui = this.mdi.ui;
  1638. //완료이벤트 (사용되어야 할지는 미지수)
  1639. dCommandResponse d = new dCommandResponse(RepeaterRecoverComplete);
  1640. //명령생성 및 실행
  1641. CmdInfo cmd = new CmdInfo(
  1642. prt_cmd_define.reset_repeater_all, // 중계기 Block 복구
  1643. mdi.myReceiverID,
  1644. 1, // 컴포트 아이디
  1645. Loop, // 채널계통
  1646. BoardID, // 통신보드
  1647. no, // 중계기 아이디
  1648. null);
  1649. ui.runCommand(cmd);
  1650. }
  1651. }
  1652. }
  1653. }
  1654. catch (Exception ex)
  1655. {
  1656. Util.UErrorMessage(ex, 0, 0);
  1657. //MessageBox.Show(ex.Message, Application.ProductName);
  1658. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  1659. }
  1660. }
  1661. // cyim 2015.6.8 아날로그 감지기 연동 추가
  1662. // 중계기 상태보기 메인 - 셀을 더블 클릭하는 경우
  1663. private void dataGridView_Repeater_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  1664. {
  1665. if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
  1666. {
  1667. //int CommID = 1;
  1668. // 보드 아이디
  1669. int BoardID = Util.StrToInt(txtBoardID.Text, 0);
  1670. // 루프 번호
  1671. int Loop = Util.StrToInt(txtLoopNo.Text, -1);
  1672. // 중계기 아이디
  1673. DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
  1674. int RepeaterID = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
  1675. RepeaterPointUnit unit = GRIDCELL[RepeaterID - 1].DeviceUnit;
  1676. RepeaterDeviceTypeInfo Info = GRIDCELL[RepeaterID - 1].DeviceInfo;
  1677. if (Info == null || unit == null)
  1678. {
  1679. MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다..", Application.ProductName);
  1680. return;
  1681. }
  1682. // 계통차단시에는 사용불가
  1683. if (LoopCut() == true
  1684. // 중계기차단시에는 사용불가
  1685. || Info.CutFlag == true)
  1686. {
  1687. MessageBox.Show("차단중에는 사용할수 없습니다..", Application.ProductName);
  1688. return;
  1689. }
  1690. // 창은 하나만 띄우도록 함
  1691. if (mdi.AnalogDetect.Form_Active_AnalogDetecter == true) // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  1692. {
  1693. MessageBox.Show("이미 실행중입니다...", Application.ProductName);
  1694. return;
  1695. }
  1696. /*
  1697. if (FormRepeater != null)
  1698. {
  1699. FormRepeater.Close();
  1700. }
  1701. FormRepeater = new FormRepeater(this.mdi);
  1702. FormRepeater.Owner = this;
  1703. FormRepeater.Visible = false;
  1704. FormRepeater.Show();// 데이타를 아직 표시하지 않았으므로 표시는 하지 않는다.
  1705. FormRepeater.Visible = false;
  1706. string[] Input_locatin = new string[4];
  1707. string[] output_locatin = new string[4];
  1708. string[] Input_context = new string[4];
  1709. string[] output_context = new string[4];
  1710. string[] Input_circuit = new string[4];
  1711. string[] output_circuit = new string[4];
  1712. string InOut_Type = "I";
  1713. //회로설정값
  1714. DacUIProcess dacUIProcess = new DacUIProcess(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  1715. for (var i = 0; i < 4; i++)
  1716. {
  1717. DataTable dt2 = dacUIProcess.Device_Select(mdi.myReceiverID, CommID, BoardID, Loop, RepeaterID, i + 1, InOut_Type);
  1718. foreach (DataRow dr2 in dt2.Rows)
  1719. {
  1720. Input_context[i] = Util.NullToStr(dr2["DEVICE_TYPE_NAME"]);
  1721. Input_locatin[i] = Util.NullToStr(dr2["POSITION_NAME"]);
  1722. Input_circuit[i] = Util.NullToStr(dr2["DEVICE_NAME"]);
  1723. }
  1724. dt2.Clear();
  1725. dt2.Dispose();
  1726. }
  1727. InOut_Type = "O";
  1728. for (var i = 0; i < 4; i++)
  1729. {
  1730. DataTable dt2 = dacUIProcess.Device_Select(mdi.myReceiverID, CommID, BoardID, Loop, RepeaterID, i + 1, InOut_Type);
  1731. foreach (DataRow dr2 in dt2.Rows)
  1732. {
  1733. output_context[i] = Util.NullToStr(dr2["DEVICE_TYPE_NAME"]);
  1734. output_locatin[i] = Util.NullToStr(dr2["POSITION_NAME"]);
  1735. output_circuit[i] = Util.NullToStr(dr2["DEVICE_NAME"]);
  1736. }
  1737. dt2.Clear();
  1738. dt2.Dispose();
  1739. }
  1740. // 입력
  1741. FormRepeater.SetInputContext1(string.Format(
  1742. "\r\n" + DeviceStatusText.InputText(unit.Repeater_Input1, Info.inDeviceTypeInfos[0]) +
  1743. "\r\n\r\n" + Input_context[0] +
  1744. "\r\n\r\n" + Input_locatin[0] +
  1745. "\r\n\r\n" + Input_circuit[0]));
  1746. FormRepeater.SetInputContext2(string.Format(
  1747. "\r\n" + DeviceStatusText.InputText(unit.Repeater_Input2, Info.inDeviceTypeInfos[1]) +
  1748. "\r\n\r\n" + Input_context[1] +
  1749. "\r\n\r\n" + Input_locatin[1] +
  1750. "\r\n\r\n" + Input_circuit[1]));
  1751. FormRepeater.SetInputContext3(string.Format(
  1752. "\r\n" + DeviceStatusText.InputText(unit.Repeater_Input3, Info.inDeviceTypeInfos[2]) +
  1753. "\r\n\r\n" + Input_context[2] +
  1754. "\r\n\r\n" + Input_locatin[2] +
  1755. "\r\n\r\n" + Input_circuit[2]));
  1756. FormRepeater.SetInputContext4(string.Format(
  1757. "\r\n" + DeviceStatusText.InputText(unit.Repeater_Input4, Info.inDeviceTypeInfos[3]) +
  1758. "\r\n\r\n" + Input_context[3] +
  1759. "\r\n\r\n" + Input_locatin[3] +
  1760. "\r\n\r\n" + Input_circuit[3]));
  1761. // 출력회로
  1762. FormRepeater.SetOutPutText1(string.Format(
  1763. "\r\n" + DeviceStatusText.OutputText(unit.Repeater_Output1, Info.outDeviceTypeInfos[0]) +
  1764. "\r\n\r\n" + output_context[0] +
  1765. "\r\n\r\n" + output_locatin[0] +
  1766. "\r\n\r\n" + output_circuit[0]));
  1767. FormRepeater.SetOutPutText2(string.Format(
  1768. "\r\n" + DeviceStatusText.OutputText(unit.Repeater_Output2, Info.outDeviceTypeInfos[1]) +
  1769. "\r\n\r\n" + output_context[1] +
  1770. "\r\n\r\n" + output_locatin[1] +
  1771. "\r\n\r\n" + output_circuit[1]));
  1772. FormRepeater.SetOutPutText3(string.Format(
  1773. "\r\n" + DeviceStatusText.OutputText(unit.Repeater_Output3, Info.outDeviceTypeInfos[2]) +
  1774. "\r\n\r\n" + output_context[2] +
  1775. "\r\n\r\n" + output_locatin[2] +
  1776. "\r\n\r\n" + output_circuit[2]));
  1777. FormRepeater.SetOutPutText4(string.Format(
  1778. "\r\n" + DeviceStatusText.OutputText(unit.Repeater_Output4, Info.outDeviceTypeInfos[3]) +
  1779. "\r\n\r\n" + output_context[3] +
  1780. "\r\n\r\n" + output_locatin[3] +
  1781. "\r\n\r\n" + output_circuit[3]));
  1782. // 위치
  1783. FormRepeater.Location = new Point(Control.MousePosition.X + 5, Control.MousePosition.Y + 5);
  1784. //표시
  1785. FormRepeater.Visible = true;
  1786. */
  1787. // 해당 셀이 중계기가 아닌 아날로그 감지기인 경우에 한하여
  1788. if (Info.RepeaterType.Equals("A") == true || Info.RepeaterType.Equals("B") == true)
  1789. {
  1790. // 특별히 경고 팝업은 생성하지 않는다
  1791. return;
  1792. }
  1793. // cyim 2016.01.07 아날로그 감지기 통신이상, 존재하지않음의 경우에는 더블클릭을 못하도록 함
  1794. if (unit.RepeaterNon == true // 존재하지 않는 감지기
  1795. || unit.RepeaterErr == true // 감지기 통신 에러
  1796. || unit.RepeaterErr == true // 감지기 전원 이상
  1797. )
  1798. {
  1799. // 특별히 경고 팝업은 생성하지 않는다
  1800. return;
  1801. }
  1802. mdi = (MDIParent)this.MdiParent;
  1803. txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
  1804. Form_AnalogDetecter AnalogDetecter = new Form_AnalogDetecter(
  1805. string.Format("{0:00}", mdi.myReceiverID),
  1806. string.Format("{0:000}", BoardID),
  1807. string.Format("{0:000}", Loop),
  1808. string.Format("{0:000}", RepeaterID),
  1809. Info.RepeaterType.ToString(),
  1810. mdi);
  1811. AnalogDetecter.Show();
  1812. }
  1813. }
  1814. }
  1815. }