hytos / DTI_PID / ID2PSN / Object / Item.cs @ 710a49f1
이력 | 보기 | 이력해설 | 다운로드 (6.83 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 ID2DBCategory { get; set; } |
34 |
public string ID2DBType { get; set; } |
35 |
public string Name { get; set; } |
36 |
public string Owner { get; set; } |
37 |
public string ID2DBName { get; set; } |
38 |
public string ANGLE { get; set; } |
39 |
public double[] POINT { get; set; } |
40 |
public List<Relation> Relations { get; set; } |
41 |
public List<Attribute> Attributes { get; set; } |
42 |
public ItemType ItemType { get; set; } |
43 |
public SubItemType SubItemType { get; set; } |
44 |
public List<Item> BranchItems { get; set; } |
45 |
public string TopologyData { get; set; } |
46 |
public string PSNPipeLineID { get; set; } |
47 |
public Topology Topology { get; set; } |
48 |
public Group Group { get; set; } |
49 |
public PSNItem PSNItem { get; set; } |
50 |
public LineNumber LineNumber { get; set; } |
51 |
public Equipment Equipment { get; set; } |
52 |
public Document Document { get; set; } |
53 |
} |
54 |
|
55 |
public class Relation |
56 |
{ |
57 |
public string UID { get; set; } |
58 |
public Item Item { get; set; } |
59 |
public double[] Point { get; set; } |
60 |
} |
61 |
public class Attribute |
62 |
{ |
63 |
public string UID { get; set; } |
64 |
public string Name { get; set; } |
65 |
public string DisplayName { get; set; } |
66 |
public string Value { get; set; } |
67 |
} |
68 |
public class Equipment |
69 |
{ |
70 |
public Equipment() |
71 |
{ |
72 |
POINT = new List<double[]>(); |
73 |
Nozzles = new List<Item>(); |
74 |
Attributes = new List<Attribute>(); |
75 |
} |
76 |
public string Name { get; set; } |
77 |
public string UID { get; set; } |
78 |
public List<double[]> POINT { get; set; } |
79 |
public List<Item> Nozzles { get; set; } |
80 |
public List<Attribute> Attributes { get; set; } |
81 |
public string ItemTag { get; set; } |
82 |
} |
83 |
public class LineNumber |
84 |
{ |
85 |
public LineNumber() |
86 |
{ |
87 |
Attributes = new List<Attribute>(); |
88 |
} |
89 |
public string UID { get; set; } |
90 |
public string Name { get; set; } |
91 |
public List<Attribute> Attributes { get; set; } |
92 |
public bool IsCopy { get; set; } |
93 |
|
94 |
public LineNumber Copy() |
95 |
{ |
96 |
LineNumber copy = new LineNumber(); |
97 |
copy.IsCopy = true; |
98 |
copy.UID = Guid.NewGuid().ToString(); |
99 |
copy.Name = Name; |
100 |
foreach (Attribute attribute in Attributes) |
101 |
{ |
102 |
copy.Attributes.Add(new Attribute() |
103 |
{ |
104 |
UID = attribute.UID, |
105 |
Name = attribute.Name, |
106 |
DisplayName = attribute.DisplayName, |
107 |
Value = attribute.Value, |
108 |
}); |
109 |
} |
110 |
Attribute seqAttr = copy.Attributes.Find(x => x.Name == "Tag Seq No"); |
111 |
if (seqAttr != null) |
112 |
{ |
113 |
copy.Name = copy.Name.Replace(seqAttr.Value, seqAttr.Value + "V"); |
114 |
seqAttr.Value += "V"; |
115 |
} |
116 |
else |
117 |
copy.Name += "V"; |
118 |
|
119 |
return copy; |
120 |
} |
121 |
} |
122 |
|
123 |
public class RunInfo |
124 |
{ |
125 |
public RunInfo() |
126 |
{ |
127 |
Items = new List<Item>(); |
128 |
} |
129 |
public string UID { get; set; } |
130 |
public int Index { get; set; } |
131 |
public List<Item> Items { get; set; } |
132 |
} |
133 |
|
134 |
public class Group |
135 |
{ |
136 |
public Group(Document document) |
137 |
{ |
138 |
_Document = document; |
139 |
} |
140 |
public Group StartGroup { get; set; } |
141 |
public Group EndGroup { get; set; } |
142 |
public string UID { get; set; } |
143 |
public List<Item> Items { get; set; } |
144 |
private Document _Document; |
145 |
public Document Document { get { return _Document; } } |
146 |
public void SortItems() |
147 |
{ |
148 |
List<Item> sorted = new List<Item>(); |
149 |
Item line = Items.Find(x => x.ItemType == ItemType.Line); |
150 |
if (line != null) |
151 |
{ |
152 |
sorted.Add(line); |
153 |
Item startItem = line.Relations[0].Item; |
154 |
if (startItem != null) |
155 |
{ |
156 |
Stack<Item> stacks = new Stack<Item>(); |
157 |
stacks.Push(startItem); |
158 |
while (stacks.Count > 0) |
159 |
{ |
160 |
Item stack = stacks.Pop(); |
161 |
if (sorted.Contains(stack)) |
162 |
continue; |
163 |
|
164 |
if (Items.Contains(stack)) |
165 |
{ |
166 |
sorted.Insert(0, stack); |
167 |
foreach (var relation in stack.Relations) |
168 |
{ |
169 |
if (relation.Item == null || !Items.Contains(relation.Item)) |
170 |
continue; |
171 |
stacks.Push(relation.Item); |
172 |
} |
173 |
} |
174 |
} |
175 |
} |
176 |
Item endItem = line.Relations[1].Item; |
177 |
if (endItem != null) |
178 |
{ |
179 |
Stack<Item> stacks = new Stack<Item>(); |
180 |
stacks.Push(endItem); |
181 |
while (stacks.Count > 0) |
182 |
{ |
183 |
Item stack = stacks.Pop(); |
184 |
if (sorted.Contains(stack)) |
185 |
continue; |
186 |
|
187 |
if (Items.Contains(stack)) |
188 |
{ |
189 |
sorted.Add(stack); |
190 |
foreach (var relation in stack.Relations) |
191 |
{ |
192 |
if (relation.Item == null || !Items.Contains(relation.Item)) |
193 |
continue; |
194 |
stacks.Push(relation.Item); |
195 |
} |
196 |
} |
197 |
} |
198 |
} |
199 |
|
200 |
if (!sorted.Count.Equals(Items.Count)) |
201 |
throw new Exception("logic error"); |
202 |
|
203 |
Items = sorted; |
204 |
} |
205 |
else |
206 |
{ |
207 |
|
208 |
} |
209 |
} |
210 |
} |
211 |
|
212 |
public class Topology |
213 |
{ |
214 |
public Topology() |
215 |
{ |
216 |
Items = new List<Item>(); |
217 |
} |
218 |
public string ID { get; set; } |
219 |
public string Type { get; set; } |
220 |
public string Index { get; set; } |
221 |
public string FullName { get { return ID + "-" + Type + Index; } } |
222 |
public List<Item> Items { get; set; } |
223 |
} |
224 |
} |