duheng
2024-11-14 60908c00556f4f53d82f5588ae3013f80c443590
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 水力工况信息ViewModel
    /// </summary>
    public class HydroWorkingInfoViewModel
    {
        /// <summary>
        /// 
        /// </summary>
        public HydroWorkingInfoViewModel()
        {
            this.Waterboxs = new List<HydroWaterboxWorkingInfoViewModel>();
            this.Pumps = new List<HydroPumpWorkingInfoViewModel>();
            this.Valves = new List<HydroValveWorkingInfoViewModel>();
            this.Monitors = new List<HydroMonitorWorkingInfoViewModel>();
        }
 
        /// <summary>
        /// 水箱
        /// </summary>
        public List<HydroWaterboxWorkingInfoViewModel> Waterboxs { get; set; }
 
        /// <summary>
        /// 水泵
        /// </summary>
        public List<HydroPumpWorkingInfoViewModel> Pumps { get; set; }
 
        /// <summary>
        /// 阀门
        /// </summary>
        public List<HydroValveWorkingInfoViewModel> Valves { get; set; }
 
        /// <summary>
        /// 监测
        /// </summary>
        public List<HydroMonitorWorkingInfoViewModel> Monitors { get; set; }
 
 
        /// <summary>
        /// 获取所有组件工况信息列表
        /// </summary>
        public List<HydroVisualWorkingInfoViewModel> GetAllVisualWorkingInfoList()
        {
            var list = new List<HydroVisualWorkingInfoViewModel>();
            this.Waterboxs?.ForEach(x => list.Add(x));
            this.Pumps?.ForEach(x => list.Add(x));
            this.Valves?.ForEach(x => list.Add(x));
            return list;
        }
 
        /// <summary>
        /// 添加组件工况信息
        /// </summary>
        public bool AppendVisualWorkingInfo(HydroVisualWorkingInfoViewModel workingInfo)
        {
            if (workingInfo == null)
            {
                return false;
            }
            if (workingInfo is HydroWaterboxWorkingInfoViewModel waterbox)
            {
                if (this.Waterboxs.Exists(x => x.Code == waterbox.Code))
                {
                    return false;
                }
                this.Waterboxs.Add(waterbox);
                return true;
            }
            else if (workingInfo is HydroPumpWorkingInfoViewModel pump)
            {
                if (this.Pumps.Exists(x => x.Code == pump.Code))
                {
                    return false;
                }
                this.Pumps.Add(pump);
                return true;
            }
            else if (workingInfo is HydroValveWorkingInfoViewModel valve)
            {
                if (this.Valves.Exists(x => x.Code == valve.Code))
                {
                    return false;
                }
                this.Valves.Add(valve);
                return true;
            }
            return false;
        }
 
 
 
    }
}