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 Microsoft.Win32; using System.Diagnostics; namespace FPER { public partial class frmReceiverConfig : Form { Boolean ThisRedundant_Flag = true; //수신기 통신보드이중화 QUERYMode cmd; //중계기 데이터 읽기 중복을 막기위해 int savBoardID = -1; int savLoop = -1; MDIParent mdi = null; //Tooltip 설정 값........... IWin32Window window; //ToolTip tp; // cyim 2014.5.7 : 수신기설정정보 변경 (하단 주석처리하고 변수는 전역으로 처리한다) //수신기설정정보 변경여부 //Boolean receiverConfig_Change_Flag = false; // cyim 2015.8.4 수신반을 위한 static 클래스 정리 private Boolean receiverConfig_Change_Flag = false; private Boolean ThisReceiverConfig_Change_Flag { get { // cyim 2015.8.4 수신반을 위한 static 클래스 정리 //return _frmReceiverConfig_Data.receiverConfig_Change_Flag; return receiverConfig_Change_Flag; } set { // cyim 2015.8.4 수신반을 위한 static 클래스 정리 //_frmReceiverConfig_Data.receiverConfig_Change_Flag = value; receiverConfig_Change_Flag = value; //if (_frmReceiverConfig_Data.receiverConfig_Change_Flag) if (receiverConfig_Change_Flag) { this.lblReceiverConfigChangeFlag.Text = "설정 변경됨! 반드시 모든 데이타 저장 버튼 실행하십시요!"; this.lblReceiverConfigChangeFlag.Visible = true; } else { this.lblReceiverConfigChangeFlag.Visible = false; } } } //listview3의 선택 item ListViewItem IOBoard_selectItem; QUERYMode IOBoard_cmd; ListViewItem IOBoardDevice_selectItem; QUERYMode IOBoardDevice_cmd; //QUERYMode Keypad_cmd; public frmReceiverConfig() { InitializeComponent(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 -> 초반에는 무조건 수신기버튼을 누른것처럼 보이도록 한다 this.button_Menu_Receiver.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30; } public void Form_Init() { try { } 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.Source), Application.ProductName); } } private void frmTcpConfig_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; this.mdi.SelectMenuIndex = 2; this.Cursor = Cursors.WaitCursor; window = this; //tp = new ToolTip(); txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID); /** 설정(수신기) 시작**/ //VIEW모드로 변경한다. Util.GroupUIChange(groubReceiver, UIMode.cancel); //그룹의 데이터를 초기화한다. GroupReceiverData(null); //cboUse_Flag 에 item넣기 Util.ComboSetting(cboUse_Flag, Util.useFlagArray(), null); Receiver_getData(); /** 설정(수신기) 끝**/ /** 설정(통신) 시작**/ //VIEW모드로 변경한다. Util.GroupUIChange(groupComm1, UIMode.input); if (ThisRedundant_Flag) Util.GroupUIChange(groupComm2, UIMode.input); else Util.GroupUIChange(groupComm2, UIMode.cancel); Util.GroupUIChange(groupComm3, UIMode.input); Util.GroupUIChange(groupComm4, UIMode.input); Comm_Init(); //통신설정 데이터 불러오기 Comm_getData(); /** 설정(통신) 끝**/ /** 설정(통신보드) 시작**/ Util.ComboSetting(cboBoardBaudRate, Util.baudRateArray(), null); //Util.ComboSetting(cboLoop0BaudRate, Util.baudRateArray(), null); //Util.ComboSetting(cboLoop1BaudRate, Util.baudRateArray(), null); //VIEW모드로 변경한다. Util.GroupUIChange(groubBoard, UIMode.cancel); //그룹의 데이터를 초기화한다. GroupBoardData(null); Board_getData(); /** 설정(통신보드) 끝**/ /** IO보드 시작**/ Util.ComboSetting(cboIOBoardBaudRate, Util.baudRateArray(), null); //VIEW모드로 변경한다. Util.GroupUIChange(panelIOBoard, UIMode.cancel); //그룹의 데이터를 초기화한다. IOBoardSelectData(null); IOBoard_getData(); IOBoardDevice_getData(); /** IO보드 끝**/ ///** KEYPAD 시작**/ //Util.ComboSetting(cboKeypadBaudRate, Util.baudRateArray(), null); //////VIEW모드로 변경한다. //Util.GroupUIChange(panelKeypad, UIMode.cancel); //Keypad_getData(); ///** KEYPAD 끝**/ /** 설정(중계기) 시작**/ DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 ArrayList ary = dacBoardConfig.Board_List(mdi.myReceiverID, mdi); Util.ComboSetting(cboBoardList, ary, null); ////입력회로 설정 Hash저장 //inputHash.Clear(); //DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(); //DataTable dtable = dacDeviceConfig.Device_type_Select("I",null); //if (dtable.Rows.Count > 0) //{ // foreach (DataRow dr in dtable.Rows) // { // //String cboText = dr["DEVICE_TYPE"].ToString() + "-" + dr["DEVICE_TYPE_NAME"].ToString(); // String cboText = dr["DEVICE_TYPE_NAME"].ToString(); // inputHash.Add(dr["DEVICE_TYPE"].ToString(), cboText); // } //} ////출력회로 설정 Hash저장 //outputHash.Clear(); //DataTable dtable2 = dacDeviceConfig.Device_type_Select("O",null); //if (dtable2.Rows.Count > 0) //{ // foreach (DataRow dr2 in dtable2.Rows) // { // //String cboText = dr2["DEVICE_TYPE"].ToString() + "-" + dr2["DEVICE_TYPE_NAME"].ToString(); // String cboText = dr2["DEVICE_TYPE_NAME"].ToString(); // outputHash.Add(dr2["DEVICE_TYPE"].ToString(), cboText); // } //} Repeater_getDate(); /** 설정(중계기) 끝**/ this.Cursor = Cursors.Default; // cyim 2015.8.4 수신반을 위한 static 클래스 정리 // cyim 2014.5.7 : 수신기설정정보 변경 //if (_frmReceiverConfig_Data.receiverConfig_Change_Flag) if (receiverConfig_Change_Flag) { this.lblReceiverConfigChangeFlag.Text = "설정 변경됨! 반드시 모든 데이타 저장 버튼 실행하십시요!"; this.lblReceiverConfigChangeFlag.Visible = true; } else { this.lblReceiverConfigChangeFlag.Visible = false; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void frmTcpConfig_Activated(object sender, EventArgs e) { try { this.mdi.SelectMenuIndex = 2; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } /******************************************************************************************************/ /* 설정정보 리셋 */ /******************************************************************************************************/ private void frmTcpConfig_Disposed(object sender, EventArgs e) { try { //설정정보가 변경되었다면 다시 읽어라~~~~~~ if (ThisReceiverConfig_Change_Flag) { this.Cursor = Cursors.WaitCursor; mdi.ui.ReceiverDBRead(); //설정정보 변경 mdi.FireReset_Process(); //데몬 RESET 명령 } this.mdi.SelectMenuIndex = 0; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //throw ex; //MessageBox.Show(ex.Message, Application.ProductName); //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName); } finally { this.Cursor = Cursors.Default; } } /******************************************************************************************************/ /******************************************************************************************************/ #region 수신기 데이터 콘트롤 private void btnReceiverAdd_Click(object sender, EventArgs e) { try { //입력모드로 변경한다. Util.GroupUIChange(groubReceiver, UIMode.input); GroupReceiverData(null); cmd = QUERYMode.insert; DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 txtReceiverID.Text = dacReceiverConfig.ReceiverID_Max().ToString(); txtReceiveName.Focus(); btnReceiverAdd.Enabled = false; btnReceiverEdit.Enabled = false; btnReceiverDel.Enabled = false; // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //GroupBox에 자료 표시하기 private void GroupReceiverData(ListViewItem itm) { try { if (itm == null) { txtReceiverID.Text = ""; txtReceiveName.Text = ""; cboUse_Flag.SelectedIndex = -1; txtIP_Address.Text = ""; txtEvent_Port_No.Text = ""; txtCommand_Port_No.Text = ""; checkRedundant_Flag.Checked = false; btnReceiverEdit.Enabled = false; btnReceiverDel.Enabled = false; } else { txtReceiverID.Text = itm.Text; txtReceiveName.Text = itm.SubItems[1].Text; txtIP_Address.Text = itm.SubItems[2].Text; txtEvent_Port_No.Text = itm.SubItems[3].Text; txtCommand_Port_No.Text = itm.SubItems[4].Text; checkRedundant_Flag.Checked = (itm.SubItems[5].Text == "Y" ? true : false); cboUse_Flag.SelectedValue = itm.SubItems[6].Text; btnReceiverEdit.Enabled = true; btnReceiverDel.Enabled = true; } btnReceiverAdd.Enabled = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnCancel_Click(object sender, EventArgs e) { try { //VIEW모드로 변경한다. Util.GroupUIChange(groubReceiver, UIMode.cancel); GroupReceiverData(null); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnReceiverEdit_Click(object sender, EventArgs e) { try { //입력모드로 변경한다. cmd = QUERYMode.update; Util.GroupUIChange(groubReceiver, UIMode.input); txtReceiverID.ReadOnly = true; btnReceiverAdd.Enabled = false; btnReceiverEdit.Enabled = false; btnReceiverDel.Enabled = false; // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } /**** * LISTVIEW에 데이터 불러오기 * * ****/ private void Receiver_getData() { try { DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 DataTable dt = dacReceiverConfig.Receiver_Select(null, null); listView1.Items.Clear(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { int ReceiverId = int.Parse(Convert.ToString(dr[0])); if (ReceiverId == mdi.myReceiverID) this.ThisRedundant_Flag = Convert.ToString(dr[5]) == "Y" ? true : false; ListViewItem item = new ListViewItem(Convert.ToString(dr[0])); item.SubItems.Add(Convert.ToString(dr[1])); item.SubItems.Add(Convert.ToString(dr[2])); item.SubItems.Add(Convert.ToString(dr[3])); item.SubItems.Add(Convert.ToString(dr[4])); item.SubItems.Add(Convert.ToString(dr[5])); item.SubItems.Add(Convert.ToString(dr[6])); //item.SubItems.Add(""); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 리스트에 '상태' 컬럼은 필요없다 listView1.Items.Add(item); } } } 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 void listView1_SelectedIndexChanged(object sender, EventArgs e) { try { ListView lv = (ListView)sender; if (lv.SelectedItems.Count > 0) { ListViewItem itm = lv.SelectedItems[0]; //VIEW모드로 변경한다. Util.GroupUIChange(groubReceiver, UIMode.cancel); GroupReceiverData(itm); } else { //VIEW모드로 변경한다. Util.GroupUIChange(groubReceiver, UIMode.cancel); GroupReceiverData(null); } } 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 void listView1_Click(object sender, EventArgs e) { try { listView1_SelectedIndexChanged(listView1, System.EventArgs.Empty); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnReceiverDel_Click(object sender, EventArgs e) { try { cmd = QUERYMode.delete; String ReceiverID = txtReceiverID.Text.Trim(); String ReceiveName = txtReceiveName.Text.Trim(); String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", ReceiveName, ReceiverID); if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacReceiverConfig.Receiver_Update(cmd, ReceiverID, null, null, null, null, null, null); } //VIEW모드로 변경한다. Util.GroupUIChange(groubReceiver, UIMode.cancel); //수신기정보 입력 CLEAR GroupReceiverData(null); //데이터 불러오기 Receiver_getData(); //수신기리스트 콤보에 넣기 //ComboReceiverList(mdi.MyReceiverId); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } 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 void btnSaveOK_Click(object sender, EventArgs e) { try { if (cmd == QUERYMode.insert || cmd == QUERYMode.update) { Util.ChkTxtBox(txtReceiverID, "수신기ID"); Util.ChkTxtBox(txtReceiveName, "수신기명"); Util.ChkTxtBox(txtIP_Address, "연결 IP"); Util.ChkTxtBox(txtEvent_Port_No, "이벤트 PORT"); Util.ChkTxtBox(txtCommand_Port_No, "명령 PORT"); Util.ChkComboBox(cboUse_Flag, "사용여부"); String ReceiverID = txtReceiverID.Text.Trim(); String ReceiveName = txtReceiveName.Text.Trim(); String Use_Flag = cboUse_Flag.SelectedValue == null ? "" : cboUse_Flag.SelectedValue.ToString(); String Redundant_Flag = (checkRedundant_Flag.Checked ? "Y" : "N"); String IP_Address = txtIP_Address.Text.Trim(); String Event_Port_No = txtEvent_Port_No.Text.Trim(); String Command_Port_No = txtCommand_Port_No.Text.Trim(); this.ThisRedundant_Flag = Redundant_Flag == "Y" ? true : false; if (ThisRedundant_Flag) Util.GroupUIChange(groupComm2, UIMode.input); else Util.GroupUIChange(groupComm2, UIMode.cancel); if (!Util.onlyLiteral(ReceiverID)) throw new Exception("수신기ID는 숫자형만 입력해 주세요."); DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacReceiverConfig.Receiver_Update(cmd, ReceiverID, ReceiveName, IP_Address, Event_Port_No, Command_Port_No, Redundant_Flag, Use_Flag); //수신기설정을 할때 기본으로 생성되어야 할 데이터를 저장한다.. if (int.Parse(ReceiverID) == this.mdi.myReceiverID) { DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacIOBoardConfig.Board_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, "IO보드15번(기본)", "Y", "Y", "N", 0, 0, 0, 0, 0); DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 1, code_InOutType.Input, "발신기", null, null); dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 2, code_InOutType.Input, "전화", null, null); dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 3, code_InOutType.Input, "교류전원", null, null); dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 4, code_InOutType.Input, "예비전원이상", null, null); dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 5, code_InOutType.Input, "출력전압", null, null); dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 1, code_InOutType.Output, "표시등", null, null); dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 2, code_InOutType.Output, "유도등", null, null); dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 3, code_InOutType.Output, "전원릴레이", null, null); DacKeypadConfig dacKeypadConfig = new DacKeypadConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacKeypadConfig.Keypad_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, "키패드(기본)", "Y", 0, 0, 0); //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 0, code_InOutType.Input, "비상 방송 정지", null, null); //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 1, code_InOutType.Input, "지구 경종 정지", null, null); //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 2, code_InOutType.Input, "주음향 정지", null, null); //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 3, code_InOutType.Input, "화면 좌표 설정", null, null); //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 4, code_InOutType.Input, "예비 전원 시험", null, null); //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 5, code_InOutType.Input, "설비연동 화면", null, null); //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 6, code_InOutType.Input, "화재 복구", null, null); //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 7, code_InOutType.Input, "부저 정지", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 1, code_InOutType.Input, "주음향 정지", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 2, code_InOutType.Input, "지구 경종 정지", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 3, code_InOutType.Input, "비상 방송 정지", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 4, code_InOutType.Input, "화면 좌표 설정", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 5, code_InOutType.Input, "부저 정지", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 6, code_InOutType.Input, "설비연동 화면", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 7, code_InOutType.Input, "화재 복구", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 8, code_InOutType.Input, "예비 전원 시험", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 1, code_InOutType.Output, "화재 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 2, code_InOutType.Output, "발신기 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 3, code_InOutType.Output, "교류 전원 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 4, code_InOutType.Output, "예비 전원 이상 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 5, code_InOutType.Output, "전화 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 6, code_InOutType.Output, "통신상태 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 7, code_InOutType.Output, "축적 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 8, code_InOutType.Output, "회로 점검 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 9, code_InOutType.Output, "설비 작동 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 10, code_InOutType.Output, "비상 방송 정지 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 11, code_InOutType.Output, "지구 음향 정지 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 12, code_InOutType.Output, "주음향 정지 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 13, code_InOutType.Output, "부저정지 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 15, code_InOutType.Output, "예비 전원 시험 LED", null, null); //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 14, code_InOutType.Output, "설비연동화면 LED", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 16, code_InOutType.Output, "주음향 부저", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 17, code_InOutType.Output, "Fault 부저", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 18, code_InOutType.Output, "전화 부저", null, null); dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 19, code_InOutType.Output, "설비 부저", null, null); DacBoardConfig dacBoardConfig = new DacBoardConfig(this.mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 if (cmd == QUERYMode.insert) { // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경 int boardID_init = 0; int boardID_cnt = 0; // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다 if (mdi.ReceiverModel == "IFC3300") { boardID_init = 1; boardID_cnt = 64; } else { boardID_init = 1; boardID_cnt = 16; } // cyim 2016.11.03 : 통신보드(중계반)는 최대 64 for (int i = boardID_init; i <= boardID_cnt; i++) { // cyim 2016.10.31 : 대용량 수신기용 UI 변경 dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, i, string.Format("통신보드{0}", i) , "N", "N", "N", "N", "N", 7, 7, 7, 7, 7, 0, 0); } } try { //통신연결 설정값을 다시 읽어서 접속한다. this.mdi.ui.SocketConfigRead(); this.mdi.ui.ServiceStop(); this.mdi.ui.ServiceStart(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(ex.Message, Application.ProductName); } // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); } } //VIEW모드로 변경한다. Util.GroupUIChange(groubReceiver, UIMode.cancel); //데이터 불러오기 Receiver_getData(); //수신기리스트 콤보에 넣기 //ComboReceiverList(mdi.myReceiverID); GroupReceiverData(null); } 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); } } #endregion /******************************************************************************************************/ /******************************************************************************************************/ #region 통신설정 데이터 콘트롤 private void Comm_Init() { //try { ArrayList comport1 = Util.ArrayComport(); ArrayList comport2 = Util.ArrayComport(); ArrayList comport3 = Util.ArrayComport(); ArrayList comport4 = Util.ArrayComport(); ArrayList comport5 = Util.ArrayComport(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 ArrayList speed1 = Util.ArraySpeed(); ArrayList speed2 = Util.ArraySpeed(); ArrayList speed3 = Util.ArraySpeed(); ArrayList speed4 = Util.ArraySpeed(); ArrayList speed5 = Util.ArraySpeed(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 ArrayList databit1 = Util.ArrayDatabit(); ArrayList databit2 = Util.ArrayDatabit(); ArrayList databit3 = Util.ArrayDatabit(); ArrayList databit4 = Util.ArrayDatabit(); ArrayList databit5 = Util.ArrayDatabit(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 ArrayList stopbit1 = Util.ArrayStopbit(); ArrayList stopbit2 = Util.ArrayStopbit(); ArrayList stopbit3 = Util.ArrayStopbit(); ArrayList stopbit4 = Util.ArrayStopbit(); ArrayList stopbit5 = Util.ArrayStopbit(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 ArrayList parity1 = Util.ArrayParity(); ArrayList parity2 = Util.ArrayParity(); ArrayList parity3 = Util.ArrayParity(); ArrayList parity4 = Util.ArrayParity(); ArrayList parity5 = Util.ArrayParity(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 Util.ComboSetting(cboSpeed1, speed1, "115200"); Util.ComboSetting(cboSpeed2, speed2, "115200"); Util.ComboSetting(cboSpeed3, speed3, "115200"); Util.ComboSetting(cboSpeed4, speed4, "115200"); Util.ComboSetting(cboSpeed5, speed5, "115200"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 Util.ComboSetting(cboDataBit1, databit1, "7"); Util.ComboSetting(cboDataBit2, databit2, "7"); Util.ComboSetting(cboDataBit3, databit3, "7"); Util.ComboSetting(cboDataBit4, databit4, "7"); Util.ComboSetting(cboDataBit5, databit5, "7"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 Util.ComboSetting(cboStopBit1, stopbit1, "1"); Util.ComboSetting(cboStopBit2, stopbit2, "1"); Util.ComboSetting(cboStopBit3, stopbit3, "1"); Util.ComboSetting(cboStopBit4, stopbit4, "1"); Util.ComboSetting(cboStopBit5, stopbit5, "1"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 Util.ComboSetting(cboParity1, parity1, "N"); Util.ComboSetting(cboParity2, parity2, "N"); Util.ComboSetting(cboParity3, parity3, "N"); Util.ComboSetting(cboParity4, parity4, "N"); Util.ComboSetting(cboParity5, parity5, "N"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 Util.ComboSetting(cboComPort1, comport1, null); Util.ComboSetting(cboComPort2, comport2, null); Util.ComboSetting(cboComPort3, comport3, null); Util.ComboSetting(cboComPort4, comport4, null); Util.ComboSetting(cboComPort5, comport5, null); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 //기본값 설정 int DelayInit = 200; int TimeOutInit = 3000; txtCommDelay1.Text = DelayInit.ToString(); txtCommTimeOut1.Text = TimeOutInit.ToString(); //txtIpAddress1.Text = ""; //txtPort1.Text = ""; //txtDelay1.Text = ""; //txtTimeOut1.Text = ""; tabControl1.SelectedIndex = 0; txtCommDelay2.Text = DelayInit.ToString(); txtCommTimeOut2.Text = TimeOutInit.ToString(); //txtIpAddress2.Text = ""; //txtPort2.Text = ""; //txtDelay2.Text = ""; //txtTimeOut2.Text = ""; txtCommDelay3.Text = DelayInit.ToString(); txtCommTimeOut3.Text = TimeOutInit.ToString(); //txtIpAddress3.Text = ""; //txtPort3.Text = ""; //txtDelay3.Text = ""; //txtTimeOut3.Text = ""; //키패드 기본 txtCommDelay4.Text = "50"; txtCommTimeOut4.Text = "1000"; //txtIpAddress4.Text = ""; //txtPort4.Text = ""; //txtDelay4.Text = ""; //txtTimeOut4.Text = ""; // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 txtCommDelay5.Text = DelayInit.ToString(); txtCommTimeOut5.Text = TimeOutInit.ToString(); //사용안함으로 통신설정값을 초기화한다. CommFlagChage(1, "N", "N"); CommFlagChage(2, "N", "N"); CommFlagChage(3, "N", "N"); CommFlagChage(4, "N", "N"); CommFlagChage(5, "N", "N"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 chkCommUseFlag1.Checked = false; chkCommUseFlag2.Checked = false; chkCommUseFlag3.Checked = false; chkCommUseFlag4.Checked = false; chkCommUseFlag5.Checked = false; // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정 } //catch (Exception ex) //{ // Util.UErrorMessage(ex, 0, 0); // throw ex; //} } /**** *통신설정 데이터 불러오기 * * ****/ private void Comm_getData() { try { DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 DataTable dt = dacCommConfig.Comm_Select(mdi.myReceiverID, 0, null); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { COMMLOOP commloop = (COMMLOOP)Enum.Parse(typeof(COMMLOOP), dr["COMM_LOOP"].ToString()); String typ = dr["COMM_TYPE"].ToString(); if (commloop == COMMLOOP.FrontLoop) { chkCommUseFlag1.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false; chkCommUseFlag1.CheckState = dr["USE_FLAG"].ToString() == "Y" ? CheckState.Checked : CheckState.Unchecked; ; chkLogFlag1.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false; txtCommTimeOut1.Text = dr["COMM_TIMEOUT"].ToString(); txtCommDelay1.Text = dr["COMM_DELAY"].ToString(); //txtTimeOut1.Text = dr["COMM_TIMEOUT"].ToString(); //txtDelay1.Text = dr["COMM_DELAY"].ToString(); chkCommRs485_1.Checked = typ.Equals("R") ? true : false; if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R { cboComPort1.SelectedValue = dr["COMM_PORT"].ToString(); cboSpeed1.SelectedValue = dr["BAUD_RATE"].ToString(); cboDataBit1.SelectedValue = dr["DATA_BITS"].ToString(); cboParity1.SelectedValue = dr["PARITY"].ToString(); cboStopBit1.SelectedValue = dr["STOP_BITS"].ToString(); tabControl1.SelectedIndex = 0; } else { //txtIpAddress1.Text = dr["IP_ADDRESS"].ToString(); //txtPort1.Text = dr["PORT_NO"].ToString(); tabControl1.SelectedIndex = 1; } CommFlagChage(1, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString()); } else if (commloop == COMMLOOP.BackLoop) { chkCommUseFlag2.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false; chkLogFlag2.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false; txtCommTimeOut2.Text = dr["COMM_TIMEOUT"].ToString(); txtCommDelay2.Text = dr["COMM_DELAY"].ToString(); //txtTimeOut2.Text = dr["COMM_TIMEOUT"].ToString(); //txtDelay2.Text = dr["COMM_DELAY"].ToString(); chkCommRs485_2.Checked = typ.Equals("R") ? true : false; if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R { cboComPort2.SelectedValue = dr["COMM_PORT"].ToString(); cboSpeed2.SelectedValue = dr["BAUD_RATE"].ToString(); cboDataBit2.SelectedValue = dr["DATA_BITS"].ToString(); cboParity2.SelectedValue = dr["PARITY"].ToString(); cboStopBit2.SelectedValue = dr["STOP_BITS"].ToString(); tabControl2.SelectedIndex = 0; } else { //txtIpAddress2.Text = dr["IP_ADDRESS"].ToString(); //txtPort2.Text = dr["PORT_NO"].ToString(); tabControl2.SelectedIndex = 1; } CommFlagChage(2, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString()); } else if (commloop == COMMLOOP.IO) { chkCommUseFlag3.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false; chkLogFlag3.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false; txtCommTimeOut3.Text = dr["COMM_TIMEOUT"].ToString(); txtCommDelay3.Text = dr["COMM_DELAY"].ToString(); //txtTimeOut3.Text = dr["COMM_TIMEOUT"].ToString(); //txtDelay3.Text = dr["COMM_DELAY"].ToString(); chkCommRs485_3.Checked = typ.Equals("R") ? true : false; if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R { cboComPort3.SelectedValue = dr["COMM_PORT"].ToString(); cboSpeed3.SelectedValue = dr["BAUD_RATE"].ToString(); cboDataBit3.SelectedValue = dr["DATA_BITS"].ToString(); cboParity3.SelectedValue = dr["PARITY"].ToString(); cboStopBit3.SelectedValue = dr["STOP_BITS"].ToString(); tabControl3.SelectedIndex = 0; } else { //txtIpAddress3.Text = dr["IP_ADDRESS"].ToString(); //txtPort3.Text = dr["PORT_NO"].ToString(); tabControl3.SelectedIndex = 1; } CommFlagChage(3, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString()); } else if (commloop == COMMLOOP.KEYPAD) { chkCommUseFlag4.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false; chkLogFlag4.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false; txtCommTimeOut4.Text = dr["COMM_TIMEOUT"].ToString(); txtCommDelay4.Text = dr["COMM_DELAY"].ToString(); //txtTimeOut4.Text = dr["COMM_TIMEOUT"].ToString(); //txtDelay4.Text = dr["COMM_DELAY"].ToString(); chkCommRs485_4.Checked = typ.Equals("R") ? true : false; if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R { cboComPort4.SelectedValue = dr["COMM_PORT"].ToString(); cboSpeed4.SelectedValue = dr["BAUD_RATE"].ToString(); cboDataBit4.SelectedValue = dr["DATA_BITS"].ToString(); cboParity4.SelectedValue = dr["PARITY"].ToString(); cboStopBit4.SelectedValue = dr["STOP_BITS"].ToString(); tabControl4.SelectedIndex = 0; } else { //txtIpAddress4.Text = dr["IP_ADDRESS"].ToString(); //txtPort4.Text = dr["PORT_NO"].ToString(); tabControl4.SelectedIndex = 1; } CommFlagChage(4, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString()); } // cyim 2013.7.10 디자인개선작업 : 수신기설정 else if (commloop == COMMLOOP.BroadCast) { chkCommUseFlag5.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false; chkLogFlag5.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false; txtCommTimeOut5.Text = dr["COMM_TIMEOUT"].ToString(); txtCommDelay5.Text = dr["COMM_DELAY"].ToString(); //txtTimeOut4.Text = dr["COMM_TIMEOUT"].ToString(); //txtDelay4.Text = dr["COMM_DELAY"].ToString(); chkCommRs485_5.Checked = typ.Equals("R") ? true : false; if (typ.Equals("C") || typ.Equals("R")) //232-C,485-R { cboComPort5.SelectedValue = dr["COMM_PORT"].ToString(); cboSpeed5.SelectedValue = dr["BAUD_RATE"].ToString(); cboDataBit5.SelectedValue = dr["DATA_BITS"].ToString(); cboParity5.SelectedValue = dr["PARITY"].ToString(); cboStopBit5.SelectedValue = dr["STOP_BITS"].ToString(); tabControl5.SelectedIndex = 0; } else { //txtIpAddress4.Text = dr["IP_ADDRESS"].ToString(); //txtPort4.Text = dr["PORT_NO"].ToString(); tabControl5.SelectedIndex = 1; } CommFlagChage(5, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString()); } } } } 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 void btnCommOK1_Click(object sender, EventArgs e) { try { if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { cmd = QUERYMode.InsertAndUpdate; Util.ChkComboBox(cboComPort1, "포트"); Util.ChkComboBox(cboDataBit1, "데이터비트"); Util.ChkComboBox(cboStopBit1, "정지비트"); Util.ChkComboBox(cboSpeed1, "최대속도"); Util.ChkComboBox(cboParity1, "패리티"); Util.ChkTxtBox(txtCommDelay1, "Delay"); Util.ChkTxtBox(txtCommTimeOut1, "Time Out"); String ComPort = cboComPort1.SelectedValue.ToString(); String DataBit = cboDataBit1.SelectedValue.ToString(); String StopBit = cboStopBit1.SelectedValue.ToString(); String Speed = cboSpeed1.SelectedValue.ToString(); String Parity = cboParity1.SelectedValue.ToString(); String CommTimeOut = txtCommTimeOut1.Text.Trim(); String Delay = txtCommDelay1.Text.Trim(); String UseFlag = chkCommUseFlag1.Checked ? "Y" : "N"; String LogFlag = chkLogFlag1.Checked ? "Y" : "N"; if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요."); if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요."); string typ = chkCommRs485_1.Checked ? "R" : "C"; DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.FrontLoop, "FRONT LOOP", COMMLOOP.FrontLoop, typ , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag); //수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; MessageBox.Show("FRONT LOOP 통신설정값을 저장하였습니다.", Application.ProductName); //VIEW모드로 변경한다. //Util.GroupUIChange(groupComm1, UIMode.cancel); //데이터 불러오기 //Comm_getData(); //수신기리스트 콤보에 넣기 //ComboReceiverList(mdi.myReceiverID); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(ex.Message, Application.ProductName); } } private void btnCommOK2_Click(object sender, EventArgs e) { try { if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { cmd = QUERYMode.InsertAndUpdate; Util.ChkComboBox(cboComPort2, "포트"); Util.ChkComboBox(cboDataBit2, "데이터비트"); Util.ChkComboBox(cboStopBit2, "정지비트"); Util.ChkComboBox(cboSpeed2, "최대속도"); Util.ChkComboBox(cboParity2, "패리티"); Util.ChkTxtBox(txtCommDelay2, "Delay"); Util.ChkTxtBox(txtCommTimeOut2, "Time Out"); String ComPort = cboComPort2.SelectedValue.ToString(); String DataBit = cboDataBit2.SelectedValue.ToString(); String StopBit = cboStopBit2.SelectedValue.ToString(); String Speed = cboSpeed2.SelectedValue.ToString(); String Parity = cboParity2.SelectedValue.ToString(); String CommTimeOut = txtCommTimeOut2.Text.Trim(); String Delay = txtCommDelay2.Text.Trim(); String UseFlag = chkCommUseFlag2.Checked ? "Y" : "N"; String LogFlag = chkLogFlag2.Checked ? "Y" : "N"; string typ = chkCommRs485_2.Checked ? "R" : "C"; if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요."); if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요."); DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.BackLoop, "BACK LOOP", COMMLOOP.BackLoop, typ , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag); //수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; MessageBox.Show("BACK LOOP 통신설정값을 저장하였습니다.", Application.ProductName); //VIEW모드로 변경한다. //Util.GroupUIChange(groupComm2, UIMode.cancel); //데이터 불러오기 //Comm_getData(); //수신기리스트 콤보에 넣기 //ComboReceiverList(mdi.myReceiverID); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(ex.Message, Application.ProductName); } } private void btnCommOK3_Click(object sender, EventArgs e) { try { if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { cmd = QUERYMode.InsertAndUpdate; Util.ChkComboBox(cboComPort3, "포트"); Util.ChkComboBox(cboDataBit3, "데이터비트"); Util.ChkComboBox(cboStopBit3, "정지비트"); Util.ChkComboBox(cboSpeed3, "최대속도"); Util.ChkComboBox(cboParity3, "패리티"); Util.ChkTxtBox(txtCommDelay3, "Delay"); Util.ChkTxtBox(txtCommTimeOut3, "Time Out"); String ComPort = cboComPort3.SelectedValue.ToString(); String DataBit = cboDataBit3.SelectedValue.ToString(); String StopBit = cboStopBit3.SelectedValue.ToString(); String Speed = cboSpeed3.SelectedValue.ToString(); String Parity = cboParity3.SelectedValue.ToString(); String CommTimeOut = txtCommTimeOut3.Text.Trim(); String Delay = txtCommDelay3.Text.Trim(); String UseFlag = chkCommUseFlag3.Checked ? "Y" : "N"; String LogFlag = chkLogFlag3.Checked ? "Y" : "N"; string typ = chkCommRs485_3.Checked ? "R" : "C"; if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요."); if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요."); DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.IO, "IO BOARD", COMMLOOP.IO, typ , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag); //수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; MessageBox.Show("IO BOARD 통신설정값을 저장하였습니다.", Application.ProductName); //VIEW모드로 변경한다. //Util.GroupUIChange(groupComm2, UIMode.cancel); //데이터 불러오기 //Comm_getData(); //수신기리스트 콤보에 넣기 //ComboReceiverList(mdi.myReceiverID); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(ex.Message, Application.ProductName); } } private void btnCommOK4_Click(object sender, EventArgs e) { try { if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { cmd = QUERYMode.InsertAndUpdate; Util.ChkComboBox(cboComPort4, "포트"); Util.ChkComboBox(cboDataBit4, "데이터비트"); Util.ChkComboBox(cboStopBit4, "정지비트"); Util.ChkComboBox(cboSpeed4, "최대속도"); Util.ChkComboBox(cboParity4, "패리티"); Util.ChkTxtBox(txtCommDelay4, "Delay"); Util.ChkTxtBox(txtCommTimeOut4, "Time Out"); String ComPort = cboComPort4.SelectedValue.ToString(); String DataBit = cboDataBit4.SelectedValue.ToString(); String StopBit = cboStopBit4.SelectedValue.ToString(); String Speed = cboSpeed4.SelectedValue.ToString(); String Parity = cboParity4.SelectedValue.ToString(); String CommTimeOut = txtCommTimeOut4.Text.Trim(); String Delay = txtCommDelay4.Text.Trim(); String UseFlag = chkCommUseFlag4.Checked ? "Y" : "N"; String LogFlag = chkLogFlag4.Checked ? "Y" : "N"; string typ = chkCommRs485_4.Checked ? "R" : "C"; if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요."); if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요."); DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.KEYPAD, "KEYPAD", COMMLOOP.KEYPAD, typ , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag); //수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; MessageBox.Show("KEYPAD 통신설정값을 저장하였습니다.", Application.ProductName); //VIEW모드로 변경한다. //Util.GroupUIChange(groupComm2, UIMode.cancel); //데이터 불러오기 //Comm_getData(); //수신기리스트 콤보에 넣기 //ComboReceiverList(mdi.myReceiverID); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(ex.Message, Application.ProductName); } } // EMERGENCY - 확인 버튼 private void btnCommOK5_Click(object sender, EventArgs e) { try { if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { cmd = QUERYMode.InsertAndUpdate; Util.ChkComboBox(cboComPort5, "포트"); Util.ChkComboBox(cboDataBit5, "데이터비트"); Util.ChkComboBox(cboStopBit5, "정지비트"); Util.ChkComboBox(cboSpeed5, "최대속도"); Util.ChkComboBox(cboParity5, "패리티"); Util.ChkTxtBox(txtCommDelay5, "Delay"); Util.ChkTxtBox(txtCommTimeOut5, "Time Out"); String ComPort = cboComPort5.SelectedValue.ToString(); String DataBit = cboDataBit5.SelectedValue.ToString(); String StopBit = cboStopBit5.SelectedValue.ToString(); String Speed = cboSpeed5.SelectedValue.ToString(); String Parity = cboParity5.SelectedValue.ToString(); String CommTimeOut = txtCommTimeOut5.Text.Trim(); String Delay = txtCommDelay5.Text.Trim(); String UseFlag = chkCommUseFlag5.Checked ? "Y" : "N"; String LogFlag = chkLogFlag5.Checked ? "Y" : "N"; string typ = chkCommRs485_5.Checked ? "R" : "C"; if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요."); if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요."); DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.BroadCast, "BroadCast", COMMLOOP.BroadCast, typ , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag); //수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; MessageBox.Show("비상방송 통신설정값을 저장하였습니다.", Application.ProductName); //VIEW모드로 변경한다. //Util.GroupUIChange(groupComm2, UIMode.cancel); //데이터 불러오기 //Comm_getData(); //수신기리스트 콤보에 넣기 //ComboReceiverList(mdi.myReceiverID); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(ex.Message, Application.ProductName); } } private void CommFlagChage(int Comm_ID, String LogFlag, String UseFlag) { try { UIMode mode = UseFlag == "Y" ? UIMode.input : UIMode.cancel; GroupBox group = (GroupBox)Util.FineControl(tabPage_CommSet, "groupComm" + Comm_ID.ToString()); TabControl tab = (TabControl)Util.FineControl(group, "tabControl" + Comm_ID.ToString()); if (tab != null) Util.GroupUIChange(tab, mode); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void chkCommUseFlag_CheckedChanged(object sender, EventArgs e) { try { CheckBox chk = (CheckBox)sender; String ObjName = chk.Name; int commId = int.Parse(ObjName.Replace("chkCommUseFlag", "")); String UseFlag = chk.Checked ? "Y" : "N"; GroupBox group = (GroupBox)Util.FineControl(tabPage_CommSet, "groupComm" + commId.ToString()); CheckBox chk2 = (CheckBox)Util.FineControl(group, "chkLogFlag" + commId.ToString()); String LogFlag = chk2.Checked ? "Y" : "N"; CommFlagChage(commId, LogFlag, UseFlag); DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 COMMLOOP commloop = (COMMLOOP)Enum.Parse(typeof(COMMLOOP), commId.ToString()); dacCommConfig.Comm_FlagUpdate(QUERYMode.InsertAndUpdate, mdi.myReceiverID, commloop, UseFlag, LogFlag); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } 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 void btnLanOK1_Click(object sender, EventArgs e) //{ // try // { // cmd = QUERYMode.InsertAndUpdate; // //Util.ChkTxtBox(txtIpAddress1, "IP"); // //Util.ChkTxtBox(txtPort1, "PORT"); // //Util.ChkTxtBox(txtDelay1, "Delay"); // //Util.ChkTxtBox(txtTimeOut1, "Time Out"); // //String IpAddress = txtIpAddress1.Text.Trim(); // //String Port = txtPort1.Text.Trim(); // //String Delay = txtDelay1.Text.Trim(); // //String TimeOut = txtTimeOut1.Text.Trim(); // String UseFlag = chkCommUseFlag1.Checked ? "Y" : "N"; // String LogFlag = chkLogFlag1.Checked ? "Y" : "N"; // //if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요."); // //if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요."); // //if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요."); // DacCommConfig dacCommConfig = new DacCommConfig(); // dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.FrontLoop, "FRONT LOOP", COMMLOOP.FrontLoop, "L" // , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag); // //수신기설정정보 변경 // mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; // MessageBox.Show("FRONT LOOP 통신설정값을 저장하였습니다.", Application.ProductName); // //VIEW모드로 변경한다. // //Util.GroupUIChange(groupComm1, UIMode.cancel); // //데이터 불러오기 // //Comm_getData(); // } // catch (Exception ex) // { // Util.UErrorMessage(ex,0,0); // //MessageBox.Show(ex.Message, Application.ProductName); // } //} //private void btnLanOK2_Click(object sender, EventArgs e) //{ // try // { // cmd = QUERYMode.InsertAndUpdate; // Util.ChkTxtBox(txtIpAddress2, "IP"); // Util.ChkTxtBox(txtPort2, "PORT"); // Util.ChkTxtBox(txtDelay2, "Delay"); // Util.ChkTxtBox(txtTimeOut2, "Time Out"); // String IpAddress = txtIpAddress2.Text.Trim(); // String Port = txtPort2.Text.Trim(); // String Delay = txtDelay2.Text.Trim(); // String TimeOut = txtTimeOut2.Text.Trim(); // String UseFlag = chkCommUseFlag2.Checked ? "Y" : "N"; // String LogFlag = chkLogFlag2.Checked ? "Y" : "N"; // if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요."); // if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요."); // if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요."); // DacCommConfig dacCommConfig = new DacCommConfig(); // dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.BackLoop, "BACK LOOP", COMMLOOP.BackLoop, "L" // , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag); // //수신기설정정보 변경 // mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; // MessageBox.Show("BACK LOOP 통신설정값을 저장하였습니다.", Application.ProductName); // //VIEW모드로 변경한다. // //Util.GroupUIChange(groupComm2, UIMode.cancel); // //데이터 불러오기 // //Comm_getData(); // } // catch (Exception ex) // { // Util.UErrorMessage(ex,0,0); // //MessageBox.Show(ex.Message, Application.ProductName); // } //} //private void btnLanOK3_Click(object sender, EventArgs e) //{ // try // { // cmd = QUERYMode.InsertAndUpdate; // Util.ChkTxtBox(txtIpAddress3, "IP"); // Util.ChkTxtBox(txtPort3, "PORT"); // Util.ChkTxtBox(txtDelay3, "Delay"); // Util.ChkTxtBox(txtTimeOut3, "Time Out"); // String IpAddress = txtIpAddress3.Text.Trim(); // String Port = txtPort3.Text.Trim(); // String Delay = txtDelay3.Text.Trim(); // String TimeOut = txtTimeOut3.Text.Trim(); // String UseFlag = chkCommUseFlag3.Checked ? "Y" : "N"; // String LogFlag = chkLogFlag3.Checked ? "Y" : "N"; // if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요."); // if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요."); // if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요."); // DacCommConfig dacCommConfig = new DacCommConfig(); // dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.IO, "IO BOARD", COMMLOOP.IO, "L" // , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag); // //수신기설정정보 변경 // mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; // MessageBox.Show("IO BOARD 통신설정값을 저장하였습니다.", Application.ProductName); // //VIEW모드로 변경한다. // //Util.GroupUIChange(groupComm3, UIMode.cancel); // //데이터 불러오기 // //Comm_getData(); // } // catch (Exception ex) // { // Util.UErrorMessage(ex,0,0); // //MessageBox.Show(ex.Message, Application.ProductName); // } //} //private void btnLanOK4_Click(object sender, EventArgs e) //{ // try // { // cmd = QUERYMode.InsertAndUpdate; // Util.ChkTxtBox(txtIpAddress4, "IP"); // Util.ChkTxtBox(txtPort4, "PORT"); // Util.ChkTxtBox(txtDelay4, "Delay"); // Util.ChkTxtBox(txtTimeOut4, "Time Out"); // String IpAddress = txtIpAddress4.Text.Trim(); // String Port = txtPort4.Text.Trim(); // String Delay = txtDelay4.Text.Trim(); // String TimeOut = txtTimeOut4.Text.Trim(); // String UseFlag = chkCommUseFlag4.Checked ? "Y" : "N"; // String LogFlag = chkLogFlag4.Checked ? "Y" : "N"; // if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요."); // if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요."); // if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요."); // DacCommConfig dacCommConfig = new DacCommConfig(); // dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.KEYPAD, "KEYPAD", COMMLOOP.KEYPAD, "L" // , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag); // //수신기설정정보 변경 // mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; // MessageBox.Show("KEYPAD 통신설정값을 저장하였습니다.", Application.ProductName); // //VIEW모드로 변경한다. // //Util.GroupUIChange(groupComm4, UIMode.cancel); // //데이터 불러오기 // //Comm_getData(); // } // catch (Exception ex) // { // Util.UErrorMessage(ex,0,0); // //MessageBox.Show(ex.Message, Application.ProductName); // } //} #endregion /******************************************************************************************************/ /******************************************************************************************************/ #region 통신보드 데이터 콘트롤 /**** * 통신보드 데이터 불러오기 * * ****/ List LTBoard = new List(); private void LoadBoardData() { try { DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 DataTable dt = dacBoardConfig.Board_Select(mdi.myReceiverID, 0, null); this.LTBoard.Clear(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { CTBoard board = new CTBoard(); board.boardID = Convert.ToInt32(dr["BOARD_ID"].ToString()); board.name = dr["BOARD_NAME"].ToString(); board.use = ((dr["USE_FLAG"].ToString() == "Y") ? true : false); // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경 board.loop0Use = ((dr["LOOP0_USE_FLAG"].ToString() == "Y") ? true : false); board.loop1Use = ((dr["LOOP1_USE_FLAG"].ToString() == "Y") ? true : false); board.loop2Use = ((Util.NullToStr(dr["LOOP2_USE_FLAG"]).ToString() == "Y") ? true : false); board.loop3Use = ((Util.NullToStr(dr["LOOP3_USE_FLAG"]).ToString() == "Y") ? true : false); this.LTBoard.Add(board); } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기 private DataTable LoadAnalogDetecterLevel(int ReceiverID, int CommBoard, int Loop, int RepeaterID) { // 전체 중계기 쓰기하는 경우에, DB 의 아날로그 감지기의 정보를 보드별, try { // 전체 DacUIProcess dacUIProcess_TB_ANALOG_DEVICE = new DacUIProcess(ReceiverID); String SQL = ""; SQL += " SELECT REPEATER_ID,FAULT_VALUE,PREFIRE_VALUE,FIRED_VALUE,FIREN_VALUE"; SQL += " FROM TB_ANALOG_DEVICE_2 "; if (RepeaterID != 0) SQL += string.Format(" WHERE RECEIVER_ID='{0}' AND COMM_ID='{1}' AND BOARD_ID='{2}' AND LOOP_NO='{3}' AND REPEATER_ID='{4}'", ReceiverID, "1", CommBoard, Loop, RepeaterID); else SQL += string.Format(" WHERE RECEIVER_ID='{0}' AND COMM_ID='{1}' AND BOARD_ID='{2}' AND LOOP_NO='{3}' ", ReceiverID, "1", CommBoard, Loop); // cyim 2016.06.15 : 아날로그 감지기 출력 포인트 고려 : 레벨값은 입력포인트만 고려한다 // 출력포인트가 있을경우에는 레벨값 조회시 중계기 아이디가 중복되어 버린다 SQL += " AND INOUT_TYPE ='I' "; DataSet dao_TB_ANALOG_DEVICE = dacUIProcess_TB_ANALOG_DEVICE.Select(SQL); DataTable dt_TB_ANALOG_DEVICE = dao_TB_ANALOG_DEVICE.Tables[0]; return dt_TB_ANALOG_DEVICE; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); return null; } } private void Board_getData() { try { //for (int i = 1; i <= 16; i++) //{ // checkPanelLoad(i, false, false, 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 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; // //checkPanelLoad(BoardId, UseFlag, Loop0UseFlag , Loop1UseFlag); // } //} listView_CommBoard.Items.Clear(); if (dt.Rows.Count > 0) { String sUseFlag; foreach (DataRow dr in dt.Rows) { int ReceiverId = int.Parse(Convert.ToString(dr[0])); if (ReceiverId == mdi.myReceiverID) this.ThisRedundant_Flag = Convert.ToString(dr[5]) == "Y" ? true : false; // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경 int i; if (mdi.ReceiverModel == "IFC3300") i = 0; else i = 15; // cyim 2016.10.24 : 통신보드 15번 -> 0번카드로 대체 // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신보드 정보중에 15번 보드는 표시 하지 않도록한다 if (dr["BOARD_ID"].ToString() != i.ToString()) { ListViewItem item = new ListViewItem(dr["BOARD_ID"].ToString()); //String version = dr["MAIN_VERSION"].ToString(); //if (!version.Equals("")) version += "." + dr["SUB_VERSION"].ToString(); //item.SubItems.Add(version); //item.SubItems.Add(" "); //item.SubItems.Add(Util.baudCodeToRate(dr["BAUD_RATE"].ToString())); sUseFlag = (dr["USE_FLAG"].ToString()); item.SubItems.Add(sUseFlag); if (sUseFlag == "Y") { // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경 item.SubItems.Add(dr["LOOP0_USE_FLAG"].ToString()); item.SubItems.Add(dr["LOOP1_USE_FLAG"].ToString()); item.SubItems.Add(Util.NullToStr(dr["LOOP2_USE_FLAG"]).ToString()); item.SubItems.Add(Util.NullToStr(dr["LOOP3_USE_FLAG"]).ToString()); } else { item.SubItems.Add("-"); item.SubItems.Add("-"); item.SubItems.Add("-"); item.SubItems.Add("-"); } //item.SubItems.Add(Util.baudCodeToRate(dr["LOOP0_BAUD_RATE"].ToString())); //item.SubItems.Add(Util.baudCodeToRate(dr["LOOP1_BAUD_RATE"].ToString())); listView_CommBoard.Items.Add(item); } } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } delegate void devent(CheckBox c, System.EventArgs e); //GroupBox에 자료 표시하기 private void GroupBoardData(ListViewItem itm) { try { if (itm == null) { txtBoardID.Text = ""; cboBoardBaudRate.SelectedIndex = -1; //txtMainVersion.Text = ""; //txtSubVersion.Text = ""; //txtCommTerm.Text = ""; chkBoardUseFlag.Checked = false; chkLoop0UseFlag.Checked = false; chkLoop1UseFlag.Checked = false; chkLoop2UseFlag.Checked = false; chkLoop3UseFlag.Checked = false; //cboLoop0BaudRate.SelectedIndex = -1; //cboLoop1BaudRate.SelectedIndex = -1; btnBoardEdit.Enabled = false; btnBoardDel.Enabled = false; } else { txtBoardID.Text = itm.Text; //String sVersion = itm.SubItems[1].Text; //if (sVersion.IndexOf(".") != -1) //{ // txtMainVersion.Text = sVersion.Substring(0, sVersion.IndexOf(".")); // txtSubVersion.Text = sVersion.Substring(sVersion.IndexOf(".") + 1); //} //else //{ // txtMainVersion.Text = sVersion; //} //txtCommTerm.Text = itm.SubItems[1].Text; //String baudrate = Util.baudRateToCode(itm.SubItems[2].Text); //if (baudrate != null) cboBoardBaudRate.SelectedValue = baudrate; //else cboBoardBaudRate.SelectedIndex = -1; chkBoardUseFlag.Checked = (itm.SubItems[1].Text == "Y" ? true : false); chkLoop0UseFlag.Checked = (itm.SubItems[2].Text == "Y" ? true : false); chkLoop1UseFlag.Checked = (itm.SubItems[3].Text == "Y" ? true : false); chkLoop2UseFlag.Checked = (itm.SubItems[4].Text == "Y" ? true : false); chkLoop3UseFlag.Checked = (itm.SubItems[5].Text == "Y" ? true : false); //String Loop0baudrate = Util.baudRateToCode(itm.SubItems[6].Text); //if (Loop0baudrate != null) cboLoop0BaudRate.SelectedValue = Loop0baudrate; //else cboLoop0BaudRate.SelectedIndex = -1; //String Loop1baudrate = Util.baudRateToCode(itm.SubItems[7].Text); //if (Loop1baudrate != null) cboLoop1BaudRate.SelectedValue = Loop1baudrate; //else cboLoop1BaudRate.SelectedIndex = -1; //cboLoop0BaudRate.SelectedValue = Util.baudRateToCode(itm.SubItems[7].Text); //cboLoop1BaudRate.SelectedValue = Util.baudRateToCode(itm.SubItems[8].Text); btnBoardEdit.Enabled = true; btnBoardDel.Enabled = true; } btnBoardAdd.Enabled = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //통신보드 입력값 완료 버튼 private void btnBoardOK_Click(object sender, EventArgs e) { try { if (cmd == QUERYMode.insert || cmd == QUERYMode.update) { Util.ChkTxtBox(txtBoardID, "통신보드ID"); if (!Util.onlyLiteral(txtBoardID.Text.Trim())) throw new Exception("통신보드ID는 숫자형만 입력해 주세요."); if (chkBoardUseFlag.Checked) { //Util.ChkComboBox(cboBoardBaudRate, "통신보드 Baud Rate"); //Util.ChkTxtBox(txtCommTerm, "송수신간격"); //Util.ChkTxtBox(txtMainVersion, "메인버젼"); //if (!Util.onlyLiteral(txtMainVersion.Text.Trim())) throw new Exception("메인버젼은 숫자형만 입력해 주세요."); //Util.ChkTxtBox(txtSubVersion, "서브버젼"); } //if (chkLoop0UseFlag.Checked) //{ // Util.ChkComboBox(cboLoop0BaudRate, "Loop0 Baud Rate"); //} //if (chkLoop1UseFlag.Checked) //{ // Util.ChkComboBox(cboLoop1BaudRate, "Loop1 Baud Rate"); //} //if (txtSubVersion.Text.Length < 1) txtSubVersion.Text = "0"; // cyim 2016.10.31 : 대용량 수신기용 UI 변경 int BoardID = int.Parse(txtBoardID.Text.Trim()); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경 int i; if (mdi.ReceiverModel == "IFC3300") i = 64; else i = 16; if (BoardID > i) { MessageBox.Show("통신보드(중계반) 아이디는 64를 초과할 수 없습니다.", Application.ProductName); return; } String BoardUseFlag = (chkBoardUseFlag.Checked ? "Y" : "N"); String Loop0UseFlag; String Loop1UseFlag; String Loop2UseFlag; String Loop3UseFlag; if (BoardUseFlag == "N") { Loop0UseFlag = "N"; Loop1UseFlag = "N"; Loop2UseFlag = "N"; Loop3UseFlag = "N"; } else { Loop0UseFlag = (chkLoop0UseFlag.Checked ? "Y" : "N"); Loop1UseFlag = (chkLoop1UseFlag.Checked ? "Y" : "N"); Loop2UseFlag = (chkLoop2UseFlag.Checked ? "Y" : "N"); Loop3UseFlag = (chkLoop3UseFlag.Checked ? "Y" : "N"); } //int BoardBaudRate = int.Parse(cboBoardBaudRate.SelectedValue == null ? "0" : cboBoardBaudRate.SelectedValue.ToString()); //int Loop0BaudRate = int.Parse(cboLoop0BaudRate.SelectedValue == null ? "0" : cboLoop0BaudRate.SelectedValue.ToString()); //int Loop1BaudRate = int.Parse(cboLoop1BaudRate.SelectedValue == null ? "0" : cboLoop1BaudRate.SelectedValue.ToString()); //수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 //dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, BoardID, "통신보드" + BoardID // , BoardUseFlag, Loop0UseFlag, Loop1UseFlag, BoardBaudRate, Loop0BaudRate, Loop1BaudRate, CommTerm, 0, 0); dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, BoardID, "통신보드" + BoardID , BoardUseFlag, Loop0UseFlag, Loop1UseFlag, Loop2UseFlag, Loop3UseFlag, 0, 0, 0, 0, 0, 0, 0); //중계기설정의 통신보드 콤보를 재설정 //DacBoardConfig dacBoardConfig = new DacBoardConfig(); ArrayList ary = dacBoardConfig.Board_List(mdi.myReceiverID, mdi); Util.ComboSetting(cboBoardList, ary, null); //통신보드설정쓰기 //CmdInfo uiCmd = new CmdInfo(prt_cmd_define.write_tbd_state, mdi.myReceiverID, 0, BoardID, 0); } //VIEW모드로 변경한다. Util.GroupUIChange(groubBoard, UIMode.cancel); //데이터 불러오기 Board_getData(); //수신기리스트 콤보에 넣기 //ComboBoardList(mdi.MyBoardID); GroupBoardData(null); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName); } } //통신보드 입력값 취소 버튼 private void btnBoardCancel_Click(object sender, EventArgs e) { try { //VIEW모드로 변경한다. Util.GroupUIChange(groubBoard, UIMode.cancel); GroupBoardData(null); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //통신보드 추가 버튼 private void btnBoardAdd_Click(object sender, EventArgs e) { try { //추가버튼을 누르면 기본설정값을 넣어준다... DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 int brdNo = dacBoardConfig.BoardID_Max(mdi.myReceiverID); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경 int i; if (mdi.ReceiverModel == "IFC3300") i = 64; else i = 15; // cyim 2016.10.24 : 통신보드 15번 -> 0번카드로 대체 (중계반 아이디는 최대 64번까지 있다) // cyim 2013.7.10 디자인개선작업 : 수신기설정 string Comment = string.Format("통신보드ID는 {0}을 초과할 수 없습니다. 그래도 계속 진행하시겠습니까?", i); if (brdNo > i && MessageBox.Show(Comment, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.No) { return; } //입력모드로 변경한다. Util.GroupUIChange(groubBoard, UIMode.input); GroupBoardData(null); cmd = QUERYMode.insert; txtBoardID.Text = brdNo.ToString(); cboBoardBaudRate.SelectedValue = "7"; //txtMainVersion.Text = "0"; //txtSubVersion.Text = "0"; //txtCommTerm.Text = "200"; chkBoardUseFlag.Checked = true; // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경 chkLoop0UseFlag.Checked = true; chkLoop1UseFlag.Checked = true; chkLoop2UseFlag.Checked = true; chkLoop3UseFlag.Checked = true; //cboLoop0BaudRate.SelectedValue = "7"; //cboLoop1BaudRate.SelectedValue = "7"; txtBoardID.Focus(); btnBoardAdd.Enabled = false; btnBoardEdit.Enabled = false; btnBoardDel.Enabled = false; // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //통신보드 수정 버튼 private void btnBoardEdit_Click(object sender, EventArgs e) { try { //입력모드로 변경한다. cmd = QUERYMode.update; Util.GroupUIChange(groubBoard, UIMode.input); txtBoardID.ReadOnly = true; btnBoardAdd.Enabled = false; btnBoardEdit.Enabled = false; btnBoardDel.Enabled = false; // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //통신보드 삭제 버튼 private void btnBoardDel_Click(object sender, EventArgs e) { try { cmd = QUERYMode.delete; int BoardID = int.Parse(txtBoardID.Text.Trim()); String msg = string.Format("통신보드 {0}을/를 삭제하시겠습니까?", BoardID); if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, BoardID, null, null, null, null, null, null, 0, 0, 0, 0, 0, 0, 0); // cyim 2016.10.31 : 대용량 수신기용 UI 변경 } //VIEW모드로 변경한다. Util.GroupUIChange(groubBoard, UIMode.cancel); //수신기정보 입력 CLEAR GroupBoardData(null); //데이터 불러오기 Board_getData(); // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName); } } //통신보드 리스트 선택 변경시 private void listView2_SelectedIndexChanged(object sender, EventArgs e) { try { ListView lv = (ListView)sender; if (lv.SelectedItems.Count > 0) { ListViewItem itm = lv.SelectedItems[0]; //VIEW모드로 변경한다. Util.GroupUIChange(groubBoard, UIMode.cancel); GroupBoardData(itm); } else { //VIEW모드로 변경한다. Util.GroupUIChange(groubBoard, UIMode.cancel); GroupBoardData(null); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName); } } //통신보드 리스트 클릭시 private void listView2_Click(object sender, EventArgs e) { listView2_SelectedIndexChanged(listView_CommBoard, System.EventArgs.Empty); } #endregion /******************************************************************************************************/ /******************************************************************************************************/ #region IO보드 데이터 콘트롤 private void mskIOBoardDeviceID_TextChanged(object sender, EventArgs e) { try { int caretPosition; caretPosition = mskIOBoardDeviceID.SelectionStart; mskIOBoardDeviceID.Text = mskIOBoardDeviceID.Text.ToUpper(); mskIOBoardDeviceID.Select(caretPosition, 0); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //IO보드 데이터 표시 private void IOBoardSelectData(ListViewItem itm) { try { IOBoard_selectItem = itm; if (itm == null) { txtIOBoardID.Text = ""; txtIOBoardName.Text = ""; cboIOBoardBaudRate.SelectedIndex = -1; //txtIOBoardMainVersion.Text = ""; //txtIOBoardSubVersion.Text = ""; txtIOBoardCommTerm.Text = ""; if (IOBoard_cmd == QUERYMode.insert) { txtIOBoardID.ReadOnly = false; txtIOBoardID.BackColor = Color.White; txtIOBoardName.ReadOnly = false; btnIOBoardOK.Enabled = true; } else { txtIOBoardID.ReadOnly = true; txtIOBoardID.BackColor = SystemColors.Control; btnIOBoardAdd.Enabled = true; btnIOBoardDel.Enabled = false; btnIOBoardOK.Enabled = false; } btnIOBoardDeviceAdd.Enabled = false; } else { txtIOBoardID.Text = itm.Text; txtIOBoardID.BackColor = SystemColors.Control; txtIOBoardName.Text = Util.NullToStr(itm.SubItems[1].Text); if (!itm.SubItems[2].Text.Equals("")) cboIOBoardBaudRate.SelectedValue = Util.baudRateToCode(Util.NullToStr(itm.SubItems[2].Text)); //String Version = Util.NullToStr(itm.SubItems[3].Text); //if (Version.IndexOf(".") > -1) //{ // txtIOBoardMainVersion.Text = Version.Substring(0, Version.IndexOf(".")); // txtIOBoardSubVersion.Text = Version.Substring(Version.IndexOf(".") + 1); //} //else //{ // txtIOBoardMainVersion.Text = Version; // txtIOBoardSubVersion.Text = ""; //} txtIOBoardCommTerm.Text = itm.SubItems[3].Text; txtIOBoardID.ReadOnly = true; btnIOBoardAdd.Enabled = true; btnIOBoardDel.Enabled = true; btnIOBoardOK.Enabled = true; btnIOBoardDeviceAdd.Enabled = true; } IOBoardDeviceSelectData(null); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } /******************************************************* * [IO보드] LISTVIEW에 데이터 불러오기 ******************************************************/ private void IOBoard_getData() { try { IOBoardSelectData(null); DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 DataTable dt = dacIOBoardConfig.Board_Select(mdi.myReceiverID, 0, "Y"); listView3.Items.Clear(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { ListViewItem item = new ListViewItem(Convert.ToString(dr["BOARD_ID"])); item.SubItems.Add(dr["BOARD_NAME"].ToString()); item.SubItems.Add(Util.baudCodeToRate(dr["BAUD_RATE"].ToString())); //String version = dr["MAIN_VERSION"].ToString(); //if (!version.Equals("")) version += "." + dr["SUB_VERSION"].ToString(); //item.SubItems.Add(version); item.SubItems.Add(" "); listView3.Items.Add(item); } } } 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 void btnIOBoardAdd_Click(object sender, EventArgs e) { try { //입력모드로 변경한다. IOBoard_cmd = QUERYMode.insert; Util.GroupUIChange(panelIOBoard, UIMode.input); IOBoardSelectData(null); cboIOBoardBaudRate.SelectedValue = "7"; txtIOBoardCommTerm.Text = "200"; DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 txtIOBoardID.Text = dacIOBoardConfig.BoardID_Max(mdi).ToString(); txtIOBoardName.Focus(); btnIOBoardAdd.Enabled = false; btnIOBoardDel.Enabled = false; btnIOBoardCancel.Visible = true; btnIOBoardOK.Enabled = true; // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnIOBoardOK_Click(object sender, EventArgs e) { try { if (IOBoard_cmd == QUERYMode.insert || IOBoard_cmd == QUERYMode.update) { Util.ChkTxtBox(txtIOBoardID, "IO보드ID"); Util.ChkTxtBox(txtIOBoardName, "IO보드명"); Util.ChkComboBox(cboIOBoardBaudRate, "Baud Rate"); //Util.ChkTxtBox(txtIOBoardMainVersion, "Version"); Util.ChkTxtBox(txtIOBoardCommTerm, "송수신간격"); //Util.ChkOnlyLiteralTextBox(txtIOBoardMainVersion, "Main Version"); //Util.ChkOnlyLiteralTextBox(txtIOBoardSubVersion, "Sub Version"); Util.ChkOnlyLiteralTextBox(txtIOBoardCommTerm, "송수신간격"); int BoardID = Util.StrToInt(txtIOBoardID.Text, -1); String BoardName = txtIOBoardName.Text.Trim(); int BaudRate = Util.StrToInt(cboIOBoardBaudRate.SelectedValue, -1); //int mainVer = Util.StrToInt(txtIOBoardMainVersion.Text, -1); //int subVer = Util.StrToInt(txtIOBoardSubVersion.Text, 0); //int CommTerm = Util.StrToInt(txtIOBoardCommTerm.Text, -1); DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacIOBoardConfig.Board_Update(IOBoard_cmd, mdi.myReceiverID, BoardID, BoardName, "Y", "Y", "N", BaudRate, 0, 0, 0, 0); //dacReceiverConfig.Receiver_Update(cmd, ReceiverID, ReceiveName, IP_Address, Event_Port_No, Command_Port_No, Redundant_Flag, Use_Flag); } IOBoard_cmd = QUERYMode.select; //VIEW모드로 변경한다. Util.GroupUIChange(panelIOBoard, UIMode.cancel); //데이터 불러오기 IOBoard_getData(); IOBoardDevice_getData(); IOBoardSelectData(null); btnIOBoardCancel.Visible = false; // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } 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 void btnIOBoardCancel_Click(object sender, EventArgs e) { try { //VIEW모드로 변경한다. IOBoard_cmd = QUERYMode.select; Util.GroupUIChange(panelIOBoard, UIMode.cancel); IOBoardSelectData(null); btnIOBoardCancel.Visible = false; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void listView3_SelectedIndexChanged(object sender, EventArgs e) { try { ListView lv = (ListView)sender; if (lv.SelectedItems.Count > 0) { ListViewItem itm = lv.SelectedItems[0]; IOBoard_cmd = QUERYMode.update; //VIEW모드로 변경한다.[IO보드] Util.GroupUIChange(panelIOBoard, UIMode.input); IOBoardSelectData(itm); IOBoardDevice_getData(); } else { IOBoard_cmd = QUERYMode.select; //VIEW모드로 변경한다. Util.GroupUIChange(panelIOBoard, UIMode.cancel); IOBoardSelectData(null); } } 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 void btnIOBoardDel_Click(object sender, EventArgs e) { try { IOBoard_cmd = QUERYMode.delete; int BoardID = Util.StrToInt(txtIOBoardID.Text, -1); String BoardName = txtIOBoardName.Text.Trim(); String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", BoardName, BoardID); if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacIOBoardConfig.Board_Update(IOBoard_cmd, mdi.myReceiverID, BoardID, BoardName, null, null, null, 0, 0, 0, 0, 0); } //VIEW모드로 변경한다. IOBoard_cmd = QUERYMode.select; Util.GroupUIChange(panelIOBoard, UIMode.cancel); //입력 CLEAR IOBoardSelectData(null); //데이터 불러오기 IOBoard_getData(); IOBoardDevice_getData(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } 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); } } /******************************************************* * [IO보드 회로정보] LISTVIEW에 데이터 불러오기 ******************************************************/ private void IOBoardDevice_getData() { try { IOBoardDeviceSelectData(null); int board_id = Util.StrToInt(txtIOBoardID.Text, 0); DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 DataTable dt = dacIODeviceConfig.Device_Select(mdi.myReceiverID, board_id, 0, null); listView4.Items.Clear(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { String dev_id = dr["DEVICE_ID"].ToString(); String dev_id_s = String.Format("I-{0}-{1:00}-{2:00}", dr["INOUT_TYPE"].ToString(), int.Parse(dr["BOARD_ID"].ToString()), int.Parse(dr["DEVICE_ID"].ToString())); ListViewItem item = new ListViewItem(dev_id_s); item.SubItems.Add(string.Format("{0}-{1}", dr["DEVICE_TYPE"].ToString(), dr["DEVICE_TYPE_NAME"].ToString())); item.SubItems.Add(string.Format("{0}-{1}", dr["POSITION_CODE"].ToString(), dr["POSITION_NAME"].ToString())); item.SubItems.Add(dr["DEVICE_NAME"].ToString()); listView4.Items.Add(item); } } } 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 void btnIODeviceOpen_Click(object sender, EventArgs e) { try { if (IOBoard_selectItem != null) { String dev_id_s = mskIOBoardDeviceID.Text; String dev_s = ""; String dev_io = "I"; if (dev_id_s.Length > 8) { dev_s = dev_id_s.Substring(7, 2).Trim(); dev_io = dev_id_s.Substring(2, 1).Trim(); } InputIDVo vo = new InputIDVo(); vo.ReceiverID = mdi.myReceiverID; vo.CommID = 3; vo.BoardID = Util.StrToInt(txtIOBoardID.Text, 0); vo.InoutType = dev_io; vo.LoopNo = 0; vo.RepeaterID = 0; vo.DeviceID = Util.StrToInt(dev_s, 1); IWin32Window window = this; frmModalIdInputIO frm = new frmModalIdInputIO(); frm.InputVo = vo; frm.ShowDialog(window); vo = frm.InputVo; //입력한 코드가 있다면 if (vo.InputOK) { //I-A-12-## mskIOBoardDeviceID.Text = String.Format("I{0}{1:00}{2:00}", vo.InoutType, vo.BoardID, vo.DeviceID); } } else { MessageBox.Show("먼저 IO보드를 선택하여 주십시요.", Application.ProductName); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //IO보드 회로 데이터 표시 private void IOBoardDeviceSelectData(ListViewItem itm) { try { IOBoardDevice_selectItem = itm; if (itm == null) { mskIOBoardDeviceID.Text = ""; txtIOBoardDeviceTypeCode.Text = ""; txtIOBoardDeviceTypeName.Text = ""; txtIOBoardDeviceMemo.Text = ""; txtIOBoardPositionCode.Text = ""; txtIOBoardPositionName.Text = ""; if (IOBoardDevice_cmd == QUERYMode.insert) { mskIOBoardDeviceID.ReadOnly = false; mskIOBoardDeviceID.BackColor = Color.White; btnIOBoardDeviceOK.Enabled = true; btnDeviceTypeOpen.Enabled = true; btnIODeviceOpen.Enabled = true; btnIOBoardPositionOpen.Enabled = true; } else { mskIOBoardDeviceID.ReadOnly = true; mskIOBoardDeviceID.BackColor = SystemColors.Control; //btnIOBoardDeviceAdd.Enabled = true; btnIOBoardDeviceDel.Enabled = false; btnIOBoardDeviceOK.Enabled = false; btnDeviceTypeOpen.Enabled = false; btnIOBoardPositionOpen.Enabled = false; btnIODeviceOpen.Enabled = false; } } else { String dev_id_s = itm.Text; dev_id_s = dev_id_s.Replace("-", ""); mskIOBoardDeviceID.Text = dev_id_s; mskIOBoardDeviceID.BackColor = SystemColors.Control; string devType = itm.SubItems[1].Text; int pos = devType.IndexOf("-"); if (pos != -1) { txtIOBoardDeviceTypeCode.Text = devType.Substring(0, pos); txtIOBoardDeviceTypeName.Text = devType.Substring(pos + 1); } string positionCode = itm.SubItems[2].Text; int pos2 = positionCode.IndexOf("-"); if (pos2 != -1 && positionCode.Length > 1) { txtIOBoardPositionCode.Text = positionCode.Substring(0, pos); txtIOBoardPositionName.Text = positionCode.Substring(pos + 1); } txtIOBoardDeviceMemo.Text = itm.SubItems[3].Text; mskIOBoardDeviceID.ReadOnly = true; //btnIOBoardDeviceAdd.Enabled = true; btnIOBoardDeviceDel.Enabled = true; btnIOBoardDeviceOK.Enabled = true; btnDeviceTypeOpen.Enabled = true; btnIOBoardPositionOpen.Enabled = true; btnIODeviceOpen.Enabled = true; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnDeviceTypeOpen_Click(object sender, EventArgs e) { try { String dev_id_s = mskIOBoardDeviceID.Text; String dev_io = null; //I-A-12-## if (dev_id_s.Length > 8) { dev_io = dev_id_s.Substring(2, 1).Trim(); } //코드를 찾는 모달창을 연다.. frmModalDeviceType frm = new frmModalDeviceType(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 SearchCodeVo vo = new SearchCodeVo(dev_io); vo.Code = txtIOBoardDeviceTypeCode.Text; vo.CodeName = txtIOBoardDeviceTypeName.Text; frm.SearchCode = vo; frm.ShowDialog(); vo = frm.SearchCode; //선택한 코드가 있다면 if (vo.SearchOK) { //선택한 코드값을 dataGridView2에 표시 txtIOBoardDeviceTypeCode.Text = vo.Code; txtIOBoardDeviceTypeName.Text = vo.CodeName; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnIOBoardDeviceAdd_Click(object sender, EventArgs e) { try { //입력모드로 변경한다. IOBoardDevice_cmd = QUERYMode.insert; Util.GroupControlChange(panelIOBoardDevice, UIMode.input); IOBoardDeviceSelectData(null); mskIOBoardDeviceID.Focus(); btnIOBoardDeviceAdd.Enabled = false; btnIOBoardDeviceDel.Enabled = false; btnIOBoardDeviceCancel.Visible = true; btnIOBoardDeviceOK.Enabled = true; // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnIOBoardDeviceCancel_Click(object sender, EventArgs e) { try { //VIEW모드로 변경한다. IOBoardDevice_cmd = QUERYMode.select; Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel); IOBoardDeviceSelectData(null); btnIOBoardDeviceCancel.Visible = false; btnIOBoardDeviceAdd.Enabled = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnIOBoardDeviceOK_Click(object sender, EventArgs e) { try { if (IOBoardDevice_cmd == QUERYMode.insert || IOBoardDevice_cmd == QUERYMode.update) { Util.ChkTxtBox(mskIOBoardDeviceID, "회로번호"); //Util.ChkTxtBox(txtIOBoardDeviceTypeCode, "연동타입코드"); String dev_id_s = mskIOBoardDeviceID.Text; String dev_id = ""; String dev_board_id = ""; String dev_io = "I"; String dev_type = txtIOBoardDeviceTypeCode.Text; String dev_name = txtIOBoardDeviceMemo.Text; String position_code = txtIOBoardPositionCode.Text; //I-A-12-## if (dev_id_s.Length > 8) { dev_id = dev_id_s.Substring(7, 2).Trim(); dev_io = dev_id_s.Substring(2, 1).Trim(); dev_board_id = dev_id_s.Substring(4, 2).Trim(); } else { throw new Exception("회로번호를 올바르게 입력하세요."); } if (int.Parse(txtIOBoardID.Text) != int.Parse(dev_board_id)) { throw new Exception(String.Format("등록하는 회로의 보드ID[{0}]와 회로번호의 보드ID[{1}]가 일치하지 않습니다." , txtIOBoardID.Text, int.Parse(dev_board_id))); } if (!Util.onlyLiteral(dev_id)) throw new Exception("회로번호를 올바르게 입력하세요."); DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacIODeviceConfig.Device_Update(IOBoardDevice_cmd, mdi.myReceiverID, Util.StrToInt(dev_board_id, 1) , Util.StrToInt(dev_id, 1), dev_io, dev_name, dev_type, position_code); } IOBoardDevice_cmd = QUERYMode.select; //VIEW모드로 변경한다. Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel); //데이터 불러오기 IOBoardDevice_getData(); IOBoardDeviceSelectData(null); btnIOBoardDeviceCancel.Visible = false; // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } 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 void listView4_SelectedIndexChanged(object sender, EventArgs e) { try { ListView lv = (ListView)sender; if (lv.SelectedItems.Count > 0) { ListViewItem itm = lv.SelectedItems[0]; IOBoardDevice_cmd = QUERYMode.update; //VIEW모드로 변경한다.[IO보드] Util.GroupControlChange(panelIOBoardDevice, UIMode.input); IOBoardDeviceSelectData(itm); } else { IOBoardDevice_cmd = QUERYMode.select; //VIEW모드로 변경한다. Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel); IOBoardDeviceSelectData(null); } } 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 void txtIOBoardDeviceTypeCode_TextChanged(object sender, EventArgs e) { try { Util.ToUpper(txtIOBoardDeviceTypeCode); String TypeValue = txtIOBoardDeviceTypeCode.Text.Trim(); if (TypeValue.Length == 2) { String IOType = TypeValue.Substring(0, 1); DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 String type_name = dacDeviceConfig.Device_Type_Name(IOType, TypeValue); txtIOBoardDeviceTypeName.Text = type_name; } else { txtIOBoardDeviceTypeName.Text = ""; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void txtIOBoardPositionCode_TextChanged(object sender, EventArgs e) { try { Util.ToUpper(txtIOBoardPositionCode); String positionCode = txtIOBoardPositionCode.Text.Trim(); if (positionCode.Length == 2) { DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 String positionName = dacDeviceConfig.Device_Position_Name(positionCode); txtIOBoardPositionName.Text = positionName; } else { txtIOBoardPositionName.Text = ""; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnIOBoardDeviceDel_Click(object sender, EventArgs e) { try { String dev_id_s = mskIOBoardDeviceID.Text; String dev_id = ""; String dev_board_id = ""; String dev_io = "I"; String dev_type = txtIOBoardDeviceTypeCode.Text; String dev_name = txtIOBoardDeviceMemo.Text; //I-A-12-## : I(구분)-I,O(회로구분)-##(보드ID)-##(회로ID) if (dev_id_s.Length > 8) { dev_id = dev_id_s.Substring(7, 2).Trim(); dev_io = dev_id_s.Substring(2, 1).Trim(); dev_board_id = dev_id_s.Substring(4, 2).Trim(); } else { throw new Exception("회로번호가 올바르지 않습니다."); } String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", dev_name, dev_id_s); IOBoardDevice_cmd = QUERYMode.delete; if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 dacIODeviceConfig.Device_Update(IOBoardDevice_cmd, mdi.myReceiverID, int.Parse(dev_board_id), int.Parse(dev_id), dev_io, null, null, null); } //VIEW모드로 변경한다. IOBoardDevice_cmd = QUERYMode.select; Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel); //입력 CLEAR IOBoardDeviceSelectData(null); //데이터 불러오기 IOBoardDevice_getData(); // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } 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 void btnIOBoardPositionOpen_Click(object sender, EventArgs e) { try { String dev_id_s = mskIOBoardDeviceID.Text; String dev_io = null; //I-A-12-## if (dev_id_s.Length > 8) { dev_io = dev_id_s.Substring(2, 1).Trim(); } //코드를 찾는 모달창을 연다.. frmModalPositionCode frm = new frmModalPositionCode(); SearchCodeVo vo = new SearchCodeVo(null); vo.Code = txtIOBoardPositionCode.Text; vo.CodeName = txtIOBoardPositionName.Text; frm.setMdiParent(this.mdi); frm.SearchCode = vo; frm.ShowDialog(); vo = frm.SearchCode; //선택한 코드가 있다면 if (vo.SearchOK) { //선택한 코드값을 dataGridView2에 표시 txtIOBoardPositionCode.Text = vo.Code; txtIOBoardPositionName.Text = vo.CodeName; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } #endregion /******************************************************************************************************/ /******************************************************************************************************/ //#region 키패드 데이터 콘트롤 //private void btnKeypadEdit_Click(object sender, EventArgs e) //{ // //입력모드로 변경한다. // Keypad_cmd = QUERYMode.InsertAndUpdate; // Util.GroupUIChange(panelKeypad, UIMode.input); // btnKeypadEdit.Enabled = false; // btnKeypadOK.Enabled = true; // btnKeypadCancel.Enabled = true; //} //private void btnKeypadCancel_Click(object sender, EventArgs e) //{ // //입력모드로 변경한다. // Keypad_cmd = QUERYMode.select; // Util.GroupUIChange(panelKeypad, UIMode.cancel); // btnKeypadEdit.Enabled = true; // btnKeypadOK.Enabled = false; // btnKeypadCancel.Enabled = false; //} //private void btnKeypadOK_Click(object sender, EventArgs e) //{ // if (Keypad_cmd == QUERYMode.InsertAndUpdate) // { // Util.ChkTxtBox(txtKeypadID, "키패드ID"); // Util.ChkTxtBox(txtKeypadName, "키패드명"); // Util.ChkComboBox(cboKeypadBaudRate, "Baud Rate"); // Util.ChkTxtBox(txtKeypadMainVersion, "Version"); // Util.ChkTxtBox(txtKeypadCommTerm, "송수신간격"); // Util.ChkOnlyLiteralTextBox(txtKeypadMainVersion, "Main Version"); // Util.ChkOnlyLiteralTextBox(txtKeypadSubVersion, "Sub Version"); // Util.ChkOnlyLiteralTextBox(txtKeypadCommTerm, "송수신간격"); // int KeypadID = Util.StrToInt(txtKeypadID.Text, 1); // String KeypadName = txtKeypadName.Text.Trim(); // int BaudRate = Util.StrToInt(cboKeypadBaudRate.SelectedValue.ToString(), -1); // int mainVer = Util.StrToInt(txtKeypadMainVersion.Text, -1); // int subVer = Util.StrToInt(txtKeypadSubVersion.Text, 0); // int CommTerm = Util.StrToInt(txtKeypadCommTerm.Text, -1); // DacKeypadConfig dacKeypadConfig = new DacKeypadConfig(); // dacKeypadConfig.Keypad_Update(Keypad_cmd, mdi.myReceiverID, KeypadName, "Y", BaudRate, CommTerm, mainVer, subVer); // } // Keypad_cmd = QUERYMode.select; // //VIEW모드로 변경한다. // Util.GroupUIChange(panelKeypad, UIMode.cancel); // //데이터 불러오기 // Keypad_getData(); // btnKeypadEdit.Enabled = true; // btnKeypadOK.Enabled = false; // btnKeypadCancel.Enabled = false; //} //private void Keypad_getData() //{ // try // { // DacKeypadConfig dacKeypadConfig = new DacKeypadConfig(); // DataTable dt = dacKeypadConfig.Keypad_Select(mdi.myReceiverID, "Y"); // if (dt.Rows.Count > 0) // { // foreach (DataRow dr in dt.Rows) // { // txtKeypadID.Text = dr["BOARD_ID"].ToString(); // txtKeypadName.Text = dr["BOARD_NAME"].ToString(); // txtKeypadMainVersion.Text = dr["MAIN_VERSION"].ToString(); // txtKeypadSubVersion.Text = dr["SUB_VERSION"].ToString(); // cboKeypadBaudRate.SelectedValue = dr["BAUD_RATE"].ToString(); // txtKeypadCommTerm.Text = dr["COMM_TERM"].ToString(); // } // } // } // catch (Exception ex) // { //MessageBox.Show(ex.Message, Application.ProductName); // MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName); // } //} //#endregion public void ReceiverConfigWriteAll() { try { if (MessageBox.Show("[전체]수신기에 전체 중계기 정보 쓰기를 수행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { timer.Enabled = true; timer.Interval = 1000; timer.Tick += new EventHandler(time_tick); timer.Start(); this.panel1.Enabled = false; mdi.panel8.Enabled = false; btnReceiverConfigWriteAll.Enabled = false; panel_Menu.Enabled = false; this.Cursor = Cursors.WaitCursor; // cyim 2015.2.10 수신기설정-전체중계기 쓰기 실행 mdi.CommandLog(MappingStatus.Log, string.Format("수신기설정-전체중계기 쓰기")); //2010.12.05, k.s.d, repeater information unit write -> don't use. ///******************************************/ ///* 중계기 쓰기 Progress 표시 */ ///******************************************/ //frmProgress frm = new frmProgress(); ////중계기 설정 데이터를 CmdInfo에 넣어준다.. //CmdInfo cmd = new CmdInfo(prt_cmd_define.write_repeater_info_unit, mdi.myReceiverID); //cmd.boardNo = 0; //전체 보드ID ////ReceiverTypeInfo Receiverinfo = this.mdi.ui.MyReceiverTypeInfo; //수신기설정 ////cmd.CommandData = Receiverinfo; //화면에 설정된 데이터를 쓰기데이터로 이용한다. //frm.Commandinfo = cmd; //frm.ui = this.mdi.ui; //frm.ShowDialog(); ///******************************************/ ////lblReceiverConfigChangeFlag.ForeColor; //2010.12.05, k.s.d, repeater information block write. btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty); mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = false; // cyim 2017.01.12 : 등록된 통신보드 및 중계반 계통만 전체중계기쓰기 시도하자 InfoWriteBoardNo = 0; InfoWriteLoopNo = 0; if (formBoardDataDownload == null || formBoardDataDownload.Created != true) { formBoardDataDownload = new FormBoardDataDownload(this); //formBoardDataDownload.MdiParent = this.mdi; } progress = -1; this.downloadResult = true; this.LoadBoardData(); formBoardDataDownload.SetBoardData(this.LTBoard, mdi); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경 formBoardDataDownload.SetMessage("통신보드 데이터 다운로드"); formBoardDataDownload.Show(); formBoardDataDownload.Location = new Point(400, 200); // 간헐적으로 화면이 갱신이 되지 않는다 formBoardDataDownload.Update(); System.Threading.Thread.Sleep(1000); // LCH 2018.02.27 : 수정됨 // 클리어 ArrayList_ComInfo.Clear(); ArrayList_ComLevelInfo.Clear(); Hashtable_ComLevelInfo_Data.Clear(); level_num = 0; DoWriteRepeaterInfoAll(); this.Cursor = Cursors.Default; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); this.Cursor = Cursors.Default; } } private int time = 0; public Timer timer = new System.Windows.Forms.Timer(); private void time_tick(object sender, EventArgs e) { time++; if (time > 60 * 5) { time = 0; timer.Enabled = false; panel_Menu.Enabled = true; btnReceiverConfigWriteAll.Enabled = true; mdi.panel8.Enabled = true; this.panel1.Enabled = true; this.formBoardDataDownload.button1.Text = "확인"; this.formBoardDataDownload.button1.Visible = true; MessageBox.Show("시간이 초과되었습니다(5분).", Application.ProductName); return; } } private void btnReceiverConfigWriteAll_Click(object sender, EventArgs e) { // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상 this.panel_Menu.Focus(); this.ReceiverConfigWriteAll(); } // cyim 2017.01.12 : 등록된 통신보드 및 중계반 계통만 전체중계기쓰기 시도하자 // 소스 분석결과 이는 응답이 오면 다시 호출되는 재귀함수이다. 문제는 등록되지 않는 중계기까지 접근하니 비효율적인 함수이다 // 하단의 중복된 코드들은 그대로 둔다... -_-;..재귀함수에다가 GetResponseWriteRepeaterInfoBlock(null); 도 그대로 일단 두도록 한다 //2010.12.05, k.s.d, repeater information block write. int InfoWriteBoardNo = 0; int InfoWriteLoopNo = 0; int progress = 0; FormBoardDataDownload formBoardDataDownload = null; bool downloadResult = true; // LCH 2018.02.27 : 수정됨 ArrayList ArrayList_ComInfo = new ArrayList(); // DB에 사용으로 되어 있는 통신보드,채널 정보 저장 ArrayList ArrayList_ComLevelInfo = new ArrayList(); // DB에 사용으로 되어 있는 통신보드,채널 정보 중에 실질적으로 레벨 정보를 전송할 통신보드,채널 정보 저장 Hashtable Hashtable_ComLevelInfo_Data = new Hashtable(); // key : Loop:Board,Data : CmdInfo // 레벨 전송 데이터 저장 private void DoWriteRepeaterInfoAll() { try { this.progress++; if (mdi.ReceiverModel == "IFC3300") { double tempcnt = this.progress; tempcnt = Math.Round((tempcnt / (65 * 4)) * 100); this.formBoardDataDownload.SetProgress(Convert.ToInt32(tempcnt)); } else { double tempcnt = this.progress; tempcnt = Math.Round((tempcnt / (17 * 4)) * 100); this.formBoardDataDownload.SetProgress(Convert.ToInt32(tempcnt)); } // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경 int boardID_cnt = 0; // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다 if (mdi.ReceiverModel == "IFC3300") { boardID_cnt = 65; } else { boardID_cnt = 16; } // 단, 3300 이하 모델에서는 보드아이디 0 을 허용하지 않는다 if (mdi.ReceiverModel != "IFC3300" && InfoWriteBoardNo == 0) InfoWriteBoardNo = 1; // cyim 2017.01.19 : IFC3300 이하 모델에서 1번보드 부터 전체중계기 쓰기한다 // 등록중인 보드 아이디인지 체크 DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); string sql = string.Format("select * from TB_BOARD where RECEIVER_ID='{0}' and BOARD_ID='{1}' and USE_FLAG='Y' and LOOP{2}_USE_FLAG='Y'", mdi.myReceiverID, InfoWriteBoardNo, InfoWriteLoopNo); DataSet data = dacBoardConfig.Select(sql); if (data.Tables[0].Rows != null && data.Tables[0].Rows.Count > 0) { // cyim 2016.11.03 : 통신보드(중계반)는 최대 64 if (InfoWriteBoardNo < boardID_cnt) { if (DoWriteRepeaterInfoBlock(InfoWriteLoopNo, InfoWriteBoardNo) == false) { Count_Edit(); GetResponseWriteRepeaterInfoBlock(null); } else Count_Edit(); } else // 초과하면 { Count_Edit(); GetResponseWriteRepeaterInfoBlock(null); } } else { Count_Edit(); GetResponseWriteRepeaterInfoBlock(null); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void Count_Edit() { //System.Threading.Thread.Sleep(300); // IFC3300 모델은 초기값이 0으로 들어오면 된다 if (mdi.ReceiverModel == "IFC3300") { if (InfoWriteLoopNo == 3) { InfoWriteLoopNo = 0; InfoWriteBoardNo++; } else if (InfoWriteLoopNo == 2) InfoWriteLoopNo = 3; else if (InfoWriteLoopNo == 1) InfoWriteLoopNo = 2; else InfoWriteLoopNo = 1; } else { if (InfoWriteLoopNo == 1) { InfoWriteLoopNo = 0; InfoWriteBoardNo++; } else { InfoWriteLoopNo = 1; } } } private bool DoWriteRepeaterInfoBlock(int LoopNo, int BoardNo) { //Util.UDebugMessage("+DoWriteRepeaterInfoBlock", 0, 0); bool bret = false; try { if (ISBoardAndLoop(BoardNo, LoopNo)) // cyim { // LCH 2018.02.27 : 수정됨 // DB에 사용으로 되어 있는 통신보드,채널 정보 저장 ArrayList_ComInfo.Add(InfoWriteLoopNo.ToString() + ";" + InfoWriteBoardNo.ToString()); CmdInfo commandinfo = new CmdInfo(prt_cmd_define.write_repeater_info_all, mdi.myReceiverID, 1, LoopNo, BoardNo, null); dCommandResponse deleg = new dCommandResponse(GetResponseWriteRepeaterInfoBlock); commandinfo.dEvent = deleg; RepeaterDataAll RepaterDataAll = new RepeaterDataAll(); RepeaterDeviceTypeInfo[] RepeaterInfo = new RepeaterDeviceTypeInfo[127]; for (int i = 0; i < 127; i++) { RepeaterInfo[i] = new RepeaterDeviceTypeInfo(i + 1); } DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 DataTable dt = dacRepeaterConfig.Repeater_Select(mdi.myReceiverID, BoardNo, LoopNo, 0, null); DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Boolean FireResetFlag = false; String RepeaterID = Convert.ToString(dr["REPEATER_ID"]); int iRepeaterID = int.Parse(RepeaterID); if (iRepeaterID == 128) break; String RepeaterType = Convert.ToString(dr["REPEATER_TYPE"]); Boolean UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false; Boolean CutFlag = Convert.ToString(dr["CUT_FLAG"]) == "Y" ? true : false; Boolean sFireResetFlag = false; if (UseFlag && !FireResetFlag) { FireResetFlag = sFireResetFlag; } // cyim 2015.6.8 아날로그 감지기 연동 추가 // '1' = A : 2X2 // '2' = B : 4X4 // '4' = C : 아날로그연감지기 // '5' = D : 아날로그열감지기 String repeaterType = ""; if (RepeaterType.Equals("1")) repeaterType = "A"; else if (RepeaterType.Equals("2")) repeaterType = "B"; else if (RepeaterType.Equals("4")) repeaterType = "C"; else if (RepeaterType.Equals("5")) repeaterType = "D"; if (!repeaterType.Equals("")) { RepeaterInfo[iRepeaterID - 1].CutFlag = CutFlag; RepeaterInfo[iRepeaterID - 1].UseFlag = true; RepeaterInfo[iRepeaterID - 1].RepeaterType = repeaterType; RepeaterInfo[iRepeaterID - 1].FireResetFlag = sFireResetFlag; } else { RepeaterInfo[iRepeaterID - 1].UseFlag = false; } } } for (int i = 0; i < 127; i++) { int RepeaterSet = 0; if (RepeaterInfo[i].UseFlag) { if (RepeaterInfo[i].RepeaterType == "A") RepeaterSet = 1; else if (RepeaterInfo[i].RepeaterType == "B") RepeaterSet = 2; else if (RepeaterInfo[i].RepeaterType == "C") RepeaterSet = 4; else if (RepeaterInfo[i].RepeaterType == "D") RepeaterSet = 5; } RepaterDataAll.Data[i].Set_Info_Data(RepeaterInfo[i].CutFlag, RepeaterInfo[i].FireResetFlag, false, false, RepeaterSet); } commandinfo.CommandData = RepaterDataAll; this.mdi.ui.runCommand(commandinfo); bret = true; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } //Util.UDebugMessage("-DoWriteRepeaterInfoBlock", 0, 0); return bret; } // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경 private bool ISBoardAndLoop(int BoardNo, int LoopNo) { bool bret = false; try { DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 DataTable dt = dacBoardConfig.Board_Select(mdi.myReceiverID, BoardNo, null); Boolean UseFlag = false; Boolean Loop0UseFlag = false; Boolean Loop1UseFlag = false; Boolean Loop2UseFlag = false; Boolean Loop3UseFlag = false; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { int BoardId = int.Parse(Convert.ToString(dr[0])); if (BoardId == BoardNo) { Loop0UseFlag = Convert.ToString(dr["LOOP0_USE_FLAG"]) == "Y" ? true : false; Loop1UseFlag = Convert.ToString(dr["LOOP1_USE_FLAG"]) == "Y" ? true : false; Loop2UseFlag = Convert.ToString(Util.NullToStr(dr["LOOP2_USE_FLAG"])) == "Y" ? true : false; Loop3UseFlag = Convert.ToString(Util.NullToStr(dr["LOOP3_USE_FLAG"])) == "Y" ? true : false; UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false; } } } if (UseFlag) { if (LoopNo == 0) { bret = Loop0UseFlag; } else if (LoopNo == 1) { bret = Loop1UseFlag; } else if (LoopNo == 2) { bret = Loop2UseFlag; } else if (LoopNo == 3) { bret = Loop3UseFlag; } } else { bret = false; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } return bret; } public void GetResponseWriteRepeaterInfoBlock(CmdInfo resInfo) { try { if (resInfo != null) { //general_ack = 0x81, //응답-정상 //general_nack = 0x80, //응답-실패 switch (resInfo.ResCommand) { case prt_res_define.general_ack: { this.formBoardDataDownload.SetBoardDataDownloadResult(resInfo.boardNo, resInfo.loopNo, 1, mdi); // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기 // 코드 분석 결과 대용량 수신기의 경우 아날로그 감지기 레벨을 일괄적으로 통신으로 보내야되는데 // 기존의 통신보드 및 중계기 셋팅하는 코드 다음에 다시 사이클이 돌아가는 것보다 실제로 통신이 성공한 통신보드에 한해서 // 레벨값을 일괄적으로 쓰는 것이 옳다고 판단한다 // 테스트를 위해 잠시 삭제 //DoWriteAnalogDetecterLevelBlock(resInfo.boardNo, resInfo.loopNo); break; } case prt_res_define.general_nack: { this.formBoardDataDownload.SetBoardDataDownloadResult(resInfo.boardNo, resInfo.loopNo, 0, mdi); this.downloadResult = false; break; } case 0: { if (this.formBoardDataDownload != null && this.formBoardDataDownload.Created) { this.formBoardDataDownload.Close(); this.formBoardDataDownload = null; } timer.Enabled = false; panel_Menu.Enabled = true; btnReceiverConfigWriteAll.Enabled = true; mdi.panel8.Enabled = true; this.panel1.Enabled = true; MessageBox.Show("통신데몬과 연결이 되어야합니다.", Application.ProductName); return; } } } // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경 int boardID_cnt = 0; // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다 if (mdi.ReceiverModel == "IFC3300") { boardID_cnt = 64;//64 } else { boardID_cnt = 16; } // cyim 2016.11.03 : 통신보드(중계반)는 최대 64 if (InfoWriteBoardNo > boardID_cnt) { // LCH 2018.02.27 : 수정됨 if (ArrayList_ComInfo.Count != 0) // 전송할 정보 있음 { // 레벨값 전송 DoWriteAnalogDetecterLevelBlock(ArrayList_ComInfo); } else // 전송할 정보 없음 { //FormBoardDataDownload.SetMessage("설정정보가 변경되어 데몬을 Reset하였습니다."); //mdi.ui.ReceiverDBRead(); //mdi.FireReset_Process(); this.Cursor = Cursors.Default; if (this.downloadResult) { this.formBoardDataDownload.SetSucess(); } else { this.formBoardDataDownload.SetFalse(); } } } else { DoWriteRepeaterInfoAll(); } } catch (Exception ex) { this.Cursor = Cursors.Default; Util.UErrorMessage(ex, 0, 0); } } // LCH 2018.02.27 : 수정됨 // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기 //private bool DoWriteAnalogDetecterLevelBlock(int LoopNo, int BoardNo) private bool DoWriteAnalogDetecterLevelBlock(ArrayList ArrayList_ComInfo) { bool bret = false; try { for (int i = 0; i < ArrayList_ComInfo.Count; i++) { string[] temp = ((string)ArrayList_ComInfo[i]).Split(';'); int LoopNo = Int32.Parse(temp[0]); int BoardNo = Int32.Parse(temp[1]); int boardID_cnt1; if (mdi.ReceiverModel == "IFC3300") { boardID_cnt1 = 64;//64 } else { boardID_cnt1 = 16; } //20200626 //보드 64이내 아날로그 감지기 레벨 쓰기 작동을 안해 수정(조건문 제거) if (BoardNo <= boardID_cnt1) { CmdInfo commandinfo = new CmdInfo(prt_cmd_define.write_analogdetecter_level_all, mdi.myReceiverID, 1, LoopNo, BoardNo, null); // 응답처리는 하지않음. 차후 삭제 예정 dCommandResponse deleg = new dCommandResponse(GetResponseWriteAnalogDetecterLevelBlock); commandinfo.dEvent = deleg; RepeaterDataAll RepaterDataAll = new RepeaterDataAll(); // 데이타베이스에는 아날로그 감지기 레벨값만 들어있는 테이블이 따로 존재한다 DataTable dt = LoadAnalogDetecterLevel(mdi.myReceiverID, BoardNo, LoopNo, 0); // 아이디가 0 이면 해당 계통 전체를 검색 if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { String RepeaterID = Convert.ToString(dr["REPEATER_ID"]); int iRepeaterID = int.Parse(RepeaterID); RepaterDataAll.Data[iRepeaterID - 1].Set_Level_AnalogDetecter( Convert.ToByte(dr["FAULT_VALUE"]), Convert.ToByte(dr["PREFIRE_VALUE"]), Convert.ToByte(dr["FIREN_VALUE"]), Convert.ToByte(dr["FIRED_VALUE"]) ); } // 단 해당하는 Loop 에 아날로그 감지기가 없으면 패킷 전송을 할 이유가 없다 commandinfo.CommandData = RepaterDataAll; // 실질적으로 레벨 정보를 전송한 통신보드,채널 정보 저장 ArrayList_ComLevelInfo.Add(LoopNo.ToString() + ";" + BoardNo.ToString()); Hashtable_ComLevelInfo_Data.Add(LoopNo.ToString() + ";" + BoardNo.ToString(), commandinfo); } } } // 3300일때만 레벨을 전송한다 if (mdi.ReceiverModel == "IFC3300") { // 레벨을 전송 할 수 있는지 확인 if (ArrayList_ComLevelInfo.Count != 0) { // 첫번째만 출발 this.mdi.ui.runCommand((CmdInfo)Hashtable_ComLevelInfo_Data[(string)ArrayList_ComLevelInfo[0]]); bret = true; } else // 전송할 레벨이 없다 { this.formBoardDataDownload.SetFinish(); } } else { this.formBoardDataDownload.SetFinish(); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } //Util.UDebugMessage("-DoWriteRepeaterInfoBlock", 0, 0); return bret; } // LCH 2018.02.27 : 수정됨 int level_num = 0; public void GetResponseWriteAnalogDetecterLevelBlock(CmdInfo resInfo) { try { if (resInfo != null) { //general_ack = 0xA2, //응답-정상 //general_nack = 0x80, //응답-실패 switch (resInfo.ResCommand) { case prt_res_define.write_analogdetecter_level_all: { //RCVData_ACK ResponseData = (RCVData_ACK)resInfo.ResponseData; //GeneralBaseInfo baseInfo = (GeneralBaseInfo)ResponseData.Baseinfo; //int boardNo = baseInfo.UnitID_u; //int loopNo = baseInfo.UnitID_d; //20200626 내용 수정 - RCVData_ACK 형변환에서 오류 발생 RCVData_WriteAnalogDetecterLevel2 ResponseData = (RCVData_WriteAnalogDetecterLevel2)resInfo.ResponseData; int boardNo = ResponseData.Board_id; int loopNo = ResponseData.Loop_no; this.formBoardDataDownload.SetBoardDataDownloadResult(boardNo, loopNo, 1, mdi); System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + boardNo.ToString() + " " + loopNo.ToString() + " 1" + "\r\n"); break; } case prt_res_define.general_nack: { RCVData_NACK ResponseData = (RCVData_NACK)resInfo.ErrResponseData; GeneralBaseInfo baseInfo = (GeneralBaseInfo)ResponseData.Baseinfo; int boardNo = baseInfo.UnitID_u; int loopNo = baseInfo.UnitID_d; this.formBoardDataDownload.SetBoardDataDownloadResult(boardNo, loopNo, 0, mdi); System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + boardNo.ToString() + " " + loopNo.ToString() + " 0" + "\r\n"); break; } } } level_num++; System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + level_num + "\r\n"); // 완료 버튼을 보이게 한다 lch 20180101 if (level_num == ArrayList_ComLevelInfo.Count) { this.formBoardDataDownload.SetFinish(); } else { // 다음 패킷 출발 this.mdi.ui.runCommand((CmdInfo)Hashtable_ComLevelInfo_Data[(string)ArrayList_ComLevelInfo[level_num]]); } } catch (Exception ex) { this.Cursor = Cursors.Default; Util.UErrorMessage(ex, 0, 0); } } public void ResetDemon() { //mdi.ui.ReceiverDBRead(); //mdi.FireReset_Process(); // // cyim 2013.6.27 : 수신기 설정 -> 중계기 쓰기 버튼 이후 데몬 초기화 되지 않는 문제 (상위주석처리) // mdi.FireReset_Process(); mdi.socketUI.ReceiverDemonReset(); } private void frmReceiverConfig_FormClosing(object sender, FormClosingEventArgs e) { if (this.formBoardDataDownload != null && this.formBoardDataDownload.Created) { this.formBoardDataDownload.Close(); this.formBoardDataDownload = null; } } // // cyim 2013.7.10 디자인개선작업 : 수신기설정 // // 수신기 버튼 private void button_Menu_Receiver_Click(object sender, EventArgs e) { button_Menu_Color_Init(); this.tabControl_Main.SelectTab(0); this.button_Menu_Receiver.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30; this.panel_Menu.Focus(); } // 통신설정 버튼 private void button_Menu_CommSet_Click(object sender, EventArgs e) { // cyim 2014.5.7 : 통신설정메뉴 다시 불러오기 // 통신 설정의 경우 탭을 선택하면 무조건 데이타베이스에 있는 값을 읽어온다 Comm_getData(); button_Menu_Color_Init(); this.tabControl_Main.SelectTab(1); this.button_Menu_CommSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30; this.panel_Menu.Focus(); } // cyim 2016.12.13 : 수신기설정에서 IFC3300 의 경우에만 통신보드의 LOOP 0~3 으로 보여지도록 한다 private bool Check_List_ColumnText(string ColumnText) { for (int i = 0; i < this.listView_CommBoard.Columns.Count; i++) { ColumnHeader col_hr = (ColumnHeader)listView_CommBoard.Columns[i]; if (col_hr.Text == ColumnText) { return true; } } return false; } private void CheckDel_List_ColumnText(string ColumnText) { ColumnHeader remove_col_hr = null; for (int i = 0; i < this.listView_CommBoard.Columns.Count; i++) { ColumnHeader col_hr = (ColumnHeader)listView_CommBoard.Columns[i]; if (col_hr.Text == ColumnText) { listView_CommBoard.Columns.Remove(col_hr); remove_col_hr = col_hr; } } if (remove_col_hr != null) listView_CommBoard.Columns.Remove(remove_col_hr); } // 통신보드 버튼 private void button_Menu_CommBoard_Click(object sender, EventArgs e) { // 통신보드 UI 컨셉이 변경될수 있다 if (mdi.ReceiverModel == "IFC3300") { this.chkLoop2UseFlag.Visible = true; this.chkLoop3UseFlag.Visible = true; if (Check_List_ColumnText("Loop2 사용여부") == false) this.listView_CommBoard.Columns.Add("columnHeader_2", "Loop2 사용여부", 170, HorizontalAlignment.Center, 0); if (Check_List_ColumnText("Loop3 사용여부") == false) this.listView_CommBoard.Columns.Add("columnHeader_3", "Loop3 사용여부", 170, HorizontalAlignment.Center, 0); this.listView_CommBoard.Update(); } else { this.chkLoop2UseFlag.Visible = false; this.chkLoop3UseFlag.Visible = false; if (Check_List_ColumnText("Loop2 사용여부") == true) CheckDel_List_ColumnText("Loop2 사용여부"); if (Check_List_ColumnText("Loop3 사용여부") == true) CheckDel_List_ColumnText("Loop3 사용여부"); this.listView_CommBoard.Update(); } button_Menu_Color_Init(); this.tabControl_Main.SelectTab(2); this.button_Menu_CommBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30; this.panel_Menu.Focus(); } // IO보드 버튼 private void button_Menu_IOBoard_Click(object sender, EventArgs e) { button_Menu_Color_Init(); this.tabControl_Main.SelectTab(3); this.button_Menu_IOBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30; this.panel_Menu.Focus(); } // 중계기 버튼 private void button_Menu_Repeater_Click(object sender, EventArgs e) { button_Menu_Color_Init(); this.tabControl_Main.SelectTab(4); this.button_Menu_Repeater.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30; this.panel_Menu.Focus(); } // 버튼 색상 초기화 private void button_Menu_Color_Init() { this.button_Menu_Receiver.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30; this.button_Menu_CommSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30; this.button_Menu_CommBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30; this.button_Menu_IOBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30; this.button_Menu_Repeater.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30; } /******************************************************************************************************/ #region 중계기 및 회로 설정 //중계기및 회로 설정정보 RepeaterDeviceTypeInfo[] REP = new RepeaterDeviceTypeInfo[127]; private void cboBoardList_SelectedIndexChanged(object sender, EventArgs e) { try { if (cboBoardList.SelectedValue != null) { String BoardId = cboBoardList.SelectedValue.ToString(); //cboLoopList DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 ArrayList ary = dacBoardConfig.Loop_List(mdi.myReceiverID, int.Parse(BoardId)); Util.ComboSetting(cboLoopList, ary, null); } else { Util.ComboSetting(cboLoopList, null, null); } Repeater_getDate(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName); } } private void Repeater_init() { try { //dataGridView1,dataGridView2 try { this.dataGridView_Repeater_Main.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++) { dataGridView_Repeater_Main.Columns.Add(new DataGridViewTextBoxColumn()); dataGridView_Repeater_Main.Columns[col].ReadOnly = true; dataGridView_Repeater_Main.Columns[col].Resizable = DataGridViewTriState.False; dataGridView_Repeater_Main.Columns[col].Width = 70; dataGridView_Repeater_Main.Columns[col].DefaultCellStyle = sty; } /************************************************************************/ /************************************************************************/ /* dataGridView1 Row 생성.. 총 127개 Cell */ /************************************************************************/ this.dataGridView_Repeater_Main.Rows.Clear(); DataGridViewRowCollection rows = this.dataGridView_Repeater_Main.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(""); chkSelectAll.Text = "전체선택"; chkSelectAll.Checked = false; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); throw ex; } } private void Device_Init(String Type) { try { this.dataGridView_Repeater_Sub.Columns.Clear(); mskDeviceID.Text = ""; txtDeviceTypeCode.Text = ""; txtDeviceTypeName.Text = ""; txtPositionCode.Text = ""; txtPositionName.Text = ""; txtDeviceMemo.Text = ""; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } try { if (Type == null) return; /************************************************************************/ /* dataGridView2 헤더 설정 */ /************************************************************************/ // 사용 DataGridViewCellStyle sty2 = new DataGridViewCellStyle(); sty2.Alignment = DataGridViewContentAlignment.MiddleCenter; sty2.BackColor = System.Drawing.Color.White; sty2.Font = new System.Drawing.Font("굴림", 12); // 비사용 DataGridViewCellStyle styGray = new DataGridViewCellStyle(); styGray.Alignment = DataGridViewContentAlignment.MiddleLeft; styGray.BackColor = System.Drawing.Color.LightGray; styGray.SelectionBackColor = System.Drawing.Color.Gray; styGray.Font = new System.Drawing.Font("굴림", 12); // cyim 2015.6.8 아날로그 감지기 연동 추가 // 아래의 타입 전부 허용 // '1' = A : 2X2 // '2' = B : 4X4 // '4' = C : 아날로그연감지기 // '5' = D : 아날로그열감지기 for (int i = 0; i < 8; i++) { dataGridView_Repeater_Sub.Columns.Add(new DataGridViewTextBoxColumn()); ((DataGridViewTextBoxColumn)dataGridView_Repeater_Sub.Columns[i]).MaxInputLength = 2; dataGridView_Repeater_Sub.Columns[i].ReadOnly = true; dataGridView_Repeater_Sub.Columns[i].Resizable = DataGridViewTriState.False; dataGridView_Repeater_Sub.Columns[i].Width = 70; if (Type.Equals("A") && (i == 2 || i == 3 || i == 6 || i == 7)) dataGridView_Repeater_Sub.Columns[i].DefaultCellStyle = styGray; else if ((Type.Equals("C") || Type.Equals("D")) && (i == 1 || i == 2 || i == 3 || i == 5 || i == 6 || i == 7)) dataGridView_Repeater_Sub.Columns[i].DefaultCellStyle = styGray; else dataGridView_Repeater_Sub.Columns[i].DefaultCellStyle = sty2; dataGridView_Repeater_Sub.Columns[i].HeaderText = i < 4 ? "I" : "O"; dataGridView_Repeater_Sub.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } // 하단 문구 초기화 mskDeviceID.Text = ""; txtDeviceTypeCode.Text = ""; txtDeviceTypeName.Text = ""; txtPositionCode.Text = ""; txtPositionName.Text = ""; txtDeviceMemo.Text = ""; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //선택값이 틀릴때마다 해당중계기 설정내용 radio에 표시 private void dataGridView1_SelectionChanged(object sender, EventArgs e) { try { if (dataGridView_Repeater_Main.SelectedCells.Count > 1) { lblRepeaterID.Text = ""; String RepeaterTypeSaved = ""; Boolean RepeaterUse = true; //Boolean outFlag = true; foreach (DataGridViewCell cell in dataGridView_Repeater_Main.SelectedCells) { if (cell.Value != null) { String value = cell.Value.ToString(); if (value.Length > 3) { String RepeaterType = value.Substring(0, 1); if (RepeaterTypeSaved.Equals("")) RepeaterTypeSaved = RepeaterType; else if (!RepeaterTypeSaved.Equals(RepeaterType)) RepeaterTypeSaved = "Un Incorrect"; //if (cell.Style.BackColor == System.Drawing.Color.Silver && outFlag) outFlag = true; else outFlag = false; } else { RepeaterTypeSaved = "Un Incorrect"; RepeaterUse = false; } // cyim 2015.6.8 아날로그 감지기 연동 추가 if (RepeaterUse && !(RepeaterTypeSaved.Equals("A") || RepeaterTypeSaved.Equals("B") || RepeaterTypeSaved.Equals("C") || RepeaterTypeSaved.Equals("D"))) RepeaterTypeSaved = "USED"; RepeaterTypeRadio(RepeaterTypeSaved); } } } else { try { DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0]; object value = cell.Value; if (value == null) RepeaterStatus(""); else { //Boolean outFlag = false; //if (cell.Style.BackColor == System.Drawing.Color.Silver) outFlag = true; RepeaterStatus(value.ToString()); //RepeaterTypeRadio(value.ToString(), outFlag); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } } 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); } // cyim 2015.6.8 아날로그 감지기 연동 추가 lblRepeaterID.Text = RepeaterID; switch (RepeaterType) { case "A": case "B": lblRepeaterName.Text = "중계기"; break; case "C": lblRepeaterName.Text = "연감지기"; break; case "D": lblRepeaterName.Text = "열감지기"; break; } RepeaterTypeRadio(RepeaterType); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //셀의 타입으로 중계기 설정을 Radio버튼에 표시 private void RepeaterTypeRadio(String tp) { try { // cyim 2015.6.8 아날로그 감지기 연동 추가 if (tp.Equals("A")) { rdoRepeaterType_A.Checked = true; rdoRepeaterType_B.Checked = false; rdoRepeaterType_C.Checked = false; rdoRepeaterType_D.Checked = false; chkRepeaterUse.Checked = true; rdoRepeaterType1_CheckedChanged(rdoRepeaterType_A, System.EventArgs.Empty); } else if (tp.Equals("B")) { rdoRepeaterType_A.Checked = false; rdoRepeaterType_B.Checked = true; rdoRepeaterType_C.Checked = false; rdoRepeaterType_D.Checked = false; chkRepeaterUse.Checked = true; rdoRepeaterType2_CheckedChanged(rdoRepeaterType_B, System.EventArgs.Empty); } else if (tp.Equals("C")) { rdoRepeaterType_A.Checked = false; rdoRepeaterType_B.Checked = false; rdoRepeaterType_C.Checked = true; rdoRepeaterType_D.Checked = false; chkRepeaterUse.Checked = true; rdoRepeaterType3_CheckedChanged(rdoRepeaterType_A, System.EventArgs.Empty); } else if (tp.Equals("D")) { rdoRepeaterType_A.Checked = false; rdoRepeaterType_B.Checked = false; rdoRepeaterType_C.Checked = false; rdoRepeaterType_D.Checked = true; chkRepeaterUse.Checked = true; rdoRepeaterType4_CheckedChanged(rdoRepeaterType_A, System.EventArgs.Empty); } else if (tp.Equals("USED")) { rdoRepeaterType_A.Checked = false; rdoRepeaterType_B.Checked = false; rdoRepeaterType_C.Checked = false; rdoRepeaterType_D.Checked = false; chkRepeaterUse.Checked = true; } else { rdoRepeaterType_A.Checked = false; rdoRepeaterType_B.Checked = false; rdoRepeaterType_C.Checked = false; rdoRepeaterType_D.Checked = false; chkRepeaterUse.Checked = false; DeviceStatus(null); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } // cyim 2015.6.8 아날로그 감지기 연동 추가 // '1' = A : 2X2 // '2' = B : 4X4 // '4' = C : 아날로그연감지기 // '5' = D : 아날로그열감지기 private void rdoRepeaterType1_Click(object sender, EventArgs e) { try { if (rdoRepeaterType_A.Checked) rdoRepeaterTypeChange("A"); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void rdoRepeaterType2_Click(object sender, EventArgs e) { try { if (rdoRepeaterType_B.Checked) rdoRepeaterTypeChange("B"); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void rdoRepeaterType3_Click(object sender, EventArgs e) { try { if (rdoRepeaterType_C.Checked) rdoRepeaterTypeChange("C"); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void rdoRepeaterType4_Click(object sender, EventArgs e) { try { if (rdoRepeaterType_D.Checked) rdoRepeaterTypeChange("D"); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //회로타입 표시 private void rdoRepeaterTypeChange(String RepeaterType) { try { DataGridViewCellStyle sty = new DataGridViewCellStyle(); sty.Alignment = DataGridViewContentAlignment.MiddleCenter; sty.BackColor = System.Drawing.Color.Aqua; foreach (DataGridViewCell cell in dataGridView_Repeater_Main.SelectedCells) { if (cell.Value != null) { String value = cell.Value.ToString(); String RepeaterID = value; if (value.Length > 3) { RepeaterID = value.Substring(1, 3); } cell.Value = RepeaterType + RepeaterID; cell.Style = sty; REP[int.Parse(RepeaterID) - 1].RepeaterType = RepeaterType; REP[int.Parse(RepeaterID) - 1].UseFlag = true; REP[int.Parse(RepeaterID) - 1].CutFlag = false; } } //사용회로로 표시 chkRepeaterUse.Checked = true; mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨. } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void chkRepeaterUse_Click(object sender, EventArgs e) { try { //사용-->비사용으로 if (chkRepeaterUse.Checked) { DataGridViewCellStyle sty = new DataGridViewCellStyle(); sty.Alignment = DataGridViewContentAlignment.MiddleCenter; sty.BackColor = System.Drawing.Color.White; foreach (DataGridViewCell cell in dataGridView_Repeater_Main.SelectedCells) { if (cell.Value != null) { String value = cell.Value.ToString(); String RepeaterID = value; if (value.Length > 3) { RepeaterID = value.Substring(1, 3); REP[int.Parse(RepeaterID) - 1].UseFlag = false; REP[int.Parse(RepeaterID) - 1].RepeaterType = ""; } cell.Value = RepeaterID; cell.Style = sty; } } //비사용회로로 표시 chkRepeaterUse.Checked = false; mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨. } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //dataGridView2에 중계기 회로설정 화면생성 private void DeviceStatus(RepeaterDeviceTypeInfo dt) { try { if (dt == null) { Device_Init(null); return; } Device_Init(dt.RepeaterType); this.dataGridView_Repeater_Sub.Rows.Clear(); if (dt != null) { DataGridViewCellStyle sty_in = new DataGridViewCellStyle(); sty_in.Alignment = DataGridViewContentAlignment.MiddleCenter; sty_in.BackColor = System.Drawing.Color.Gold; DataGridViewCellStyle sty_out = new DataGridViewCellStyle(); sty_out.Alignment = DataGridViewContentAlignment.MiddleCenter; sty_out.BackColor = System.Drawing.Color.MintCream; if (dt.RepeaterType.Equals("A")) { string[] row1 = new string[] { "1", "2", "", "", "1", "2", "", "" }; this.dataGridView_Repeater_Sub.Rows.Add(row1); DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows; //입력설정값 for (int i = 0; i < 2; i++) rows2[0].Cells[i].Style = sty_in; //출력설정값 for (int i = 0; i < 2; i++) rows2[0].Cells[i + 4].Style = sty_out; // 인덱스 오류 수정 rows2[0].Height = 40; } else if (dt.RepeaterType.Equals("B")) { string[] row2 = new string[] { "1", "2", "3", "4", "1", "2", "3", "4" }; this.dataGridView_Repeater_Sub.Rows.Add(row2); DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows; //입력설정값 for (int i = 0; i < 4; i++) rows2[0].Cells[i].Style = sty_in; //출력설정값 for (int i = 0; i < 4; i++) rows2[0].Cells[i + 4].Style = sty_out; rows2[0].Height = 40; } // cyim 2015.6.8 아날로그 감지기 연동 추가 else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D")) { string[] row1 = new string[] { "1", "", "", "", "1", "", "", "" }; this.dataGridView_Repeater_Sub.Rows.Add(row1); DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows; //입력설정값 for (int i = 0; i < 1; i++) rows2[0].Cells[i].Style = sty_in; //출력설정값 for (int i = 0; i < 1; i++) rows2[0].Cells[i + 4].Style = sty_out; rows2[0].Height = 40; } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } // cyim 2015.6.8 아날로그 감지기 연동 추가 // '1' = A : 2X2 // '2' = B : 4X4 // '4' = C : 아날로그연감지기 // '5' = D : 아날로그열감지기 private void rdoRepeaterType1_CheckedChanged(object sender, EventArgs e) { try { if (rdoRepeaterType_A.Checked) { if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1) { DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0]; if (cell.Value != null) { String value = cell.Value.ToString(); String RepeaterID = value; if (value.Length > 3) { RepeaterID = value.Substring(1, 3); } //Boolean outFlag = false; //if (cell.Style.BackColor == System.Drawing.Color.Silver) outFlag = true; //해당 중계기의 회로표시 RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 dev.RepeaterType = "A"; DeviceStatus(dev); } } else { DeviceStatus(null); } } else { DeviceStatus(null); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //중계기가 1개만 선택되었을때 회로 표시(4*4 회로) private void rdoRepeaterType2_CheckedChanged(object sender, EventArgs e) { try { if (rdoRepeaterType_B.Checked) { if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1) { DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0]; if (cell.Value != null) { String value = cell.Value.ToString(); String RepeaterID = value; if (value.Length > 3) { RepeaterID = value.Substring(1, 3); } //Boolean outFlag = false; //if (cell.Style.BackColor == System.Drawing.Color.Silver) outFlag = true; //해당 중계기의 회로표시 RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 dev.RepeaterType = "B"; DeviceStatus(dev); } } else { DeviceStatus(null); } } else { DeviceStatus(null); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void rdoRepeaterType3_CheckedChanged(object sender, EventArgs e) { try { if (rdoRepeaterType_C.Checked) { if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1) { DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0]; if (cell.Value != null) { String value = cell.Value.ToString(); String RepeaterID = value; if (value.Length > 3) { RepeaterID = value.Substring(1, 3); } //해당 중계기의 회로표시 RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 dev.RepeaterType = "C"; DeviceStatus(dev); } } else { DeviceStatus(null); } } else { DeviceStatus(null); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void rdoRepeaterType4_CheckedChanged(object sender, EventArgs e) { try { if (rdoRepeaterType_D.Checked) { if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1) { DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0]; if (cell.Value != null) { String value = cell.Value.ToString(); String RepeaterID = value; if (value.Length > 3) { RepeaterID = value.Substring(1, 3); } //해당 중계기의 회로표시 RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 dev.RepeaterType = "D"; DeviceStatus(dev); } } else { DeviceStatus(null); } } else { DeviceStatus(null); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //중계기 DB에서 자료가져오기 private void Repeater_getDate() { try { if (cboBoardList.Items.Count < 1 || cboLoopList.Items.Count < 1) { this.dataGridView_Repeater_Main.Columns.Clear(); //중계기 설정내용 표시 RepeaterStatus(""); savBoardID = -1; savLoop = -1; return; } if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) { Repeater_init(); return; } String BoardID = cboBoardList.SelectedItem.ToString(); String Loop = cboLoopList.SelectedItem.ToString(); if (int.Parse(BoardID) == savBoardID && int.Parse(Loop) == savLoop) return; savBoardID = int.Parse(BoardID); savLoop = int.Parse(Loop); Repeater_init(); DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 DataTable dt = dacRepeaterConfig.Repeater_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), 0, null); DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 Boolean FireResetFlag = false; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { //중계기설정값 String RepeaterID = Convert.ToString(dr["REPEATER_ID"]); // '1' = A : 2X2 // '2' = B : 4X4 // '4' = C : 아날로그연감지기 // '5' = D : 아날로그열감지기 String RepeaterType = Convert.ToString(dr["REPEATER_TYPE"]); Boolean UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false; Boolean CutFlag = Convert.ToString(dr["CUT_FLAG"]) == "Y" ? true : false; //사용중인 중계기의 비화재보호 FALG를 읽는다. Boolean sFireResetFlag = false; if (UseFlag && !FireResetFlag) FireResetFlag = sFireResetFlag; String repeaterType = ""; if (RepeaterType.Equals("1")) repeaterType = "A"; else if (RepeaterType.Equals("2")) repeaterType = "B"; else if (RepeaterType.Equals("4")) repeaterType = "C"; else if (RepeaterType.Equals("5")) repeaterType = "D"; RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 if (!repeaterType.Equals("")) { dev.UseFlag = true; dev.RepeaterType = repeaterType; dev.CutFlag = CutFlag; dev.FireResetFlag = sFireResetFlag; } else dev.UseFlag = false; //회로설정값 //String[] InType = new String[4]; //String[] InTypeName = new String[4]; //String[] OutType = new String[4]; //String[] OutTypeName = new String[4]; DeviceTypeInfo[] inDeviceTypeInfo; DeviceTypeInfo[] outDeviceTypeInfo; if (repeaterType.Equals("A")) { inDeviceTypeInfo = new DeviceTypeInfo[2] { new DeviceTypeInfo(1), new DeviceTypeInfo(2) }; outDeviceTypeInfo = new DeviceTypeInfo[2] { new DeviceTypeInfo(1), new DeviceTypeInfo(2) }; DataTable dt2 = dacDeviceConfig.Device_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), int.Parse(RepeaterID), 0, null); foreach (DataRow dr2 in dt2.Rows) { int DeviceID = int.Parse(dr2["DEVICE_ID"].ToString()); String InoutType = dr2["INOUT_TYPE"].ToString(); if (InoutType.Equals(code_GroupIO.Input)) { inDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID); inDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString(); inDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString(); inDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false; inDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString(); } else { outDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID); outDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString(); outDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString(); outDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false; outDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString(); } } dev.inDeviceTypeInfos = inDeviceTypeInfo; dev.outDeviceTypeInfos = outDeviceTypeInfo; } else if (repeaterType.Equals("B")) { inDeviceTypeInfo = new DeviceTypeInfo[4]; outDeviceTypeInfo = new DeviceTypeInfo[4]; DataTable dt2 = dacDeviceConfig.Device_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), int.Parse(RepeaterID), 0, null); foreach (DataRow dr2 in dt2.Rows) { int DeviceID = int.Parse(dr2["DEVICE_ID"].ToString()); String InoutType = dr2["INOUT_TYPE"].ToString(); if (InoutType.Equals(code_GroupIO.Input)) { inDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID); inDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString(); inDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString(); inDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false; inDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString(); } else { outDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID); outDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString(); outDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString(); outDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false; outDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString(); } } dev.inDeviceTypeInfos = inDeviceTypeInfo; dev.outDeviceTypeInfos = outDeviceTypeInfo; } // cyim 2015.6.8 아날로그 감지기 연동 추가 else if (repeaterType.Equals("C") || repeaterType.Equals("D")) { inDeviceTypeInfo = new DeviceTypeInfo[1] { new DeviceTypeInfo(1) }; outDeviceTypeInfo = new DeviceTypeInfo[1] { new DeviceTypeInfo(1) }; DataTable dt2 = dacDeviceConfig.Device_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), int.Parse(RepeaterID), 0, null); foreach (DataRow dr2 in dt2.Rows) { int DeviceID = int.Parse(dr2["DEVICE_ID"].ToString()); String InoutType = dr2["INOUT_TYPE"].ToString(); if (InoutType.Equals(code_GroupIO.Input)) { inDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID); inDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString(); inDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString(); inDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false; inDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString(); } else { outDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID); outDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString(); outDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString(); outDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false; outDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString(); } } dev.inDeviceTypeInfos = inDeviceTypeInfo; dev.outDeviceTypeInfos = outDeviceTypeInfo; } } } 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; //중계기 차단 스타일 DataGridViewCellStyle styOut = new DataGridViewCellStyle(); styOut.Alignment = DataGridViewContentAlignment.MiddleCenter; styOut.BackColor = System.Drawing.Color.Silver; foreach (DataGridViewRow row in this.dataGridView_Repeater_Main.Rows) { colCnt = 0; foreach (DataGridViewCell col in row.Cells) { ++colCnt; int no = rowCnt * 10 + colCnt; if (no <= 127) { RepeaterDeviceTypeInfo dev = REP[no - 1]; //중계기및 회로 설정정보 col.Value = String.Format("{0}{1:000}", dev.RepeaterType, no); if (dev.CutFlag) { col.Style = styOut; } else if (dev.UseFlag) { col.Style = styUse; } else { col.Style = styUnUse; } } } ++rowCnt; } //비화재보호기능 chkFireResetFlag.Checked = FireResetFlag; //첫번째 중계기가 선택되므로 회로 표시 RepeaterStatus(String.Format("{0}001", REP[0].RepeaterType)); DeviceStatus(REP[0]); // cyim 2014.5.7 : 수신기설정정보 변경 (하단 코드로 인하여 강제로 삭제되버린다) //표시된 보드가 변경되면 수신기 변경은 무효됨... //mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = false; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName); } } //중계기 회로 설정값 저장버튼 클릭시 private void btnRepeaterSave_Click(object sender, EventArgs e) { try { if (cboBoardList.Items.Count < 1) return; if (cboLoopList.Items.Count < 1) return; if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) return; String BoardID = cboBoardList.SelectedItem.ToString(); String Loop = cboLoopList.SelectedItem.ToString(); int LoopNo = int.Parse(Loop); //String FireResetFlag = chkFireResetFlag.Checked ? "Y" : "N"; this.Cursor = Cursors.WaitCursor; DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 for (int i = 0; i < 127; i++) { int RepeaterId = i + 1; //중계기및 회로 설정정보 RepeaterDeviceTypeInfo dev = REP[i]; String RepeaterType = dev.RepeaterType == null ? "" : dev.RepeaterType; if (RepeaterType.Equals("")) { //중계기 타입이 없는경우는 삭제한다. dacRepeaterConfig.Repeater_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, "중계기" + RepeaterId.ToString(), "", ""); dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo, RepeaterId, 0, "", "", "", ""); } else { //차단된 중계기는 비사용으로 저장한다. //String UseFlag = dev.CutFlag ? "N" : "Y"; String UseFlag = "Y"; // cyim 2015.6.8 아날로그 감지기 연동 추가 // '1' = A : 2X2 // '2' = B : 4X4 // '4' = C : 아날로그연감지기 // '5' = D : 아날로그열감지기 if (dev.RepeaterType == "A") RepeaterType = "1"; else if (dev.RepeaterType == "B") RepeaterType = "2"; else if (dev.RepeaterType == "C") RepeaterType = "4"; else if (dev.RepeaterType == "D") RepeaterType = "5"; //중계기 설정값 저장 dacRepeaterConfig.Repeater_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, "중계기" + RepeaterId.ToString() , RepeaterType, UseFlag); DeviceTypeInfo[] inDeviceTypeInfo = dev.inDeviceTypeInfos; DeviceTypeInfo[] outDeviceTypeInfo = dev.outDeviceTypeInfos; if (dev.RepeaterType.Equals("A")) { for (int DevID = 1; DevID <= 2; DevID++) { if (inDeviceTypeInfo[DevID - 1] != null) { //회로타입이 없는경우 삭제한다.. if (inDeviceTypeInfo[DevID - 1].DeviceType.Equals("")) { dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode); } else { dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode); } } if (outDeviceTypeInfo[DevID - 1] != null) { //회로타입이 없는경우 삭제한다.. if (outDeviceTypeInfo[DevID - 1].DeviceType.Equals("")) { dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode); } else { dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode); } } } } else if (dev.RepeaterType.Equals("B")) { for (int DevID = 1; DevID <= 4; DevID++) { if (inDeviceTypeInfo[DevID - 1] != null) { //회로타입이 없는경우 삭제한다.. if (inDeviceTypeInfo[DevID - 1].DeviceType.Equals("")) { dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode); } else { dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode); } } if (outDeviceTypeInfo[DevID - 1] != null) { //회로타입이 없는경우 삭제한다.. if (outDeviceTypeInfo[DevID - 1].DeviceType.Equals("")) { dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode); } else { dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode); } } } } // cyim 2015.6.8 아날로그 감지기 연동 추가 else if (dev.RepeaterType.Equals("C") || dev.RepeaterType.Equals("D")) { for (int DevID = 1; DevID <= 1; DevID++) { if (inDeviceTypeInfo[DevID - 1] != null) { //회로타입이 없는경우 삭제한다.. if (inDeviceTypeInfo[DevID - 1].DeviceType.Equals("")) { dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode); } else { dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode); } } if (outDeviceTypeInfo[DevID - 1] != null) { //회로타입이 없는경우 삭제한다.. if (outDeviceTypeInfo[DevID - 1].DeviceType.Equals("")) { dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode); } else { dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode); } } } } } } //수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //MessageBox.Show("저장되었습니다.", Application.ProductName); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName); } finally { this.Cursor = Cursors.Default; } } //Loop선택을 변경하면 데이터를 다시 읽는다 private void cboLoopList_SelectedIndexChanged(object sender, EventArgs e) { try { Repeater_getDate(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //1Page로 이동 private void btnPage1_Click(object sender, EventArgs e) { try { Point pos = dataGridView_Repeater_Main.Location; pos.Y = 0; dataGridView_Repeater_Main.Location = pos; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //2Page로 이동 private void btnPage2_Click(object sender, EventArgs e) { try { Point pos = dataGridView_Repeater_Main.Location; pos.Y = -(23 * 7 + 1); //row height : 23, 페이지row수: 7 dataGridView_Repeater_Main.Location = pos; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } //수신기쓰기 버튼 private void btnReceiverWrite_Click(object sender, EventArgs e) { try { if (cboBoardList.Items.Count < 1) return; if (cboLoopList.Items.Count < 1) return; //btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty); if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) return; String BoardID = cboBoardList.SelectedItem.ToString(); String Loop = cboLoopList.SelectedItem.ToString(); int LoopNo = int.Parse(Loop); int BoardNo = int.Parse(BoardID); bool FireResetFlag = chkFireResetFlag.Checked; if (MessageBox.Show("모든 데이타 저장(수신기 쓰기) 버튼을 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes) { this.Cursor = Cursors.WaitCursor; btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty); //2010.12.05, k.s.d, repeater information unit write -> don't use. /******************************************/ /* 중계기 쓰기 Progress 표시 */ /******************************************/ //frmProgress frm = new frmProgress(); ////중계기 설정 데이터를 CmdInfo에 넣어준다.. //CmdInfo cmd = new CmdInfo(prt_cmd_define.write_repeater_info_unit, mdi.myReceiverID, 1, LoopNo, BoardNo, null); ////ReceiverTypeInfo Receiverinfo = this.mdi.ui.MyReceiverTypeInfo; //수신기설정 ////BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(BoardNo); //통신보드savBoardID의 설정값 ////RepeaterDeviceTypeInfo[] repinfo; //중계기설정정보-설정쓰기를 위해 ////if (LoopNo == 0) ////{ //// repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값 ////} ////else ////{ //// repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값 ////} ////cmd.CommandData = repinfo; //cmd.CommandData = REP; //화면에 설정된 데이터를 쓰기데이터로 이용한다. //frm.Commandinfo = cmd; //frm.ui = this.mdi.ui; ////frm.ShowDialog(); ///******************************************/ //2010.12.05, k.s.d, repeater information block write. DoWriteRepeaterInfoBoard_Loop(LoopNo, BoardNo); btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty); this.Cursor = Cursors.Default; mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = false; //수신기쓰기완료 } } 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.Source), Application.ProductName); } finally { this.Cursor = Cursors.Default; } } //2010.12.05, k.s.d, repeater information block write. private void DoWriteRepeaterInfoBoard_Loop(int LoopNo, int BoardNo) { CmdInfo commandinfo = new CmdInfo(prt_cmd_define.write_repeater_info_all, mdi.myReceiverID, 1, LoopNo, BoardNo, null); dCommandResponse deleg = new dCommandResponse(GetResponseWriteRepeaterInfoAll); commandinfo.dEvent = deleg; RepeaterDataAll RepaterDataAll = new RepeaterDataAll(); for (int i = 0; i < 127; i++) { int RepeaterSet = 0; if (REP[i].UseFlag) { // cyim 2015.6.8 아날로그 감지기 연동 추가 if (REP[i].RepeaterType == "A") RepeaterSet = 1; else if (REP[i].RepeaterType == "B") RepeaterSet = 2; else if (REP[i].RepeaterType == "C") RepeaterSet = 4; else if (REP[i].RepeaterType == "D") RepeaterSet = 5; } RepaterDataAll.Data[i].Set_Info_Data(REP[i].CutFlag, REP[i].FireResetFlag, false, false, RepeaterSet); } commandinfo.CommandData = RepaterDataAll; this.mdi.ui.runCommand(commandinfo); } public void GetResponseWriteRepeaterInfoAll(CmdInfo resInfo) { mdi.ui.ReceiverDBRead(); //DB Read mdi.FireReset_Process(); //demon RESET this.lblReceiverConfigChangeFlag.Text = "모든 데이타 저장 (수신기 쓰기)이 완료되었습니다."; this.lblReceiverConfigChangeFlag.Visible = true; this.Cursor = Cursors.Default; MessageBox.Show("설정정보가 변경되어 데몬을 Reset하였습니다.", Application.ProductName); } //선택값이 틀릴때마다 해당중계기 설정내용 radio에 표시 private void dataGridView2_SelectionChanged(object sender, EventArgs e) { if (dataGridView_Repeater_Sub.SelectedCells.Count > 0) { try { if (cboBoardList.Items.Count < 1) return; if (cboLoopList.Items.Count < 1) return; DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0]; int devNo = selectCell.ColumnIndex; string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText); devNo = (devNo % 4); int RepeaterID = Util.StrToInt(lblRepeaterID.Text, 0); if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) return; int BoardID = Util.StrToInt(cboBoardList.SelectedItem, -1); int LoopNo = Util.StrToInt(cboLoopList.SelectedItem, -1); MskDeviceIDString device_str = new MskDeviceIDString(1, BoardID , LoopNo, RepeaterID, devNo + 1, inputType); mskDeviceID.Text = device_str.MskId; RepeaterDeviceTypeInfo rep = REP[RepeaterID - 1]; //중계기및 회로 설정정보 if (rep != null) { DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 if (inputType.Equals(code_InOutType.Input)) { DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo]; if (dev != null) { txtDeviceTypeCode.Text = dev.DeviceType; String type_name = dacDeviceConfig.Device_Type_Name(inputType, dev.DeviceType); txtDeviceTypeName.Text = type_name; txtPositionCode.Text = dev.PositionCode; String position_name = dacDeviceConfig.Device_Position_Name(dev.PositionCode); txtPositionName.Text = position_name; txtDeviceMemo.Text = dev.DeviceName; } else { mskDeviceID.Text = ""; txtDeviceTypeCode.Text = ""; txtDeviceTypeName.Text = ""; txtPositionCode.Text = ""; txtPositionName.Text = ""; txtDeviceMemo.Text = ""; } } else if (inputType.Equals(code_InOutType.Output)) { DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo]; if (dev != null) { txtDeviceTypeCode.Text = dev.DeviceType; String type_name = dacDeviceConfig.Device_Type_Name(inputType, dev.DeviceType); txtDeviceTypeName.Text = type_name; txtPositionCode.Text = dev.PositionCode; String position_name = dacDeviceConfig.Device_Position_Name(dev.PositionCode); txtPositionName.Text = position_name; txtDeviceMemo.Text = dev.DeviceName; } else { mskDeviceID.Text = ""; txtDeviceTypeCode.Text = ""; txtDeviceTypeName.Text = ""; txtPositionCode.Text = ""; txtPositionName.Text = ""; txtDeviceMemo.Text = ""; } } } else { mskDeviceID.Text = ""; txtDeviceTypeCode.Text = ""; txtDeviceTypeName.Text = ""; txtPositionCode.Text = ""; txtPositionName.Text = ""; txtDeviceMemo.Text = ""; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName); } } } private void btnDeviceSearchOpen_Click(object sender, EventArgs e) { try { if (this.dataGridView_Repeater_Sub.SelectedCells.Count < 1) return; //코드를 찾는 모달창을 연다.. DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0]; int devNo = selectCell.ColumnIndex; string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText); devNo = (devNo % 4); frmModalDeviceType frm = new frmModalDeviceType(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경 SearchCodeVo vo = new SearchCodeVo(inputType); vo.Code = txtDeviceTypeCode.Text.Trim(); vo.CodeName = txtDeviceTypeName.Text.Trim(); frm.SearchCode = vo; frm.ShowDialog(); vo = frm.SearchCode; //선택한 코드가 있다면 if (vo.SearchOK) { //선택한 코드값을 dataGridView2에 표시 txtDeviceTypeCode.Text = vo.Code; txtDeviceTypeName.Text = vo.CodeName; //변경값 저장 String RepeaterID = lblRepeaterID.Text; if (!RepeaterID.Equals("")) { RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 if (rep != null) { if (inputType.Equals(code_InOutType.Input)) { DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.DeviceType = vo.Code; //dev.DeviceName = txtDeviceMemo.Text.Trim(); //dev.PositionCode = txtPositionCode.Text.Trim(); //REP[int.Parse(RepeaterID) - 1].setInputDeviceTypeInfo(devNo + 1, vo.Code, txtDeviceMemo.Text.Trim(),txtPositionCode.Text.Trim(), false); rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨. //DeviceStatus(rep); } else if (inputType.Equals(code_InOutType.Output)) { DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.DeviceType = vo.Code; //dev.DeviceName = txtDeviceMemo.Text.Trim(); //dev.PositionCode = txtPositionCode.Text.Trim(); //REP[int.Parse(RepeaterID) - 1].setOutputDeviceTypeInfo(devNo + 1, vo.Code, txtDeviceMemo.Text.Trim(), txtPositionCode.Text.Trim(), false); rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨. } } } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName); } } private void btnPositionSearchOpen_Click(object sender, EventArgs e) { try { if (this.dataGridView_Repeater_Sub.SelectedCells.Count < 1) return; //코드를 찾는 모달창을 연다.. DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0]; int devNo = selectCell.ColumnIndex; string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText); devNo = (devNo % 4); frmModalPositionCode frm = new frmModalPositionCode(); SearchCodeVo vo = new SearchCodeVo(null); vo.Code = txtPositionCode.Text.Trim(); vo.CodeName = txtPositionName.Text.Trim(); frm.setMdiParent(this.mdi); frm.SearchCode = vo; frm.ShowDialog(); vo = frm.SearchCode; //선택한 코드가 있다면 if (vo.SearchOK) { //선택한 코드값을 dataGridView2에 표시 txtPositionCode.Text = vo.Code; txtPositionName.Text = vo.CodeName; //변경값 저장 String RepeaterID = lblRepeaterID.Text; if (!RepeaterID.Equals("")) { RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 if (rep != null) { if (inputType.Equals(code_InOutType.Input)) { DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.PositionCode = vo.Code; mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨. } else if (inputType.Equals(code_InOutType.Output)) { DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.PositionCode = vo.Code; mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; //설정변경됨. } } } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName); } } private void txtDeviceMemo_TextChanged(object sender, EventArgs e) { try { //코드를 찾는 모달창을 연다.. if (txtDeviceMemo.Text.Trim().Equals("")) return; if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0) { DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0]; int devNo = selectCell.ColumnIndex; string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText); devNo = (devNo % 4); String RepeaterID = lblRepeaterID.Text; if (!RepeaterID.Equals("")) { RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 if (rep != null) { if (inputType.Equals(code_InOutType.Input)) { DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.DeviceName = txtDeviceMemo.Text.Trim(); rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장 } else if (inputType.Equals(code_InOutType.Output)) { DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.DeviceName = txtDeviceMemo.Text.Trim(); rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장 } } } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void txtDeviceTypeCode_TextChanged(object sender, EventArgs e) { try { Util.ToUpper(txtDeviceTypeCode); String typeCode = txtDeviceTypeCode.Text.Trim(); if (typeCode.Length == 2) { if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0) { DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0]; int devNo = selectCell.ColumnIndex; string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText); devNo = (devNo % 4); DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경 String type_name = dacDeviceConfig.Device_Type_Name(inputType, typeCode); txtDeviceTypeName.Text = type_name; String RepeaterID = lblRepeaterID.Text; if (!RepeaterID.Equals("")) { RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 if (rep != null) { if (inputType.Equals(code_InOutType.Input)) { DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.DeviceType = typeCode; rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장 } else if (inputType.Equals(code_InOutType.Output)) { DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.DeviceType = typeCode; rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장 } } } } } else { txtDeviceTypeName.Text = ""; if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0) { DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0]; int devNo = selectCell.ColumnIndex; string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText); devNo = (devNo % 4); String RepeaterID = lblRepeaterID.Text; if (!RepeaterID.Equals("")) { RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 if (rep != null) { if (inputType.Equals(code_InOutType.Input)) { DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo]; if (dev != null) { dev.DeviceType = ""; rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장 } } else if (inputType.Equals(code_InOutType.Output)) { DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo]; if (dev != null) { dev.DeviceType = ""; rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장 } } } } } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void txtPositionCode_TextChanged(object sender, EventArgs e) { try { Util.ToUpper(txtPositionCode); String positionCode = txtPositionCode.Text.Trim(); if (positionCode.Length == 2) { if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0) { DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0]; int devNo = selectCell.ColumnIndex; string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText); devNo = (devNo % 4); DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경 String position_name = dacDeviceConfig.Device_Position_Name(positionCode); txtPositionName.Text = position_name; String RepeaterID = lblRepeaterID.Text; if (!RepeaterID.Equals("")) { RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1]; //중계기및 회로 설정정보 if (rep != null) { if (inputType.Equals(code_InOutType.Input)) { DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.PositionCode = positionCode; rep.setDeviceTypeInfo(dev, code_InOutType.Input); //저장 } else if (inputType.Equals(code_InOutType.Output)) { DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo]; if (dev == null) dev = new DeviceTypeInfo(devNo + 1); dev.PositionCode = positionCode; rep.setDeviceTypeInfo(dev, code_InOutType.Output); //저장 } } } } } else { txtPositionName.Text = ""; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void chkSelectAll_CheckedChanged(object sender, EventArgs e) { try { if (chkSelectAll.Checked) { dataGridView_Repeater_Main.SelectAll(); chkSelectAll.Text = "선택해제"; } else { int rowIndx = this.dataGridView_Repeater_Main.Rows.Count; int colIndx = this.dataGridView_Repeater_Main.ColumnCount; for (int i = 0; i < rowIndx; i++) //전체 셀 숫자에 따라서.. { for (int j = 0; j < colIndx; j++) //전체 셀 숫자에 따라서.. dataGridView_Repeater_Main.Rows[i].Cells[j].Selected = false; } chkSelectAll.Text = "전체선택"; } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void btnWinClose_Click(object sender, EventArgs e) { try { if (mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag == true) { MessageBox.Show("설정 변경되었음. 반드시 모든 데이타 저장(수신기 쓰기) 버튼을 실행하십시요!"); return; } this.Close(); } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { try { chkSelectAll.Text = "전체선택"; chkSelectAll.Checked = false; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } private void chkNoFireResetFlag_CheckedChanged(object sender, EventArgs e) { try { bool FireResetFlag = chkFireResetFlag.Checked; int rowIndx = this.dataGridView_Repeater_Main.Rows.Count; int colIndx = this.dataGridView_Repeater_Main.ColumnCount; for (int i = 0; i < rowIndx; i++) //전체 셀 숫자에 따라서.. { for (int j = 0; j < colIndx; j++) //전체 셀 숫자에 따라서.. { int RepeaterID = i * 10 + j; if (RepeaterID < 127) { RepeaterDeviceTypeInfo dev = REP[RepeaterID]; //중계기및 회로 설정정보 if (!dev.RepeaterType.Equals("")) dev.FireResetFlag = FireResetFlag; } } } // cyim 2014.5.7 : 수신기설정정보 변경 mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true; } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } /******************************************************************************************************/ #endregion } public class CTBoard { public int boardID; public string name; public bool use; // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경 public bool loop0Use; public bool loop1Use; public bool loop2Use; public bool loop3Use; } }