示例#1
0
        //수정 버튼 클릭
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            if (this.WDeviceLV.SelectedItems.Count != 1)
            {
                MessageBox.Show("수정할 한 개의 측기를 선택하세요.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            using (this.addWDevice = new AddWDevice())
            {
                this.addWDevice.Mode = 1;
                WDevice wd = this.dataMng.GetWDevice(uint.Parse(this.WDeviceLV.SelectedItems[0].Name));
                this.addWDevice.WDivision = string.Format("{0}({1})",
                                                          this.dataMng.GetTypeDevice(wd.TypeDevice).Name,
                                                          this.dataMng.GetTypeDevice(wd.TypeDevice).Remark);
                this.addWDevice.WDIDTB        = wd.ID;
                this.addWDevice.WDNameTB      = wd.Name;
                this.addWDevice.WDTelTB       = wd.CellNumber;
                this.addWDevice.WDPKID        = this.WDeviceLV.SelectedItems[0].Name;
                this.addWDevice.WDSensor      = wd.HaveSensor;
                this.addWDevice.WDEthernetUse = wd.EthernetUse;
                this.addWDevice.WDeviceRemark = wd.Remark;
                this.addWDevice.ShowDialog();
            }
        }
示例#2
0
        /// <summary>
        /// 임계치 알람 데이터 수신 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataMng_onAddAlarmDataEvt(object sender, AddAlarmEventArgs e)
        {
            WDevice     wDeviceTmp = this.dataMng.GetWDevice(e.WA.FKDevice);
            WTypeDevice wTypeTmp   = this.dataMng.GetTypeDevice(wDeviceTmp.TypeDevice);
            string      level      = (e.WA.AlarmType.ToString() == "1") ? "우량계" :
                                     (e.WA.AlarmType.ToString() == "2") ? "수위계" :
                                     (e.WA.AlarmType.ToString() == "3") ? "유속계" :
                                     (e.WA.AlarmType.ToString() == "4") ? "풍향풍속계" : "기타";

            level += (e.WA.AlarmLevel.ToString() == "0") ? ", 해제" :
                     (e.WA.AlarmLevel.ToString() == "1") ? ", 주의(1단계)" :
                     (e.WA.AlarmLevel.ToString() == "2") ? ", 경계(2단계)" :
                     (e.WA.AlarmLevel.ToString() == "3") ? ", 대피(3단계)" : ", 기타";

            if (this.WeatherDataTextBox.InvokeRequired)
            {
                this.Invoke(new InvokeSetWeatherDataLog(this.SetWeatherData), new object[] { string.Format("{0}의 {1} 측기의 {2} 임계치 알람 이벤트가 발생되었습니다.",
                                                                                                           wTypeTmp.Name, wDeviceTmp.ID, level) });
            }
            else
            {
                this.SetWeatherData(string.Format("{0}의 {1} 측기의 {2} 임계치 알람 이벤트가 발생되었습니다.",
                                                  wTypeTmp.Name, wDeviceTmp.ID, level));
            }
        }
示例#3
0
        /// <summary>
        /// 수정 메소드
        /// </summary>
        private void WDeviceUpdate()
        {
            WTypeDevice wtd       = this.dataMng.GetTypeDevice(this.WDeviceDivisionCB.Text.Substring(0, 3));
            byte        tmpSensor = this.GetSensorValue();
            WDevice     wd        = new WDevice(uint.Parse(this.wDevicePkid), this.WDeviceIDTB.Text, this.WDeviceNameTB.Text,
                                                this.WDeviceTelNumTB.Text.Replace("-", ""), wtd.PKID, tmpSensor, this.EternetUseCB.Checked, this.WDeviceRemarkTB.Text);

            this.dataMng.UpdateWDevice(wd);
            this.SaveBtn.Enabled = false;
        }
示例#4
0
        /// <summary>
        /// 강수 데이터 수신 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataMng_onAddRainDataEvt(object sender, AddRainDataEventArgs e)
        {
            WDevice     wDeviceTmp = this.dataMng.GetWDevice(e.WR.FKDevice);
            WTypeDevice wTypeTmp   = this.dataMng.GetTypeDevice(wDeviceTmp.TypeDevice);

            if (this.WeatherDataTextBox.InvokeRequired)
            {
                this.Invoke(new InvokeSetWeatherDataLog(this.SetWeatherData), new object[] { string.Format("{0}의 {1} 측기의 강수 데이터가 수신되었습니다.", wTypeTmp.Name, wDeviceTmp.ID) });
            }
            else
            {
                this.SetWeatherData(string.Format("{0}의 {1} 측기의 강수 데이터가 수신되었습니다.", wTypeTmp.Name, wDeviceTmp.ID));
            }
        }
示例#5
0
        /// <summary>
        /// WDevice 클래스를 받아 LisetViewItem으로 반환한다.
        /// </summary>
        /// <param name="_wd"></param>
        /// <returns></returns>
        private ListViewItem GetListViewItem(WDevice _wd)
        {
            ListViewItem lvi = new ListViewItem();

            lvi.Name = string.Format("{0}", _wd.PKID);
            lvi.Text = string.Empty;
            lvi.SubItems.Add(string.Format("{0}", this.WDeviceLV.Items.Count + 1));
            lvi.SubItems.Add(this.dataMng.GetTypeDevice(_wd.TypeDevice).Name);
            lvi.SubItems.Add(_wd.ID);
            lvi.SubItems.Add(_wd.Name);
            lvi.SubItems.Add(_wd.CellNumber);

            return(lvi);
        }
示例#6
0
        //Remark 텍스트박스의 내용이 크기를 넘어섰을 때..
        private void RemarkLB_MouseHover(object sender, EventArgs e)
        {
            if (this.WeatherListView.SelectedItems.Count == 1)
            {
                WDevice tmpWDevice = this.dataMng.GetWDevice(uint.Parse(this.WeatherListView.SelectedItems[0].Name));

                if (tmpWDevice.Remark.Length > 14)
                {
                    this.RemarkToolTip.SetToolTip(this.RemarkLB, tmpWDevice.Remark);
                }
                else
                {
                    this.RemarkToolTip.RemoveAll();
                }
            }
        }
示例#7
0
        /// <summary>
        /// 측기 요청/제어를 한 후 이벤트(사용자가 발생시키는 이벤트)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void dataMng_onAddWDeviceRequestEvt(object sender, AddWDeviceRequestEventArgs e)
        {
            WDevice         wDevice        = this.dataMng.GetWDevice(e.WDR.FkDevice);
            WTypeDevice     wTypeTmp       = this.dataMng.GetTypeDevice(wDevice.TypeDevice);
            WTypeDeviceItem typeDeviceItem = this.dataMng.GetTypeDeviceItem(e.WDR.FkDeviceItem);
            string          real           = (e.WDR.IsControl == 0) ? "요청" : "제어";

            if (this.WeatherDataTextBox.InvokeRequired)
            {
                this.Invoke(new InvokeSetWeatherDataLog(this.SetWeatherData), new object[] { string.Format("{0}의 {1} 측기의 {2} 항목을 {3} 하였습니다.",
                                                                                                           wTypeTmp.Name, wDevice.ID, typeDeviceItem.Name, real) });
            }
            else
            {
                this.SetWeatherData(string.Format("{0}의 {1} 측기의 {2} 항목을 {3} 하였습니다.",
                                                  wTypeTmp.Name, wDevice.ID, typeDeviceItem.Name, real));
            }
        }
        /// <summary>
        /// WDevice 클래스를 받아 LisetViewItem으로 반환한다.
        /// </summary>
        /// <param name="_wd"></param>
        /// <returns></returns>
        private ListViewItem GetListViewItem(WDevice _wd)
        {
            ListViewItem lvi = new ListViewItem();

            lvi.UseItemStyleForSubItems = false;

            lvi.Name = string.Format("{0}", _wd.PKID);
            lvi.Text = string.Empty;
            lvi.SubItems.Add(string.Format("{0}", this.SelfTestDeviceLV.Items.Count + 1));
            lvi.SubItems.Add(string.Format("{0}({1})", _wd.Name, this.dataMng.GetTypeDevice(_wd.TypeDevice).Name));
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);

            return(lvi);
        }
