hytos / DTI_PID / ID2PSN / Object / Item.cs @ 54be6611
이력 | 보기 | 이력해설 | 다운로드 (8.88 KB)
1 | 0f07fa34 | gaqhf | using DevExpress.XtraGrid.Views.Layout; |
---|---|---|---|
2 | using System; |
||
3 | 6b9e7a56 | gaqhf | 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 | 879ce10b | LJIYEON | Keyword |
23 | 6b9e7a56 | gaqhf | } |
24 | |||
25 | public class Item |
||
26 | { |
||
27 | public Item() |
||
28 | { |
||
29 | BranchItems = new List<Item>(); |
||
30 | 0f07fa34 | gaqhf | Attributes = new List<Attribute>(); |
31 | 6b9e7a56 | gaqhf | } |
32 | |||
33 | public string UID { get; set; } |
||
34 | 7881ec8f | gaqhf | public string ID2DBCategory { get; set; } |
35 | public string ID2DBType { get; set; } |
||
36 | 6b9e7a56 | gaqhf | public string Name { get; set; } |
37 | public string Owner { get; set; } |
||
38 | 7881ec8f | gaqhf | public string ID2DBName { get; set; } |
39 | 6b9e7a56 | gaqhf | public string ANGLE { get; set; } |
40 | public double[] POINT { get; set; } |
||
41 | public List<Relation> Relations { get; set; } |
||
42 | public List<Attribute> Attributes { get; set; } |
||
43 | public ItemType ItemType { get; set; } |
||
44 | public SubItemType SubItemType { get; set; } |
||
45 | public List<Item> BranchItems { get; set; } |
||
46 | public string TopologyData { get; set; } |
||
47 | 8f24b438 | gaqhf | public string PSNPipeLineID { get; set; } |
48 | 7cbebfe9 | 이지연 | public string PSNPipeSystemID { get; set; } |
49 | 6b9e7a56 | gaqhf | public Topology Topology { get; set; } |
50 | 36a45f13 | gaqhf | public Group Group { get; set; } |
51 | public PSNItem PSNItem { get; set; } |
||
52 | 6b9e7a56 | gaqhf | public LineNumber LineNumber { get; set; } |
53 | 85eeb2be | 이지연 | |
54 | 4c76a67a | gaqhf | public Equipment Equipment { get; set; } |
55 | 7881ec8f | gaqhf | public Document Document { get; set; } |
56 | 879ce10b | LJIYEON | public string Keyword { get; set; } |
57 | 4f02de16 | 이지연 | |
58 | public Item pairItem { get; set; } |
||
59 | public Item LineItemCopy() |
||
60 | { |
||
61 | Item newItem = new Item(); |
||
62 | |||
63 | newItem.UID = Guid.NewGuid().ToString(); |
||
64 | |||
65 | newItem.Name = this.Name; |
||
66 | newItem.ID2DBType = this.ID2DBType; |
||
67 | newItem.Owner = this.Owner; |
||
68 | newItem.ItemType = ItemType.Line; |
||
69 | |||
70 | List<Attribute> attributes = new List<Attribute>(); |
||
71 | foreach (var attr in this.Attributes) |
||
72 | { |
||
73 | attributes.Add(new Attribute() |
||
74 | { |
||
75 | UID = attr.UID, |
||
76 | Name = attr.Name, |
||
77 | DisplayName = attr.DisplayName, |
||
78 | Value = attr.Value |
||
79 | }); |
||
80 | } |
||
81 | newItem.Attributes = attributes; |
||
82 | |||
83 | List<Relation> relations = new List<Relation>(); |
||
84 | foreach (var _relation in this.Relations) |
||
85 | { |
||
86 | relations.Add(new Relation() |
||
87 | { |
||
88 | UID = "None", |
||
89 | Point = (double[])_relation.Point.Clone() |
||
90 | }); |
||
91 | } |
||
92 | newItem.Relations = relations; |
||
93 | |||
94 | return newItem; |
||
95 | } |
||
96 | |||
97 | public string GetAttributeByName(string name) |
||
98 | { |
||
99 | Attribute attribute = this.Attributes.Find(x => x.Name.ToUpper() == name.ToUpper()); |
||
100 | if (attribute != null && !string.IsNullOrEmpty(attribute.Value) && attribute.Value != "None") |
||
101 | { |
||
102 | return attribute.Value; |
||
103 | } |
||
104 | |||
105 | if (this.LineNumber != null) |
||
106 | { |
||
107 | attribute = this.LineNumber.Attributes.Find(x => x.Name.ToUpper() == name.ToUpper()); |
||
108 | if (attribute != null) |
||
109 | { |
||
110 | return attribute.Value; |
||
111 | } |
||
112 | } |
||
113 | |||
114 | return null; |
||
115 | } |
||
116 | |||
117 | 6b9e7a56 | gaqhf | } |
118 | |||
119 | public class Relation |
||
120 | { |
||
121 | public string UID { get; set; } |
||
122 | public Item Item { get; set; } |
||
123 | public double[] Point { get; set; } |
||
124 | } |
||
125 | 4a18cb33 | LJIYEON | |
126 | 6b9e7a56 | gaqhf | public class Attribute |
127 | { |
||
128 | public string UID { get; set; } |
||
129 | public string Name { get; set; } |
||
130 | public string DisplayName { get; set; } |
||
131 | public string Value { get; set; } |
||
132 | } |
||
133 | 4a18cb33 | LJIYEON | |
134 | 6b9e7a56 | gaqhf | public class Equipment |
135 | { |
||
136 | public Equipment() |
||
137 | { |
||
138 | POINT = new List<double[]>(); |
||
139 | Nozzles = new List<Item>(); |
||
140 | c6503eaa | gaqhf | Attributes = new List<Attribute>(); |
141 | 6b9e7a56 | gaqhf | } |
142 | 4c76a67a | gaqhf | public string Name { get; set; } |
143 | 6b9e7a56 | gaqhf | public string UID { get; set; } |
144 | public List<double[]> POINT { get; set; } |
||
145 | public List<Item> Nozzles { get; set; } |
||
146 | c6503eaa | gaqhf | public List<Attribute> Attributes { get; set; } |
147 | public string ItemTag { get; set; } |
||
148 | 6b9e7a56 | gaqhf | } |
149 | 4a18cb33 | LJIYEON | |
150 | 6b9e7a56 | gaqhf | public class LineNumber |
151 | { |
||
152 | 0f07fa34 | gaqhf | public LineNumber() |
153 | { |
||
154 | Attributes = new List<Attribute>(); |
||
155 | } |
||
156 | 6b9e7a56 | gaqhf | public string UID { get; set; } |
157 | public string Name { get; set; } |
||
158 | public List<Attribute> Attributes { get; set; } |
||
159 | 710a49f1 | gaqhf | public bool IsCopy { get; set; } |
160 | 7d6d1693 | 이지연 | public bool MissingLineNumber1 { get; set; } |
161 | public bool MissingLineNumber2 { get; set; } |
||
162 | 85eeb2be | 이지연 | |
163 | 710a49f1 | gaqhf | public LineNumber Copy() |
164 | { |
||
165 | LineNumber copy = new LineNumber(); |
||
166 | copy.IsCopy = true; |
||
167 | copy.UID = Guid.NewGuid().ToString(); |
||
168 | copy.Name = Name; |
||
169 | foreach (Attribute attribute in Attributes) |
||
170 | { |
||
171 | copy.Attributes.Add(new Attribute() |
||
172 | { |
||
173 | UID = attribute.UID, |
||
174 | Name = attribute.Name, |
||
175 | DisplayName = attribute.DisplayName, |
||
176 | Value = attribute.Value, |
||
177 | }); |
||
178 | } |
||
179 | Attribute seqAttr = copy.Attributes.Find(x => x.Name == "Tag Seq No"); |
||
180 | if (seqAttr != null) |
||
181 | { |
||
182 | copy.Name = copy.Name.Replace(seqAttr.Value, seqAttr.Value + "V"); |
||
183 | seqAttr.Value += "V"; |
||
184 | } |
||
185 | else |
||
186 | copy.Name += "V"; |
||
187 | |||
188 | a2973aa3 | LJIYEON | |
189 | |||
190 | 710a49f1 | gaqhf | return copy; |
191 | } |
||
192 | 6b9e7a56 | gaqhf | } |
193 | |||
194 | public class RunInfo |
||
195 | { |
||
196 | public RunInfo() |
||
197 | { |
||
198 | Items = new List<Item>(); |
||
199 | } |
||
200 | public string UID { get; set; } |
||
201 | public int Index { get; set; } |
||
202 | public List<Item> Items { get; set; } |
||
203 | } |
||
204 | |||
205 | public class Group |
||
206 | { |
||
207 | public Group(Document document) |
||
208 | { |
||
209 | _Document = document; |
||
210 | } |
||
211 | public Group StartGroup { get; set; } |
||
212 | public Group EndGroup { get; set; } |
||
213 | public string UID { get; set; } |
||
214 | public List<Item> Items { get; set; } |
||
215 | private Document _Document; |
||
216 | public Document Document { get { return _Document; } } |
||
217 | public void SortItems() |
||
218 | { |
||
219 | List<Item> sorted = new List<Item>(); |
||
220 | Item line = Items.Find(x => x.ItemType == ItemType.Line); |
||
221 | if (line != null) |
||
222 | { |
||
223 | sorted.Add(line); |
||
224 | Item startItem = line.Relations[0].Item; |
||
225 | if (startItem != null) |
||
226 | { |
||
227 | Stack<Item> stacks = new Stack<Item>(); |
||
228 | stacks.Push(startItem); |
||
229 | while (stacks.Count > 0) |
||
230 | { |
||
231 | Item stack = stacks.Pop(); |
||
232 | if (sorted.Contains(stack)) |
||
233 | continue; |
||
234 | |||
235 | if (Items.Contains(stack)) |
||
236 | { |
||
237 | sorted.Insert(0, stack); |
||
238 | foreach (var relation in stack.Relations) |
||
239 | { |
||
240 | if (relation.Item == null || !Items.Contains(relation.Item)) |
||
241 | continue; |
||
242 | stacks.Push(relation.Item); |
||
243 | } |
||
244 | } |
||
245 | } |
||
246 | } |
||
247 | Item endItem = line.Relations[1].Item; |
||
248 | if (endItem != null) |
||
249 | { |
||
250 | Stack<Item> stacks = new Stack<Item>(); |
||
251 | stacks.Push(endItem); |
||
252 | while (stacks.Count > 0) |
||
253 | { |
||
254 | Item stack = stacks.Pop(); |
||
255 | if (sorted.Contains(stack)) |
||
256 | continue; |
||
257 | |||
258 | if (Items.Contains(stack)) |
||
259 | { |
||
260 | sorted.Add(stack); |
||
261 | foreach (var relation in stack.Relations) |
||
262 | { |
||
263 | if (relation.Item == null || !Items.Contains(relation.Item)) |
||
264 | continue; |
||
265 | stacks.Push(relation.Item); |
||
266 | } |
||
267 | } |
||
268 | } |
||
269 | } |
||
270 | |||
271 | if (!sorted.Count.Equals(Items.Count)) |
||
272 | throw new Exception("logic error"); |
||
273 | |||
274 | Items = sorted; |
||
275 | } |
||
276 | else |
||
277 | { |
||
278 | |||
279 | } |
||
280 | } |
||
281 | } |
||
282 | |||
283 | public class Topology |
||
284 | { |
||
285 | public Topology() |
||
286 | { |
||
287 | Items = new List<Item>(); |
||
288 | } |
||
289 | public string ID { get; set; } |
||
290 | public string Type { get; set; } |
||
291 | public string Index { get; set; } |
||
292 | public string FullName { get { return ID + "-" + Type + Index; } } |
||
293 | public List<Item> Items { get; set; } |
||
294 | } |
||
295 | } |