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