示例#1
0
        ////是否是单步操作(对应流程化多步操作)
        //public bool IsSingleOperate { get; }

        //public SingleOperate()
        //{
        //    switch (OperateType)
        //    {
        //        case SingleOperateType.验电:
        //        case SingleOperateType.分闸:
        //        case SingleOperateType.合闸:
        //            IsSingleOperate = true;
        //            break;
        //        case SingleOperateType.断电:
        //        case SingleOperateType.送电:
        //            IsSingleOperate = false;
        //            break;
        //    }

        //}

        public override bool Equals(object obj)
        {
            if (obj == null || !(obj is MultipleOperate))
            {
                return(false);
            }
            MultipleOperate ope = obj as MultipleOperate;

            return(ope.EquipmentType == EquipmentType && ope.OperateType == OperateType);
        }
 public bool CanExecute(EquipmentBase equipment, MultipleOperate operateType)
 {
     return(false);
 }
        private OperateHelper()
        {
            SingleOperConditionDic = new ObservableDictionary <SingleOperate, ObservableCollection <OperateCondition> >();

            #region 备用
            ////构造接地设备合闸条件
            //{
            //    SingleOperate so1 = new SingleOperate() { EquipmentType = typeof(Device), OperateType = SingleOperateType.合闸 };
            //    List<OperateCondition> ocList1 = new List<OperateCondition>();
            //    ocList1.Add(new OperateCondition() { PropertyMark = "合闸", PropertyName = "IsClosed", PropertyType = typeof(Switch).GetProperty("IsClosed").PropertyType, PropertyValue = false });
            //    OperateCondition oc1 = new OperateCondition() { PropertyMark = "隔离开关", PropertyType = typeof(Device).GetProperty("SwitchsRelated").PropertyType, PropertyName = "SwitchsRelated", RelatedEquipProList = ocList1 };
            //    OperateCondition oc2 = new OperateCondition() { PropertyMark = "合闸", PropertyType = typeof(Device).GetProperty("IsClosed").PropertyType, PropertyName = "IsClosed", PropertyValue = false };
            //    OperateCondition oc3 = new OperateCondition() { PropertyMark = "闭锁", PropertyType = typeof(Device).GetProperty("IsLocked").PropertyType, PropertyName = "IsLocked", PropertyValue = false };
            //    OperateCondition oc4 = new OperateCondition() { PropertyMark = "告警", PropertyType = typeof(Device).GetProperty("IsAlarming").PropertyType, PropertyName = "IsAlarming", PropertyValue = false };
            //    OperateCondition oc5 = new OperateCondition() { PropertyMark = "通过验电", PropertyType = typeof(Device).GetProperty("IsElecChecked").PropertyType, PropertyName = "IsElecChecked", PropertyValue = true };

            //    ObservableCollection<OperateCondition> list1 = new ObservableCollection<OperateCondition>();
            //    list1.Add(oc1);
            //    list1.Add(oc2);
            //    list1.Add(oc3);
            //    list1.Add(oc4);
            //    list1.Add(oc5);
            //    SingleOperConditionDic.Add(so1, list1);
            //}
            ////构造接地设备分闸条件
            //{
            //    SingleOperate so1 = new SingleOperate() { EquipmentType = typeof(Device), OperateType = SingleOperateType.分闸 };
            //    List<OperateCondition> ocList1 = new List<OperateCondition>();
            //    ocList1.Add(new OperateCondition() { PropertyMark = "门状态", PropertyName = "DoorState", PropertyType = typeof(Door).GetProperty("DoorState").PropertyType, PropertyValue = DoorState.关门 });
            //    OperateCondition oc1 = new OperateCondition() { PropertyMark = "门禁", PropertyType = typeof(Device).GetProperty("DoorsRelated").PropertyType, PropertyName = "DoorsRelated", RelatedEquipProList = ocList1 };
            //    OperateCondition oc2 = new OperateCondition() { PropertyMark = "合闸", PropertyType = typeof(Device).GetProperty("IsClosed").PropertyType, PropertyName = "IsClosed", PropertyValue = true };
            //    OperateCondition oc3 = new OperateCondition() { PropertyMark = "闭锁", PropertyType = typeof(Device).GetProperty("IsLocked").PropertyType, PropertyName = "IsLocked", PropertyValue = false };
            //    OperateCondition oc4 = new OperateCondition() { PropertyMark = "告警", PropertyType = typeof(Device).GetProperty("IsAlarming").PropertyType, PropertyName = "IsAlarming", PropertyValue = false };
            //    //OperateCondition oc5 = new OperateCondition() { PropertyType = typeof(Device).GetProperty("SwitchsRelated").PropertyType, PropertyName = "IsElecChecked", PropertyValue = true };//分闸不需要验电

            //    ObservableCollection<OperateCondition> list1 = new ObservableCollection<OperateCondition>();
            //    list1.Add(oc1);
            //    list1.Add(oc2);
            //    list1.Add(oc3);
            //    list1.Add(oc4);
            //    //list1.Add(oc5);
            //    SingleOperConditionDic.Add(so1, list1);
            //}
            #endregion


            //构造设备类基础元数据
            Type   baseType   = typeof(EquipmentBase);
            Type[] equipTypes = baseType.Assembly.GetTypes();
            foreach (var equipType in equipTypes)
            {
                if (equipType.IsSubclassOf(baseType))//是EquipmentBase的子类
                {
                    var operAttr = equipType.GetCustomAttribute <OperateTypeAttribute>(false);
                    if (operAttr != null)
                    {
                        if (operAttr.OperateType == typeof(ESingleOperateType))
                        {
                            foreach (var operType in operAttr.OperateTypeList)
                            {
                                SingleOperate so = new SingleOperate()
                                {
                                    EquipmentType = equipType, OperateType = (ESingleOperateType)operType
                                };
                                SingleOperConditionDic.Add(so, new ObservableCollection <OperateCondition>());
                            }
                        }
                        else if (operAttr.OperateType == typeof(EMultipleOperateType))
                        {
                            foreach (var operType in operAttr.OperateTypeList)
                            {
                                MultipleOperate mo = new MultipleOperate()
                                {
                                    EquipmentType = equipType, OperateType = (EMultipleOperateType)operType
                                };
                                MultiOperConditionDic.Add(mo, new ObservableCollection <SingleOperate>());
                            }
                        }
                    }

                    EquipmentSetupDic.Add(equipType.Name, new EquipmentSetup()
                    {
                        ClassName     = equipType.Name,
                        IsOperatable  = operAttr != null,
                        EquipmentName = equipType.GetCustomAttribute <OperationConfigMarkAttribute>(false)?.Mark,
                        //IsReal = false,
                        IsMultiStepOperation = operAttr.OperateType == typeof(EMultipleOperateType),
                        ClassFullName        = equipType.FullName,
                        AssemblyName         = equipType.Assembly.FullName,
                        ClassType            = equipType
                    });
                }
            }
        }