1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Diagnostics;
- using System.Collections;
- using System.Threading;
- namespace FPER
- {
- public partial class frmRepeaterGroup : Form
- {
- int savBoardID = -1;
- int savLoop = -1;
- bool BoardGroup_change;
- MDIParent mdi;
-
- delegate void deleFormInit();
- LogFileCreate LFC = new LogFileCreate();
-
- private Thread tRepeaterReadThread;
- private int tRepeaterReadThreadStatus = 0;
-
-
- Hashtable AnalogDetecterRepeaterID_Hashtable = new Hashtable();
-
- GridRepeater[] GRIDCELL = new GridRepeater[127];
-
- public frmRepeaterGroup()
- {
- InitializeComponent();
-
- this.FormClosing += new FormClosingEventHandler(frmRepeaterGroup_FormClosing);
- }
-
- public void _Event_AnalogLevel_Update_SendMessage_Event(MDIParent mdi)
- {
-
-
- AnalogDetecterRepeaterID_Hashtable = mdi.GetAnalogDetecterRepeaterID(mdi.myReceiverID, savBoardID, savLoop);
- }
-
- public void frmRepeaterGroup_FormClosing(object sender, FormClosingEventArgs e)
- {
-
- mdi.Event.AnalogLevel_Update_SendMessage_Event -= new _Event.AnalogLevel_Update_SendMessage_Handler(_Event_AnalogLevel_Update_SendMessage_Event);
- }
-
- public void Form_Init()
- {
- try
- {
- if (this.InvokeRequired)
- {
- deleFormInit d = new deleFormInit(Form_Init);
- this.Invoke(d, new object[] { });
- }
- else
- {
- Repeater_SettingData();
- btnRepeaterAllInfo_Click(btnRepeaterAllInfo, EventArgs.Empty);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
-
- }
- }
- bool load = false;
-
- private void frmRepeaterGroup_Load(object sender, EventArgs e)
- {
-
- SetStyle(ControlStyles.UserPaint, true);
-
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
-
- SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.UpdateStyles();
- try
- {
- this.Cursor = Cursors.WaitCursor;
- mdi = (MDIParent)this.MdiParent;
- txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
- if (BoardGroup_change)
- {
- mdi.temptxtBoardID = txtBoardID.Text;
- mdi.temptxtLoopNo = txtLoopNo.Text;
- BoardGroup_change = false;
- }
-
-
-
- load = true;
- Repeater_SettingData();
- btnRepeaterAllInfo_Click(btnRepeaterAllInfo, EventArgs.Empty);
- this.timer_RepeaterAllInfo_BlockRead.Start();
-
- mdi.Event.AnalogLevel_Update_SendMessage_Event += new _Event.AnalogLevel_Update_SendMessage_Handler(_Event_AnalogLevel_Update_SendMessage_Event);
-
- timer_RepeaterAllInfo_BlockRead_ChangeStart(4000);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
-
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- private void frmRepeaterGroup_Activated(object sender, EventArgs e)
- {
- this.mdi.SelectMenuIndex = 3;
- }
- private void frmRepeaterGroup_Disposed(object sender, EventArgs e)
- {
- this.mdi.SelectMenuIndex = 0;
- }
-
- public void setBoardId(int boardId, int loopNo)
- {
- try
- {
- txtBoardID.Text = String.Format("{0:00}", boardId);
- txtLoopNo.Text = String.Format("{0}", loopNo);
- BoardGroup_change = true;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- private void Repeater_init()
- {
-
-
-
-
-
-
- try
- {
- this.dataGridView_Repeater_Main.Columns.Clear();
- DataGridViewCellStyle sty = new DataGridViewCellStyle();
- sty.Alignment = DataGridViewContentAlignment.MiddleCenter;
- for (int col = 0; col < 10; col++)
- {
- DataGridViewImageColumn imageColumn = new DataGridViewImageColumn();
- imageColumn.ImageLayout = DataGridViewImageCellLayout.Normal;
-
- imageColumn.Image = imgListRepeaterBack.Images[0];
- dataGridView_Repeater_Main.Columns.Add(imageColumn);
- dataGridView_Repeater_Main.Columns[col].ReadOnly = true;
- dataGridView_Repeater_Main.Columns[col].Resizable = DataGridViewTriState.False;
- dataGridView_Repeater_Main.Columns[col].Width = 76;
- dataGridView_Repeater_Main.Columns[col].DefaultCellStyle = sty;
- }
-
- Image[] rowData12 = new Image[10] {
- imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3] , imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3],
- imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3] , imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3], imgListRepeaterBack.Images[3]};
- try
- {
- this.dataGridView_Repeater_Main.Rows.Clear();
- DataGridViewRowCollection rows = dataGridView_Repeater_Main.Rows;
- for (int row = 0; row <= 12; row++)
- {
- rows.Add(rowData12);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
-
- for (int row = 0; row <= 12; row++)
- {
- for (int col = 1; col <= 10; col++)
- {
-
- int no = row * 10 + col;
- if (no <= 127)
- {
- GRIDCELL[no - 1] = new GridRepeater(dataGridView_Repeater_Main.Rows[row].Cells[col - 1], imgListRepeaterBack, no);
- }
- }
- dataGridView_Repeater_Main.Rows[row].Height = 45;
-
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- throw ex;
- }
- }
- bool ex = false;
-
- private void Repeater_SettingData()
- {
- try
- {
- if (this.InvokeRequired)
- {
- deleFormInit d = new deleFormInit(Repeater_SettingData);
- this.Invoke(d, new object[] { });
- }
- else
- {
-
-
-
-
- ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo;
- if (load)
- {
- if (mdi.temptxtBoardID != null && mdi.temptxtLoopNo != null)
- {
- int boardid = Convert.ToInt32(mdi.temptxtBoardID);
- int tempboard = boardid - 1;
- int loopid = Convert.ToInt32(mdi.temptxtLoopNo);
- if (Receiverinfo.MyBoardType[tempboard] != null)
- {
- if (Receiverinfo.MyBoardType[tempboard].UseFlag == true)
- {
- switch (loopid)
- {
- case 0:
- {
- if (Receiverinfo.MyBoardType[tempboard].Loop0UseFlag == true)
- {
- if (boardid > 9)
- {
- txtBoardID.Text = boardid.ToString();
- mdi.temptxtBoardID = txtBoardID.Text;
- }
- else
- {
- txtBoardID.Text = "0" + boardid.ToString();
- mdi.temptxtBoardID = boardid.ToString();
- }
- txtLoopNo.Text = "0";
- mdi.temptxtLoopNo = txtLoopNo.Text;
- ex = true;
- break;
- }
- ex = false;
- break;
- }
- case 1:
- {
- if (Receiverinfo.MyBoardType[tempboard].Loop1UseFlag == true)
- {
- if (boardid > 9)
- {
- txtBoardID.Text = boardid.ToString();
- mdi.temptxtBoardID = txtBoardID.Text;
- }
- else
- {
- txtBoardID.Text = "0" + boardid.ToString();
- mdi.temptxtBoardID = boardid.ToString();
- }
- txtLoopNo.Text = "1";
- mdi.temptxtLoopNo = txtLoopNo.Text;
- ex = true;
- break;
- }
- ex = false;
- break;
- }
- case 2:
- {
- if (Receiverinfo.MyBoardType[tempboard].Loop2UseFlag == true)
- {
- if (boardid > 9)
- {
- txtBoardID.Text = boardid.ToString();
- mdi.temptxtBoardID = txtBoardID.Text;
- }
- else
- {
- txtBoardID.Text = "0" + boardid.ToString();
- mdi.temptxtBoardID = boardid.ToString();
- }
- txtLoopNo.Text = "2";
- mdi.temptxtLoopNo = txtLoopNo.Text;
- ex = true;
- break;
- }
- ex = false;
- break;
- }
- case 3:
- {
- if (Receiverinfo.MyBoardType[tempboard].Loop3UseFlag == true)
- {
- if (boardid > 9)
- {
- txtBoardID.Text = boardid.ToString();
- mdi.temptxtBoardID = txtBoardID.Text;
- }
- else
- {
- txtBoardID.Text = "0" + boardid.ToString();
- mdi.temptxtBoardID = boardid.ToString();
- }
- txtLoopNo.Text = "3";
- mdi.temptxtLoopNo = txtLoopNo.Text;
- ex = true;
- break;
- }
- ex = false;
- break;
- }
- }
- }
- }
- }
- if (!ex)
- {
- for (var i = 0; i < Receiverinfo.MyBoardType.Length; i++)
- {
- if (Receiverinfo.MyBoardType[i] != null)
- {
- if (Receiverinfo.MyBoardType[i].UseFlag == true)
- {
- if (Receiverinfo.MyBoardType[i].Loop0UseFlag == true || Receiverinfo.MyBoardType[i].Loop1UseFlag == true || Receiverinfo.MyBoardType[i].Loop2UseFlag == true || Receiverinfo.MyBoardType[i].Loop3UseFlag == true)
- {
- int tempcnt = i + 1;
- if (tempcnt > 9)
- {
- txtBoardID.Text = tempcnt.ToString();
- }
- else
- {
- txtBoardID.Text = "0" + tempcnt.ToString();
- }
- if (Receiverinfo.MyBoardType[i].Loop0UseFlag == true)
- {
- txtLoopNo.Text = "0";
- break;
- }
- else if (Receiverinfo.MyBoardType[i].Loop1UseFlag == true)
- {
- txtLoopNo.Text = "1";
- break;
- }
- else if (Receiverinfo.MyBoardType[i].Loop2UseFlag == true)
- {
- txtLoopNo.Text = "2";
- break;
- }
- else
- {
- txtLoopNo.Text = "3";
- break;
- }
- }
- }
- }
- }
- }
- load = false;
- }
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- if (txtBoardID.Text.Substring(0, 1) == "0")
- {
- mdi.temptxtBoardID = txtBoardID.Text.Substring(1, 1);
- }
- else
- {
- mdi.temptxtBoardID = txtBoardID.Text;
- }
- mdi.temptxtLoopNo = txtLoopNo.Text;
- if (BoardID == savBoardID && Loop == savLoop) return;
- this.Cursor = Cursors.WaitCursor;
-
- Repeater_init();
- savBoardID = BoardID;
- savLoop = Loop;
-
-
- BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(savBoardID);
- RepeaterDeviceTypeInfo[] repinfo;
- RepeaterPointUnit[] repdata;
- bool LoopCutFlag = false;
-
-
-
- AnalogDetecterRepeaterID_Hashtable = mdi.GetAnalogDetecterRepeaterID(mdi.myReceiverID, savBoardID, savLoop);
-
-
- if (savLoop == 0)
- {
- LoopCutFlag = brdinfo.Loop0CutFlag;
- repinfo = brdinfo.Loop0_RepeaterType;
- repdata = brdinfo.Loop0_RepeaterUnit_Data;
- }
- else if (savLoop == 1)
- {
- LoopCutFlag = brdinfo.Loop1CutFlag;
- repinfo = brdinfo.Loop1_RepeaterType;
- repdata = brdinfo.Loop1_RepeaterUnit_Data;
- }
- else if (savLoop == 2)
- {
- LoopCutFlag = brdinfo.Loop2CutFlag;
- repinfo = brdinfo.Loop2_RepeaterType;
- repdata = brdinfo.Loop2_RepeaterUnit_Data;
- }
- else if (savLoop == 3)
- {
- LoopCutFlag = brdinfo.Loop3CutFlag;
- repinfo = brdinfo.Loop3_RepeaterType;
- repdata = brdinfo.Loop3_RepeaterUnit_Data;
- }
- else
- {
- LoopCutFlag = brdinfo.Loop0CutFlag;
- repinfo = null;
- repdata = null;
- }
-
- if (LoopCutFlag)
- {
- btnRepeaterRecoverCmd.Enabled = false;
- btnRepeaterSearchCmd.Enabled = false;
- btnInWrite.Enabled = false;
- btnOutWrite.Enabled = false;
- this.btnRepeaterReset.Enabled = false;
- }
- else
- {
- btnRepeaterRecoverCmd.Enabled = true;
- btnRepeaterSearchCmd.Enabled = true;
- btnInWrite.Enabled = true;
- btnOutWrite.Enabled = true;
- this.btnRepeaterReset.Enabled = true;
- }
-
- for (int i = 0; i < repinfo.Length; i++)
- {
- RepeaterDeviceTypeInfo dev = repinfo[i];
- GRIDCELL[i].LoopCutFlag = LoopCutFlag;
-
-
- int RepeaterID = i + 1;
-
- GRIDCELL[i].Set_DeviceInfo(dev);
-
- GRIDCELL[i].Set_DeviceUnit(repdata[RepeaterID - 1]);
-
- }
-
-
-
-
-
- }
- this.Cursor = Cursors.Default;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 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 dataGridView1_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (dataGridView_Repeater_Main.SelectedCells.Count > 0)
- {
- DataGridViewCell cell = this.dataGridView_Repeater_Main.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 (GRIDCELL[no - 1] != null)
- {
- lblInfoMessage.Text = GRIDCELL[no - 1].InfoMessage;
-
- RepeaterDeviceTypeInfo dev = GRIDCELL[no - 1].DeviceInfo;
- RepeaterPointUnit unit = GRIDCELL[no - 1].DeviceUnit;
- DeviceStatus(dev, unit);
- }
- else
- {
- lblRepeaterID.Text = "";
- }
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
-
- private bool LoopCut()
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo;
- BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(BoardID);
-
-
- bool LoopCutFlag = false;
-
- if (savLoop == 0)
- {
- LoopCutFlag = brdinfo.Loop0CutFlag;
-
-
- }
- else if (savLoop == 1)
- {
- LoopCutFlag = brdinfo.Loop1CutFlag;
-
-
- }
- else if (savLoop == 2)
- {
- LoopCutFlag = brdinfo.Loop2CutFlag;
-
-
- }
- else if (savLoop == 3)
- {
- LoopCutFlag = brdinfo.Loop3CutFlag;
-
-
- }
- return LoopCutFlag;
- }
-
- private void DeviceStatus(RepeaterDeviceTypeInfo dt, RepeaterPointUnit unit)
- {
- try
- {
- if (dt != null && dt.UseFlag == true)
- {
- if (dt.RepeaterType.Equals("")
-
- || LoopCut() == true
-
- || dt.CutFlag == true
- )
- {
- btnInWrite.Enabled = false;
- btnOutWrite.Enabled = false;
- btnRepeaterRecoverCmd.Enabled = false;
- btnRepeaterSearchCmd.Enabled = false;
- this.btnRepeaterReset.Enabled = false;
- }
-
- else
- {
- btnInWrite.Enabled = true;
- btnOutWrite.Enabled = true;
- btnRepeaterRecoverCmd.Enabled = true;
- btnRepeaterSearchCmd.Enabled = true;
- this.btnRepeaterReset.Enabled = true;
- }
-
- 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;
-
- for (int col = 0; col < 4; col++)
- {
- dataGridView_Repeater_Sub.Columns[col].ReadOnly = true;
- dataGridView_Repeater_Sub.Columns[col].Resizable = DataGridViewTriState.False;
- dataGridView_Repeater_Sub.Columns[col].Width = 70;
- dataGridView_Repeater_Sub.Columns[col].DefaultCellStyle = sty;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (unit != null)
- {
- DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;
- if (dt != null)
- {
- if (dt.RepeaterType.Equals("A"))
- {
-
- String[] inData = { DeviceStatusText.InputText(unit.Repeater_Input1,dt.inDeviceTypeInfos[0]),
- DeviceStatusText.InputText(unit.Repeater_Input2,dt.inDeviceTypeInfos[1]),
- "",
- "" };
- String[] outData = { DeviceStatusText.OutputText(unit.Repeater_Output1,dt.outDeviceTypeInfos[0]),
- DeviceStatusText.OutputText(unit.Repeater_Output2,dt.outDeviceTypeInfos[1]),
- "",
- "" };
- rows2.Clear();
- rows2.Add(inData);
- rows2.Add(outData);
- }
- else if (dt.RepeaterType.Equals("B"))
- {
- String[] inData = { DeviceStatusText.InputText(unit.Repeater_Input1,dt.inDeviceTypeInfos[0]),
- DeviceStatusText.InputText(unit.Repeater_Input2,dt.inDeviceTypeInfos[1]),
- DeviceStatusText.InputText(unit.Repeater_Input3,dt.inDeviceTypeInfos[2]),
- DeviceStatusText.InputText(unit.Repeater_Input4,dt.inDeviceTypeInfos[3]) };
- String[] outData = { DeviceStatusText.OutputText(unit.Repeater_Output1,dt.outDeviceTypeInfos[0]),
- DeviceStatusText.OutputText(unit.Repeater_Output2,dt.outDeviceTypeInfos[1]),
- DeviceStatusText.OutputText(unit.Repeater_Output3,dt.outDeviceTypeInfos[2]),
- DeviceStatusText.OutputText(unit.Repeater_Output4,dt.outDeviceTypeInfos[3])};
- rows2.Clear();
- rows2.Add(inData);
- rows2.Add(outData);
- }
-
- else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))
- {
- String[] inData = { DeviceStatusText.InputText(unit.Repeater_Input1, dt.inDeviceTypeInfos[0]) };
- String[] outData = { DeviceStatusText.OutputText(unit.Repeater_Output1, dt.outDeviceTypeInfos[0]) };
- rows2.Clear();
- rows2.Add(inData);
- rows2.Add(outData);
- }
- }
- }
- else
- {
- DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;
- if (dt != null)
- {
- rows2.Clear();
-
- if (dt.RepeaterType.Equals("A"))
- {
- String[] inData = { "-", "-", "", "" };
- String[] outData = { "-", "-", "", "" };
- rows2.Add(inData);
- rows2.Add(outData);
- }
- else if (dt.RepeaterType.Equals("B"))
- {
- String[] inData = { "-", "-", "-", "-" };
- String[] outData = { "-", "-", "-", "-" };
- rows2.Add(inData);
- rows2.Add(outData);
- }
-
- else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))
- {
- String[] inData = { "-", "", "", "" };
- String[] outData = { "-", "", "", "" };
- rows2.Add(inData);
- rows2.Add(outData);
- }
- }
- }
- }
- else
- {
- this.dataGridView_Repeater_Sub.Rows.Clear();
- btnInWrite.Enabled = false;
- btnOutWrite.Enabled = false;
- btnRepeaterRecoverCmd.Enabled = false;
- btnRepeaterSearchCmd.Enabled = false;
- lblRepeaterID.Text = "";
- this.btnRepeaterReset.Enabled = false;
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private Boolean dtCutFlag(DeviceTypeInfo dtInfo)
- {
- bool cutFlag = false;
- try
- {
- if (dtInfo != null) cutFlag = dtInfo.CutFlag;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- return cutFlag;
- }
-
- private void btnRepeaterAllInfo_Click(object sender, EventArgs e)
- {
- try
- {
- SocketUI ui = this.mdi.ui;
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- if (BoardID == 0)
- {
- this.label_Warning.Text = string.Format("통신보드ID를 입력하여 주십시요.");
- this.label_Warning.Visible = true;
- txtBoardID.Focus();
- return;
- }
- else
- if (Loop != 0 && Loop != 1 && Loop != 2 && Loop != 3)
- {
- this.label_Warning.Text = string.Format("Loop No를 올바르게 입력하여 주십시요.");
- this.label_Warning.Visible = true;
- txtLoopNo.Focus();
- return;
- }
- else
- {
- this.label_Warning.Visible = false;
- }
- button_end(false);
- dCommandResponse d = new dCommandResponse(RepeaterInfoAll);
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_repeater_all, mdi.myReceiverID, 1, Loop, BoardID, d);
- ui.runCommand(cmd);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- private void button_end(Boolean val)
- {
- try
- {
- if (val)
- {
- this.btnRepeaterAllInfo.Enabled = true;
- this.Cursor = Cursors.Default;
- }
- else
- {
- this.btnRepeaterAllInfo.Enabled = false;
- this.Cursor = Cursors.WaitCursor;
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- public void timer_RepeaterAllInfo_BlockRead_ChangeStart(int interval)
- {
- if (timer_RepeaterAllInfo_BlockRead.Interval != interval)
- {
- timer_RepeaterAllInfo_BlockRead.Stop();
- timer_RepeaterAllInfo_BlockRead.Interval = interval;
- timer_RepeaterAllInfo_BlockRead.Start();
- }
- }
-
-
-
- public void RepeaterInfoAll(CmdInfo cmd)
- {
- try
- {
- if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_ReadRepeaterPointAll"))
- {
-
- button_end(true);
-
- timer_RepeaterAllInfo_BlockRead_ChangeStart(7200);
- return;
- }
-
- timer_RepeaterAllInfo_BlockRead_ChangeStart(4000);
- 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)
- {
- ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo;
- BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(savBoardID);
- RepeaterDeviceTypeInfo[] repinfo;
- RepeaterPointUnit[] repdata;
-
- if (savLoop == 0)
- {
- repinfo = brdinfo.Loop0_RepeaterType;
- repdata = brdinfo.Loop0_RepeaterUnit_Data;
- }
- else if (savLoop == 1)
- {
- repinfo = brdinfo.Loop1_RepeaterType;
- repdata = brdinfo.Loop1_RepeaterUnit_Data;
- }
- else if (savLoop == 2)
- {
- repinfo = brdinfo.Loop2_RepeaterType;
- repdata = brdinfo.Loop2_RepeaterUnit_Data;
- }
- else if (savLoop == 3)
- {
- repinfo = brdinfo.Loop3_RepeaterType;
- repdata = brdinfo.Loop3_RepeaterUnit_Data;
- }
- else
- {
- repinfo = null;
- repdata = null;
- }
- bool dataChanged = false;
- for (int repeaterNo = 0; repeaterNo < data.Length; repeaterNo++)
- {
- if (repinfo[repeaterNo] != null)
- {
-
- if (repinfo[repeaterNo].RepeaterType.Equals("C") || repinfo[repeaterNo].RepeaterType.Equals("D"))
- {
-
-
- AnalogLevel analoglevel = (AnalogLevel)AnalogDetecterRepeaterID_Hashtable[(repeaterNo + 1).ToString()];
- if (GRIDCELL[repeaterNo].Unit == null)
- {
- RepeaterPointUnit newdata = new RepeaterPointUnit(repeaterNo + 1, data[repeaterNo], analoglevel, mdi);
- repdata[repeaterNo] = newdata;
- GRIDCELL[repeaterNo].Set_DeviceUnit(newdata);
- dataChanged = true;
- }
- else if (GRIDCELL[repeaterNo].UpdateDeviceUnit(data[repeaterNo], analoglevel, mdi))
- {
- dataChanged = true;
- }
- }
-
- else
- {
- if (GRIDCELL[repeaterNo].Unit == null)
- {
- RepeaterPointUnit newdata = new RepeaterPointUnit(repeaterNo + 1, data[repeaterNo]);
- repdata[repeaterNo] = newdata;
- GRIDCELL[repeaterNo].Set_DeviceUnit(newdata);
- dataChanged = true;
- }
- else if (GRIDCELL[repeaterNo].UpdateDeviceUnit(data[repeaterNo]))
- {
- dataChanged = true;
- }
- }
- }
- }
- if (dataChanged)
- {
- dataGridView1_SelectionChanged(dataGridView_Repeater_Main, System.EventArgs.Empty);
- }
- }
- }
- button_end(true);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
-
-
-
-
- }
- private void btnInputOpen_Click(object sender, EventArgs e)
- {
- try
- {
- 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);
- 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_SettingData();
- btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- try
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- if (BoardID == 0)
- {
- this.label_Warning.Text = string.Format("통신보드ID를 입력하여 주십시요.");
- this.label_Warning.Visible = true;
-
- txtBoardID.Focus();
- return;
- }
- else
- if (Loop != 0 && Loop != 1 && Loop != 2 && Loop != 3)
- {
- this.label_Warning.Text = string.Format("Loop No를 올바르게 입력하여 주십시요.");
- this.label_Warning.Visible = true;
-
- txtLoopNo.Focus();
- return;
- }
- else
- {
- this.label_Warning.Visible = false;
- }
- Repeater_SettingData();
- btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void btnWinClose_Click(object sender, EventArgs e)
- {
- try
- {
- this.Close();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void btnRepeaterRecoverCmd_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
- int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- if (no <= 127)
- {
- SocketUI ui = this.mdi.ui;
-
- dCommandResponse d = new dCommandResponse(RepeaterRecoverComplete);
-
- CmdInfo cmd = new CmdInfo(prt_cmd_define.reset_repeater_unit, mdi.myReceiverID, 1, Loop, BoardID, no, d);
- ui.runCommand(cmd);
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- public void RepeaterRecoverComplete(CmdInfo cmd)
- {
- try
- {
-
- if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_ACK"))
- {
- button_end(true);
- return;
- }
- MessageBox.Show("중계기복구 완료");
- btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- private void dataGridView2_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- txtDeviceTypeName.Text = "";
- txtPositionName.Text = "";
- txtDeviceMemo.Text = "";
- if (dataGridView_Repeater_Main.SelectedCells.Count > 0 && dataGridView_Repeater_Sub.SelectedCells.Count > 0)
- {
- int CommID = 1;
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
- DataGridViewCell repCell = this.dataGridView_Repeater_Main.SelectedCells[0];
- int RepeaterID = (repCell.RowIndex * 10) + repCell.ColumnIndex + 1;
- DataGridViewCell devCell = this.dataGridView_Repeater_Sub.SelectedCells[0];
- string InOut_Type = "I";
- if (devCell.RowIndex > 0) InOut_Type = "O";
- int deviceId = devCell.ColumnIndex + 1;
-
- DacUIProcess dacUIProcess = new DacUIProcess(mdi.myReceiverID);
- DataTable dt2 = dacUIProcess.Device_Select(mdi.myReceiverID, CommID, BoardID, LoopNo, RepeaterID, deviceId, InOut_Type);
- foreach (DataRow dr2 in dt2.Rows)
- {
- txtDeviceTypeName.Text = Util.NullToStr(dr2["DEVICE_TYPE_NAME"]);
- txtPositionName.Text = Util.NullToStr(dr2["POSITION_NAME"]);
- txtDeviceMemo.Text = Util.NullToStr(dr2["DEVICE_NAME"]);
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- private void btnRepeaterSearchCmd_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
- int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- if (no <= 127)
- {
- SocketUI ui = this.mdi.ui;
-
- dCommandResponse d = new dCommandResponse(RepeaterSearchComplete);
-
- CmdInfo cmd = new CmdInfo(prt_cmd_define.search_repeater_unit, mdi.myReceiverID, 1, Loop, BoardID, no, d);
- ui.runCommand(cmd);
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
-
- }
- }
-
- public void RepeaterSearchComplete(CmdInfo cmd)
- {
-
- if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_SearchRepeaterUNIT"))
- {
- button_end(true);
- return;
- }
- try
- {
- RCVData_SearchRepeaterUNIT unit = (RCVData_SearchRepeaterUNIT)cmd.ResponseData;
- if (unit == null) throw new Exception("중계기 검색에 실패하였습니다. 통신상태 및 중계기 설정을 확인하십시요.");
- if (unit.Data == null) throw new Exception("중계기 검색에 실패하였습니다. 통신상태 및 중계기 설정을 확인하십시요.");
- RepeaterData dat = (RepeaterData)unit.Data;
- 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;
- RepeaterPointUnit rep = new RepeaterPointUnit(cmd.repeaterNo, dat);
- GRIDCELL[RepeaterID - 1].Set_DeviceUnit(rep);
-
- if (rep.RepeaterS == false)
- {
- MessageBox.Show(string.Format("중계기검색 완료. 중계기번호:{0}", RepeaterID));
- }
- else
- {
- MessageBox.Show(string.Format("중계기검색 실패. 중계기번호:{0}", RepeaterID));
- }
- btnRepeaterAllInfo_Click(btnRepeaterAllInfo, System.EventArgs.Empty);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
-
- }
- finally
- {
-
- button_end(true);
- }
- }
- private void btnInWrite_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
- int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- if (no <= 127)
- {
- SocketUI ui = this.mdi.ui;
-
- RepeaterPointUnit unit = GRIDCELL[no - 1].DeviceUnit;
- RepeaterDeviceTypeInfo Info = GRIDCELL[no - 1].DeviceInfo;
- if (Info == null || unit == null)
- {
- MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다..통신상태를 확인하십시요..", Application.ProductName);
- return;
- }
- if (MessageBox.Show("TEST용 회로만 입력쓰기가 가능합니다..그래도 입력쓰기를 하시겠습니까?", Application.ProductName, MessageBoxButtons.OKCancel)
- == DialogResult.OK)
- {
-
- 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 = no;
- vo.RepeaterType = Info.RepeaterType;
- vo.InoutType = "I";
- InputDeviceStatus[] devData = new InputDeviceStatus[4]{ unit.Repeater_Input1
- ,unit.Repeater_Input2
- ,unit.Repeater_Input3
- ,unit.Repeater_Input4};
- vo.InputUnitData = devData;
- IWin32Window window = this;
- frmModalUnitDataSelect frm = new frmModalUnitDataSelect(Info);
- frm.InputVo = vo;
- frm.ShowDialog(window);
- vo = frm.InputVo;
-
- if (vo.InputOK)
- {
- devData = vo.InputUnitData;
-
- RepeaterData inputdata = new RepeaterData((byte)vo.RepeaterID);
- inputdata.Set_Input_Data((int)devData[3], (int)devData[2], (int)devData[1], (int)devData[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;
- ui.runCommand(cmd);
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
-
- }
- }
-
- public void RepeaterInputWriteComplete(CmdInfo cmd)
- {
-
- if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_WriteRepeaterInputUNIT"))
- {
- 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);
- RepeaterPointUnit[] repdata;
- if (savLoop == 0)
- {
- repdata = brdinfo.Loop0_RepeaterUnit_Data;
- }
- else
- {
- repdata = brdinfo.Loop1_RepeaterUnit_Data;
- }
- repdata[RepeaterID - 1] = newdata;
-
- GRIDCELL[RepeaterID - 1].Set_DeviceUnit(newdata);
-
- RepeaterDeviceTypeInfo dev = GRIDCELL[RepeaterID - 1].DeviceInfo;
- RepeaterPointUnit unit = GRIDCELL[RepeaterID - 1].DeviceUnit;
- DeviceStatus(dev, unit);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
-
- }
- finally
- {
-
- button_end(true);
- }
- }
-
-
- public void RepeaterOutputWriteComplete(CmdInfo cmd)
- {
-
- if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_WriteRepeaterOutputUNIT"))
- {
- 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);
- RepeaterPointUnit[] repdata;
- if (savLoop == 0)
- {
- repdata = brdinfo.Loop0_RepeaterUnit_Data;
- }
- else if (savLoop == 1)
- {
- repdata = brdinfo.Loop1_RepeaterUnit_Data;
- }
- else if (savLoop == 2)
- {
- repdata = brdinfo.Loop2_RepeaterUnit_Data;
- }
- else if (savLoop == 3)
- {
- repdata = brdinfo.Loop3_RepeaterUnit_Data;
- }
- else
- {
- repdata = null;
- }
- repdata[RepeaterID - 1] = newdata;
-
- GRIDCELL[RepeaterID - 1].Set_DeviceUnit(newdata);
-
- RepeaterDeviceTypeInfo dev = GRIDCELL[RepeaterID - 1].DeviceInfo;
- RepeaterPointUnit unit = GRIDCELL[RepeaterID - 1].DeviceUnit;
- DeviceStatus(dev, unit);
- if (this.tRepeaterReadThreadStatus == 1)
- {
- this.tRepeaterReadThread = new Thread(this.RepeaterInfoRead);
- this.tRepeaterReadThreadStatus = 1;
- this.tRepeaterReadThread.Start();
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- finally
- {
-
- button_end(true);
- }
- }
-
- private void btnOutWrite_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
- {
-
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
-
- DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
- int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- if (no <= 127)
- {
- SocketUI ui = this.mdi.ui;
-
-
-
- RepeaterPointUnit unit = GRIDCELL[no - 1].DeviceUnit;
- RepeaterDeviceTypeInfo Info = GRIDCELL[no - 1].DeviceInfo;
- if (Info == null || unit == null)
- {
- MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다", Application.ProductName);
- return;
- }
-
- if (LoopCut() == true
-
- || Info.CutFlag == true)
- {
- MessageBox.Show("차단중에는 사용할수 없습니다", Application.ProductName);
- return;
- }
-
- if (unit.RepeaterErr == true)
- {
- MessageBox.Show("통신 에러중에는 사용할 수 없습니다", Application.ProductName);
- return;
- }
-
-
-
- if (MessageBox.Show("실제로 화재 및 설비 연동감지가 될수 있습니다. 그래도 출력쓰기를 하시겠습니까?", Application.ProductName, MessageBoxButtons.OKCancel)
- == DialogResult.OK)
- {
-
-
-
- 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 = no;
- vo.RepeaterType = Info.RepeaterType;
- vo.InoutType = "O";
-
-
-
-
-
- OutputDeviceStatus[] devData = new OutputDeviceStatus[4]{
- unit.Repeater_Output1
- ,unit.Repeater_Output2
- ,unit.Repeater_Output3
- ,unit.Repeater_Output4};
-
- vo.OutputUnitData = devData;
-
-
-
- IWin32Window window = this;
- frmModalUnitDataSelect frm = new frmModalUnitDataSelect(Info);
- frm.InputVo = vo;
- frm.ShowDialog(window);
- vo = frm.InputVo;
-
- if (vo.InputOK)
- {
-
- this.mdi.SetInputTestMode(true);
-
- mdi.CommandLog(MappingStatus.Log, string.Format("출력테스트 실행 CommID:{0},LoopNo:{1},BoardID:{2},RepeaterID:{3},devID:{4}-{5}-{6}-{7}",
- vo.CommID, vo.LoopNo, vo.BoardID, vo.RepeaterID, vo.OutputUnitData[0], vo.OutputUnitData[1], vo.OutputUnitData[2], vo.OutputUnitData[3]));
-
- RepeaterData outputdata = new RepeaterData((byte)vo.RepeaterID);
- devData = vo.OutputUnitData;
- outputdata.Set_Output_Data(
- devData[3] == OutputDeviceStatus.Blocking ? true : false
- , devData[2] == OutputDeviceStatus.Blocking ? true : false
- , devData[1] == OutputDeviceStatus.Blocking ? true : false
- , devData[0] == OutputDeviceStatus.Blocking ? true : false
- , devData[3] == OutputDeviceStatus.Write ? true : false
- , devData[2] == OutputDeviceStatus.Write ? true : false
- , devData[1] == OutputDeviceStatus.Write ? true : false
- , devData[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,
- vo.RepeaterID,
- d);
- cmd.CommandData = outputdata;
- ui.runCommand(cmd);
-
-
- this.tRepeaterReadThreadStatus = 1;
-
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
-
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- this.btnRepeaterAllInfo_Click(null, null);
- }
-
- private void dataGridView2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
-
- if (this.dataGridView_Repeater_Sub.SelectedCells.Count == 1)
- {
- DataGridViewCell cell = this.dataGridView_Repeater_Sub.SelectedCells[0];
-
- if (cell.RowIndex == 0)
- {
-
- int CommID = 1;
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int LoopNo = Util.StrToInt(txtLoopNo.Text, 0);
-
- DataGridViewCell repCell = this.dataGridView_Repeater_Main.SelectedCells[0];
- int RepeaterID = (repCell.RowIndex * 10) + repCell.ColumnIndex + 1;
- int devID = cell.ColumnIndex + 1;
-
- if (AnalogDetecterRepeaterID_Hashtable.ContainsKey(RepeaterID.ToString()) == true)
- {
- MessageBox.Show("중계기 타입 2*2 혹은 4*4 만 가능합니다", Application.ProductName);
- return;
- }
-
-
-
-
- RepeaterPointUnit unit = GRIDCELL[RepeaterID - 1].DeviceUnit;
- RepeaterDeviceTypeInfo Info = GRIDCELL[RepeaterID - 1].DeviceInfo;
- if (Info == null || unit == null)
- {
- MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다", Application.ProductName);
- return;
- }
-
- if (Info.inDeviceTypeInfos[devID - 1].CutFlag == true
-
- || LoopCut() == true
-
- || Info.CutFlag == true)
- {
- MessageBox.Show("차단중에는 사용할수 없습니다", Application.ProductName);
- return;
- }
-
- if (MessageBox.Show(string.Format("입력 강제 시험을 하겠습니까? 출력 연동이 될수 있습니다"), "입력 시험", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- this.mdi.SetInputTestMode(true);
- SocketUI ui = mdi.ui;
-
-
- CmdInfo cmd = new CmdInfo(
- prt_cmd_define.write_repeater_input_unit,
- mdi.myReceiverID,
- CommID,
- LoopNo,
- BoardID,
- RepeaterID,
- null);
-
- mdi.CommandLog(MappingStatus.Log, string.Format("입력테스트 실행 CommID:{0},LoopNo:{1},BoardID:{2},RepeaterID:{3},devID:{4}", CommID, LoopNo, BoardID, RepeaterID, devID));
- switch (devID)
- {
- case 1:
- {
- cmd.CommandData = (byte)0xFC;
- break;
- }
- case 2:
- {
- cmd.CommandData = (byte)0xF3;
- break;
- }
- case 3:
- {
- cmd.CommandData = (byte)0xCF;
- break;
- }
- case 4:
- {
- cmd.CommandData = (byte)0x3F;
- break;
- }
- }
- ui.runCommand(cmd);
- }
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
-
-
- private void btnRepeaterReset_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
- {
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
- DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
- int no = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- if (no <= 127)
- {
-
-
- if (MessageBox.Show(string.Format(Loop + "번 Loop를 복구할까요?"), "중계기 복구", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
-
- LFC.Log("타입: 수신기 조작 로그, 메세지: 중계기 개별복구 실행");
- SocketUI ui = this.mdi.ui;
-
- dCommandResponse d = new dCommandResponse(RepeaterRecoverComplete);
-
- CmdInfo cmd = new CmdInfo(
- prt_cmd_define.reset_repeater_all,
- mdi.myReceiverID,
- 1,
- Loop,
- BoardID,
- no,
- null);
- ui.runCommand(cmd);
- }
- }
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
-
-
- }
- }
-
-
- private void dataGridView_Repeater_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (this.dataGridView_Repeater_Main.SelectedCells.Count > 0)
- {
-
-
- int BoardID = Util.StrToInt(txtBoardID.Text, 0);
-
- int Loop = Util.StrToInt(txtLoopNo.Text, -1);
-
- DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];
- int RepeaterID = (cell.RowIndex * 10) + cell.ColumnIndex + 1;
- RepeaterPointUnit unit = GRIDCELL[RepeaterID - 1].DeviceUnit;
- RepeaterDeviceTypeInfo Info = GRIDCELL[RepeaterID - 1].DeviceInfo;
- if (Info == null || unit == null)
- {
- MessageBox.Show("회로설정 및 데이터를 읽을수 없습니다..", Application.ProductName);
- return;
- }
-
- if (LoopCut() == true
-
- || Info.CutFlag == true)
- {
- MessageBox.Show("차단중에는 사용할수 없습니다..", Application.ProductName);
- return;
- }
-
- if (mdi.AnalogDetect.Form_Active_AnalogDetecter == true)
- {
- MessageBox.Show("이미 실행중입니다...", Application.ProductName);
- return;
- }
-
-
- if (Info.RepeaterType.Equals("A") == true || Info.RepeaterType.Equals("B") == true)
- {
-
- return;
- }
-
- if (unit.RepeaterNon == true
- || unit.RepeaterErr == true
- || unit.RepeaterErr == true
- )
- {
-
- return;
- }
- mdi = (MDIParent)this.MdiParent;
- txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
- Form_AnalogDetecter AnalogDetecter = new Form_AnalogDetecter(
- string.Format("{0:00}", mdi.myReceiverID),
- string.Format("{0:000}", BoardID),
- string.Format("{0:000}", Loop),
- string.Format("{0:000}", RepeaterID),
- Info.RepeaterType.ToString(),
- mdi);
- AnalogDetecter.Show();
- }
- }
- }
- }
|