private void QueryBtn_Click(object sender, EventArgs e) { try { if (StartDateTimePicker.Value > EndDateTimePicker.Value) { MessageBox.Show("기간을 다시 설정하세요.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { WaitBarMng.Start(); WaitBarMng.Msg = "데이터 조회중 입니다..."; List <Log> logList = new List <Log>(); if (this.DmbEventLogListView.Items.Count > 0) { this.DmbEventLogListView.Items.Clear(); } logList = eventLogMng.ReadLog("DMB_DS", StartDateTimePicker.Value, EndDateTimePicker.Value); this.DmbEventLogListView.StateImageList = imageList1; foreach (Log log in logList) { ListViewItem item = new ListViewItem(); if (log.Kind == "Error") { item.StateImageIndex = 1; } else { item.StateImageIndex = 0; } this.DmbEventLogListView.Items.Insert(0, item); //종류 item.SubItems.Add(log.Kind); //날짜 item.SubItems.Add(log.Date); //시간 item.SubItems.Add(log.Time); //내용 item.SubItems.Add(log.Message); //사용자명 item.SubItems.Add(log.UserName); } WaitBarMng.Close(); } } catch (Exception ex) { Console.WriteLine("EventLogForm.QueryBtn_Click - " + ex.Message); WaitBarMng.Close(); } }
/// <summary> /// 관제/제어 발령 요청 실행 /// </summary> public bool Processing(string title) { try { WMessage tempmsg = new WMessage(); bool tempdc; bool state = false; //if (Properties.Settings.Default.totalityFlag == false) //{ // WaitBarMng.Start(); // WaitBarMng.Msg = "데이터 전송중 입니다..."; // System.Threading.Thread.Sleep(500); //} wmsg.MapTarget = this.mapmsgrgList; tempmsg = controldatamng.sendWMessage(this.wmsg); if (tempmsg.ID != (uint)0) { if (Properties.Settings.Default.totalityFlag == false) { //WaitBarMng.Close(); MessageBox.Show(title + " 요청을 성공하였습니다.", title, MessageBoxButtons.OK, MessageBoxIcon.Information); } state = true; } else { if (Properties.Settings.Default.totalityFlag == false) { //WaitBarMng.Close(); MessageBox.Show(title + " 요청을 실패하였습니다.", title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } state = false; } wmsg = null; tempdc = false; mapmsgrgList.Clear(); controldatamng.DeviceControlList.Clear(); return(state); } catch (Exception ex) { WaitBarMng.Close(); MessageBox.Show(title + " 요청을 실패하였습니다.", title, MessageBoxButtons.OK, MessageBoxIcon.Warning); Console.WriteLine("Processing - " + ex.Message); return(false); } }
//전송 버튼 클릭 private void SmsTestSendBtn_Click(object sender, EventArgs e) { try { if (this.dataMng.CDMA) { if (!this.SmsSendTestValidation()) { MessageBox.Show("전화번호를 정확히 입력해 주세요.", "SMS 전송 시험", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!this.smsSending) { this.smsSending = true; WaitBarMng.Start(); Thread.Sleep(1500); if (this.dataMng.SmsUserComparer(this.SmsSendNumTB.Text.Replace("-", ""))) //등록된 사람이 있으면..(DB 저장함) { List <WSmsUser> tmpSmsUserList = this.dataMng.getSmsUser(this.SmsSendNumTB.Text.Replace("-", "")); for (int i = 0; i < tmpSmsUserList.Count; i++) { WSmsSend tmpSmsSend = new WSmsSend(0, tmpSmsUserList[i].PKID, DateTime.Now, this.SmsTestTB.Text); this.dataMng.AddSmsSend(tmpSmsSend); } } else //중복되는 사람이 없으면..(DB 저장 안함) { } this.dataMng.SendSmsUserMsg(this.SmsSendNumTB.Text.Replace("-", ""), Encoding.Default.GetBytes(this.SmsTestTB.Text)); } } else { MessageBox.Show("CDMA 장치가 준비되지 않았습니다.", "SMS 전송 시험", MessageBoxButtons.OK, MessageBoxIcon.Information); } WaitBarMng.Close(); this.smsSending = false; } catch (Exception ex) { Console.WriteLine(string.Format("SMSMainForm.SmsTestSendBtn_Click() - {0}", ex.Message)); } }
/// <summary> /// 관제/제어 발령 요청 실행 /// </summary> public bool Processing(string title) { try { WMessage tempmsg = new WMessage(); bool state = false; tempmsg = controldatamng.sendWMessage(this.wmsg); if (tempmsg == null) { MessageBox.Show(title + " 요청을 실패하였습니다.", title, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } WaitBarMng.Start(); WaitBarMng.Msg = "데이터 전송중 입니다..."; System.Threading.Thread.Sleep(1000); if (tempmsg.ID != (uint)0) { WaitBarMng.Close(); MessageBox.Show(title + " 요청을 성공하였습니다.", title, MessageBoxButtons.OK, MessageBoxIcon.Information); state = true; } else { WaitBarMng.Close(); MessageBox.Show(title + " 요청을 실패하였습니다.", title, MessageBoxButtons.OK, MessageBoxIcon.Warning); state = false; } wmsg = null; return(state); } catch (Exception ex) { WaitBarMng.Close(); MessageBox.Show(title + " 요청을 실패하였습니다.", title, MessageBoxButtons.OK, MessageBoxIcon.Warning); Console.WriteLine("Processing - " + ex.Message); return(false); } }
//마우스 오른쪽 버튼 제어 클릭 private void 제어ToolStripMenuItem_Click(object sender, EventArgs e) { try { List <uint> WDeviceSelected = new List <uint>(); for (int i = 0; i < this.WeatherListView.SelectedItems.Count; i++) { WDeviceSelected.Add(uint.Parse(this.WeatherListView.SelectedItems[i].Name)); } this.controlForm = new WeatherControlMng(WDeviceSelected); this.controlForm.Show(); } catch (Exception ex) { Console.WriteLine(string.Format("WeatherForm.제어ToolStripMenuItem_Click() - {0}", ex.Message)); WaitBarMng.Close(); } }
//제어 버튼 클릭 private void RequestBtn_Click(object sender, EventArgs e) { //유효성 검사 if (!this.TreeViewValidation()) { MessageBox.Show("제어할 측기를 선택하거나 항목을 올바르게 넣어주세요.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < this.WDeviceTV.Nodes.Count; i++) { if (this.WDeviceTV.Nodes[i].Checked) { WaitBarMng.Start(); Thread.Sleep(1500); WDevice wDevice = this.dataMng.GetWDevice(uint.Parse(this.WDeviceTV.Nodes[i].Name)); WTypeDevice wTypeTmp = this.dataMng.GetTypeDevice(wDevice.TypeDevice); if (wTypeTmp.Name == "RAT") //RAT 우량기를 선택했을 때.. { if (this.AlarmRB.Checked) //임계치 선택 { //DB 저장 if (this.AlarmCB.Text == "우량계") { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.강수임계치1단계; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.강수임계치2단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.강수임계치3단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm3TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); } else if (this.AlarmCB.Text == "수위계") { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.수위임계치1단계; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.수위임계치2단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.수위임계치3단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm3TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); } else if (this.AlarmCB.Text == "유속계") { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.속임계치1단계; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.속임계치2단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.속임계치3단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm3TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); } CProto01 cProto01 = CProtoMng.GetProtoObj("01") as CProto01; cProto01.Header = "["; cProto01.Length = "037"; cProto01.ID = wDevice.ID; cProto01.MainCode = "1"; cProto01.SubCode = "L"; cProto01.RecvType = "1"; if (this.AlarmCB.Text == "우량계") { cProto01.Data = "1"; int tmpDouble1 = (int)(double.Parse(this.Alarm1TB.Text) * 10); int tmpDouble2 = (int)(double.Parse(this.Alarm2TB.Text) * 10); int tmpDouble3 = (int)(double.Parse(this.Alarm3TB.Text) * 10); cProto01.Data += string.Format("{0}{1}{2}", tmpDouble1.ToString().PadLeft(5, '0'), tmpDouble2.ToString().PadLeft(5, '0'), tmpDouble3.ToString().PadLeft(5, '0')); } else if (this.AlarmCB.Text == "수위계") { cProto01.Data = "2"; int tmpDouble1 = (int)(double.Parse(this.Alarm1TB.Text) * 10); int tmpDouble2 = (int)(double.Parse(this.Alarm2TB.Text) * 10); int tmpDouble3 = (int)(double.Parse(this.Alarm3TB.Text) * 10); cProto01.Data += string.Format("{0}0{1}0{2}0", tmpDouble1.ToString().PadLeft(4, '0'), tmpDouble2.ToString().PadLeft(4, '0'), tmpDouble3.ToString().PadLeft(4, '0')); } else if (this.AlarmCB.Text == "유속계") { cProto01.Data = "3"; int tmpDouble1 = (int)(double.Parse(this.Alarm1TB.Text) * 10); int tmpDouble2 = (int)(double.Parse(this.Alarm2TB.Text) * 10); int tmpDouble3 = (int)(double.Parse(this.Alarm3TB.Text) * 10); cProto01.Data += string.Format("{0}{1}{2}", tmpDouble1.ToString().PadLeft(5, '0'), tmpDouble2.ToString().PadLeft(5, '0'), tmpDouble3.ToString().PadLeft(5, '0')); } cProto01.CRC = "00000"; cProto01.Tail = "]"; byte[] buff = cProto01.MakeProto(); if (wDevice.EthernetUse) { cProto01.RecvType = "3"; byte[] eBuff = cProto01.MakeProto(); this.dataMng.SendEthernetMsg(wDevice.ID, eBuff); } else { this.dataMng.SendSmsMsg(wDevice.CellNumber, buff); } } else if (this.FTimeRB.Checked) //무시시간 선택 { //DB 저장 WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.동일레벨무시시간; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.FTime1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.하향레벨무시시간; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.FTime2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); CProto02 cProto02 = CProtoMng.GetProtoObj("02") as CProto02; cProto02.Header = "["; cProto02.Length = "040"; cProto02.ID = wDevice.ID; cProto02.MainCode = "1"; cProto02.SubCode = "s"; cProto02.RecvType = "1"; cProto02.Data = string.Format("010010010010{0}{1}0", this.FTime1TB.Text.PadLeft(3, '0'), this.FTime2TB.Text.PadLeft(3, '0')); cProto02.CRC = "00000"; cProto02.Tail = "]"; if (wDevice.EthernetUse) { cProto02.RecvType = "3"; byte[] buff = cProto02.MakeProto(); this.dataMng.SendEthernetMsg(wDevice.ID, buff); } else { byte[] buff = cProto02.MakeProto(); this.dataMng.SendSmsMsg(wDevice.CellNumber, buff); } } else if (this.IpPortRB.Checked) //CDMA IP, PORT 선택 { //DB 저장 WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.IP; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.IpPort1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.PORT; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.IpPort2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); CProto03 cProto03 = CProtoMng.GetProtoObj("03") as CProto03; cProto03.Header = "["; cProto03.Length = "040"; cProto03.ID = wDevice.ID; cProto03.MainCode = "1"; cProto03.SubCode = "g"; cProto03.RecvType = "1"; string[] tmpIpStr = this.IpPort1TB.Text.Split('.'); cProto03.Data = string.Format("{0}.{1}.{2}.{3}{4}", tmpIpStr[0].PadLeft(3, '0'), tmpIpStr[1].PadLeft(3, '0'), tmpIpStr[2].PadLeft(3, '0'), tmpIpStr[3].PadLeft(3, '0'), this.IpPort2TB.Text.PadLeft(4, '0')); cProto03.CRC = "00000"; cProto03.Tail = "]"; if (wDevice.EthernetUse) { cProto03.RecvType = "3"; byte[] buff = cProto03.MakeProto(); this.dataMng.SendEthernetMsg(wDevice.ID, buff); } else { byte[] buff = cProto03.MakeProto(); this.dataMng.SendSmsMsg(wDevice.CellNumber, buff); } } else if (this.EIpPortRB.Checked) //이더넷 IP, PORT 선택 { //DB 저장 WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.이더넷IP; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.EIpPort1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.이더넷PORT; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.EIpPort2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); CProto09 cProto09 = CProtoMng.GetProtoObj("09") as CProto09; cProto09.Header = "["; cProto09.Length = "040"; cProto09.ID = wDevice.ID; cProto09.MainCode = "1"; cProto09.SubCode = "h"; cProto09.RecvType = "1"; string[] tmpIpStr = this.EIpPort1TB.Text.Split('.'); cProto09.Data = string.Format("{0}.{1}.{2}.{3}{4}", tmpIpStr[0].PadLeft(3, '0'), tmpIpStr[1].PadLeft(3, '0'), tmpIpStr[2].PadLeft(3, '0'), tmpIpStr[3].PadLeft(3, '0'), this.EIpPort2TB.Text.PadLeft(4, '0')); cProto09.CRC = "00000"; cProto09.Tail = "]"; if (wDevice.EthernetUse) { cProto09.RecvType = "3"; byte[] buff = cProto09.MakeProto(); this.dataMng.SendEthernetMsg(wDevice.ID, buff); } else { byte[] buff = cProto09.MakeProto(); this.dataMng.SendSmsMsg(wDevice.CellNumber, buff); } } else if (this.UpgradeRB.Checked) //업그레이드 선택 { //DB 저장 WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.업그레이드IP; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Upgrade1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.업그레이드PORT; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Upgrade2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); CProto04 cProto04 = CProtoMng.GetProtoObj("04") as CProto04; cProto04.Header = "["; cProto04.Length = "038"; cProto04.ID = wDevice.ID; cProto04.MainCode = "2"; cProto04.SubCode = "c"; cProto04.RecvType = "1"; string[] tmpUpgradeStr = this.Upgrade1TB.Text.Split('.'); cProto04.Data = string.Format("1{0}{1}{2}{3}{4}", tmpUpgradeStr[0].PadLeft(3, '0'), tmpUpgradeStr[1].PadLeft(3, '0'), tmpUpgradeStr[2].PadLeft(3, '0'), tmpUpgradeStr[3].PadLeft(3, '0'), this.Upgrade2TB.Text.PadLeft(4, '0')); cProto04.CRC = "00000"; cProto04.Tail = "]"; if (wDevice.EthernetUse) { cProto04.RecvType = "3"; byte[] buff = cProto04.MakeProto(); this.dataMng.SendEthernetMsg(wDevice.ID, buff); } else { byte[] buff = cProto04.MakeProto(); this.dataMng.SendSmsMsg(wDevice.CellNumber, buff); } } else if (this.ResetRB.Checked) //리셋 선택 { //DB 저장 WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.RESET; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, string.Empty); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); CProto05 cProto05 = CProtoMng.GetProtoObj("05") as CProto05; cProto05.Header = "["; cProto05.Length = "022"; cProto05.ID = wDevice.ID; cProto05.MainCode = "2"; cProto05.SubCode = "c"; cProto05.RecvType = "1"; cProto05.Data = string.Format("0"); cProto05.CRC = "00000"; cProto05.Tail = "]"; if (wDevice.EthernetUse) { cProto05.RecvType = "3"; byte[] buff = cProto05.MakeProto(); this.dataMng.SendEthernetMsg(wDevice.ID, buff); } else { byte[] buff = cProto05.MakeProto(); this.dataMng.SendSmsMsg(wDevice.CellNumber, buff); } } } else if (wTypeTmp.Name == "WOU") //WOU 우량기를 선택했을 때.. { if (this.AlarmRB.Checked) //임계치 선택 { //DB 저장 if (this.AlarmCB.Text == "우량계") { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.강수임계치1단계; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.강수임계치2단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.강수임계치3단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm3TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); } else if (this.AlarmCB.Text == "수위계") { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.수위임계치1단계; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.수위임계치2단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.수위임계치3단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm3TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); } else if (this.AlarmCB.Text == "유속계") { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.속임계치1단계; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.속임계치2단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.속임계치3단계; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.Alarm3TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); } byte tmpByte = byte.MinValue; string tmpValue1 = string.Empty; string tmpValue2 = string.Empty; string tmpValue3 = string.Empty; if (this.AlarmCB.Text == "우량계") { tmpByte = 1; int tmpDouble1 = (int)(double.Parse(this.Alarm1TB.Text) * 10); int tmpDouble2 = (int)(double.Parse(this.Alarm2TB.Text) * 10); int tmpDouble3 = (int)(double.Parse(this.Alarm3TB.Text) * 10); tmpValue1 = string.Format("{0}{1}{2}", tmpDouble1.ToString().PadLeft(5, '0'), tmpDouble2.ToString().PadLeft(5, '0'), tmpDouble3.ToString().PadLeft(5, '0')); } else if (this.AlarmCB.Text == "수위계") { tmpByte = 2; int tmpDouble1 = (int)(double.Parse(this.Alarm1TB.Text) * 10); int tmpDouble2 = (int)(double.Parse(this.Alarm2TB.Text) * 10); int tmpDouble3 = (int)(double.Parse(this.Alarm3TB.Text) * 10); tmpValue2 = string.Format("{0}0{1}0{2}0", tmpDouble1.ToString().PadLeft(4, '0'), tmpDouble2.ToString().PadLeft(4, '0'), tmpDouble3.ToString().PadLeft(4, '0')); } else if (this.AlarmCB.Text == "유속계") { tmpByte = 3; int tmpDouble1 = (int)(double.Parse(this.Alarm1TB.Text) * 10); int tmpDouble2 = (int)(double.Parse(this.Alarm2TB.Text) * 10); int tmpDouble3 = (int)(double.Parse(this.Alarm3TB.Text) * 10); tmpValue3 = string.Format("{0}{1}{2}", tmpDouble1.ToString().PadLeft(5, '0'), tmpDouble2.ToString().PadLeft(5, '0'), tmpDouble3.ToString().PadLeft(5, '0')); } this.dataMng.WOUWDeviceAlarmCtr(wDevice.PKID, tmpByte, tmpValue1, tmpValue2, tmpValue3); } else if (this.FTimeRB.Checked) //무시시간 선택 { //DB 저장 WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.동일레벨무시시간; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.FTime1TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); wiTypeAll = WeatherDataMng.WIType.하향레벨무시시간; AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); tmp = new WDeviceRequest(0, wDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 1, this.FTime2TB.Text); this.dataMng.AddDeviceRequest(tmp); Thread.Sleep(20); this.dataMng.WOUWDeviceFTimeCtr(wDevice.PKID, this.FTime1TB.Text.PadLeft(3, '0'), this.FTime2TB.Text.PadLeft(3, '0')); } } } } WaitBarMng.Close(); }
//마우스 오른쪽 버튼 상태요청 클릭 private void 상태요청ToolStripMenuItem_Click(object sender, EventArgs e) { try { if (this.WeatherListView.SelectedItems.Count > 0) { WaitBarMng.Start(); Thread.Sleep(2000); for (int i = 0; i < this.WeatherListView.SelectedItems.Count; i++) { WDevice tmpDevice = this.dataMng.GetWDevice(uint.Parse(this.WeatherListView.SelectedItems[i].Name)); for (int j = 0; j < this.dataMng.TypeDeviceList.Count; j++) { if (tmpDevice.TypeDevice == this.dataMng.TypeDeviceList[j].PKID) { if (this.dataMng.TypeDeviceList[j].Name == "RAT") //RAT에 전체 상태 요청하는 경우 { //DB 저장 WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.ALL; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, tmpDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 0, string.Empty); this.dataMng.AddDeviceRequest(tmp); CProto00 cProto00 = CProtoMng.GetProtoObj("00") as CProto00; cProto00.Header = "["; cProto00.Length = "021"; cProto00.ID = tmpDevice.ID; cProto00.MainCode = "0"; cProto00.SubCode = "a"; cProto00.RecvType = "1"; cProto00.CRC = "00000"; cProto00.Tail = "]"; if (tmpDevice.EthernetUse) { cProto00.RecvType = "3"; byte[] buff = cProto00.MakeProto(); this.dataMng.SendEthernetMsg(tmpDevice.ID, buff); } else { byte[] buff = cProto00.MakeProto(); this.dataMng.SendSmsMsg(tmpDevice.CellNumber, buff); } } else if (this.dataMng.TypeDeviceList[j].Name == "WOU") //WOU에 상태 요청하는 경우 { //DB 저장 WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.ALL; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, tmpDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 0, string.Empty); this.dataMng.AddDeviceRequest(tmp); this.dataMng.WOUWDeviceRequest(tmpDevice.PKID); //serial로 요청한다. } } } } WaitBarMng.Close(); } else { MessageBox.Show("선택한 측기가 없습니다.", "상태 요청", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Console.WriteLine(string.Format("WeatherForm.상태요청ToolStripMenuItem_Click() - {0}", ex.Message)); WaitBarMng.Close(); } }
//요청 버튼 클릭 private void SelfTestBtn_Click(object sender, EventArgs e) { if (this.SelfTestDeviceLV.SelectedItems.Count == 0) { MessageBox.Show("요청할 측기를 선택하세요.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (this.RainFallCB.Checked == false && this.WaterLevelCB.Checked == false && this.WaterFlowCB.Checked == false && this.SunBattCB.Checked == false) { MessageBox.Show("요청 항목을 선택하세요.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (this.SunBattCB.Checked) { MessageBox.Show("태양전지는 센서가 위치한 지역의 일조량이 충분해야 정확한 상태를 진단합니다.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } WaitBarMng.Start(); Thread.Sleep(2000); for (int i = 0; i < this.SelfTestDeviceLV.SelectedItems.Count; i++) { WDevice tmpDevice = this.dataMng.GetWDevice(uint.Parse(this.SelfTestDeviceLV.SelectedItems[i].Name)); if (this.RainFallCB.Checked) { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.강수센서상태; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, tmpDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 0, string.Empty); this.dataMng.AddDeviceRequest(tmp); CProto06 cProto06 = CProtoMng.GetProtoObj("06") as CProto06; cProto06.Header = "["; cProto06.Length = "022"; cProto06.ID = tmpDevice.ID; cProto06.MainCode = "0"; cProto06.SubCode = "O"; cProto06.RecvType = "1"; cProto06.Data = "1"; cProto06.CRC = "00000"; cProto06.Tail = "]"; if (tmpDevice.EthernetUse) { cProto06.RecvType = "3"; byte[] buff = cProto06.MakeProto(); this.dataMng.SendEthernetMsg(tmpDevice.ID, buff); } else { byte[] buff = cProto06.MakeProto(); this.dataMng.SendSmsMsg(tmpDevice.CellNumber, buff); } Thread.Sleep(20); } if (this.WaterLevelCB.Checked) { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.수위센서상태; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, tmpDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 0, string.Empty); this.dataMng.AddDeviceRequest(tmp); CProto06 cProto06 = CProtoMng.GetProtoObj("06") as CProto06; cProto06.Header = "["; cProto06.Length = "022"; cProto06.ID = tmpDevice.ID; cProto06.MainCode = "0"; cProto06.SubCode = "O"; cProto06.RecvType = "1"; cProto06.Data = "2"; cProto06.CRC = "00000"; cProto06.Tail = "]"; if (tmpDevice.EthernetUse) { cProto06.RecvType = "3"; byte[] buff = cProto06.MakeProto(); this.dataMng.SendEthernetMsg(tmpDevice.ID, buff); } else { byte[] buff = cProto06.MakeProto(); this.dataMng.SendSmsMsg(tmpDevice.CellNumber, buff); } Thread.Sleep(20); } if (this.WaterFlowCB.Checked) { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.속센서상태; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, tmpDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 0, string.Empty); this.dataMng.AddDeviceRequest(tmp); CProto06 cProto06 = CProtoMng.GetProtoObj("06") as CProto06; cProto06.Header = "["; cProto06.Length = "022"; cProto06.ID = tmpDevice.ID; cProto06.MainCode = "0"; cProto06.SubCode = "O"; cProto06.RecvType = "1"; cProto06.Data = "3"; cProto06.CRC = "00000"; cProto06.Tail = "]"; if (tmpDevice.EthernetUse) { cProto06.RecvType = "3"; byte[] buff = cProto06.MakeProto(); this.dataMng.SendEthernetMsg(tmpDevice.ID, buff); } else { byte[] buff = cProto06.MakeProto(); this.dataMng.SendSmsMsg(tmpDevice.CellNumber, buff); } Thread.Sleep(20); } if (this.SunBattCB.Checked) { WeatherDataMng.WIType wiTypeAll = WeatherDataMng.WIType.태양전지; WTypeDeviceItem AllTypeDeviceItem = this.dataMng.GetTypeDeviceItem(wiTypeAll); WDeviceRequest tmp = new WDeviceRequest(0, tmpDevice.PKID, AllTypeDeviceItem.PKID, DateTime.Now, 0, string.Empty); this.dataMng.AddDeviceRequest(tmp); CProto06 cProto06 = CProtoMng.GetProtoObj("06") as CProto06; cProto06.Header = "["; cProto06.Length = "022"; cProto06.ID = tmpDevice.ID; cProto06.MainCode = "0"; cProto06.SubCode = "O"; cProto06.RecvType = "1"; cProto06.Data = "4"; cProto06.CRC = "00000"; cProto06.Tail = "]"; if (tmpDevice.EthernetUse) { cProto06.RecvType = "3"; byte[] buff = cProto06.MakeProto(); this.dataMng.SendEthernetMsg(tmpDevice.ID, buff); } else { byte[] buff = cProto06.MakeProto(); this.dataMng.SendSmsMsg(tmpDevice.CellNumber, buff); } Thread.Sleep(20); } } WaitBarMng.Close(); }
public void SetIssuesUpdate() { try { WaitBarMng.Start(); WaitBarMng.Msg = "데이터 조회중 입니다..."; List <WMessage> datewmsgList = new List <WMessage>(); WMessageIDComparer wcomparer = new WMessageIDComparer(); if (this.DmbIssueListView.Items.Count != 0) { this.DmbIssueListView.Items.Clear(); } datewmsgList = datamanager.GetDateWMessageList((DateTime)this.StartDateTimePicker.Value, (DateTime)this.EndDateTimePicker.Value); datewmsgList.Sort(wcomparer); if (datewmsgList.Count != 0) { foreach (WMessage wmessage in datewmsgList) { if (wmessage.SendPart == WMessage.E_sendPart.SMS) { continue; } if (wmessage.BCenterList.Count != 0) { foreach (broadcast broad in wmessage.BCenterList) { if (broad.StageID != (uint)Properties.Settings.Default.cnfBroad) { continue; } this.DmbIssueListView.Items.Add(this.orderlistset.setWmsgCollection(wmessage)); } } else if (wmessage.BCenterList.Count == 0)//특수수신기 제어 또는 상태 요청 시 { string broadTmp = this.datamanager.getBroadName((uint)Properties.Settings.Default.cnfBroad); //============박찬호 수정 - 2013/11/19======================================== if (broadTmp == "<KBS>" || broadTmp == "<MBC>" || broadTmp == "<SBS>" || broadTmp == "<YTN>") //============================================================================ { this.DmbIssueListView.Items.Add(this.orderlistset.setWmsgCollection(wmessage)); } } } this.orderlistset.PkidIndex = 0; } this.controlset.SetListViewIndex(this.DmbIssueListView); WaitBarMng.Close(); } catch (Exception ex) { Console.WriteLine("IssueListForm.SetIssuesUpdate - " + ex.Message); WaitBarMng.Close(); } }