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