duheng
2024-11-19 ca5f300a7cef85d22b5e0f9d59d117c49f9909b3
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using Yw.Geometry;
 
namespace HStation.WinFrmUI.PhartRelation
{
    public partial class PumpPerform2dMultiViewDlg : XtraForm
    {
        public PumpPerform2dMultiViewDlg()
        {
            InitializeComponent();
        }
 
 
 
        public string SetBindingData(List<Perform2dMultiViewModel> list, PerformPoint2dViewModel design_pt, bool only_line, bool is_parallel = true)
        {
            if (list == null || !list.Any())
            {
                return "数据为空!";
            }
            var vm_list = new List<Yw.WinFrmUI.Phart.PumpSerialParallelViewModel>();
            var helper = new Yw.WinFrmUI.Phart.PumpParallelConnectionHelper();
            foreach (var item in list)
            {
                var id = item.Id;
                var name = item.Name;
                var hz = item.SpeedRatio * 50;
                var point_list_qh = item.PointsQH;
                var point_list_qe = item.PointsQE;
                var point_list_qp = item.PointsQP;
 
                if (point_list_qh == null)
                {
                    continue;
                }
 
                List<Yw.Geometry.Point2d> pt_qh_list = null, pt_qe_list = null, pt_qp_list = null;
                pt_qh_list = point_list_qh?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                pt_qe_list = point_list_qe?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
                pt_qp_list = point_list_qp?.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList();
 
 
                Yw.Geometry.CubicSpline2d cubic_spline_qh = null, cubic_spline_qe = null, cubic_spline_qp = null;
                cubic_spline_qh = new Yw.Geometry.CubicSpline2d(pt_qh_list);
                if (pt_qe_list != null)
                    cubic_spline_qe = new Yw.Geometry.CubicSpline2d(pt_qe_list);
                if (pt_qp_list != null)
                    cubic_spline_qp = new Yw.Geometry.CubicSpline2d(pt_qp_list);
 
                cubic_spline_qh = Yw.WinFrmUI.Phart.PumpCalcHelper.CalculateSimilarQH(cubic_spline_qh, 50, hz);
                cubic_spline_qe = Yw.WinFrmUI.Phart.PumpCalcHelper.CalculateSimilarQE(cubic_spline_qe, 50, hz);
                cubic_spline_qp = Yw.WinFrmUI.Phart.PumpCalcHelper.CalculateSimilarQP(cubic_spline_qp, 50, hz);
 
                if (!only_line)
                {
                    var color = ColorHelper.GetRandomColor();
                    var vm = new Yw.WinFrmUI.Phart.PumpSerialParallelViewModel();
                    vm.Id = id;
                    vm.Name = name;
                    vm.Qh = cubic_spline_qh;
                    vm.Qe = cubic_spline_qe;
                    vm.Qp = cubic_spline_qp;
                    vm_list.Add(vm);
                }
 
                helper.Add(cubic_spline_qh, cubic_spline_qp);
            }
 
            var calc_bol = false;
            var line_name = "";
            List<Yw.Geometry.Point2d> calc_pt_qh_list;
            List<Yw.Geometry.Point2d> calc_pt_qe_list;
            List<Yw.Geometry.Point2d> calc_pt_qp_list;
            if (is_parallel)
            {
                line_name = "并联曲线";
                calc_bol = helper.CalculateParallel(out calc_pt_qh_list, out calc_pt_qe_list, out calc_pt_qp_list);
            }
            else
            {
                line_name = "串联曲线";
                calc_bol = helper.CalculateSeries(out calc_pt_qh_list, out calc_pt_qe_list, out calc_pt_qp_list);
            }
 
            if (!calc_bol)
            {
                return "无法计算串并联曲线!";
            }
            var min_q = calc_pt_qh_list.Min(x => x.X);
            var max_q = calc_pt_qh_list.Max(x => x.X);
 
            var min_h = calc_pt_qh_list.Min(x => x.Y);
            var max_h = calc_pt_qh_list.Max(x => x.Y);
            if (design_pt != null)
            {
                if (design_pt.X > max_q || design_pt.X < min_q)
                {
                    return "设计流量无效!";
                }
 
                if (design_pt.Y > max_h || design_pt.Y < min_h)
                {
                    return "设计扬程无效!";
                }
            }
            else
            {
                var design_q = calc_pt_qh_list.Max(x => x.X) / 2;
                var design_h = calc_pt_qh_list.GetInterPointsY(design_q).Last();
                design_pt = new PerformPoint2dViewModel(design_q, design_h);
            }
 
 
            var vm_sp = new Yw.WinFrmUI.Phart.PumpSerialParallelInfoViewModel();
            vm_sp.Id = "-1";
            vm_sp.Name = line_name;
            vm_sp.Qh = new Yw.Geometry.CubicSpline2d(calc_pt_qh_list);
            vm_sp.Qe = new Yw.Geometry.CubicSpline2d(calc_pt_qe_list);
            vm_sp.Qp = new Yw.Geometry.CubicSpline2d(calc_pt_qp_list); 
            vm_sp.QhCalc= vm_sp.Qh; 
            vm_sp.QeCalc= vm_sp.Qe; 
            vm_sp.QpCalc= vm_sp.Qp;
            vm_sp.IsBp = true; 
            vm_list.Add(vm_sp);
            this.xtrPerform2dMultiChart1.Add(vm_sp, new Yw.Geometry.Point2d(design_pt.X, design_pt.Y));
 
            return string.Empty;
        }
 
 
 
    }
}