프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / ID2PSN / Object / Item.cs @ c6503eaa

이력 | 보기 | 이력해설 | 다운로드 (5.7 KB)

1
using DevExpress.XtraGrid.Views.Layout;
2
using System;
3
using System.Collections.Generic;
4
using System.Linq;
5
using System.Text;
6
using System.Threading.Tasks;
7

    
8
namespace ID2PSN
9
{
10
    public enum ItemType
11
    {
12
        None,
13
        Symbol,
14
        Line
15
    }
16
    public enum SubItemType
17
    {
18
        None,
19
        OPC,
20
        Header,
21
        Nozzle,
22
    }
23

    
24
    public class Item
25
    {
26
        public Item()
27
        {
28
            BranchItems = new List<Item>();
29
            Attributes = new List<Attribute>();
30
        }
31

    
32
        public string UID { get; set; }
33
        public string Type { get; set; }
34
        public string Name { get; set; }
35
        public string Owner { get; set; }
36
        public string Parent { get; set; }
37
        public string ANGLE { get; set; }
38
        public double[] POINT { get; set; }
39
        public List<Relation> Relations { get; set; }
40
        public List<Attribute> Attributes { get; set; }
41
        public ItemType ItemType { get; set; }
42
        public SubItemType SubItemType { get; set; }
43
        public List<Item> BranchItems { get; set; }
44
        public string TopologyData { get; set; }
45
        public string PSNPipeLineID { get; set; }
46
        public Topology Topology { get; set; }
47
        public LineNumber LineNumber { get; set; }
48
        public Equipment Equipment { get; set; }
49
    }
50

    
51
    public class Relation 
52
    { 
53
        public string UID { get; set; }
54
        public Item Item { get; set; }
55
        public double[] Point { get; set; }
56
    }
57
    public class Attribute
58
    {
59
        public string UID { get; set; }
60
        public string Name { get; set; }
61
        public string DisplayName { get; set; }
62
        public string Value { get; set; }
63
    }
64
    public class Equipment
65
    {
66
        public Equipment()
67
        {
68
            POINT = new List<double[]>();
69
            Nozzles = new List<Item>();
70
            Attributes = new List<Attribute>();
71
        }
72
        public string Name { get; set; }
73
        public string UID { get; set; }
74
        public List<double[]> POINT { get; set; }
75
        public List<Item> Nozzles { get; set; }
76
        public List<Attribute> Attributes { get; set; }
77
        public string ItemTag { get; set; }
78
    }
79
    public class LineNumber
80
    {
81
        public LineNumber()
82
        {
83
            Attributes = new List<Attribute>();
84
        }
85
        public string UID { get; set; }
86
        public string Name { get; set; }
87
        public List<Attribute> Attributes { get; set; }
88
    }
89

    
90
    public class RunInfo 
91
    { 
92
        public RunInfo()
93
        {
94
            Items = new List<Item>();
95
        }
96
        public string UID { get; set; }
97
        public int Index { get; set; }
98
        public List<Item> Items { get; set; }
99
    }
100

    
101
    public class Group
102
    {
103
        public Group(Document document)
104
        {
105
            _Document = document;
106
        }
107
        public Group StartGroup { get; set; }
108
        public Group EndGroup { get; set; }
109
        public string UID { get; set; }
110
        public List<Item> Items { get; set; }
111
        private Document _Document;
112
        public Document Document { get { return _Document; } }
113
        public void SortItems()
114
        {
115
            List<Item> sorted = new List<Item>();
116
            Item line = Items.Find(x => x.ItemType == ItemType.Line);
117
            if (line != null)
118
            {
119
                sorted.Add(line);
120
                Item startItem = line.Relations[0].Item;
121
                if (startItem != null)
122
                {
123
                    Stack<Item> stacks = new Stack<Item>();
124
                    stacks.Push(startItem);
125
                    while (stacks.Count > 0)
126
                    {
127
                        Item stack = stacks.Pop();
128
                        if (sorted.Contains(stack))
129
                            continue;
130

    
131
                        if (Items.Contains(stack))
132
                        {
133
                            sorted.Insert(0, stack); 
134
                            foreach (var relation in stack.Relations)
135
                            {
136
                                if (relation.Item == null || !Items.Contains(relation.Item))
137
                                    continue;
138
                                stacks.Push(relation.Item);
139
                            }
140
                        }
141
                    }
142
                }
143
                Item endItem = line.Relations[1].Item;
144
                if (endItem != null)
145
                {
146
                    Stack<Item> stacks = new Stack<Item>();
147
                    stacks.Push(endItem);
148
                    while (stacks.Count > 0)
149
                    {
150
                        Item stack = stacks.Pop();
151
                        if (sorted.Contains(stack))
152
                            continue;
153

    
154
                        if (Items.Contains(stack))
155
                        {
156
                            sorted.Add(stack);
157
                            foreach (var relation in stack.Relations)
158
                            {
159
                                if (relation.Item == null || !Items.Contains(relation.Item))
160
                                    continue;
161
                                stacks.Push(relation.Item);
162
                            }
163
                        }
164
                    }
165
                }
166

    
167
                if (!sorted.Count.Equals(Items.Count))
168
                    throw new Exception("logic error");
169

    
170
                Items = sorted;
171
            }
172
            else
173
            {
174

    
175
            }
176
        }
177
    }
178

    
179
    public class Topology
180
    {
181
        public Topology()
182
        {
183
            Items = new List<Item>();
184
        }
185
        public string ID { get; set; }
186
        public string Type { get; set; }
187
        public string Index { get; set; }
188
        public string FullName { get { return ID + "-" + Type + Index; } }
189
        public List<Item> Items { get; set; }
190
    }
191
}
클립보드 이미지 추가 (최대 크기: 500 MB)