/// <summary>
        /// 处理上行数据报文
        /// </summary>
        /// <param name="updata"></param>
        private void parse_Updata(object updata)
        {
            //初始话
            string datagram = updata as string;
            var    gsm      = new CGSMStruct();

            if (!GsmHelper.Parse_2(datagram, out gsm))
            {
                return;
            }
            IUp upParser = new UpParse();
            //TODO 增加router,根据站点绑定调用协议
            CReportStruct report = new CReportStruct();

            string data = datagram.Substring(datagram.IndexOf("$")).Replace(";", "");

            if (Up.Parse(data, out report)) /* 解析成功 */
            {
                report.ChannelType = EChannelType.GSM;
                report.ListenPort  = "COM" + this.ListenPort.PortName;
                report.flagId      = gsm.PhoneNumber;
                if (this.UpDataReceived != null)
                {
                    InvokeMessage(datagram, "[GSM]接收");
                    this.UpDataReceived.Invoke(null, new UpEventArgs()
                    {
                        Value = report, RawData = datagram
                    });
                }
            }
        }
        private void Parser_3(object str)
        {
            try
            {
                string data = str as string;
                /* 删除 '\r\n' 字符串 */
                while (data.StartsWith("\r\n"))
                {
                    data = data.Substring(2);
                }

                /*
                 * 解析数据,获取CGSMStruct
                 */
                var gsm = new CGSMStruct();
                if (!GsmHelper.Parse_3(data, out gsm))
                {
                    return;
                }
                /*  如果解析成功,触发GSM数据接收完成事件  */
                //string rawdata = "";
                //string rawdata1 = gsm.Message;
                //if (!rawdata1.Contains('$'))
                //{
                //    rawdata = "$" + rawdata1;
                //}

                if (data.EndsWith("+"))
                {
                    data = data.Substring(0, data.Length - 1);
                }
                InvokeMessage(data, "接收");

                string msg = string.Empty;
                if (!ProtocolHelpers.DeleteSpecialChar(gsm.Message, out msg))
                {
                    return;
                }
                msg = gsm.Message;
                string rawdata = msg;
                if (msg.Contains('$'))
                {
                    msg = msg.Substring(1);
                }
                //if (msg.Contains('9'))
                //{
                //    msg = msg.Substring(1);
                //}


                if (!msg.ToUpper().Contains("TRU"))
                {
                    string sid  = msg.Substring(0, 4);
                    string type = msg.Substring(4, 2);

                    /*
                     *  上行指令信息,
                     *  或者读取参数返回的信息
                     */
                    #region 1G
                    if (type == "1G")
                    {
                        string reportType = msg.Substring(6, 2);
                        /*  定时报,加报 */
                        if (reportType == "21" || reportType == "22")
                        {
                            //  YAC设备的墒情协议:
                            string stationType = msg.Substring(8, 2);
                            switch (stationType)
                            {
                            //  站类为04时墒情站 05墒情雨量站 06,16墒情水位站 07,17墒情水文站
                            case "04":
                            case "05":
                            case "06":
                            case "07":
                                //case "17":
                                //    {
                                //        CEntitySoilData soil = new CEntitySoilData();
                                //        CReportStruct soilReport = new CReportStruct();
                                //        Soil = new Protocol.Data.Lib.SoilParser();
                                //        if (Soil.Parse(rawdata, out soil, out soilReport))
                                //        {
                                //            soil.ChannelType = EChannelType.GSM;

                                //            if (null != this.SoilDataReceived)
                                //                this.SoilDataReceived(null, new CEventSingleArgs<CEntitySoilData>(soil));
                                //            //1111gm
                                //            string temp = soilReport.ReportType == EMessageType.EAdditional ? "加报" : "定时报";
                                //            //InvokeMessage(String.Format("{0,-10}   ", temp) + rawdata, "接收");

                                //            if (null != soilReport && null != this.UpDataReceived)
                                //           // if (null != soilReport)
                                //             {
                                //                soilReport.ChannelType = EChannelType.GSM;
                                //                soilReport.ListenPort = "COM" + this.ListenPort.PortName;
                                //                this.UpDataReceived(null, new UpEventArgs() { RawData = rawdata, Value = soilReport });
                                //            }
                                //        }
                                //        else
                                //        {
                                //            //string temp = soilReport.ReportType == EMessageType.EAdditional ? "加报" : "定时报";
                                //            InvokeMessage(" " + rawdata, "接收");
                                //        }
                                //    }
                                break;

                            //  站类为01,02,03,12,13时,不是墒情站
                            case "01":
                            case "02":
                            case "03":
                            case "12":
                            case "13":
                            {
                                CReportStruct report = new CReportStruct();
                                if (Up.Parse(msg, out report))         /* 解析成功 */
                                {
                                    report.ChannelType = EChannelType.GSM;
                                    report.ListenPort  = "COM" + this.ListenPort.PortName;
                                    report.flagId      = gsm.PhoneNumber;
                                    if (this.UpDataReceived != null)
                                    {
                                        this.UpDataReceived.Invoke(null, new UpEventArgs()
                                            {
                                                Value = report, RawData = data
                                            });
                                    }
                                }
                            }
                            break;

                            default:
                                break;
                            }
                        }
                        else if (reportType == "11")    //  人工水位
                        {
                        }
                        else if (reportType == "23")    //  人工流量
                        {
                        }
                        else if (reportType == "25")
                        {
                        }
                        else /* 下行指令 */
                        {
                            CDownConf downconf = new CDownConf();
                            if (Down.Parse(msg, out downconf)) /* 解析成功 */
                            {
                                if (this.DownDataReceived != null)
                                {
                                    this.DownDataReceived.Invoke(null, new DownEventArgs()
                                    {
                                        Value = downconf, RawData = data
                                    });
                                }
                            }
                        }
                    }

                    #endregion

                    #region 1K
                    if (type == "1K") /* 批量传输 */
                    {
                        var station = FindStationBySID(sid);
                        if (station == null)
                        {
                            throw new Exception("批量传输,站点传输类型匹配错误");
                        }
                        //  EStationBatchType batchType = station.BatchTranType;

                        //if (batchType == EStationBatchType.EFlash)          /* Flash传输 */
                        //{
                        CBatchStruct batch = new CBatchStruct();
                        if (FlashBatch.Parse(gsm.Message, out batch)) /* 解析成功 */
                        {
                            if (this.BatchDataReceived != null)
                            {
                                this.BatchDataReceived.Invoke(null, new BatchEventArgs()
                                {
                                    Value = batch, RawData = data
                                });
                            }
                        }
                        //}
                        //else if (batchType == EStationBatchType.EUPan)  /* U盘传输 */
                        //{
                        //    CBatchStruct batch = new CBatchStruct();
                        //    if (UBatch.Parse(gsm.Message, out batch))   /* 解析成功 */
                        //    {
                        //        if (this.BatchDataReceived != null)
                        //            this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = data });
                        //    }
                        //}
                        else
                        {
                            throw new Exception("批量传输,站点传输类型匹配错误");
                        }
                    }
                    #endregion

                    #region 1S
                    if (type == "1S") /* 远地下行指令,设置参数 */
                    {
                        CDownConf downconf = new CDownConf();
                        if (Down.Parse(gsm.Message, out downconf))/* 解析成功 */
                        {
                            if (this.DownDataReceived != null)
                            {
                                this.DownDataReceived.Invoke(null, new DownEventArgs()
                                {
                                    Value = downconf, RawData = data
                                });
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    if (this.ErrorReceived != null)
                    {
                        this.ErrorReceived.Invoke(null, new ReceiveErrorEventArgs()
                        {
                            Msg = data
                        });
                    }
                }
            }
            catch (Exception exp)
            {
                Debug.WriteLine(exp.Message);
            }
        }