hytos / DTI_PID / APIDConverter / Model / PlantItem / Document.cs @ 128c844f
이력 | 보기 | 이력해설 | 다운로드 (25.6 KB)
1 | 6ec631d2 | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Text; |
||
4 | dbac61ab | gaqhf | using System.Linq; |
5 | 6ec631d2 | gaqhf | using System.Threading.Tasks; |
6 | dbac61ab | gaqhf | using System.Xml.Linq; |
7 | 6ec631d2 | gaqhf | using System.IO; |
8 | dbac61ab | gaqhf | using System.Data; |
9 | 5aec7e24 | gaqhf | using System.Windows.Forms; |
10 | 6ec631d2 | gaqhf | |
11 | namespace AVEVA.PID.CustomizationUtility.Model |
||
12 | { |
||
13 | public class Document |
||
14 | { |
||
15 | 5aec7e24 | gaqhf | private string _DWGNAME; |
16 | private string _SIZE; |
||
17 | private double _SIZE_WIDTH; |
||
18 | private double _SIZE_HEIGHT; |
||
19 | private string _UID; |
||
20 | private List<Symbol> _SYMBOLS = new List<Symbol>(); |
||
21 | private List<Line> _LINES = new List<Line>(); |
||
22 | private List<LineNumber> _LINENUMBERS = new List<LineNumber>(); |
||
23 | private List<TrimLine> _TRIMLINES = new List<TrimLine>(); |
||
24 | private List<EndBreak> _EndBreaks = new List<EndBreak>(); |
||
25 | private List<SpecBreak> _SpecBreaks = new List<SpecBreak>(); |
||
26 | private List<Equipment> _Equipments = new List<Equipment>(); |
||
27 | private bool _Enable; |
||
28 | private bool _Validation; |
||
29 | private bool _MappingValidation; |
||
30 | private string _ValidationMessage = string.Empty; |
||
31 | bool validationResult = false; |
||
32 | dbac61ab | gaqhf | private DataTable ID2SymbolTypeDT; |
33 | 6ec631d2 | gaqhf | |
34 | e49e1de9 | gaqhf | public string AvevaDrawingNumber { get; set; } |
35 | public string AvevaSheetNumber { get; set; } |
||
36 | public string AvevaTemplateID { get; set; } |
||
37 | public string AvevaTemplateName { get; set; } |
||
38 | |||
39 | 5aec7e24 | gaqhf | public string ValidationMessage { get => _ValidationMessage; set => _ValidationMessage = value; } |
40 | |||
41 | public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
||
42 | public List<Line> LINES { get => _LINES; set => _LINES = value; } |
||
43 | public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; } |
||
44 | public List<EndBreak> EndBreaks { get => _EndBreaks; set => _EndBreaks = value; } |
||
45 | public List<SpecBreak> SpecBreaks { get => _SpecBreaks; set => _SpecBreaks = value; } |
||
46 | public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; } |
||
47 | public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; } |
||
48 | public string SIZE |
||
49 | { |
||
50 | get |
||
51 | { |
||
52 | return _SIZE; |
||
53 | } |
||
54 | set |
||
55 | { |
||
56 | _SIZE = value; |
||
57 | string[] pointArr = _SIZE.Split(new char[] { ',' }); |
||
58 | if (pointArr.Length == 2) |
||
59 | { |
||
60 | _SIZE_WIDTH = Convert.ToDouble(pointArr[0]); |
||
61 | _SIZE_HEIGHT = Convert.ToDouble(pointArr[1]); |
||
62 | } |
||
63 | } |
||
64 | } |
||
65 | public double SIZE_WIDTH { get => _SIZE_WIDTH; } |
||
66 | public double SIZE_HEIGHT { get => _SIZE_HEIGHT; } |
||
67 | public List<TrimLine> TRIMLINES { get => _TRIMLINES; set => _TRIMLINES = value; } |
||
68 | public string PATH { get; set; } |
||
69 | public bool Enable { get => _Enable; set => _Enable = value; } |
||
70 | public bool Validation { get => _Validation; set => _Validation = value; } |
||
71 | public bool MappingValidation { get => _MappingValidation; set => _MappingValidation = value; } |
||
72 | public string UID { get => _UID; set => _UID = value; } |
||
73 | |||
74 | StringBuilder validationStringBuilder = new StringBuilder(); |
||
75 | |||
76 | public List<PlantItem> PlantItems = new List<PlantItem>(); |
||
77 | 6ec631d2 | gaqhf | |
78 | dbac61ab | gaqhf | public Document(string xmlPath, DataTable ID2SymbolTypeDT) |
79 | 6ec631d2 | gaqhf | { |
80 | dbac61ab | gaqhf | this.ID2SymbolTypeDT = ID2SymbolTypeDT; |
81 | 5aec7e24 | gaqhf | validationStringBuilder.AppendLine("Document Path : " + xmlPath); |
82 | validationStringBuilder.AppendLine(""); |
||
83 | try |
||
84 | { |
||
85 | if (xmlPath != null) |
||
86 | { |
||
87 | PATH = xmlPath; |
||
88 | XElement xml = XElement.Load(xmlPath); |
||
89 | DWGNAME = xml.Element("DWGNAME").Value; |
||
90 | SIZE = xml.Element("SIZE").Value; |
||
91 | dbac61ab | gaqhf | |
92 | 5aec7e24 | gaqhf | validationStringBuilder.AppendLine("Drawing Name : " + DWGNAME); |
93 | validationStringBuilder.AppendLine(""); |
||
94 | 6ec631d2 | gaqhf | |
95 | 5aec7e24 | gaqhf | SetSymbol(xml.Element("SYMBOLS")); |
96 | SetLine(xml.Element("LINEINFOS")); |
||
97 | SetLineNumber(xml.Element("LINENOS")); |
||
98 | SetTrimLine(xml.Element("TRIMLINENOS")); |
||
99 | 6ec631d2 | gaqhf | |
100 | 5aec7e24 | gaqhf | SetAllConnectors(); |
101 | Enable = true; |
||
102 | } |
||
103 | } |
||
104 | catch (Exception ex) |
||
105 | { |
||
106 | Enable = false; |
||
107 | MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
108 | 6ec631d2 | gaqhf | } |
109 | } |
||
110 | dbac61ab | gaqhf | |
111 | 5aec7e24 | gaqhf | #region READ XML |
112 | dbac61ab | gaqhf | private void SetSymbol(XElement node) |
113 | { |
||
114 | foreach (XElement item in node.Elements("SYMBOL")) |
||
115 | { |
||
116 | string sType = item.Element("TYPE").Value; |
||
117 | |||
118 | 5aec7e24 | gaqhf | DataRow[] rows = ID2SymbolTypeDT.Select(string.Format("Type = '{0}'", sType.Replace("'", "''"))); |
119 | string sCategory = rows[0]["Category"].ToString(); |
||
120 | |||
121 | if (sType == "Segment Breaks") |
||
122 | { |
||
123 | SpecBreak specBreak = new SpecBreak() |
||
124 | { |
||
125 | UID = item.Element("UID").Value, |
||
126 | DBUID = item.Element("DBUID").Value, |
||
127 | NAME = item.Element("NAME").Value, |
||
128 | TYPE = item.Element("TYPE").Value, |
||
129 | OWNER = item.Element("OWNER").Value, |
||
130 | ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
||
131 | CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
||
132 | LOCATION = item.Element("LOCATION").Value, |
||
133 | SIZE = item.Element("SIZE").Value, |
||
134 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
135 | PARENT = item.Element("PARENT").Value, |
||
136 | CHILD = item.Element("CHILD").Value, |
||
137 | HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
||
138 | AREA = item.Element("AREA").Value, |
||
139 | FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
||
140 | CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
||
141 | }; |
||
142 | SetAssociations(item.Element("ASSOCIATIONS"), specBreak.ASSOCIATIONS); |
||
143 | SetSymbolConnectors(item.Element("CONNECTORS"), specBreak.CONNECTORS, specBreak.CONNECTIONPOINT); |
||
144 | SetProperties(item.Element("PROPERTIES"), specBreak.PROPERTIES); |
||
145 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), specBreak.ATTRIBUTES); |
||
146 | SetSpecBreakAttribute(specBreak); |
||
147 | |||
148 | SpecBreaks.Add(specBreak); |
||
149 | } |
||
150 | else if (sType == "End Break") |
||
151 | { |
||
152 | EndBreak endBreak = new EndBreak() |
||
153 | { |
||
154 | UID = item.Element("UID").Value, |
||
155 | DBUID = item.Element("DBUID").Value, |
||
156 | NAME = item.Element("NAME").Value, |
||
157 | TYPE = item.Element("TYPE").Value, |
||
158 | OWNER = item.Element("OWNER").Value, |
||
159 | ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
||
160 | CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
||
161 | LOCATION = item.Element("LOCATION").Value, |
||
162 | SIZE = item.Element("SIZE").Value, |
||
163 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
164 | PARENT = item.Element("PARENT").Value, |
||
165 | CHILD = item.Element("CHILD").Value, |
||
166 | HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
||
167 | AREA = item.Element("AREA").Value, |
||
168 | FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
||
169 | CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
||
170 | }; |
||
171 | SetAssociations(item.Element("ASSOCIATIONS"), endBreak.ASSOCIATIONS); |
||
172 | SetSymbolConnectors(item.Element("CONNECTORS"), endBreak.CONNECTORS, endBreak.CONNECTIONPOINT); |
||
173 | SetProperties(item.Element("PROPERTIES"), endBreak.PROPERTIES); |
||
174 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), endBreak.ATTRIBUTES); |
||
175 | |||
176 | EndBreaks.Add(endBreak); |
||
177 | } |
||
178 | else if (sCategory == "Equipment" || |
||
179 | sCategory == "Equipment Components") |
||
180 | { |
||
181 | Equipment equipment = new Equipment() |
||
182 | { |
||
183 | UID = item.Element("UID").Value, |
||
184 | DBUID = item.Element("DBUID").Value, |
||
185 | NAME = item.Element("NAME").Value, |
||
186 | TYPE = item.Element("TYPE").Value, |
||
187 | OWNER = item.Element("OWNER").Value, |
||
188 | ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
||
189 | CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
||
190 | LOCATION = item.Element("LOCATION").Value, |
||
191 | SIZE = item.Element("SIZE").Value, |
||
192 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
193 | PARENT = item.Element("PARENT").Value, |
||
194 | CHILD = item.Element("CHILD").Value, |
||
195 | HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
||
196 | AREA = item.Element("AREA").Value, |
||
197 | FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
||
198 | CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
||
199 | }; |
||
200 | SetAssociations(item.Element("ASSOCIATIONS"), equipment.ASSOCIATIONS); |
||
201 | SetSymbolConnectors(item.Element("CONNECTORS"), equipment.CONNECTORS, equipment.CONNECTIONPOINT); |
||
202 | SetProperties(item.Element("PROPERTIES"), equipment.PROPERTIES); |
||
203 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), equipment.ATTRIBUTES); |
||
204 | |||
205 | Equipments.Add(equipment); |
||
206 | } |
||
207 | else |
||
208 | { |
||
209 | Symbol symbol = new Symbol() |
||
210 | { |
||
211 | UID = item.Element("UID").Value, |
||
212 | DBUID = item.Element("DBUID").Value, |
||
213 | NAME = item.Element("NAME").Value, |
||
214 | TYPE = item.Element("TYPE").Value, |
||
215 | OWNER = item.Element("OWNER").Value, |
||
216 | ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
||
217 | CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
||
218 | LOCATION = item.Element("LOCATION").Value, |
||
219 | SIZE = item.Element("SIZE").Value, |
||
220 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
221 | PARENT = item.Element("PARENT").Value, |
||
222 | CHILD = item.Element("CHILD").Value, |
||
223 | HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
||
224 | AREA = item.Element("AREA").Value, |
||
225 | FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
||
226 | CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
||
227 | }; |
||
228 | |||
229 | SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS); |
||
230 | SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT); |
||
231 | SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES); |
||
232 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES); |
||
233 | SetChildSymbol(symbol); |
||
234 | |||
235 | SYMBOLS.Add(symbol); |
||
236 | } |
||
237 | } |
||
238 | |||
239 | PlantItems.AddRange(SpecBreaks); |
||
240 | PlantItems.AddRange(EndBreaks); |
||
241 | PlantItems.AddRange(Equipments); |
||
242 | PlantItems.AddRange(SYMBOLS); |
||
243 | } |
||
244 | |||
245 | private void SetLine(XElement node) |
||
246 | { |
||
247 | foreach (XElement item in node.Elements("LINE")) |
||
248 | { |
||
249 | Line line = new Line() |
||
250 | { |
||
251 | OWNER = item.Attribute("OWNER").Value, |
||
252 | UID = item.Element("UID").Value, |
||
253 | STARTPOINT = item.Element("STARTPOINT").Value, |
||
254 | ENDPOINT = item.Element("ENDPOINT").Value, |
||
255 | TYPE = item.Element("TYPE").Value, |
||
256 | TYPEUID = item.Element("TYPE").Attribute("TYPEUID").Value, |
||
257 | AREA = item.Element("AREA").Value, |
||
258 | THICKNESS = item.Element("THICKNESS").Value, |
||
259 | }; |
||
260 | int flowMarkPercent = 0; |
||
261 | if (int.TryParse(item.Element("FLOWMARK").Value, out flowMarkPercent)) |
||
262 | { |
||
263 | line.FLOWMARK = true; |
||
264 | line.FLOWMARK_PERCENT = flowMarkPercent; |
||
265 | } |
||
266 | else |
||
267 | line.FLOWMARK = false; |
||
268 | |||
269 | SetAssociations(item.Element("ASSOCIATIONS"), line.ASSOCIATIONS); |
||
270 | SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS); |
||
271 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), line.ATTRIBUTES); |
||
272 | 016701e5 | gaqhf | line.SetSlopeType(); |
273 | 5aec7e24 | gaqhf | LINES.Add(line); |
274 | } |
||
275 | PlantItems.AddRange(LINES); |
||
276 | } |
||
277 | |||
278 | private void SetLineNumber(XElement node) |
||
279 | { |
||
280 | foreach (XElement item in node.Elements("LINE_NO")) |
||
281 | { |
||
282 | LineNumber lineNumber = new LineNumber() |
||
283 | { |
||
284 | UID = item.Element("UID").Value, |
||
285 | TEXT = item.Element("TEXT").Value, |
||
286 | LOCATION = item.Element("LOCATION").Value, |
||
287 | WIDTH = item.Element("WIDTH").Value, |
||
288 | HEIGHT = item.Element("HEIGHT").Value, |
||
289 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
290 | AREA = item.Element("AREA").Value, |
||
291 | SCENE = item.Element("SCENE").Value |
||
292 | }; |
||
293 | if (item.Element("CONNLINE") != null) |
||
294 | lineNumber.CONNLINE = item.Element("CONNLINE").Value; |
||
295 | else |
||
296 | { |
||
297 | validationStringBuilder.AppendLine("Not exist CONNLINE!" + "\r\nLineNumber UID : " + lineNumber.UID); |
||
298 | validationStringBuilder.AppendLine(); |
||
299 | validationResult = true; |
||
300 | } |
||
301 | |||
302 | SetLineNumberRuns(item, lineNumber.RUNS); |
||
303 | SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES); |
||
304 | SetAttributes(item, lineNumber.ATTRIBUTES); |
||
305 | LINENUMBERS.Add(lineNumber); |
||
306 | } |
||
307 | PlantItems.AddRange(LINENUMBERS); |
||
308 | } |
||
309 | |||
310 | private void SetTrimLine(XElement node) |
||
311 | { |
||
312 | foreach (XElement item in node.Elements("TRIM_LINE_NO")) |
||
313 | { |
||
314 | TrimLine trimLine = new TrimLine() |
||
315 | { |
||
316 | UID = item.Element("UID").Value, |
||
317 | }; |
||
318 | SetLineNumberRuns(item, trimLine.RUNS); |
||
319 | TRIMLINES.Add(trimLine); |
||
320 | } |
||
321 | PlantItems.AddRange(TRIMLINES); |
||
322 | } |
||
323 | |||
324 | private void SetAssociations(XElement node, List<Association> associations) |
||
325 | { |
||
326 | foreach (XElement item in node.Elements("ASSOCIATION")) |
||
327 | { |
||
328 | Association association = new Association() |
||
329 | { |
||
330 | TYPE = item.Attribute("TYPE").Value, |
||
331 | VALUE = item.Value |
||
332 | }; |
||
333 | |||
334 | associations.Add(association); |
||
335 | } |
||
336 | } |
||
337 | |||
338 | private void SetConnectors(XElement node, List<Connector> connectors) |
||
339 | { |
||
340 | foreach (XElement item in node.Elements("CONNECTOR")) |
||
341 | { |
||
342 | connectors.Add(new Connector() |
||
343 | { |
||
344 | UID = item.Attribute("UID").Value, |
||
345 | CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value), |
||
346 | CONNECTEDITEM = item.Element("CONNECTEDITEM").Value, |
||
347 | CONNECTPOINT = item.Element("CONNECTPOINT").Value, |
||
348 | SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value, |
||
349 | }); |
||
350 | } |
||
351 | } |
||
352 | |||
353 | private void SetSymbolConnectors(XElement node, List<Connector> connectors, string CONNECTIONPOINT) |
||
354 | { |
||
355 | foreach (XElement item in node.Elements("CONNECTOR")) |
||
356 | { |
||
357 | connectors.Add(new Connector() |
||
358 | { |
||
359 | UID = item.Attribute("UID").Value, |
||
360 | CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value), |
||
361 | CONNECTEDITEM = item.Element("CONNECTEDITEM").Value, |
||
362 | CONNECTPOINT = item.Element("CONNECTPOINT").Value, |
||
363 | SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value, |
||
364 | }); |
||
365 | } |
||
366 | } |
||
367 | |||
368 | private void SetProperties(XElement node, List<Property> properties) |
||
369 | { |
||
370 | foreach (XElement item in node.Elements("PROPERTY")) |
||
371 | { |
||
372 | properties.Add(new Property() |
||
373 | { |
||
374 | UID = item.Attribute("UID").Value, |
||
375 | LENGTH = item.Attribute("Length").Value, |
||
376 | EXPRESSION = item.Attribute("Expression").Value, |
||
377 | DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value, |
||
378 | ATTRIBUTETYPE = item.Attribute("AttributeType").Value, |
||
379 | ATTRIBUTE = item.Attribute("Attribute").Value, |
||
380 | VALUE = item.Value |
||
381 | }); |
||
382 | } |
||
383 | } |
||
384 | |||
385 | private void SetAttributes(XElement node, List<Attribute> attributes) |
||
386 | { |
||
387 | foreach (XElement item in node.Elements("ATTRIBUTE")) |
||
388 | { |
||
389 | Attribute attribute = new Attribute() |
||
390 | { |
||
391 | UID = item.Attribute("UID").Value, |
||
392 | LENGTH = item.Attribute("Length").Value, |
||
393 | EXPRESSION = item.Attribute("Expression").Value, |
||
394 | DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value, |
||
395 | ATTRIBUTETYPE = item.Attribute("AttributeType").Value, |
||
396 | ATTRIBUTE = item.Attribute("Attribute").Value, |
||
397 | ATTRAT = item.Attribute("AttrAt").Value, |
||
398 | ASSOCITEM = item.Attribute("AssocItem").Value, |
||
399 | VALUE = item.Value |
||
400 | }; |
||
401 | |||
402 | attributes.Add(attribute); |
||
403 | } |
||
404 | } |
||
405 | |||
406 | private void SetSpecBreakAttribute(SpecBreak specBreak) |
||
407 | { |
||
408 | string upStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "UpStream").VALUE; |
||
409 | string downStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "DownStream").VALUE; |
||
410 | |||
411 | specBreak.UpStreamUID = upStream; |
||
412 | specBreak.DownStreamUID = downStream; |
||
413 | } |
||
414 | |||
415 | private void SetLineNumberRuns(XElement node, List<LineRun> lineNumberRuns) |
||
416 | { |
||
417 | foreach (XElement item in node.Elements("RUN")) |
||
418 | { |
||
419 | LineRun run = new LineRun() |
||
420 | { |
||
421 | TYPE = item.Attribute("TYPE").Value |
||
422 | }; |
||
423 | |||
424 | foreach (XElement element in item.Elements()) |
||
425 | { |
||
426 | if (element.Name == "SYMBOL") |
||
427 | { |
||
428 | Symbol symbol = GetSymbolByUID(element.Element("UID").Value); |
||
429 | Equipment equipment = GetEquipmentByUID(element.Element("UID").Value); |
||
430 | if (symbol == null && equipment == null) |
||
431 | { |
||
432 | validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value); |
||
433 | validationStringBuilder.AppendLine(); |
||
434 | validationResult = true; |
||
435 | } |
||
436 | if (symbol != null) |
||
437 | run.RUNITEMS.Add(symbol); |
||
438 | else if (equipment != null) |
||
439 | run.RUNITEMS.Add(equipment); |
||
440 | } |
||
441 | else if (element.Name == "LINE") |
||
442 | { |
||
443 | Line line = GetLineByUID(element.Element("UID").Value); |
||
444 | if (line == null) |
||
445 | { |
||
446 | validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value); |
||
447 | validationStringBuilder.AppendLine(); |
||
448 | validationResult = true; |
||
449 | } |
||
450 | run.RUNITEMS.Add(line); |
||
451 | } |
||
452 | } |
||
453 | lineNumberRuns.Add(run); |
||
454 | } |
||
455 | } |
||
456 | |||
457 | private void SetChildSymbol(Symbol symbol) |
||
458 | { |
||
459 | List<ChildSymbol> childList = new List<ChildSymbol>(); |
||
460 | if (!string.IsNullOrEmpty(symbol.CHILD) && symbol.CHILD != "None") |
||
461 | { |
||
462 | string[] childArray = symbol.CHILD.Split(new char[] { '/' }); |
||
463 | foreach (string sChild in childArray) |
||
464 | { |
||
465 | string[] sChildInfo = sChild.Split(new char[] { ',' }); |
||
466 | childList.Add(new ChildSymbol() |
||
467 | { |
||
468 | ParentAt = Convert.ToInt32(sChildInfo[0]), |
||
469 | Direction = sChildInfo[1], |
||
470 | NAME = sChildInfo[2] |
||
471 | }); |
||
472 | } |
||
473 | |||
474 | foreach (ChildSymbol child in childList) |
||
475 | { |
||
476 | if (child.ParentAt == 0) |
||
477 | symbol.ChildSymbols.Add(child); |
||
478 | else |
||
479 | childList[child.ParentAt - 1].ChildSymbols.Add(child); |
||
480 | } |
||
481 | } |
||
482 | if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None") |
||
483 | { |
||
484 | // 현재 부모 Symbol에 자식 Connector까지 들어가 있음 |
||
485 | string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' }); |
||
486 | string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' }); |
||
487 | for (int i = 0; i < array.Length; i++) |
||
488 | { |
||
489 | string[] arrConn = array[i].Split(new char[] { ',' }); |
||
490 | int connIndex = Convert.ToInt32(arrConn[3]); |
||
491 | if (connIndex != 0) |
||
492 | { |
||
493 | childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]); |
||
494 | symbol.CONNECTORS[i].Index = connIndex; |
||
495 | } |
||
496 | } |
||
497 | dbac61ab | gaqhf | } |
498 | } |
||
499 | 5aec7e24 | gaqhf | #endregion |
500 | |||
501 | public void SetAllConnectors() |
||
502 | { |
||
503 | foreach (var item in SYMBOLS) |
||
504 | foreach (var connector in item.CONNECTORS) |
||
505 | connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM); |
||
506 | |||
507 | foreach (var item in LINES) |
||
508 | foreach (var connector in item.CONNECTORS) |
||
509 | connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM); |
||
510 | |||
511 | foreach (var item in Equipments) |
||
512 | foreach (var connector in item.CONNECTORS) |
||
513 | connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM); |
||
514 | } |
||
515 | |||
516 | public Symbol GetSymbolByUID(string uid) |
||
517 | { |
||
518 | return SYMBOLS.Find(x => x.UID == uid); |
||
519 | } |
||
520 | |||
521 | public Equipment GetEquipmentByUID(string uid) |
||
522 | { |
||
523 | return Equipments.Find(x => x.UID == uid); |
||
524 | } |
||
525 | |||
526 | public Line GetLineByUID(string uid) |
||
527 | { |
||
528 | return LINES.Find(x => x.UID == uid); |
||
529 | } |
||
530 | a999464f | gaqhf | |
531 | 9dab7146 | gaqhf | #region For Aveva |
532 | |||
533 | b90890eb | gaqhf | public bool SetAvevaInfo(DataTable symbolMappingTable, DataTable lineMappingTable) |
534 | a999464f | gaqhf | { |
535 | bool result = true; |
||
536 | foreach (var item in LINES) |
||
537 | { |
||
538 | DataRow[] rows = lineMappingTable.Select(string.Format("UID = '{0}'", item.TYPEUID)); |
||
539 | if (rows.Length == 1 && !DBNull.Value.Equals(rows[0]["APID_SYMBOL"]) && !string.IsNullOrEmpty((string)rows[0]["APID_SYMBOL"])) |
||
540 | { |
||
541 | item.Aveva = new AvevaLineInfo(); |
||
542 | item.Aveva.Name = (string)rows[0]["APID_SYMBOL"]; |
||
543 | item.Aveva.Start_X = item.Start_X; |
||
544 | 53344e2c | gaqhf | item.Aveva.Start_Y = SIZE_HEIGHT - item.Start_Y; |
545 | a999464f | gaqhf | item.Aveva.End_X = item.End_X; |
546 | 53344e2c | gaqhf | item.Aveva.End_Y = SIZE_HEIGHT - item.End_Y; |
547 | 9dab7146 | gaqhf | |
548 | if (!DBNull.Value.Equals(rows[0]["DATA1"])) |
||
549 | { |
||
550 | if (rows[0]["DATA1"].ToString() == "PIPE") |
||
551 | item.Aveva.Type = Type.Pipe; |
||
552 | else if (rows[0]["DATA1"].ToString() == "SIGNAL") |
||
553 | item.Aveva.Type = Type.Signal; |
||
554 | } |
||
555 | a999464f | gaqhf | } |
556 | else |
||
557 | result = false; |
||
558 | b90890eb | gaqhf | } |
559 | |||
560 | foreach (var item in SYMBOLS) |
||
561 | { |
||
562 | DataRow[] rows = symbolMappingTable.Select(string.Format("UID = '{0}'", item.DBUID)); |
||
563 | if (rows.Length == 1 && !DBNull.Value.Equals(rows[0]["APID_SYMBOL"]) && !string.IsNullOrEmpty((string)rows[0]["APID_SYMBOL"])) |
||
564 | { |
||
565 | item.Aveva = new AvevaSymbolInfo(); |
||
566 | item.Aveva.X = item.X; |
||
567 | item.Aveva.Y = SIZE_HEIGHT - item.Y; |
||
568 | 73152510 | gaqhf | item.Aveva.FullName = (string)rows[0]["APID_SYMBOL"]; |
569 | string[] split = item.Aveva.FullName.Split(new char[] { '\\' }); |
||
570 | item.Aveva.Name = split[split.Length - 1]; |
||
571 | a999464f | gaqhf | } |
572 | b90890eb | gaqhf | else |
573 | result = false; |
||
574 | a999464f | gaqhf | } |
575 | |||
576 | return result; |
||
577 | } |
||
578 | 9dab7146 | gaqhf | |
579 | #endregion |
||
580 | 6ec631d2 | gaqhf | } |
581 | } |