Exemple #1
0
        /// <summary>
        /// 处理输入信息
        /// </summary>
        /// <param name="input">输入的信息</param>
        public void Filter(string input)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return;
            }

            #region 方法3 新正则提取
            MatchCollection col = pattern.Matches(input);
            if (col == null || col.Count == 0)
            {
                return;
            }
            foreach (Match match in col)
            {
                BaseMessage message = new BaseMessage(match.Value);
                dynamic     obj;
                switch (message.MessageId)
                {
                case SensorMessageId_0.RadarState_Out:
                    this.RadarState.Base = message;
                    break;

                case SensorMessageId_0.Cluster_0_Status_Out:
                    obj = new ClusterStatus(message);
                    this.DataPushFinalize();
                    this.CurrentSensorMode = SensorMode.Cluster;
                    this.BufferSize        = obj.NofClustersNear + obj.NofClustersFar;
                    break;

                case SensorMessageId_0.Cluster_1_General_Out:
                    obj = new ClusterGeneral(message, this.Radar);
                    this.DataPush <ClusterGeneral>(obj);
                    this.ActualSize++;
                    break;

                case SensorMessageId_0.Cluster_2_Quality_Out:
                    obj = new ClusterQuality(message);
                    this.DataQualityUpdate <ClusterQuality>(obj);
                    break;

                case SensorMessageId_0.Obj_0_Status_Out:
                    obj = new ObjectStatus(message);
                    this.DataPushFinalize();
                    this.CurrentSensorMode = SensorMode.Object;
                    this.BufferSize        = obj.NofObjects;
                    break;

                case SensorMessageId_0.Obj_1_General_Out:
                    obj = new ObjectGeneral(message, this.Radar);
                    this.DataPush <ObjectGeneral>(obj);
                    this.ActualSize++;
                    break;

                case SensorMessageId_0.Obj_2_Quality_Out:
                    obj = new ObjectQuality(message);
                    this.DataQualityUpdate <ObjectQuality>(obj);
                    break;

                default:
                    continue;
                }
            }
            #endregion
        }
Exemple #2
0
        /// <summary>
        /// 处理输入信息
        /// </summary>
        /// <param name="input">输入的信息</param>
        public void Filter(string input)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return;
            }

            #region 方法1 旧正则提取方法(注释)
            //this.Messages = RegexMatcher.FindMatches(input, BaseConst.Pattern_SensorMessage);
            //if (this.Messages == null || this.Messages.Length == 0)
            //    return;
            //foreach (var m in this.Messages)
            //{
            //    BaseMessage message = new BaseMessage(m);
            //    dynamic obj;
            //    switch (message.MessageId)
            //    {
            //        case SensorMessageId_0.Cluster_0_Status_Out:
            //            obj = new ClusterStatus(message);
            //            this.DataPushFinalize();
            //            this.BufferSize = obj.NofClustersNear + obj.NofClustersFar;
            //            break;
            //        case SensorMessageId_0.Cluster_1_General_Out:
            //            obj = new ClusterGeneral(message);
            //            this.DataPush(obj);
            //            //this.List_ClusterGeneral.Add(obj);
            //            break;
            //        case SensorMessageId_0.Cluster_2_Quality_Out:
            //            obj = new ClusterQuality(message);
            //            break;
            //        default:
            //            continue;
            //    }
            //    //this.List_SensorInfos.Add(obj);
            //}
            #endregion

            #region 方法2 逐字符分解(注释)
            //this.Messages = this.GatherMessages(input); //方法2 逐字符分解
            #endregion

            #region 方法3 新正则提取
            MatchCollection col = pattern.Matches(input);
            if (col == null || col.Count == 0)
            {
                return;
            }
            foreach (Match match in col)
            {
                BaseMessage message = new BaseMessage(match.Value);
                dynamic     obj;
                switch (message.MessageId)
                {
                case SensorMessageId_0.RadarState_Out:
                    //obj = new RadarState(message);
                    this.RadarState.Base = message;
                    //this.Timer = 0;
                    //this.RadarState.Working = true;
                    break;

                case SensorMessageId_0.Cluster_0_Status_Out:
                    obj = new ClusterStatus(message);
                    this.DataPushFinalize();
                    this.CurrentSensorMode = SensorMode.Cluster;
                    this.BufferSize        = obj.NofClustersNear + obj.NofClustersFar;
                    break;

                case SensorMessageId_0.Cluster_1_General_Out:
                    obj = new ClusterGeneral(message, this.Radar);
                    this.DataPush <ClusterGeneral>(obj);
                    break;

                case SensorMessageId_0.Cluster_2_Quality_Out:
                    obj = new ClusterQuality(message);
                    this.DataQualityUpdate <ClusterQuality>(obj);
                    break;

                case SensorMessageId_0.Obj_0_Status_Out:
                    obj = new ObjectStatus(message);
                    this.DataPushFinalize();
                    this.CurrentSensorMode = SensorMode.Object;
                    this.BufferSize        = obj.NofObjects;
                    break;

                case SensorMessageId_0.Obj_1_General_Out:
                    obj = new ObjectGeneral(message, this.Radar);
                    this.DataPush <ObjectGeneral>(obj);
                    break;

                case SensorMessageId_0.Obj_2_Quality_Out:
                    obj = new ObjectQuality(message);
                    this.DataQualityUpdate <ObjectQuality>(obj);
                    break;

                default:
                    continue;
                }
            }
            #endregion
        }