cloudflight
2024-06-10 07ffb6029da759a8ce4498207cfa5f6d069c44b1
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
using Hydro.CommonBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Hydro.MapView.Common
{
    public static class wParamExtension
    {
        public static void UpdateWParamByWaterEquivalentSettings(this WdnmoParam wdnmoParam, List<WaterEquivalentSettings> settings, double TotalDemand)
        {
            int setID = 1;
            var SumCount = settings.Sum(s => s.Meters.Count);
            wdnmoParam.VarSets_Import = new List<vSet>();
            wdnmoParam.Vars_Import = new List<variable>();
            settings.ForEach(s =>
            {
                double CurrentDemand = TotalDemand * s.Meters.Count / SumCount;
                vSet vset = new vSet();
                vset.ID = 10000 + setID;
                vset.Name = $"水表集合{setID}";
 
                vset.IndicatorType = "节点自由压力";
                vset.ObjectType = "节点";
                vset.defaultExpress = "最小值";
                vset.isNode = true;
                vset.IDs = s.Meters;
                wdnmoParam.VarSets_Import.Add(vset);
 
                variable var0 = new variable();
                var0.ID = 20000 + setID;
                var0.Name = $"水量分配参数{setID}";
                var0.expressString = $"{CurrentDemand}:";
                s.waterEquivalents.WaterEquivalentCollection.ForEach(w =>
                {
                    for (int i = 0; i < w.Count; i++)
                    {
                        //如果var0.expressString最后一个字符是冒号,说明是第一个,不需要加逗号
                        if (var0.expressString[var0.expressString.Length - 1] != ':')
                        {
                            var0.expressString += ",";
                        }
                        var0.expressString += $"{w.ID},{w.MinRatedFlow},{w.RatedFlow}";
                    }
 
                    
                });
                var0.IndicatorType = "当量分配";
                var0.logicType = "水量分配";
                var0.modelObjectID = $"{{|{vset.Name}|}}";
                var0.expressType = "基准值(界面)";
                wdnmoParam.Vars_Import.Add(var0);
 
                setID++;
 
            });
        }
    }
}