frmControlMode.cs 92 KB

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