ningshuxia
2024-04-25 769413fc5ff52240f001fb4bcfcca21728fb275a
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
using IStation.Epanet.Enums;
 
namespace IStation.Epanet.Network.Structures
{
 
    ///<summary>Control statement</summary>
    public class Control
    {
 
        public void ConvertUnits(Network net)
        {
            FieldsMap fMap = net.FieldsMap;
 
            if (Link == null)
                return;
 
            if (Node != null)
            {
                Grade = Node.NodeType == NodeType.Junction
                    ? Node.Elevation + Grade / fMap.GetUnits(FieldType.PRESSURE)
                    : Node.Elevation + Grade / fMap.GetUnits(FieldType.ELEV);
            }
 
            if (!double.IsNaN(Setting) && Link.LinkType == LinkType.VALVE)
            {
                switch (((Valve)Link).ValveType)
                {
                    case ValveType.PRV:
                    case ValveType.PSV:
                    case ValveType.PBV:
                        Setting /= fMap.GetUnits(FieldType.PRESSURE);
                        break;
                    case ValveType.FCV:
                        Setting /= fMap.GetUnits(FieldType.FLOW);
                        break;
                }
            }
 
        }
 
        ///<summary>Control grade.</summary>
        public double Grade { get; set; }
 
        ///<summary>Assigned link reference.</summary>
        public Link Link { get; set; }
 
        ///<summary>Assigned node reference.</summary>
        public Node Node { get; set; }
 
        ///<summary>New link setting.</summary>
        public double Setting { get; set; }
 
        ///<summary>New link status.</summary>
        public StatusType Status { get; set; }
 
        ///<summary>Control time (in seconds).</summary>
        public TimeSpan Time { get; set; }
 
        ///<summary>Control type</summary>
        public ControlType Type { get; set; }
    }
 
}