public static bool BuildPropsPreview(PumpSystem ppSys)
        {
            IMongoCollection <BsonDocument> collection;

            if (!TryGetDb(DBCollections.ppSysReport + "_" + ppSys.Guid, out collection))
            {
                return(false);
            }
            collection.DeleteMany(Builders <BsonDocument> .Filter.Empty);
            var insertItems =
                (from reportItem in ppSys.GetReport()
                 select new BsonDocument {
                { nameof(reportItem.PumpCode), reportItem.PumpCode },
                { nameof(reportItem.CompCode), reportItem.CompCode },
                { nameof(reportItem.CompName), reportItem.CompName },
                { nameof(reportItem.CompType), reportItem.CompType.ToString() },
                { nameof(reportItem.TdPos), reportItem.TdPos?.ToString() ?? "" },
                { nameof(reportItem.PropName), reportItem.PropName },
                { nameof(reportItem.Variable), reportItem.Variable },
                { nameof(reportItem.Value), reportItem.Value ?? "" }
            }).ToList();

            collection.InsertMany(insertItems);
            return(true);
        }
        private static double?GetSpeed(PumpSystem ppSys)
        {
            //获取一下转速
            var speedSignal = ppSys.GetReport().First(rpt => rpt.CompType == CompType.Td_S && rpt.Variable == "@Speed").Value;
            var speed       = RuntimeRepo.RtData.FindSignalValue(speedSignal);

            return(speed);
        }
        public void DiagnoseRunningPump_Round1(PumpSystem ppSys)
        {
#if DEBUG
            //显示信号量与属性关联的结果, 结果通过robo3T可视化工具查看表格
            MyMongo.BuildPropsPreview(ppSys);
#endif

            var ppSysReport = ppSys.GetReport();

            //对系统中的每一个部件
            foreach (var comp in ppSys)
            {
                //寻找其对应的判据
                foreach (var ct in comp.GetAllCriteria())
                {
                    #region 获取实时数据的字典

                    var filtedRpt = ppSysReport.Where(rptItem =>
                    {
                        var td = comp as BaseTransducer;
                        if (td == null)   //如果不是传感器,直接过滤组件类型
                        {
                            return(rptItem.CompType == ct.CompType);
                        }
                        //如果是传感器,还要过滤传感器的位置
                        return(rptItem.CompType == ct.CompType && rptItem.TdPos == td.Position);
                    }).ToList();


                    //检查不重复后添加到字典
                    var dict      = new Dictionary <string, string>();
                    var conflicts = new List <string>();
                    foreach (var reportItem in filtedRpt)
                    {
                        var key   = reportItem.Variable;
                        var value = reportItem.Value;
                        if (dict.ContainsKey(key))
                        {
                            conflicts.Add(key);
                        }
                        else
                        {
                            dict.Add(key, value);
                        }
                    }

                    //提示修改重复项
                    if (conflicts.Any())
                    {
                        Log.Warn(
                            $"!!!组件{Repo.Map.TypeToEnum.First(t => t.Value == comp.Type).Key} 属性重复(请从access中手动去除):!!!");
                        foreach (var cfl in conflicts)
                        {
                            Console.Write($"{cfl}, ");
                        }
                        Log.Inform();
                    }

                    #endregion

                    _ctParser.ParseCriterion(ct, comp.Code, dict);
                }
            }

            FaultItemHappened?.Invoke(ppSys);
        }