Exemple #1
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();
            }
        }
        //제어 버튼 클릭
        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();
        }