예제 #1
0
        /// <summary>
        /// 检查某一秒的指定的故障条件是否成立
        /// </summary>
        /// <param name="fault"></param>
        /// <param name="paramValues"></param>
        /// <param name="second"></param>
        /// <returns></returns>
        public static bool CheckFault(AircraftFault fault, Dictionary<string, List<float>> paramValues, int second)
        {
            second = second - 1;//为了减少下面循环里的计算这里先减1
            foreach (ParameterCondition pc in fault.ParamConditions)
            {
                List<float> list = paramValues[pc.Parameter.ID];
                bool isValid = false;
                int freq = pc.Parameter.Frequence;
                for (int i = 0; i < freq; i++)
                {
                    try
                    {
                        isValid = pc.Condition.Check(list[second * freq + i]);
                    }
                    catch (Exception ex)
                    {
                    }
                    //如果持续时间为0,则其中有一个值符合条件,这个条件就成立
                    if (fault.Duration == 0 && isValid)
                        break;

                    //如果持续时间大于0,则其中有一个值不符合条件,这个条件就不成立
                    if (fault.Duration > 0 && isValid == false)
                        break;
                }

                if (isValid == false)
                    return false;
            }
            return true;
        }
예제 #2
0
        private static List<AircraftFault> GetFaultFromXML()
        {
            List<AircraftFault> list = new List<AircraftFault>();

            XmlDocument doc = new XmlDocument();
            doc.Load(Application.StartupPath+ "\\AircraftFault.xml");
            XmlNodeList nodes = doc.DocumentElement.SelectNodes("Fault");
            foreach (XmlNode n in nodes)
            {
                AircraftFault fault = new AircraftFault();
                fault.Title = n.Attributes["title"].Value;
                fault.Duration = Convert.ToInt32(n.Attributes["duratioin"].Value);
                fault.EventLevel = Convert.ToInt32(n.Attributes["EventLevel"].Value);
                fault.EventHandling = n.Attributes["EventHandling"].Value;
                fault.Remark = n.Attributes["Remark"].Value;

                XmlNodeList conditionNodes = n.SelectNodes("ParameterCondition");
                foreach (XmlNode cnode in conditionNodes)
                {
                    ParameterCondition pc = new ParameterCondition();
                    pc.Parameter = FlyParameter.Parameters[cnode.Attributes["ParameterKey"].Value];
                    float value = Convert.ToSingle(cnode.Attributes["value"].Value);
                    switch (cnode.Attributes["condition"].Value.ToLower())
                    {
                        case "大于":
                            pc.Condition = new LargeCondition { BottomBoundary = value, IncludeBottom = false };
                            break;
                        case "大于等于":
                            pc.Condition = new LargeCondition { BottomBoundary = value, IncludeBottom = true };
                            break;
                        case "小于":
                            pc.Condition = new SmallCondition { TopBoundary = value, IncludeTop = false };
                            break;
                        case "小于等于":
                            pc.Condition = new SmallCondition { TopBoundary = value, IncludeTop = true };
                            break;
                        case "等于":
                            pc.Condition = new EqualCondition { EqualValue = value };
                            break;
                        case "is":
                            pc.Condition = new BooleanCondition();
                            break;
                        case "范围":
                            float value2 = Convert.ToSingle(cnode.Attributes["value2"].Value);
                            bool top = Convert.ToBoolean(cnode.Attributes["top"].Value);
                            bool bottom = Convert.ToBoolean(cnode.Attributes["bottom"].Value);
                            bool nop = Convert.ToBoolean(cnode.Attributes["nop"].Value);
                            pc.Condition = new BoundCondition { TopBoundary = value2, BottomBoundary = value, IncludeTop = top, IncludeBottom = bottom, Nop = nop };
                            break;
                    }
                    fault.ParamConditions.Add(pc);
                }
                list.Add(fault);
            }
            return list;
        }
예제 #3
0
        private static List<AircraftFault> GetFaultList()
        {
            List<AircraftFault> list = new List<AircraftFault>();
            AircraftFault fault = new AircraftFault();

            ParameterCondition pc = new ParameterCondition();
            pc.Parameter = new FlyParameter { Index = 77, Caption = "俯仰角", Frequence = 4 };
            pc.Condition = new LargeCondition { BottomBoundary = 11, IncludeBottom = false };
            fault.ParamConditions.Add(pc);

            pc = new ParameterCondition();
            pc.Parameter = new FlyParameter { Index = 223, Caption = "左发高压转子转速", Frequence = 4 };
            pc.Condition = new LargeCondition { BottomBoundary = 0.95F, IncludeBottom = false };
            fault.ParamConditions.Add(pc);

            pc = new ParameterCondition();
            pc.Parameter = new FlyParameter { Index = 225, Caption = "右发高压转子转速", Frequence = 4 };
            pc.Condition = new LargeCondition { BottomBoundary = 0.95F, IncludeBottom = false };
            fault.ParamConditions.Add(pc);

            fault.Title = "起飞时仰角大";
            fault.Duration = 1;
            fault.EventLevel = 2;
            fault.EventHandling = "(1)通知训练部门(2)查看飞机腹鳍是否擦伤";

            list.Add(fault);

            return list;
        }