123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Collections;
- using System.Threading;
- using System.IO;
- namespace FPER
- {
- public partial class frmControlMode : Form
- {
- MDIParent mdi = null;
- //delegate void CheckBox_Event(CheckBox c, System.EventArgs e);
- CheckBox[] checkLoop0;
- CheckBox[] checkLoop1;
- // cyim 2015.2.16 계통차단이후에 차단해제의 경우에 한해서 복구 실행하도록 한다
- bool[] Check_checkLoop0 = new bool[16];
- bool[] Check_checkLoop1 = new bool[16];
- BoardTypeInfo[] brdinfos;
- delegate void deleFormInit();
- LogFileCreate LFC = new LogFileCreate();
- int selectRepNo = 0;
- //중계기 읽기를 진행하기 위해
- private Thread tRepeaterReadThread;
- private int tRepeaterReadThreadStatus = 0;
- public frmControlMode()
- {
- InitializeComponent();
- // cyim 2013.7.12 디자인개선작업 : 제어 - 중계기차단
- this.button_LoopCut.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
- // cyim 2015.2.24 쓰기버튼 사용금지
- btnOutWrite.Text = null;
- btnOutWrite.Enabled = false;
- }
- int savBoardID = -1;
- int savLoop = -1;
- //중계기및 회로 설정정보
- RepeaterDeviceTypeInfo[] REP;
- RepeaterPointUnit[] REPDATA;
- public void Form_Init()
- {
- try
- {
- if (this.InvokeRequired)
- {
- deleFormInit d = new deleFormInit(Form_Init);
- this.Invoke(d, new object[] { });
- }
- else
- {
- Board_getData();
- Repeater_getData();
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
- }
- }
- //판넬의 checkbox를 체크및 해제한다.
- private void checkPanelLoad(int BoardID, Boolean Loop0CutFlag, Boolean Loop1CutFlag)
- {
- try
- {
- this.checkLoop0[BoardID - 1].Checked = Loop0CutFlag;
- this.checkLoop1[BoardID - 1].Checked = Loop1CutFlag;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void frmControlMode_Load(object sender, EventArgs e)
- {
- // cyim 2013.8.1 : 더블버퍼링 적용
- SetStyle(ControlStyles.UserPaint, true);
- //this.UpdateStyles();
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- //this.UpdateStyles();
- SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.UpdateStyles();
- try
- {
- mdi = (MDIParent)this.MdiParent;
- txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
- txtThisReceiverID2.Text = string.Format("{0:00}", mdi.myReceiverID);
- checkLoop0 = new CheckBox[16] { checkLoop0Board1, checkLoop0Board2, checkLoop0Board3, checkLoop0Board4
- ,checkLoop0Board5, checkLoop0Board6, checkLoop0Board7, checkLoop0Board8
- ,checkLoop0Board9, checkLoop0Board10, checkLoop0Board11, checkLoop0Board12
- ,checkLoop0Board13, checkLoop0Board14, checkLoop0Board15, checkLoop0Board16 };
- checkLoop1 = new CheckBox[16]{ checkLoop1Board1, checkLoop1Board2, checkLoop1Board3, checkLoop1Board4
- ,checkLoop1Board5, checkLoop1Board6, checkLoop1Board7, checkLoop1Board8
- ,checkLoop1Board9, checkLoop1Board10, checkLoop1Board11, checkLoop1Board12
- ,checkLoop1Board13, checkLoop1Board14, checkLoop1Board15, checkLoop1Board16 };
- ReceiverTypeInfo Receiverinfo = this.mdi.ui.MyReceiverTypeInfo; //수신기설정
- this.brdinfos = Receiverinfo.MyBoardType; //통신보드설정값
- Board_getData();
- Repeater_getData();
- // cyim 2015.2.16 계통차단이후에 차단해제의 경우에 한해서 복구 실행하도록 한다
- Save_LineCutStatus();
- Reg_EventHandler_ChangeChecked();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void frmControlMode_Activated(object sender, EventArgs e)
- {
- try
- {
- this.mdi.SelectMenuIndex = 6;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void frmControlMode_Disposed(object sender, EventArgs e)
- {
- try
- {
- // cyim 2015.2.16 계통차단이후에 차단해제의 경우에 한해서 복구 실행하도록 한다
- Del_EventHandler_ChangeChecked();
- this.mdi.SelectMenuIndex = 0;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- /********************************************************************
- * 통신보드 데이터 불러오기
- *********************************************************************/
- private void Board_getData()
- {
- try
- {
- if (this.InvokeRequired)
- {
- deleFormInit d = new deleFormInit(Board_getData);
- this.Invoke(d, new object[] { });
- }
- else
- {
- for (int i = 1; i <= 16; i++)
- {
- Panel panelBoard = (Panel)Util.FineControl(tabPage_Board, "panelBoard" + i);
- UIImageChange(false, panelBoard);
- //this.chkCutFlag[i - 1].Visible = false;
- this.checkLoop0[i - 1].Visible = false;
- this.checkLoop1[i - 1].Visible = false;
- }
- DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
- DataTable dt = dacBoardConfig.Board_Select(mdi.myReceiverID, 0, null);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- int BoardId = int.Parse(Convert.ToString(dr[0]));
- Boolean Loop0CutFlag = Convert.ToString(dr["LOOP0_CUT_FLAG"]) == "Y" ? true : false;
- Boolean Loop1CutFlag = Convert.ToString(dr["LOOP1_CUT_FLAG"]) == "Y" ? true : false;
- //Boolean CutFlag = Convert.ToString(dr["CUT_FLAG"]) == "Y" ? true : false;
- Boolean Loop0UseFlag = Convert.ToString(dr["LOOP0_USE_FLAG"]) == "Y" ? true : false;
- Boolean Loop1UseFlag = Convert.ToString(dr["LOOP1_USE_FLAG"]) == "Y" ? true : false;
- Boolean UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false;
- if (UseFlag)
- {
- if (Loop0UseFlag) this.checkLoop0[BoardId - 1].Visible = true;
- if (Loop1UseFlag) this.checkLoop1[BoardId - 1].Visible = true;
- //if (Loop0UseFlag)
- //{
- // this.checkLoop0[BoardId - 1].Visible = true;
- // btnBoardN_loopN_Visible(BoardId - 1, 0, true);
- //}
- //if (Loop1UseFlag)
- //{
- // this.checkLoop1[BoardId - 1].Visible = true;
- // btnBoardN_loopN_Visible(BoardId - 1, 1, true);
- //}
- }
- Panel panelBoard = (Panel)Util.FineControl(tabPage_Board, "panelBoard" + BoardId);
- UIImageChange(UseFlag, panelBoard);
- checkPanelLoad(BoardId, Loop0CutFlag, Loop1CutFlag);
- }
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
- }
- }
- /*
- private Image ImgLoad(string path) {
- Image ret = null;
- try {
- ret = Image.FromFile(path);
- }
- catch (Exception e) {
- Util.UErrorMessage(e, 0, 0);
- }
- return ret;
- }
- private string strImgBasePath = "image";
- private string ImgBasePath { get { return Path.Combine(Directory.GetCurrentDirectory(), this.strImgBasePath); } }
- private string strImagePathPanelUse = "중계반_사용0.gif";
- private string ImagePathPanelUse { get { return Path.Combine(this.ImgBasePath, this.strImagePathPanelUse); } }
- private Image ImageLoadingPanelUse() {
- return ImgLoad(this.ImagePathPanelUse);
- }
- private string strImagePathPanelUnuse = "중계반_비사용0.gif";
- private string ImagePathPanelUnuse { get { return Path.Combine(this.ImgBasePath, this.strImagePathPanelUnuse); } }
- private Image ImageLoadingPanelUnuse() {
- return ImgLoad(this.ImagePathPanelUnuse);
- }
- */
- //사용여부 체크하면 중계반 이미지 변경 및 UI입력모드를 바꿔준다.
- private void UIImageChange(bool chkUse, Panel p)
- {
- try
- {
- if (chkUse)
- {
- // cyim 2013.8.1 디자인개선작업 : 제어 - 계통차단 ImgLstBoardUseFlag->imageList_BoardUseFlag
- p.BackgroundImage = imageList_BoardUseFlag.Images[0];
- //p.BackgroundImage = this.ImageLoadingPanelUse();
- }
- else
- {
- // cyim 2013.8.1 디자인개선작업 : 제어 - 계통차단 ImgLstBoardUseFlag->imageList_BoardUseFlag
- p.BackgroundImage = imageList_BoardUseFlag.Images[1];
- //p.BackgroundImage = this.ImageLoadingPanelUnuse();
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void btnBoardSave_Click(object sender, EventArgs e)
- {
- // cyim 2013.8.5 제어화면 버튼 포커스 조절
- this.panel_Menu.Focus();
- try
- {
- // cyim 2015.2.16 차단명령을 내리겠습니까 팝업창출력후 취소하면 진행되버리는 문제 수정
- if (MessageBox.Show("수신기에 차단명령을 내리시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
- int chkChangeCount = 0;
- //Control[] coll;
- // cyim 2013.8.2 통신보드 16은 사용안함 16->15
- for (int i = 0; i < 15; i++)
- {
- int BoardId = i + 1;
- Boolean Loop0CutFlag = false;
- Boolean Loop1CutFlag = false;
- Panel pan = (Panel)Util.FineControl(tabPage_Board, "panelBoard" + Convert.ToString(BoardId));
- CheckBox checkLoop0 = (CheckBox)Util.FineControl(pan, "checkLoop0Board" + Convert.ToString(BoardId));
- CheckBox checkLoop1 = (CheckBox)Util.FineControl(pan, "checkLoop1Board" + Convert.ToString(BoardId));
- if (checkLoop0 != null && checkLoop0.Visible)
- {
- Loop0CutFlag = checkLoop0.Checked;
- this.brdinfos[i].Loop0CutFlagChange = Loop0CutFlag;
- if (this.brdinfos[i].Loop0CutFlagChange) chkChangeCount++;
- }
- if (checkLoop1 != null && checkLoop1.Visible)
- {
- Loop1CutFlag = checkLoop1.Checked;
- this.brdinfos[i].Loop1CutFlagChange = Loop1CutFlag;
- if (this.brdinfos[i].Loop1CutFlagChange) chkChangeCount++;
- }
- //DB에 자료저장
- dacBoardConfig.Board_Cut_Update(mdi.myReceiverID, BoardId, Loop0CutFlag ? "Y" : "N", Loop1CutFlag ? "Y" : "N");
- }
- // cyim 2015.2.16 계통차단이후에 차단해제의 경우에 한해서 복구 실행하도록 한다
- bool RecoverExcuteEnable = false;
- if (chkChangeCount > 0) // 여기서 0이 들어올 확률이 있는가?.........................................................
- {
- if (Check_Change() == true)
- {
- LFC.Log("타입: 수신기 조작 로그, 메세지: 차단-계통차단 해제");
- }
- else
- {
- LFC.Log("타입: 수신기 조작 로그, 메세지: 차단-계통차단 적용");
- }
- // cyim 2015.2.17 적용하기 버튼 누르자마자 DB 에 반영되버리는 문제 수정 -> 상위에서 묻도록 함
- //if (MessageBox.Show("수신기에 차단명령을 내리시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- this.Cursor = Cursors.WaitCursor;
- /***************************************************************/
- /* 통신보드 차단명령 */
- /***************************************************************/
- frmProgress frm = new frmProgress(mdi); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
- //중계기 설정 데이터를 CmdInfo에 넣어준다..
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, 0, 0, null);
- cmd.CommandType = "DC";
- cmd.ApplyRange = "L";
- cmd.CommandData = this.brdinfos;
- frm.Commandinfo = cmd;
- frm.ui = this.mdi.ui;
- frm.ShowDialog();
- /**************************************************************/
- this.Cursor = Cursors.Default;
- // cyim 2015.2.16 계통차단이후에 차단해제의 경우에 한해서 복구 실행하도록 한다
- RecoverExcuteEnable = true;
- }
- }
- // cyim 2013.8.5 화면갱신전 대기화면 팝업창 출력
- mdi.Popup.CommonPopupShow(this); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
- // cyim 2013.9.23 화면갱신코드 추가
- this.Update();
- //수신기설정및차단카운트 다시 계산
- this.mdi.ui.ReceiverDBRead();
- // cyim 2013.8.5 화면갱신전 대기화면 팝업창 출력
- mdi.Popup.CommonPopupClose(this); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
- // cyim 2013.9.26 중계기차단 보완
- // UI 갱신
- Repeater_getData();
- // cyim 2015.2.16 계통차단이후에 차단해제의 경우에 한해서 복구 실행하도록 한다
- if (RecoverExcuteEnable == true)
- {
- if (Check_Change() == true)
- {
- mdi.FireReset_Process();
- mdi.socketUI.ReceiverDemonReset();
- }
- }
- this.label_InfoApplyComment.Visible = false;
- // 현재 상태를 저장해둔다
- Save_LineCutStatus();
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
- }
- }
- //
- // cyim 2015.2.16 계통차단이후에 차단해제의 경우에 한해서 복구 실행하도록 한다
- //
- // 현재상태가 변경되었는지 체크한다
- private bool Check_Change()
- {
- for (int i = 1; i <= 16; i++)
- {
- CheckBox uCheckBoxLoop0 = (CheckBox)Util.FineControl(tabPage_Board, "checkLoop0Board" + i);
- CheckBox uCheckBoxLoop1 = (CheckBox)Util.FineControl(tabPage_Board, "checkLoop1Board" + i);
- // 1개라도 기존의 값에서 차단해제로 변경되었는 경우에는 무조건 true 반환
- if (this.checkLoop0[i - 1].Visible == true && (uCheckBoxLoop0.Checked != Check_checkLoop0[i - 1]) && uCheckBoxLoop0.Checked == false)
- return true;
- if (this.checkLoop1[i - 1].Visible == true && (uCheckBoxLoop1.Checked != Check_checkLoop1[i - 1]) && uCheckBoxLoop1.Checked == false)
- return true;
- }
- return false;
- }
- // 화면 처음 시작 혹은 적용하기 누른후에 동작하도록 한다
- private void Save_LineCutStatus()
- {
- for (int i = 1; i <= 16; i++)
- {
- CheckBox uCheckBoxLoop0 = (CheckBox)Util.FineControl(tabPage_Board, "checkLoop0Board" + i);
- CheckBox uCheckBoxLoop1 = (CheckBox)Util.FineControl(tabPage_Board, "checkLoop1Board" + i);
- Check_checkLoop0[i - 1] = uCheckBoxLoop0.Checked;
- Check_checkLoop1[i - 1] = uCheckBoxLoop1.Checked;
- }
- }
- // 값이 변경되는 경우의 이벤트를 일괄적으로 등록한다 (주의할점 체크박스가 셋팅이 완료된후에 이벤트를 등록해야한다)
- private void Reg_EventHandler_ChangeChecked()
- {
- for (int i = 1; i <= 16; i++)
- {
- CheckBox uCheckBoxLoop0 = (CheckBox)Util.FineControl(tabPage_Board, "checkLoop0Board" + i);
- CheckBox uCheckBoxLoop1 = (CheckBox)Util.FineControl(tabPage_Board, "checkLoop1Board" + i);
- uCheckBoxLoop0.CheckStateChanged += new EventHandler(uCheckBoxLoop_CheckStateChanged);
- uCheckBoxLoop1.CheckStateChanged += new EventHandler(uCheckBoxLoop_CheckStateChanged);
- }
- }
- // 값이 변경되는 경우의 이벤트를 일괄적으로 등록한다
- private void Del_EventHandler_ChangeChecked()
- {
- for (int i = 1; i <= 16; i++)
- {
- CheckBox uCheckBoxLoop0 = (CheckBox)Util.FineControl(tabPage_Board, "checkLoop0Board" + i);
- CheckBox uCheckBoxLoop1 = (CheckBox)Util.FineControl(tabPage_Board, "checkLoop1Board" + i);
- uCheckBoxLoop0.CheckStateChanged -= new EventHandler(uCheckBoxLoop_CheckStateChanged);
- uCheckBoxLoop1.CheckStateChanged -= new EventHandler(uCheckBoxLoop_CheckStateChanged);
- }
- }
- private void uCheckBoxLoop_CheckStateChanged(object sender, EventArgs e)
- {
- if (Check_Change() == true)
- this.label_InfoApplyComment.Visible = true;
- else
- this.label_InfoApplyComment.Visible = false;
- }
- private void btnWinClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void btnInputOpen_Click(object sender, EventArgs e)
- {
- try
- {
- InputIDVo vo = new InputIDVo();
- vo.ReceiverID = int.Parse(txtThisReceiverID2.Text);
- vo.CommID = 1;
- vo.BoardID = Util.StrToInt(txtBoardID.Text, 0);
- vo.LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- IWin32Window window = this;
- frmModalLoopSelect frm = new frmModalLoopSelect(mdi);
- frm.InputVo = vo;
- frm.ShowDialog(window);
- vo = frm.InputVo;
- //입력한 코드가 있다면
- if (vo.InputOK)
- {
- txtThisReceiverID.Text = String.Format("{0:00}", vo.ReceiverID);
- txtBoardID.Text = String.Format("{0:00}", vo.BoardID);
- txtLoopNo.Text = String.Format("{0}", vo.LoopNo);
- Repeater_getData();
- // cyim 2013.9.26 중계기차단 보완
- //중계기 전체 읽기 명령
- dCommandResponse d = new dCommandResponse(RepeaterInfoAll);
- //명령생성 및 실행
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_repeater_all, mdi.myReceiverID, 1, vo.LoopNo, vo.BoardID, d);
- this.mdi.ui.runCommand(cmd);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- //cell값으로 중계기 설정을 Radio버튼에 표시
- private void RepeaterStatus(String CellText)
- {
- try
- {
- String RepeaterID = CellText;
- String RepeaterType = "";
- if (CellText.Length > 3)
- {
- RepeaterType = CellText.Substring(0, 1);
- RepeaterID = CellText.Substring(1, 3);
- }
- lblRepeaterID.Text = RepeaterID;
- //RepeaterTypeRadio(RepeaterType);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void Repeater_init()
- {
- try
- {
- //dataGridView1,dataGridView2
- try
- {
- this.dataGridView1.Columns.Clear();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- /************************************************************************/
- /* dataGridView1 헤더 설정 */
- /************************************************************************/
- DataGridViewCellStyle sty = new DataGridViewCellStyle();
- sty.Alignment = DataGridViewContentAlignment.MiddleCenter;
- for (int col = 0; col < 10; col++)
- {
- dataGridView1.Columns.Add(new DataGridViewTextBoxColumn());
- dataGridView1.Columns[col].ReadOnly = true;
- dataGridView1.Columns[col].Resizable = DataGridViewTriState.False;
- dataGridView1.Columns[col].Width = 70;
- dataGridView1.Columns[col].DefaultCellStyle = sty;
- }
- /************************************************************************/
- /************************************************************************/
- /* dataGridView1 Row 생성.. 총 127개 Cell */
- /************************************************************************/
- this.dataGridView1.Rows.Clear();
- DataGridViewRowCollection rows = this.dataGridView1.Rows;
- for (int row = 0; row <= 12; row++)
- {
- String[] rowData = new String[10];
- for (int col = 1; col <= 10; col++)
- {
- int no = row * 10 + col;
- if (no <= 127)
- {
- rowData[col - 1] = String.Format("{0:000}", no);
- //REP[no - 1] = new RepeaterDeviceTypeInfo(no); //중계기및 회로 설정정보
- }
- }
- rows.Add(rowData);
- }
- /************************************************************************/
- //중계기 설정내용 표시
- RepeaterStatus("");
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- throw ex;
- }
- }
- // cyim 2013.9.26 중계기차단 보완
- // 중계기 정보를 조회해서 하나라로 (입력 혹은 출력) 회로 차단이 있는 경우 true 반환
- private bool Repeater_GetData_Circuit_CutInfo(RepeaterDeviceTypeInfo dev, RepeaterPointUnit unit)
- {
- int Count = 0;
- if (dev == null)
- return false;
- // cyim 2015.6.8 아날로그 감지기 연동 추가
- // '1' = A : 2X2
- // '2' = B : 4X4
- // '4' = C : 아날로그연감지기
- // '5' = D : 아날로그열감지기
- if (dev.RepeaterType.Equals("A"))
- Count = 2;
- else if (dev.RepeaterType.Equals("B"))
- Count = 4;
- else if (dev.RepeaterType.Equals("C") || dev.RepeaterType.Equals("D"))
- Count = 1;
- else
- return false;
- // 검색하는 경우 하나라로 차단이 있는 경우가 있는지 살펴본다
- for (int i = 0; i < Count; i++)
- {
- // cyim 2013.10.2 : 입력 출력 쌍으로 존재하지않으면 에러가 발생함
- // 입력
- if (dev.inDeviceTypeInfos[i] != null && dev.inDeviceTypeInfos[i].CutFlag == true)
- return true;
- // 출력
- else if (dev.outDeviceTypeInfos[i] != null && dev.outDeviceTypeInfos[i].CutFlag == true)
- return true;
- }
- // 단, 출력은 차단 플래그가 설정이 안되어있더라도 블럭킹이 되어있다면 차단으로 한다 (본래 코드에는 이렇게 되어있으므로 그대로 적용함)
- if (unit == null)
- return false;
- else
- {
- // '1' = A : 2X2
- if (Count == 2)
- {
- if (unit.Repeater_Output1 == OutputDeviceStatus.Blocking)
- return true;
- else if (unit.Repeater_Output2 == OutputDeviceStatus.Blocking)
- return true;
- }
- // '2' = B : 4X4
- else if (Count == 4)
- {
- if (unit.Repeater_Output1 == OutputDeviceStatus.Blocking)
- return true;
- else if (unit.Repeater_Output2 == OutputDeviceStatus.Blocking)
- return true;
- else if (unit.Repeater_Output3 == OutputDeviceStatus.Blocking)
- return true;
- else if (unit.Repeater_Output4 == OutputDeviceStatus.Blocking)
- return true;
- }
- // '4' = C : 아날로그연감지기
- // '5' = D : 아날로그열감지기
- else
- {
- if (unit.Repeater_Output1 == OutputDeviceStatus.Blocking) // cyim 2015.7.6 차단의 경우 아날로그 감지기는 입력은 1개뿐이므로 루틴을 새로 추가한다
- return true;
- }
- }
- return false;
- }
- //중계기 DB에서 자료가져오기
- private void Repeater_getData()
- {
- try
- {
- if (this.InvokeRequired)
- {
- deleFormInit d = new deleFormInit(Repeater_getData);
- this.Invoke(d, new object[] { });
- }
- else
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- bool LoopCutFlag = false;
- //if (BoardID == savBoardID && LoopNo == savLoop) return;
- savBoardID = BoardID;
- savLoop = LoopNo;
- Repeater_init();
- ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
- BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(savBoardID); //통신보드savBoardID의 loop0의 설정값
- if (savLoop == 0)
- {
- LoopCutFlag = brdinfo.Loop0CutFlag;
- REP = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
- REPDATA = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
- }
- else
- {
- LoopCutFlag = brdinfo.Loop1CutFlag;
- REP = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
- REPDATA = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
- }
- int rowCnt = 0, colCnt = 0;
- //중계기 비사용 스타일
- DataGridViewCellStyle styUnUse = new DataGridViewCellStyle();
- styUnUse.Alignment = DataGridViewContentAlignment.MiddleCenter;
- styUnUse.BackColor = System.Drawing.Color.White;
- // 중계기 사용 스타일
- DataGridViewCellStyle styUse = new DataGridViewCellStyle();
- styUse.Alignment = DataGridViewContentAlignment.MiddleCenter;
- styUse.BackColor = System.Drawing.Color.Aqua;
- // cyim 2013.9.26 중계기차단 보완
- // 중계기 차단은 회색이며, 중계기차단이 아닌 1개이상 회로차단인 경우 색상은 구분되어야 한다
- // 회로차단 스타일
- DataGridViewCellStyle styOut_Circuit = new DataGridViewCellStyle();
- styOut_Circuit.Alignment = DataGridViewContentAlignment.MiddleCenter;
- styOut_Circuit.BackColor = System.Drawing.Color.Pink;
- // 중계기 차단 스타일
- DataGridViewCellStyle styOut = new DataGridViewCellStyle();
- styOut.Alignment = DataGridViewContentAlignment.MiddleCenter;
- styOut.BackColor = System.Drawing.Color.Silver;
- foreach (DataGridViewRow row in this.dataGridView1.Rows)
- {
- colCnt = 0;
- foreach (DataGridViewCell col in row.Cells)
- {
- ++colCnt;
- int no = rowCnt * 10 + colCnt;
- if (no <= 127)
- {
- if (LoopCutFlag)
- {
- col.Style = styOut;
- }
- else
- {
- RepeaterDeviceTypeInfo dev = REP[no - 1]; //중계기및 회로 설정정보
- if (dev != null)
- {
- if (dev.RepeaterType != null)
- col.Value = String.Format("{0}{1:000}", dev.RepeaterType, no);
- else
- col.Value = String.Format("{0:000}", no);
- if (dev.UseFlag)
- {
- if (dev.CutFlag)
- {
- col.Style = styOut;
- }
- else
- {
- // cyim 2013.9.26 중계기차단 보완
- // 중계기 차단은 회색이며, 중계기차단이 아닌 1개이상 회로차단인 경우 색상은 구분되어야 한다
- // 단, 중계기 차단이 먼저 우선순위가 높으므로 나중에 중계기 차단 스타일이 있다면 적용된다
- if (Repeater_GetData_Circuit_CutInfo(REP[no - 1], REPDATA[no - 1]) == true)
- col.Style = styOut_Circuit;
- else
- col.Style = styUse;
- }
- }
- else
- {
- col.Style = styUnUse;
- }
- }
- else
- {
- col.Value = String.Format("{0:000}", no);
- col.Style = styUnUse;
- }
- }
- }
- }
- ++rowCnt;
- }
- if (this.selectRepNo > 0)
- {
- if (dataGridView1.SelectedCells.Count > 0)
- {
- foreach (DataGridViewCell cell in dataGridView1.SelectedCells)
- {
- cell.Selected = false;
- }
- }
- int row = (this.selectRepNo - 1) / 10;
- int col = (this.selectRepNo - 1) % 10;
- dataGridView1.Rows[row].Cells[col].Selected = true;
- }
- else
- {
- this.selectRepNo = 1;
- }
- //중계기가 선택되므로 회로 표시
- if (REP[this.selectRepNo - 1] != null)
- {
- if (REP[this.selectRepNo - 1].RepeaterType != null) RepeaterStatus(String.Format("{0}{1:000}", REP[this.selectRepNo - 1].RepeaterType, this.selectRepNo));
- else RepeaterStatus(string.Format("{0:000}", this.selectRepNo));
- }
- else
- {
- RepeaterStatus(string.Format("{0:000}", this.selectRepNo));
- }
- DeviceStatus(REP[this.selectRepNo - 1], REPDATA[this.selectRepNo - 1]);
- if (LoopCutFlag)
- {
- chkRepeaterCut.Enabled = false; //중계기차단
- chkDeviceCutFlag.Enabled = false; //회로차단
- btnInWrite.Enabled = false;
- btnOutWrite.Enabled = false;
- }
- // cyim 2014.4.3 : 화면 전환시에 중계기가 없는 경우에도 회로차단 버튼이 활성화된다
- // 루프가 차단이라면 전부 비활성화가 맞다
- // 아래 버튼의 활성화는 주석으로 처리함. DeviceStatus 에서 이미 처리함
- //else
- //{
- // chkRepeaterCut.Enabled = true;
- // chkDeviceCutFlag.Enabled = true; // 이미 상위에서 처리함
- // btnInWrite.Enabled = true;
- // btnOutWrite.Enabled = true;
- //}
- if (LoopCutFlag)
- {
- //MessageBox.Show(string.Format("해당 계통은 차단설정 중입니다.. 통신보드[{0}] 계통[{1}] 차단설정 해제후 제어하십시요..", savBoardID, LoopNo));
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
- // throw ex;
- }
- }
- //선택셀이 바뀔때마다 해당중계기 설정내용 및 데이터 표시
- private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (dataGridView1.SelectedCells.Count > 0)
- {
- DataGridViewCell cell = this.dataGridView1.SelectedCells[0];
- int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- this.selectRepNo = no; //선택중계기 저장
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- // throw ex;
- }
- }
- //선택셀이 바뀔때마다 해당중계기 설정내용 및 데이터 표시
- private void dataGridView1_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (dataGridView1.SelectedCells.Count > 0)
- {
- DataGridViewCell cell = this.dataGridView1.SelectedCells[0];
- int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- if (no > 127)
- {
- lblRepeaterID.Text = "";
- DeviceStatus(null, null);
- return;
- }
- else
- {
- lblRepeaterID.Text = String.Format("{0:000}", no);
- if (REP[no - 1] != null)
- {
- DeviceStatus(REP[no - 1], REPDATA[no - 1]);
- }
- else
- {
- DeviceStatus(null, null);
- }
- }
- }
- // cyim 2014.4.3 : 화면 전환시에 중계기가 없는 경우에도 회로차단 버튼이 활성화된다
- else
- DeviceStatus(null, null);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- //선택셀이 바뀔때마다 해당중계기 설정내용 및 데이터 표시
- private void dataGridView2_SelectionChanged(object sender, EventArgs e)
- {
- // cyim 2014.4.3 : 회로차단 및 쓰기 방지
- bool InDBCircuit = false; // 데이타베이스에 회로정보가 있는지 여부
- txtDeviceTypeName.Text = "";
- txtPositionName.Text = "";
- txtDeviceMemo.Text = "";
- // 수정(lch_13.08.28)
- // UI를 리셋
- chkDeviceCutFlag.Text = "회로차단";
- chkDeviceCutFlag.Checked = false;
- if (dataGridView1.SelectedCells.Count > 0 && dataGridView2.SelectedCells.Count > 0)
- {
- try
- {
- int CommID = 1;
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- DataGridViewCell repCell = this.dataGridView1.SelectedCells[0];
- int RepeaterID = (repCell.RowIndex * 10) + repCell.ColumnIndex + 1;
- DataGridViewCell devCell = this.dataGridView2.SelectedCells[0];
- string InOut_Type = "I";
- if (devCell.RowIndex > 0) InOut_Type = "O";
- int deviceId = devCell.ColumnIndex + 1;
- //회로설정값
- DacUIProcess dacUIProcess = new DacUIProcess(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
- DataTable dt2 = dacUIProcess.Device_Select(mdi.myReceiverID, CommID, BoardID, LoopNo, RepeaterID, deviceId, InOut_Type);
- foreach (DataRow dr2 in dt2.Rows)
- {
- // cyim 2014.4.3 : 회로차단 및 쓰기 방지
- InDBCircuit = true;
- txtDeviceTypeName.Text = Util.NullToStr(dr2["DEVICE_TYPE_NAME"]);
- txtPositionName.Text = Util.NullToStr(dr2["POSITION_NAME"]);
- txtDeviceMemo.Text = Util.NullToStr(dr2["DEVICE_NAME"]);
- String CutFlag = Util.NullToStr(dr2["CUT_FLAG"]);
- // 수정(lch_13.08.28) - 차단이 되어있는거는 "차단해제" 버튼으로 올라오게 하기 위해서
- if (CutFlag.Equals("Y"))
- {
- chkDeviceCutFlag.Checked = true;
- chkDeviceCutFlag.Text = "차단해제";
- }
- else
- {
- chkDeviceCutFlag.Checked = false;
- }
- }
- // cyim 2015.2.17 계통차단시에는 사용불가
- //int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- //int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- bool LoopCutFlag = false;
- savBoardID = BoardID;
- savLoop = LoopNo;
- ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
- BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(savBoardID); //통신보드savBoardID의 loop0의 설정값
- if (savLoop == 0)
- {
- LoopCutFlag = brdinfo.Loop0CutFlag;
- //REP = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
- //REPDATA = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
- }
- else
- {
- LoopCutFlag = brdinfo.Loop1CutFlag;
- //REP = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
- //REPDATA = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
- }
- // cyim 2014.4.3 : 회로차단 및 쓰기 방지
- if (InDBCircuit == false)
- {
- // 데이타가 없다면 사용불가
- btnInWrite.Enabled = false;
- btnOutWrite.Enabled = false;
- chkDeviceCutFlag.Enabled = false;
- }
- else
- {
- btnInWrite.Enabled = true;
- //btnOutWrite.Enabled = true; // cyim 2015.2.24 쓰기버튼 사용금지
- //chkDeviceCutFlag.Enabled = true; // 상위에서 처리함
- // cyim 2015.2.17 계통차단시에는 사용불가
- if (LoopCutFlag == true)
- {
- chkRepeaterCut.Enabled = false;
- btnInWrite.Enabled = false;
- btnOutWrite.Enabled = false;
- chkDeviceCutFlag.Enabled = false;
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- }
- //dataGridView2에 중계기 회로정보 표시
- private void DeviceStatus(RepeaterDeviceTypeInfo dt, RepeaterPointUnit unit)
- {
- try
- {
- //dataGridView2
- //this.dataGridView2.Columns.Clear();
- this.dataGridView2.Rows.Clear();
- if (dt != null)
- {
- chkRepeaterCut.Enabled = true;
- if (dt.UseFlag && dt.CutFlag)
- {
- chkRepeaterCut.Checked = true;
- btnInWrite.Enabled = false;
- btnOutWrite.Enabled = false;
- chkDeviceCutFlag.Enabled = false;
- }
- else
- {
- chkRepeaterCut.Checked = false;
- btnInWrite.Enabled = true;
- //btnOutWrite.Enabled = true; // cyim 2015.2.24 쓰기버튼 사용금지
- chkDeviceCutFlag.Enabled = true;
- }
- //
- // cyim 2014.4.3 : 계통차단시에도 버튼비활성화
- //
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- bool LoopCutFlag = false;
- savBoardID = BoardID;
- savLoop = LoopNo;
- ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
- BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(savBoardID); //통신보드savBoardID의 loop0의 설정값
- if (savLoop == 0)
- {
- LoopCutFlag = brdinfo.Loop0CutFlag;
- //REP = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
- //REPDATA = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
- }
- else
- {
- LoopCutFlag = brdinfo.Loop1CutFlag;
- //REP = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
- //REPDATA = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
- }
- if (LoopCutFlag == true)
- {
- chkRepeaterCut.Enabled = false;
- btnInWrite.Enabled = false;
- btnOutWrite.Enabled = false;
- chkDeviceCutFlag.Enabled = false;
- }
- DataGridViewCellStyle sty = new DataGridViewCellStyle();
- sty.Alignment = DataGridViewContentAlignment.MiddleCenter;
- sty.BackColor = System.Drawing.Color.White;
- DataGridViewCellStyle styGray = new DataGridViewCellStyle();
- styGray.Alignment = DataGridViewContentAlignment.MiddleCenter;
- styGray.BackColor = System.Drawing.Color.Gray;
- styGray.SelectionBackColor = System.Drawing.Color.Gray;
- if (dt.RepeaterType.Equals("A"))
- {
- for (int col = 0; col < 2; col++)
- {
- //dataGridView2.Columns.Add(new DataGridViewTextBoxColumn());
- dataGridView2.Columns[col].ReadOnly = true;
- dataGridView2.Columns[col].Resizable = DataGridViewTriState.False;
- dataGridView2.Columns[col].Width = 90;
- dataGridView2.Columns[col].DefaultCellStyle = sty;
- }
- //dt.InType3 = "";
- //dt.InType4 = "";
- //dt.OutType3 = "";
- //dt.OutType4 = "";
- // cyim 2015.6.8 아날로그 감지기 연동 추가 : 아래 소스는 필요없음
- //dataGridView2.Columns[2].ReadOnly = true;
- //dataGridView2.Columns[2].Resizable = DataGridViewTriState.False;
- //dataGridView2.Columns[2].Width = 90;
- //dataGridView2.Columns[2].DefaultCellStyle = styGray;
- //dataGridView2.Columns[3].ReadOnly = true;
- //dataGridView2.Columns[3].Resizable = DataGridViewTriState.False;
- //dataGridView2.Columns[3].Width = 90;
- //dataGridView2.Columns[3].DefaultCellStyle = styGray;
- }
- else if (dt.RepeaterType.Equals("B"))
- {
- for (int col = 0; col < 4; col++)
- {
- //dataGridView2.Columns.Add(new DataGridViewTextBoxColumn());
- dataGridView2.Columns[col].ReadOnly = true;
- dataGridView2.Columns[col].Resizable = DataGridViewTriState.False;
- dataGridView2.Columns[col].Width = 90;
- dataGridView2.Columns[col].DefaultCellStyle = sty;
- }
- }
- // cyim 2015.6.8 아날로그 감지기 연동 추가
- else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))
- {
- for (int col = 0; col < 1; col++)
- {
- dataGridView2.Columns[col].ReadOnly = true;
- dataGridView2.Columns[col].Resizable = DataGridViewTriState.False;
- dataGridView2.Columns[col].Width = 90;
- dataGridView2.Columns[col].DefaultCellStyle = sty;
- }
- }
- //회로입력,출력값 표시
- if (unit != null)
- {
- DataGridViewRowCollection rows2 = this.dataGridView2.Rows;
- if (dt != null)
- {
- if (dt.RepeaterType.Equals("A"))
- {
- // 수정(lch_13.08.28) - 디바이스 정보 출력 에러 해결
- // 입력 디바이스
- String[] inData = new String[2];
- for (int i = 0; i < 2; i++)
- {
- if (dt.inDeviceTypeInfos[i] == null)
- {
- inData[i] = "-";
- }
- else
- {
- if (i == 0) inData[i] = DeviceStatusText.InputText(unit.Repeater_Input1, dt.inDeviceTypeInfos[i].CutFlag);
- else inData[i] = DeviceStatusText.InputText(unit.Repeater_Input2, dt.inDeviceTypeInfos[i].CutFlag);
- }
- }
- // 출력 디바이스
- String[] outData = new String[2];
- for (int i = 0; i < 2; i++)
- {
- if (dt.outDeviceTypeInfos[i] == null)
- {
- outData[i] = "-";
- }
- else
- {
- if (i == 0) outData[i] = DeviceStatusText.OutputText(unit.Repeater_Output1, dt.outDeviceTypeInfos[i].CutFlag);
- else outData[i] = DeviceStatusText.OutputText(unit.Repeater_Output2, dt.outDeviceTypeInfos[i].CutFlag);
- }
- }
- //기존꺼
- //String[] inData = { DeviceStatusText.InputText(unit.Repeater_Input1,dt.inDeviceTypeInfos[0].CutFlag)
- // , DeviceStatusText.InputText(unit.Repeater_Input2,dt.inDeviceTypeInfos[1].CutFlag), "", "" };
- //String[] outData = { DeviceStatusText.OutputText(unit.Repeater_Output1,dt.outDeviceTypeInfos[0].CutFlag)
- // , DeviceStatusText.OutputText(unit.Repeater_Output2,dt.outDeviceTypeInfos[1].CutFlag), "", "" };
- rows2.Add(inData);
- rows2.Add(outData);
- }
- else if (dt.RepeaterType.Equals("B"))
- {
- // 수정(lch_13.08.28) - 디바이스 정보 출력 에러 해결
- // 입력 디바이스
- String[] inData = new String[4];
- for (int i = 0; i < 4; i++)
- {
- if (dt.inDeviceTypeInfos[i] == null)
- {
- inData[i] = "-";
- }
- else
- {
- if (i == 0) inData[i] = DeviceStatusText.InputText(unit.Repeater_Input1, dt.inDeviceTypeInfos[i].CutFlag);
- else if (i == 1) inData[i] = DeviceStatusText.InputText(unit.Repeater_Input2, dt.inDeviceTypeInfos[i].CutFlag);
- else if (i == 2) inData[i] = DeviceStatusText.InputText(unit.Repeater_Input3, dt.inDeviceTypeInfos[i].CutFlag);
- else if (i == 3) inData[i] = DeviceStatusText.InputText(unit.Repeater_Input4, dt.inDeviceTypeInfos[i].CutFlag);
- }
- }
- // 출력 디바이스
- String[] outData = new String[4];
- for (int i = 0; i < 4; i++)
- {
- if (dt.outDeviceTypeInfos[i] == null)
- {
- outData[i] = "-";
- }
- else
- {
- if (i == 0) outData[i] = DeviceStatusText.OutputText(unit.Repeater_Output1, dt.outDeviceTypeInfos[i].CutFlag);
- else if (i == 1) outData[i] = DeviceStatusText.OutputText(unit.Repeater_Output2, dt.outDeviceTypeInfos[i].CutFlag);
- else if (i == 2) outData[i] = DeviceStatusText.OutputText(unit.Repeater_Output3, dt.outDeviceTypeInfos[i].CutFlag);
- else if (i == 3) outData[i] = DeviceStatusText.OutputText(unit.Repeater_Output4, dt.outDeviceTypeInfos[i].CutFlag);
- }
- }
- //String[] inData = { DeviceStatusText.InputText(unit.Repeater_Input1,dtCutFlag(dt.inDeviceTypeInfos[0]))
- // , DeviceStatusText.InputText(unit.Repeater_Input2,dtCutFlag(dt.inDeviceTypeInfos[1]))
- // , DeviceStatusText.InputText(unit.Repeater_Input3,dtCutFlag(dt.inDeviceTypeInfos[2]))
- // , DeviceStatusText.InputText(unit.Repeater_Input4,dtCutFlag(dt.inDeviceTypeInfos[3])) };
- //String[] outData = { DeviceStatusText.OutputText(unit.Repeater_Output1,dtCutFlag(dt.outDeviceTypeInfos[0]))
- // , DeviceStatusText.OutputText(unit.Repeater_Output2,dtCutFlag(dt.outDeviceTypeInfos[1]))
- // , DeviceStatusText.OutputText(unit.Repeater_Output3,dtCutFlag(dt.outDeviceTypeInfos[2]))
- // , DeviceStatusText.OutputText(unit.Repeater_Output4,dtCutFlag(dt.outDeviceTypeInfos[3])) };
- rows2.Add(inData);
- rows2.Add(outData);
- }
- // cyim 2015.6.8 아날로그 감지기 연동 추가
- else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))
- {
- // 입력 디바이스
- String[] inData = new String[1];
- for (int i = 0; i < 1; i++)
- {
- if (dt.inDeviceTypeInfos[i] == null)
- {
- inData[i] = "-";
- }
- else
- {
- if (i == 0) inData[i] = DeviceStatusText.InputText(unit.Repeater_Input1, dt.inDeviceTypeInfos[i].CutFlag);
- else inData[i] = DeviceStatusText.InputText(unit.Repeater_Input2, dt.inDeviceTypeInfos[i].CutFlag);
- }
- }
- // 출력 디바이스
- String[] outData = new String[1];
- for (int i = 0; i < 1; i++)
- {
- if (dt.outDeviceTypeInfos[i] == null)
- {
- outData[i] = "-";
- }
- else
- {
- if (i == 0) outData[i] = DeviceStatusText.OutputText(unit.Repeater_Output1, dt.outDeviceTypeInfos[i].CutFlag);
- else outData[i] = DeviceStatusText.OutputText(unit.Repeater_Output2, dt.outDeviceTypeInfos[i].CutFlag);
- }
- }
- rows2.Add(inData);
- rows2.Add(outData);
- }
- }
- }
- else
- {
- DataGridViewRowCollection rows2 = this.dataGridView2.Rows;
- if (dt != null)
- {
- // cyim 2013.9.26 중계기차단 보완 : 초기화값을 숫자에서 - 로 변경
- //case InputDeviceStatus.Init: toText = " - "; break;
- //case InputDeviceStatus.Use: toText = "감지"; break;
- //case InputDeviceStatus.Normal: toText = "정상"; break;
- //case InputDeviceStatus.Blocking: toText = "단선"; break;
- if (dt.RepeaterType.Equals("A"))
- {
- // cyim 2014.4.3 : 초기값 수정 1,2,3,4 -> "-"
- //String[] inData = { "1", "2", "", "" };
- //String[] outData = { "1", "2", "", "" };
- String[] inData = { "-", "-", "", "" };
- String[] outData = { "-", "-", "", "" };
- rows2.Add(inData);
- rows2.Add(outData);
- }
- else if (dt.RepeaterType.Equals("B"))
- {
- //String[] inData = { "", "2", "3", "4" };
- //String[] outData = { "1", "2", "3", "4" };
- String[] inData = { "-", "-", "-", "-" };
- String[] outData = { "-", "-", "-", "-" };
- rows2.Add(inData);
- rows2.Add(outData);
- }
- // cyim 2015.6.8 아날로그 감지기 연동 추가
- else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))
- {
- String[] inData = { "-", "", "", "" };
- String[] outData = { "-", "", "", "" };
- rows2.Add(inData);
- rows2.Add(outData);
- }
- }
- }
- }
- else
- {
- chkRepeaterCut.Enabled = false;
- btnInWrite.Enabled = false;
- btnOutWrite.Enabled = false;
- chkDeviceCutFlag.Enabled = false;
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private Boolean dtCutFlag(DeviceTypeInfo dtInfo)
- {
- bool cutFlag = false;
- if (dtInfo != null) cutFlag = dtInfo.CutFlag;
- return cutFlag;
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- // cyim 2013.8.5 제어화면 버튼 포커스 조절
- this.panel_Menu.Focus();
- try
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- // cyim 2013.8.2 화면 전환시에 라벨 사라지는 문제 : label1 -> label_Comment
- if (BoardID == 0)
- {
- this.label_Comment.Text = string.Format("통신보드ID를 입력하여 주십시요.");
- this.label_Comment.Visible = true;
- //MessageBox.Show("통신보드ID를 입력하여 주십시요.", Application.ProductName);
- txtBoardID.Focus();
- return;
- }
- else if (Loop != 0 && Loop != 1)
- {
- this.label_Comment.Text = string.Format("Loop No를 올바르게 입력하여 주십시요");
- this.label_Comment.Visible = true;
- //MessageBox.Show("Loop No를 올바르게 입력하여 주십시요.", Application.ProductName);
- txtLoopNo.Focus();
- return;
- }
- else
- {
- this.label_Comment.Visible = false;
- }
- Repeater_getData();
- // 수정(lch_13.08.28)
- //중계기 전체 읽기 명령
- dCommandResponse d = new dCommandResponse(RepeaterInfoAll);
- //명령생성 및 실행
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_repeater_all, mdi.myReceiverID, 1, Loop, BoardID, d);
- this.mdi.ui.runCommand(cmd);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void btnRepeaterAllInfo_Click(object sender, EventArgs e)
- {
- // cyim 2013.8.5 제어화면 버튼 포커스 조절
- this.panel_Menu.Focus();
- try
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- // cyim 2013.8.2 화면 전환시에 라벨 사라지는 문제 : label1 -> label_Comment
- if (BoardID == 0)
- {
- this.label_Comment.Text = string.Format("통신보드ID를 입력하여 주십시요.");
- this.label_Comment.Visible = true;
- //MessageBox.Show("통신보드ID를 입력하여 주십시요.", Application.ProductName);
- txtBoardID.Focus();
- return;
- }
- else if (Loop != 0 && Loop != 1)
- {
- this.label_Comment.Text = string.Format("Loop No를 올바르게 입력하여 주십시요");
- this.label_Comment.Visible = true;
- //MessageBox.Show("Loop No를 올바르게 입력하여 주십시요.", Application.ProductName);
- txtLoopNo.Focus();
- return;
- }
- else
- {
- this.label_Comment.Visible = false;
- }
- //버튼 비활성 설정
- button_end(false);
- LFC.Log("타입: 수신기 조작 로그, 메세지: 차단-읽기명령 클릭");
- //중계기 전체 읽기 명령
- dCommandResponse d = new dCommandResponse(RepeaterInfoAll);
- //명령생성 및 실행
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_repeater_all, mdi.myReceiverID, 1, Loop, BoardID, d);
- this.mdi.ui.runCommand(cmd);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
- }
- }
- //*********************************************************************//
- // 중계기 전체읽기 응답데이터 이벤트 //
- //*********************************************************************//
- public void RepeaterInfoAll(CmdInfo cmd)
- {
- //에러응답처리
- if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_ReadRepeaterPointAll")) // cyim 2015.7.23 NACK 처리 부분 오류
- {
- button_end(true);
- return;
- }
- try
- {
- RCVData_ReadRepeaterPointAll ResponseData = (RCVData_ReadRepeaterPointAll)cmd.ResponseData;
- RepeaterData[] data = ResponseData.Data;
- if (cmd.Command == prt_cmd_define.read_repeater_all || cmd.ResCommand == prt_res_define.read_repeater_all)
- {
- if (savBoardID == cmd.boardNo && savLoop == cmd.loopNo)
- {
- for (int repeaterNo = 0; repeaterNo < data.Length; repeaterNo++)
- {
- REPDATA[repeaterNo] = new RepeaterPointUnit(repeaterNo + 1, data[repeaterNo]);
- }
- Repeater_getData();
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]{1}", ex.StackTrace, ex.Message), Application.ProductName);
- }
- finally
- {
- //버튼 비활성 해제
- button_end(true);
- }
- }
- //화면 마우스 커서 및 버튼 다시 클릭 못하도록 설정 및 해제
- private void button_end(Boolean val)
- {
- if (val)
- {
- this.btnRepeaterAllInfo.Enabled = true;
- this.Cursor = Cursors.Default;
- }
- else
- {
- this.btnRepeaterAllInfo.Enabled = false;
- this.Cursor = Cursors.WaitCursor;
- }
- }
- private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (tabControl_Main.SelectedIndex == 1)
- {
- // cyim 2015.2.17 화면 전환시 잘못된 정보가 올라옴 (단, 아래 주석 처리함, 어차피 btnRepeaterAllInfo_Click 에서 처리하도록 되어있음)
- //Repeater_getData();
- //중계기 회로 데이터 읽기 명령
- btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty);
- }
- else
- {
- // cyim 2015.2.17 화면 전환시 잘못된 정보가 올라옴
- Board_getData();
- this.tRepeaterReadThreadStatus = 0;
- }
- }
- void RepeaterInfoRead()
- {
- try
- {
- while (tRepeaterReadThreadStatus > 0)
- {
- if (this.mdi.ui.Connected)
- {
- try
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- if (BoardID == 0)
- {
- tRepeaterReadThreadStatus = 0;
- }
- if (Loop != 0 && Loop != 1)
- {
- tRepeaterReadThreadStatus = 0;
- }
- tRepeaterReadThreadStatus++;
- //중계기 전체 읽기 명령
- dCommandResponse d = new dCommandResponse(RepeaterInfoAll);
- //명령생성 및 실행
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_repeater_all, mdi.myReceiverID, 1, Loop, BoardID, d);
- this.mdi.ui.runCommand(cmd);
- if (tRepeaterReadThreadStatus > 4) tRepeaterReadThreadStatus = 0;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- tRepeaterReadThreadStatus = 0;
- }
- Thread.Sleep(1000);
- }
- else
- {
- tRepeaterReadThreadStatus = 0;
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- tRepeaterReadThreadStatus = 0;
- }
- }
- private void chkRepeaterCut_Click(object sender, EventArgs e)
- {
- if (dataGridView1.SelectedCells.Count > 0)
- {
- try
- {
- bool chkCutFlag = chkRepeaterCut.Checked ? false : true;
- int cutActionCnt = 0;
- if (MessageBox.Show(string.Format("중계기 차단{0} 명령을 수행하시겠습니까?", chkCutFlag ? "설정" : "해제")
- , Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- this.Cursor = Cursors.WaitCursor;
- DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
- //int CommID = 1;
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- //DataGridViewCell repCell = this.dataGridView1.SelectedCells[0];
- //int RepeaterID = (repCell.RowIndex * 10) + repCell.ColumnIndex + 1;
- //REP[RepeaterID - 1].CutFlag = true;
- foreach (DataGridViewCell repCell in this.dataGridView1.SelectedCells)
- {
- int RepeaterID = (repCell.RowIndex * 10) + repCell.ColumnIndex + 1;
- if (REP[RepeaterID - 1] != null)
- {
- if (REP[RepeaterID - 1].CutFlag != chkCutFlag)
- {
- //이미 변경이 이루어 진거라면 다시 원상태로 회복.
- if (REP[RepeaterID - 1].CutFlagChange)
- {
- REP[RepeaterID - 1].CutFlagChangeReset();
- }
- else
- {
- REP[RepeaterID - 1].CutFlagChange = chkCutFlag;
- }
- dacRepeaterConfig.Repeater_Cut_Update(mdi.myReceiverID, BoardID, LoopNo, RepeaterID, chkCutFlag ? "Y" : "N");
- cutActionCnt++;
- }
- }
- }
- if (cutActionCnt < 1)
- {
- this.Cursor = Cursors.Default;
- MessageBox.Show("중계기설정을 확인 하십시요.. 차단설정을 할 수 없습니다.", Application.ProductName);
- return;
- }
- if (chkCutFlag)
- {
- LFC.Log("타입: 수신기 조작 로그, 메세지: 차단-중계기차단 설정");
- }
- else
- {
- LFC.Log("타입: 수신기 조작 로그, 메세지: 차단-중계기차단 해제");
- }
- /******************************************/
- /* 중계기 차단 명령 Progress 표시 */
- /******************************************/
- frmProgress frm = new frmProgress(mdi); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, LoopNo, BoardID, null);
- cmd.CommandType = "DC";
- cmd.ApplyRange = "R"; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
- cmd.CommandData = REP;
- frm.Commandinfo = cmd;
- frm.ui = this.mdi.ui;
- frm.ShowDialog();
- ///******************************************/
- // cyim 2013.8.5 화면갱신전 대기화면 팝업창 출력
- mdi.Popup.CommonPopupShow(this); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
- // cyim 2013.9.23 화면갱신코드 추가
- this.Update();
- this.mdi.ui.ReceiverDBRead(); //수신기설정및차단카운트 다시 계산
- this.Cursor = Cursors.Default;
- //체크상태를 변경해준다..
- chkRepeaterCut.Checked = chkCutFlag;
- // cyim 2013.8.5 화면갱신전 대기화면 팝업창 출력 + 중복루틴 제거
- mdi.Popup.CommonPopupClose(this); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
- //this.mdi.ui.ReceiverDBRead(); //수신기설정및차단카운트 다시 계산
- // cyim 2013.9.23 화면갱신코드 추가
- this.Update();
- //중계기 회로 데이터 읽기 명령
- btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty);
- // cyim 2013.9.26 중계기차단 보완
- // UI 갱신
- Repeater_getData();
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]{1}", ex.StackTrace, ex.Message), Application.ProductName);
- }
- }
- }
- //회로차단명령
- private void chkDeviceCutFlag_Click(object sender, EventArgs e)
- {
- // cyim 2014.4.3 : 화면 전환시에 중계기가 없는 경우에도 회로차단 버튼이 활성화된다 : 조건 추가
- // 수정(lch_13.08.28) - 중계기 2*2의 회색 배경으로 된 34번 디바이스를 클릭하였을 경우는 회로 차단을 하지 못함
- if (dataGridView2.SelectedCells.Count == 0 || this.dataGridView2.SelectedCells[0].Value == null)
- {
- return;
- }
- if (dataGridView2.SelectedCells.Count > 0 && !lblRepeaterID.Text.Equals(""))
- {
- try
- {
- bool chkCutFlag = chkDeviceCutFlag.Checked ? false : true;
- DataGridViewCell upCell = this.dataGridView1.SelectedCells[0];
- DataGridViewCell repCell = this.dataGridView2.SelectedCells[0];
- String InOutType = repCell.RowIndex == 0 ? "I" : "O";
- int DeviceId = repCell.ColumnIndex + 1;
- if (MessageBox.Show(string.Format("{0}회로[{1}] 차단{2} 명령을 수행하시겠습니까?"
- , InOutType == "I" ? "입력" : "출력", DeviceId, chkCutFlag ? "설정" : "해제")
- , Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- this.Cursor = Cursors.WaitCursor;
- DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
- //int CommID = 1;
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- int RepeaterId = (upCell.RowIndex * 10) + upCell.ColumnIndex + 1;
- //int RepeaterId = Util.StrToInt(lblRepeaterID.Text, 0);
- dacDeviceConfig.Device_Cut_Update(mdi.myReceiverID, BoardID, LoopNo, RepeaterId, DeviceId, InOutType, chkCutFlag ? "Y" : "N");
- /******************************************/
- /* 회로 차단 명령 Progress 표시 */
- /******************************************/
- frmProgress frm = new frmProgress(mdi);// cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, LoopNo, BoardID, null);
- cmd.CommandType = "DC";
- cmd.ApplyRange = InOutType; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
- cmd.repeaterNo = RepeaterId;
- cmd.DeviceId = DeviceId;
- cmd.Status = chkCutFlag ? 0 : 1;//k.s.d 20120102, 1 : 0; -> 0 : 1; with jys(ub).
- cmd.CommandData = "CUTCOMMAND";
- frm.Commandinfo = cmd;
- cmd.Devicetype = InOutType; //k.s.d 20101022, cut setting bug fix with jys(ub).
- frm.ui = this.mdi.ui;
- frm.ShowDialog();
- ///******************************************/
- // cyim 2013.8.5 화면갱신전 대기화면 팝업창 출력
- mdi.Popup.CommonPopupShow(this); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
- this.mdi.ui.ReceiverDBRead(); //수신기설정및차단카운트 다시 계산
- this.Cursor = Cursors.Default;
- //체크상태를 변경해준다..
- chkDeviceCutFlag.Checked = chkCutFlag;
- // cyim 2013.8.5 화면갱신전 대기화면 팝업창 출력 + 중복루틴 제거
- mdi.Popup.CommonPopupClose(this); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
- //this.mdi.ui.ReceiverDBRead(); //수신기설정및차단카운트 다시 계산
- //중계기 회로 데이터 읽기 명령
- btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty);
- // cyim 2013.9.26 중계기차단 보완
- // UI 갱신
- Repeater_getData();
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]{1}", ex.StackTrace, ex.Message), Application.ProductName);
- }
- }
- }
- private void btnInWrite_Click(object sender, EventArgs e)
- {
- if (dataGridView1.SelectedCells.Count > 0)
- {
- try
- {
- DataGridViewCell cell = this.dataGridView1.SelectedCells[0];
- if (MessageBox.Show("TEST용 회로만 입력쓰기가 가능합니다..그래도 입력쓰기를 하시겠습니까?"
- , Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- int RepeaterID = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- if (REPDATA == null || REPDATA[RepeaterID - 1] == null)
- {
- MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다..통신상태를 확인하십시요..", Application.ProductName);
- return;
- }
- InputIDVo vo = new InputIDVo();
- vo.ReceiverID = int.Parse(txtThisReceiverID.Text);
- vo.CommID = 1;
- vo.BoardID = Util.StrToInt(txtBoardID.Text, 0);
- vo.LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- vo.RepeaterID = RepeaterID;
- vo.RepeaterType = REP[RepeaterID - 1].RepeaterType;
- vo.InoutType = "I"; //입력타입
- InputDeviceStatus[] devData = new InputDeviceStatus[4]{REPDATA[RepeaterID - 1].Repeater_Input1
- ,REPDATA[RepeaterID - 1].Repeater_Input2
- ,REPDATA[RepeaterID - 1].Repeater_Input3
- ,REPDATA[RepeaterID - 1].Repeater_Input4};
- vo.InputUnitData = devData;
- // cyim 2015.2.23 회로차단시에는 사용불가
- // 중계기 인덱스
- int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- IWin32Window window = this;
- frmModalUnitDataSelect frm = new frmModalUnitDataSelect(REP[no - 1]);
- frm.InputVo = vo;
- frm.ShowDialog(window);
- vo = frm.InputVo;
- //입력한 코드가 있다면
- if (vo.InputOK)
- {
- InputDeviceStatus[] inData = vo.InputUnitData;
- RepeaterData inputdata = new RepeaterData((byte)RepeaterID);
- inputdata.Set_Input_Data((int)inData[3], (int)inData[2], (int)inData[1], (int)inData[0]);
- //완료이벤트
- dCommandResponse d = new dCommandResponse(RepeaterInputWriteComplete);
- //명령생성 및 실행
- CmdInfo cmd = new CmdInfo(prt_cmd_define.write_repeater_input_unit, mdi.myReceiverID, 1, vo.LoopNo, vo.BoardID, vo.RepeaterID, d);
- cmd.CommandData = inputdata;
- mdi.ui.runCommand(cmd);
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]{1}", ex.StackTrace, ex.Message), Application.ProductName);
- }
- }
- }
- //중계기 입력쓰기 완료
- public void RepeaterInputWriteComplete(CmdInfo cmd)
- {
- //에러응답처리
- if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_WriteRepeaterInputUNIT")) // cyim 2015.7.23 NACK 처리 부분 오류
- {
- button_end(true);
- return;
- }
- try
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- if (BoardID == cmd.boardNo && cmd.loopNo == Loop)
- {
- int RepeaterID = cmd.repeaterNo;
- RCVData_WriteRepeaterInputUNIT ResponseData = (RCVData_WriteRepeaterInputUNIT)cmd.ResponseData;
- RepeaterPointUnit newdata = new RepeaterPointUnit(BoardID, ResponseData.Data);
- //데이터저장
- ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
- BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(BoardID); //통신보드savBoardID의 loop0의 설정값
- RepeaterPointUnit[] repdata;
- if (savLoop == 0)
- {
- repdata = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
- }
- else
- {
- repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
- }
- repdata[RepeaterID - 1] = newdata;
- //셀에 표시
- DeviceStatus(REP[RepeaterID - 1], REPDATA[RepeaterID - 1]); //회로내용표시
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
- }
- finally
- {
- //버튼 비활성 해제
- button_end(true);
- }
- }
- //중계기 출력쓰기 완료
- public void RepeaterOutputWriteComplete(CmdInfo cmd)
- {
- //에러응답처리
- if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_WriteRepeaterOutputUNIT")) // cyim 2015.7.23 NACK 처리 부분 오류
- {
- button_end(true);
- return;
- }
- try
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- if (BoardID == cmd.boardNo && cmd.loopNo == Loop)
- {
- int RepeaterID = cmd.repeaterNo;
- RCVData_WriteRepeaterOutputUNIT ResponseData = (RCVData_WriteRepeaterOutputUNIT)cmd.ResponseData;
- RepeaterPointUnit newdata = new RepeaterPointUnit(BoardID, ResponseData.Data);
- //데이터저장
- ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
- BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(BoardID); //통신보드savBoardID의 loop0의 설정값
- RepeaterPointUnit[] repdata;
- if (savLoop == 0)
- {
- repdata = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
- }
- else
- {
- repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
- }
- repdata[RepeaterID - 1] = newdata;
- //셀에 표시
- DeviceStatus(REP[RepeaterID - 1], REPDATA[RepeaterID - 1]); //회로내용표시
- if (this.tRepeaterReadThreadStatus == 1)
- {
- this.tRepeaterReadThread = new Thread(this.RepeaterInfoRead);
- this.tRepeaterReadThreadStatus = 1;
- this.tRepeaterReadThread.Start();
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
- }
- finally
- {
- //버튼 비활성 해제
- button_end(true);
- }
- }
- private void btnOutWrite_Click(object sender, EventArgs e)
- {
- if (dataGridView1.SelectedCells.Count > 0)
- {
- try
- {
- DataGridViewCell cell = this.dataGridView1.SelectedCells[0];
- if (MessageBox.Show("실제로 화재 및 설비 연동감지가 될수 있습니다. 그래도 출력쓰기를 하시겠습니까?"
- , Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- int RepeaterID = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- if (REPDATA == null || REPDATA[RepeaterID - 1] == null)
- {
- MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다..통신상태를 확인하십시요..", Application.ProductName);
- return;
- }
- InputIDVo vo = new InputIDVo();
- vo.ReceiverID = int.Parse(txtThisReceiverID.Text);
- vo.CommID = 1;
- vo.BoardID = Util.StrToInt(txtBoardID.Text, 0);
- vo.LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- vo.RepeaterID = RepeaterID;
- vo.RepeaterType = REP[RepeaterID - 1].RepeaterType;
- vo.InoutType = "O"; //출력타입
- OutputDeviceStatus[] devData = new OutputDeviceStatus[4]{REPDATA[RepeaterID - 1].Repeater_Output1
- ,REPDATA[RepeaterID - 1].Repeater_Output2
- ,REPDATA[RepeaterID - 1].Repeater_Output3
- ,REPDATA[RepeaterID - 1].Repeater_Output4};
- vo.OutputUnitData = devData;
- // cyim 2015.2.23 회로차단시에는 사용불가
- // 중계기 인덱스
- int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- IWin32Window window = this;
- frmModalUnitDataSelect frm = new frmModalUnitDataSelect(REP[no - 1]);
- frm.InputVo = vo;
- frm.ShowDialog(window);
- vo = frm.InputVo;
- //입력한 코드가 있다면
- if (vo.InputOK)
- {
- OutputDeviceStatus[] outData = vo.OutputUnitData;
- RepeaterData outputdata = new RepeaterData((byte)RepeaterID);
- outputdata.Set_Output_Data(outData[3] == OutputDeviceStatus.Blocking ? true : false
- , outData[2] == OutputDeviceStatus.Blocking ? true : false
- , outData[1] == OutputDeviceStatus.Blocking ? true : false
- , outData[0] == OutputDeviceStatus.Blocking ? true : false
- , outData[3] == OutputDeviceStatus.Write ? true : false
- , outData[2] == OutputDeviceStatus.Write ? true : false
- , outData[1] == OutputDeviceStatus.Write ? true : false
- , outData[0] == OutputDeviceStatus.Write ? true : false
- );
- //완료이벤트
- dCommandResponse d = new dCommandResponse(RepeaterOutputWriteComplete);
- //명령생성 및 실행
- CmdInfo cmd = new CmdInfo(prt_cmd_define.write_repeater_output_unit, mdi.myReceiverID, 1, vo.LoopNo, vo.BoardID, RepeaterID, d);
- cmd.CommandData = outputdata;
- mdi.ui.runCommand(cmd);
- //연동으로 인해 출력값이 변경될 수 있으므로 계속 읽는다..
- //this.tRepeaterReadThread = new Thread(this.RepeaterInfoRead);
- this.tRepeaterReadThreadStatus = 1;
- //this.tRepeaterReadThread.Start();
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- //MessageBox.Show(ex.Message, Application.ProductName);
- //MessageBox.Show(string.Format("[{0}]{1}", ex.StackTrace, ex.Message), Application.ProductName);
- }
- }
- }
- //
- // cyim 2013.7.12 디자인개선작업 : 제어 - 중계단
- //
- private void button_LoopCut_Click(object sender, EventArgs e)
- {
- LFC.Log("타입: 수신기 조작 로그, 메세지: 차단-계통차단 클릭");
- button_Menu_Color_Init();
- this.tabControl_Main.SelectTab(0);
- this.button_LoopCut.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
- this.panel_Menu.Focus();
- }
- private void button_Menu_RepeaterCut_Click(object sender, EventArgs e)
- {
- LFC.Log("타입: 수신기 조작 로그, 메세지: 차단-중계기차단 클릭");
- button_Menu_Color_Init();
- this.tabControl_Main.SelectTab(1);
- this.button_Menu_RepeaterCut.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;
- this.panel_Menu.Focus();
- }
- private void button_Menu_Color_Init()
- {
- this.button_LoopCut.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
- this.button_Menu_RepeaterCut.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;
- }
- }
- }
|