示例#9
0
        /// <summary>
        /// 저장 메소드
        /// </summary>
        private bool save()
        {
            WTypeDevice wtd       = this.dataMng.GetTypeDevice(this.WDeviceDivisionCB.Text.Substring(0, 3));
            byte        tmpSensor = this.GetSensorValue();
            WDevice     wd        = new WDevice(0, this.WDeviceIDTB.Text, this.WDeviceNameTB.Text, this.WDeviceTelNumTB.Text.Replace("-", ""),
                                                wtd.PKID, tmpSensor, this.EternetUseCB.Checked, this.WDeviceRemarkTB.Text);

            if (this.dataMng.GetWDeviceComparer(wd))
            {
                MessageBox.Show("이미 등록된 ID 입니다.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            else
            {
                this.dataMng.AddWDevice(wd);
                this.SaveBtn.Enabled = false;
                return(true);
            }
        }
示例#10
0
        //유속 리스트뷰 아이템 더블 클릭
        private void WData3LV_DoubleClick(object sender, EventArgs e)
        {
            WDevice tmpDevice = this.dataMng.GetWDevice(uint.Parse(this.WData3LV.SelectedItems[0].Name));

            if (this.dataMng.GetTypeDevice(tmpDevice.TypeDevice).Name == "HSD" ||
                this.dataMng.GetTypeDevice(tmpDevice.TypeDevice).Name == "DSD")
            {
                MessageBox.Show("타 측기 시스템은 선택할 수 없습니다.", "측기 선택", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (!(this.DeviceIndexLV.Items.ContainsKey(tmpDevice.PKID.ToString())))
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Name = tmpDevice.PKID.ToString();
                    lvi.Text = string.Format("{0}(ID:{1})", tmpDevice.Name, tmpDevice.ID);
                    this.DeviceIndexLV.Items.Add(lvi);
                }
            }
        }
示例#11
0
        /// <summary>
        /// WDevice 클래스를 받아 LisetViewItem으로 반환한다. (유속)
        /// </summary>
        /// <param name="_wd"></param>
        /// <returns></returns>
        private ListViewItem GetListViewItemFS(WDevice _wd, ListView _lv)
        {
            ListViewItem lvi = new ListViewItem();

            lvi.Name = string.Format("{0}", _wd.PKID);
            lvi.Text = string.Empty;
            lvi.SubItems.Add(string.Format("{0}", _lv.Items.Count + 1));
            lvi.SubItems.Add(_wd.Name);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);

            return(lvi);
        }
示例#12
0
        /// <summary>
        /// WDevice 클래스를 받아 LisetViewItem으로 반환한다.
        /// </summary>
        /// <param name="_wd"></param>
        /// <returns></returns>
        private ListViewItem GetListViewItem(WDevice _wd)
        {
            ListViewItem lvi = new ListViewItem();

            lvi.UseItemStyleForSubItems = false;

            if (_wd.EthernetUse)
            {
                lvi.StateImageIndex = 0;
            }

            lvi.Name = string.Format("{0}", _wd.PKID);
            lvi.Text = string.Empty;
            lvi.SubItems.Add(string.Format("{0}", this.WeatherListView.Items.Count + 1));
            lvi.SubItems.Add(this.dataMng.GetTypeDevice(_wd.TypeDevice).Name);
            lvi.SubItems.Add(_wd.ID);
            lvi.SubItems.Add(_wd.Name);
            lvi.SubItems.Add(_wd.CellNumber);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);
            lvi.SubItems.Add(string.Empty);

            return(lvi);
        }
示例#13
0
        //삭제 버튼 클릭
        private void DelBtn_Click(object sender, EventArgs e)
        {
            if (this.WDeviceLV.SelectedItems.Count == 0)
            {
                MessageBox.Show("삭제할 측기를 선택하세요.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (DialogResult.Yes == MessageBox.Show("측기를 삭제하겠습니까?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
            {
                List <WDevice> wdList = new List <WDevice>();
                WDevice        wd;

                for (int i = 0; i < this.WDeviceLV.SelectedItems.Count; i++)
                {
                    wd = new WDevice();
                    wd = dataMng.GetWDevice(uint.Parse(this.WDeviceLV.SelectedItems[i].Name));
                    wdList.Add(wd);
                }

                this.dataMng.DeleteWDevice(wdList);
            }
        }
        //제어 버튼 클릭
        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 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();
        }
示例#16
0
        //마우스 오른쪽 버튼 상태요청 클릭
        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();
            }
        }
示例#17
0
        //리스트뷰 클릭 이벤트
        private void WeatherListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.WeatherListView.SelectedItems.Count == 1)
            {
                WDevice tmpWDevice = this.dataMng.GetWDevice(uint.Parse(this.WeatherListView.SelectedItems[0].Name));

                this.SameFTimeLB.Text  = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[6].Text;
                this.DownFTimeLB.Text  = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[7].Text;
                this.BattVoltLB.Text   = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[8].Text;
                this.BattALB.Text      = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[9].Text;
                this.BattCLB.Text      = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[10].Text;
                this.BattTempoLB.Text  = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[11].Text;
                this.BattLifeLB.Text   = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[12].Text;
                this.BattStateLB.Text  = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[13].Text;
                this.BattVolt2LB.Text  = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[14].Text;
                this.BattA2LB.Text     = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[15].Text;
                this.BattC2LB.Text     = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[16].Text;
                this.BattTempo2LB.Text = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[17].Text;
                this.BattLife2LB.Text  = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[18].Text;
                this.BattState2LB.Text = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[19].Text;
                this.FanStateLB.Text   = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[20].Text;
                this.DoorStateLB.Text  = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[21].Text;
                this.FWVerStateLB.Text = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[22].Text;
                this.CdmaRssiLB.Text   = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[23].Text;
                this.CdmaIpLB.Text     = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[24].Text;
                this.CdmaPortLB.Text   = this.WeatherListView.Items[this.WeatherListView.SelectedItems[0].Name].SubItems[25].Text;
                this.RemarkLB.Text     = tmpWDevice.Remark;

                if (this.BattLifeLB.Text == "정상")
                {
                    this.BattLifeLB.ForeColor = Color.Black;
                }
                else
                {
                    this.BattLifeLB.ForeColor = Color.OrangeRed;
                }

                if (this.BattStateLB.Text == "정상")
                {
                    this.BattStateLB.ForeColor = Color.Black;
                }
                else
                {
                    this.BattStateLB.ForeColor = Color.OrangeRed;
                }

                if (this.BattLife2LB.Text == "정상")
                {
                    this.BattLife2LB.ForeColor = Color.Black;
                }
                else
                {
                    this.BattLife2LB.ForeColor = Color.OrangeRed;
                }

                if (this.BattState2LB.Text == "정상")
                {
                    this.BattState2LB.ForeColor = Color.Black;
                }
                else
                {
                    this.BattState2LB.ForeColor = Color.OrangeRed;
                }

                if (this.FanStateLB.Text == "이상")
                {
                    this.FanStateLB.ForeColor = Color.OrangeRed;
                }
                else
                {
                    this.FanStateLB.ForeColor = Color.Black;
                }

                if (this.DoorStateLB.Text == "닫힘")
                {
                    this.DoorStateLB.ForeColor = Color.Black;
                }
                else
                {
                    this.DoorStateLB.ForeColor = Color.Blue;
                }
            }
            else
            {
                this.SameFTimeLB.Text  = string.Empty;
                this.DownFTimeLB.Text  = string.Empty;
                this.BattVoltLB.Text   = string.Empty;
                this.BattALB.Text      = string.Empty;
                this.BattCLB.Text      = string.Empty;
                this.BattTempoLB.Text  = string.Empty;
                this.BattLifeLB.Text   = string.Empty;
                this.BattStateLB.Text  = string.Empty;
                this.BattVolt2LB.Text  = string.Empty;
                this.BattA2LB.Text     = string.Empty;
                this.BattC2LB.Text     = string.Empty;
                this.BattTempo2LB.Text = string.Empty;
                this.BattLife2LB.Text  = string.Empty;
                this.BattState2LB.Text = string.Empty;
                this.FanStateLB.Text   = string.Empty;
                this.DoorStateLB.Text  = string.Empty;
                this.FWVerStateLB.Text = string.Empty;
                this.CdmaRssiLB.Text   = string.Empty;
                this.CdmaIpLB.Text     = string.Empty;
                this.CdmaPortLB.Text   = string.Empty;
                this.RemarkLB.Text     = string.Empty;
            }
        }