hytos / DTI_PID / APIDConverter / Model / PlantItem / Document.cs @ 98fdb329
이력 | 보기 | 이력해설 | 다운로드 (39.9 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 | 0a8db7fe | gaqhf | private List<Text> _Texts = new List<Text>(); |
28 | private List<Note> _Notes = new List<Note>(); |
||
29 | a19bd6e2 | gaqhf | private List<OPC> _OPCs = new List<OPC>(); |
30 | 5aec7e24 | gaqhf | private bool _Enable; |
31 | private bool _Validation; |
||
32 | private bool _MappingValidation; |
||
33 | private string _ValidationMessage = string.Empty; |
||
34 | bool validationResult = false; |
||
35 | dbac61ab | gaqhf | private DataTable ID2SymbolTypeDT; |
36 | 6ec631d2 | gaqhf | |
37 | e49e1de9 | gaqhf | public string AvevaDrawingNumber { get; set; } |
38 | public string AvevaSheetNumber { get; set; } |
||
39 | public string AvevaTemplateID { get; set; } |
||
40 | public string AvevaTemplateName { get; set; } |
||
41 | |||
42 | 5aec7e24 | gaqhf | public string ValidationMessage { get => _ValidationMessage; set => _ValidationMessage = value; } |
43 | |||
44 | public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
||
45 | public List<Line> LINES { get => _LINES; set => _LINES = value; } |
||
46 | public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; } |
||
47 | public List<EndBreak> EndBreaks { get => _EndBreaks; set => _EndBreaks = value; } |
||
48 | public List<SpecBreak> SpecBreaks { get => _SpecBreaks; set => _SpecBreaks = value; } |
||
49 | public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; } |
||
50 | public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; } |
||
51 | public string SIZE |
||
52 | { |
||
53 | get |
||
54 | { |
||
55 | return _SIZE; |
||
56 | } |
||
57 | set |
||
58 | { |
||
59 | _SIZE = value; |
||
60 | string[] pointArr = _SIZE.Split(new char[] { ',' }); |
||
61 | if (pointArr.Length == 2) |
||
62 | { |
||
63 | _SIZE_WIDTH = Convert.ToDouble(pointArr[0]); |
||
64 | _SIZE_HEIGHT = Convert.ToDouble(pointArr[1]); |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 | public double SIZE_WIDTH { get => _SIZE_WIDTH; } |
||
69 | public double SIZE_HEIGHT { get => _SIZE_HEIGHT; } |
||
70 | public List<TrimLine> TRIMLINES { get => _TRIMLINES; set => _TRIMLINES = value; } |
||
71 | public string PATH { get; set; } |
||
72 | public bool Enable { get => _Enable; set => _Enable = value; } |
||
73 | public bool Validation { get => _Validation; set => _Validation = value; } |
||
74 | public bool MappingValidation { get => _MappingValidation; set => _MappingValidation = value; } |
||
75 | public string UID { get => _UID; set => _UID = value; } |
||
76 | a19bd6e2 | gaqhf | public List<OPC> OPCs { get => _OPCs; set => _OPCs = value; } |
77 | 0a8db7fe | gaqhf | public List<Text> Texts { get => _Texts; set => _Texts = value; } |
78 | public List<Note> Notes { get => _Notes; set => _Notes = value; } |
||
79 | 5aec7e24 | gaqhf | |
80 | StringBuilder validationStringBuilder = new StringBuilder(); |
||
81 | |||
82 | public List<PlantItem> PlantItems = new List<PlantItem>(); |
||
83 | 6ec631d2 | gaqhf | |
84 | dbac61ab | gaqhf | public Document(string xmlPath, DataTable ID2SymbolTypeDT) |
85 | 6ec631d2 | gaqhf | { |
86 | dbac61ab | gaqhf | this.ID2SymbolTypeDT = ID2SymbolTypeDT; |
87 | 5aec7e24 | gaqhf | validationStringBuilder.AppendLine("Document Path : " + xmlPath); |
88 | validationStringBuilder.AppendLine(""); |
||
89 | try |
||
90 | { |
||
91 | if (xmlPath != null) |
||
92 | { |
||
93 | PATH = xmlPath; |
||
94 | XElement xml = XElement.Load(xmlPath); |
||
95 | DWGNAME = xml.Element("DWGNAME").Value; |
||
96 | SIZE = xml.Element("SIZE").Value; |
||
97 | dbac61ab | gaqhf | |
98 | 5aec7e24 | gaqhf | validationStringBuilder.AppendLine("Drawing Name : " + DWGNAME); |
99 | validationStringBuilder.AppendLine(""); |
||
100 | 6ec631d2 | gaqhf | |
101 | 0a8db7fe | gaqhf | SetText(xml.Element("TEXTINFOS")); |
102 | SetNote(xml.Element("NOTES")); |
||
103 | 5aec7e24 | gaqhf | SetSymbol(xml.Element("SYMBOLS")); |
104 | SetLine(xml.Element("LINEINFOS")); |
||
105 | SetLineNumber(xml.Element("LINENOS")); |
||
106 | SetTrimLine(xml.Element("TRIMLINENOS")); |
||
107 | 6ec631d2 | gaqhf | |
108 | 5aec7e24 | gaqhf | SetAllConnectors(); |
109 | Enable = true; |
||
110 | } |
||
111 | } |
||
112 | catch (Exception ex) |
||
113 | { |
||
114 | Enable = false; |
||
115 | MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
116 | 6ec631d2 | gaqhf | } |
117 | } |
||
118 | dbac61ab | gaqhf | |
119 | 5aec7e24 | gaqhf | #region READ XML |
120 | dbac61ab | gaqhf | private void SetSymbol(XElement node) |
121 | { |
||
122 | foreach (XElement item in node.Elements("SYMBOL")) |
||
123 | { |
||
124 | string sType = item.Element("TYPE").Value; |
||
125 | |||
126 | 5aec7e24 | gaqhf | DataRow[] rows = ID2SymbolTypeDT.Select(string.Format("Type = '{0}'", sType.Replace("'", "''"))); |
127 | string sCategory = rows[0]["Category"].ToString(); |
||
128 | |||
129 | if (sType == "Segment Breaks") |
||
130 | { |
||
131 | SpecBreak specBreak = new SpecBreak() |
||
132 | { |
||
133 | UID = item.Element("UID").Value, |
||
134 | DBUID = item.Element("DBUID").Value, |
||
135 | NAME = item.Element("NAME").Value, |
||
136 | TYPE = item.Element("TYPE").Value, |
||
137 | OWNER = item.Element("OWNER").Value, |
||
138 | ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
||
139 | CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
||
140 | LOCATION = item.Element("LOCATION").Value, |
||
141 | SIZE = item.Element("SIZE").Value, |
||
142 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
143 | PARENT = item.Element("PARENT").Value, |
||
144 | CHILD = item.Element("CHILD").Value, |
||
145 | HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
||
146 | AREA = item.Element("AREA").Value, |
||
147 | FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
||
148 | acfb1ca2 | Denny | //CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
149 | CURRENTPOINTMODEINDEX = Convert.ToInt32(string.IsNullOrWhiteSpace(item.Element("CURRENTPOINTMODEINDEX").Value) ? "0" : item.Element("CURRENTPOINTMODEINDEX").Value) |
||
150 | 5aec7e24 | gaqhf | }; |
151 | SetAssociations(item.Element("ASSOCIATIONS"), specBreak.ASSOCIATIONS); |
||
152 | SetSymbolConnectors(item.Element("CONNECTORS"), specBreak.CONNECTORS, specBreak.CONNECTIONPOINT); |
||
153 | SetProperties(item.Element("PROPERTIES"), specBreak.PROPERTIES); |
||
154 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), specBreak.ATTRIBUTES); |
||
155 | SetSpecBreakAttribute(specBreak); |
||
156 | |||
157 | SpecBreaks.Add(specBreak); |
||
158 | } |
||
159 | else if (sType == "End Break") |
||
160 | { |
||
161 | EndBreak endBreak = new EndBreak() |
||
162 | { |
||
163 | UID = item.Element("UID").Value, |
||
164 | DBUID = item.Element("DBUID").Value, |
||
165 | NAME = item.Element("NAME").Value, |
||
166 | TYPE = item.Element("TYPE").Value, |
||
167 | OWNER = item.Element("OWNER").Value, |
||
168 | ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
||
169 | CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
||
170 | LOCATION = item.Element("LOCATION").Value, |
||
171 | SIZE = item.Element("SIZE").Value, |
||
172 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
173 | PARENT = item.Element("PARENT").Value, |
||
174 | CHILD = item.Element("CHILD").Value, |
||
175 | HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
||
176 | AREA = item.Element("AREA").Value, |
||
177 | FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
||
178 | acfb1ca2 | Denny | //CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
179 | CURRENTPOINTMODEINDEX = Convert.ToInt32(string.IsNullOrWhiteSpace(item.Element("CURRENTPOINTMODEINDEX").Value) ? "0" : item.Element("CURRENTPOINTMODEINDEX").Value) |
||
180 | 5aec7e24 | gaqhf | }; |
181 | SetAssociations(item.Element("ASSOCIATIONS"), endBreak.ASSOCIATIONS); |
||
182 | SetSymbolConnectors(item.Element("CONNECTORS"), endBreak.CONNECTORS, endBreak.CONNECTIONPOINT); |
||
183 | SetProperties(item.Element("PROPERTIES"), endBreak.PROPERTIES); |
||
184 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), endBreak.ATTRIBUTES); |
||
185 | |||
186 | EndBreaks.Add(endBreak); |
||
187 | } |
||
188 | else if (sCategory == "Equipment" || |
||
189 | sCategory == "Equipment Components") |
||
190 | { |
||
191 | Equipment equipment = new Equipment() |
||
192 | { |
||
193 | UID = item.Element("UID").Value, |
||
194 | DBUID = item.Element("DBUID").Value, |
||
195 | NAME = item.Element("NAME").Value, |
||
196 | TYPE = item.Element("TYPE").Value, |
||
197 | OWNER = item.Element("OWNER").Value, |
||
198 | ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
||
199 | CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
||
200 | LOCATION = item.Element("LOCATION").Value, |
||
201 | SIZE = item.Element("SIZE").Value, |
||
202 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
203 | PARENT = item.Element("PARENT").Value, |
||
204 | CHILD = item.Element("CHILD").Value, |
||
205 | HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
||
206 | AREA = item.Element("AREA").Value, |
||
207 | FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
||
208 | acfb1ca2 | Denny | //CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
209 | CURRENTPOINTMODEINDEX = Convert.ToInt32(string.IsNullOrWhiteSpace(item.Element("CURRENTPOINTMODEINDEX").Value) ? "0" : item.Element("CURRENTPOINTMODEINDEX").Value) |
||
210 | 5aec7e24 | gaqhf | }; |
211 | SetAssociations(item.Element("ASSOCIATIONS"), equipment.ASSOCIATIONS); |
||
212 | SetSymbolConnectors(item.Element("CONNECTORS"), equipment.CONNECTORS, equipment.CONNECTIONPOINT); |
||
213 | SetProperties(item.Element("PROPERTIES"), equipment.PROPERTIES); |
||
214 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), equipment.ATTRIBUTES); |
||
215 | |||
216 | Equipments.Add(equipment); |
||
217 | } |
||
218 | a19bd6e2 | gaqhf | else if (sType == "Piping OPC's" || sType == "Instrument OPC's") |
219 | { |
||
220 | OPC opc = new OPC() |
||
221 | { |
||
222 | UID = item.Element("UID").Value, |
||
223 | DBUID = item.Element("DBUID").Value, |
||
224 | NAME = item.Element("NAME").Value, |
||
225 | TYPE = item.Element("TYPE").Value, |
||
226 | OWNER = item.Element("OWNER").Value, |
||
227 | ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
||
228 | CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
||
229 | LOCATION = item.Element("LOCATION").Value, |
||
230 | SIZE = item.Element("SIZE").Value, |
||
231 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
232 | PARENT = item.Element("PARENT").Value, |
||
233 | CHILD = item.Element("CHILD").Value, |
||
234 | HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
||
235 | AREA = item.Element("AREA").Value, |
||
236 | FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
||
237 | acfb1ca2 | Denny | //CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
238 | CURRENTPOINTMODEINDEX = Convert.ToInt32(string.IsNullOrWhiteSpace(item.Element("CURRENTPOINTMODEINDEX").Value) ? "0" : item.Element("CURRENTPOINTMODEINDEX").Value) |
||
239 | a19bd6e2 | gaqhf | }; |
240 | |||
241 | SetAssociations(item.Element("ASSOCIATIONS"), opc.ASSOCIATIONS); |
||
242 | SetSymbolConnectors(item.Element("CONNECTORS"), opc.CONNECTORS, opc.CONNECTIONPOINT); |
||
243 | SetProperties(item.Element("PROPERTIES"), opc.PROPERTIES); |
||
244 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), opc.ATTRIBUTES); |
||
245 | SetChildSymbol(opc); |
||
246 | |||
247 | if (sType == "Piping OPC's") |
||
248 | opc.OPCType = OPCType.Pipe; |
||
249 | else if (sType == "Instrument OPC's") |
||
250 | opc.OPCType = OPCType.Signal; |
||
251 | |||
252 | OPCs.Add(opc); |
||
253 | } |
||
254 | 5aec7e24 | gaqhf | else |
255 | { |
||
256 | Symbol symbol = new Symbol() |
||
257 | { |
||
258 | UID = item.Element("UID").Value, |
||
259 | DBUID = item.Element("DBUID").Value, |
||
260 | NAME = item.Element("NAME").Value, |
||
261 | TYPE = item.Element("TYPE").Value, |
||
262 | OWNER = item.Element("OWNER").Value, |
||
263 | ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
||
264 | CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
||
265 | LOCATION = item.Element("LOCATION").Value, |
||
266 | SIZE = item.Element("SIZE").Value, |
||
267 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
268 | PARENT = item.Element("PARENT").Value, |
||
269 | CHILD = item.Element("CHILD").Value, |
||
270 | HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
||
271 | AREA = item.Element("AREA").Value, |
||
272 | FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
||
273 | acfb1ca2 | Denny | //CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
274 | CURRENTPOINTMODEINDEX = Convert.ToInt32(string.IsNullOrWhiteSpace(item.Element("CURRENTPOINTMODEINDEX").Value) ? "0" : item.Element("CURRENTPOINTMODEINDEX").Value) |
||
275 | 5aec7e24 | gaqhf | }; |
276 | |||
277 | SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS); |
||
278 | SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT); |
||
279 | SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES); |
||
280 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES); |
||
281 | SetChildSymbol(symbol); |
||
282 | |||
283 | SYMBOLS.Add(symbol); |
||
284 | } |
||
285 | } |
||
286 | |||
287 | PlantItems.AddRange(SpecBreaks); |
||
288 | PlantItems.AddRange(EndBreaks); |
||
289 | PlantItems.AddRange(Equipments); |
||
290 | PlantItems.AddRange(SYMBOLS); |
||
291 | a19bd6e2 | gaqhf | PlantItems.AddRange(OPCs); |
292 | 5aec7e24 | gaqhf | } |
293 | |||
294 | private void SetLine(XElement node) |
||
295 | { |
||
296 | foreach (XElement item in node.Elements("LINE")) |
||
297 | { |
||
298 | Line line = new Line() |
||
299 | { |
||
300 | OWNER = item.Attribute("OWNER").Value, |
||
301 | UID = item.Element("UID").Value, |
||
302 | STARTPOINT = item.Element("STARTPOINT").Value, |
||
303 | ENDPOINT = item.Element("ENDPOINT").Value, |
||
304 | TYPE = item.Element("TYPE").Value, |
||
305 | TYPEUID = item.Element("TYPE").Attribute("TYPEUID").Value, |
||
306 | AREA = item.Element("AREA").Value, |
||
307 | THICKNESS = item.Element("THICKNESS").Value, |
||
308 | }; |
||
309 | int flowMarkPercent = 0; |
||
310 | if (int.TryParse(item.Element("FLOWMARK").Value, out flowMarkPercent)) |
||
311 | { |
||
312 | line.FLOWMARK = true; |
||
313 | line.FLOWMARK_PERCENT = flowMarkPercent; |
||
314 | } |
||
315 | else |
||
316 | line.FLOWMARK = false; |
||
317 | |||
318 | SetAssociations(item.Element("ASSOCIATIONS"), line.ASSOCIATIONS); |
||
319 | SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS); |
||
320 | SetAttributes(item.Element("SYMBOLATTRIBUTES"), line.ATTRIBUTES); |
||
321 | 016701e5 | gaqhf | line.SetSlopeType(); |
322 | 5aec7e24 | gaqhf | LINES.Add(line); |
323 | } |
||
324 | PlantItems.AddRange(LINES); |
||
325 | } |
||
326 | |||
327 | private void SetLineNumber(XElement node) |
||
328 | { |
||
329 | foreach (XElement item in node.Elements("LINE_NO")) |
||
330 | { |
||
331 | LineNumber lineNumber = new LineNumber() |
||
332 | { |
||
333 | UID = item.Element("UID").Value, |
||
334 | TEXT = item.Element("TEXT").Value, |
||
335 | LOCATION = item.Element("LOCATION").Value, |
||
336 | WIDTH = item.Element("WIDTH").Value, |
||
337 | HEIGHT = item.Element("HEIGHT").Value, |
||
338 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
339 | AREA = item.Element("AREA").Value, |
||
340 | SCENE = item.Element("SCENE").Value |
||
341 | }; |
||
342 | if (item.Element("CONNLINE") != null) |
||
343 | lineNumber.CONNLINE = item.Element("CONNLINE").Value; |
||
344 | else |
||
345 | { |
||
346 | validationStringBuilder.AppendLine("Not exist CONNLINE!" + "\r\nLineNumber UID : " + lineNumber.UID); |
||
347 | validationStringBuilder.AppendLine(); |
||
348 | validationResult = true; |
||
349 | } |
||
350 | |||
351 | SetLineNumberRuns(item, lineNumber.RUNS); |
||
352 | SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES); |
||
353 | SetAttributes(item, lineNumber.ATTRIBUTES); |
||
354 | LINENUMBERS.Add(lineNumber); |
||
355 | } |
||
356 | PlantItems.AddRange(LINENUMBERS); |
||
357 | } |
||
358 | |||
359 | private void SetTrimLine(XElement node) |
||
360 | { |
||
361 | foreach (XElement item in node.Elements("TRIM_LINE_NO")) |
||
362 | { |
||
363 | TrimLine trimLine = new TrimLine() |
||
364 | { |
||
365 | UID = item.Element("UID").Value, |
||
366 | }; |
||
367 | SetLineNumberRuns(item, trimLine.RUNS); |
||
368 | TRIMLINES.Add(trimLine); |
||
369 | } |
||
370 | PlantItems.AddRange(TRIMLINES); |
||
371 | } |
||
372 | |||
373 | private void SetAssociations(XElement node, List<Association> associations) |
||
374 | { |
||
375 | foreach (XElement item in node.Elements("ASSOCIATION")) |
||
376 | { |
||
377 | Association association = new Association() |
||
378 | { |
||
379 | TYPE = item.Attribute("TYPE").Value, |
||
380 | VALUE = item.Value |
||
381 | }; |
||
382 | |||
383 | associations.Add(association); |
||
384 | } |
||
385 | } |
||
386 | |||
387 | private void SetConnectors(XElement node, List<Connector> connectors) |
||
388 | { |
||
389 | foreach (XElement item in node.Elements("CONNECTOR")) |
||
390 | { |
||
391 | connectors.Add(new Connector() |
||
392 | { |
||
393 | UID = item.Attribute("UID").Value, |
||
394 | CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value), |
||
395 | CONNECTEDITEM = item.Element("CONNECTEDITEM").Value, |
||
396 | CONNECTPOINT = item.Element("CONNECTPOINT").Value, |
||
397 | SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value, |
||
398 | }); |
||
399 | } |
||
400 | } |
||
401 | |||
402 | private void SetSymbolConnectors(XElement node, List<Connector> connectors, string CONNECTIONPOINT) |
||
403 | { |
||
404 | foreach (XElement item in node.Elements("CONNECTOR")) |
||
405 | { |
||
406 | connectors.Add(new Connector() |
||
407 | { |
||
408 | UID = item.Attribute("UID").Value, |
||
409 | CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value), |
||
410 | CONNECTEDITEM = item.Element("CONNECTEDITEM").Value, |
||
411 | CONNECTPOINT = item.Element("CONNECTPOINT").Value, |
||
412 | SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value, |
||
413 | }); |
||
414 | } |
||
415 | } |
||
416 | |||
417 | private void SetProperties(XElement node, List<Property> properties) |
||
418 | { |
||
419 | foreach (XElement item in node.Elements("PROPERTY")) |
||
420 | { |
||
421 | properties.Add(new Property() |
||
422 | { |
||
423 | UID = item.Attribute("UID").Value, |
||
424 | LENGTH = item.Attribute("Length").Value, |
||
425 | EXPRESSION = item.Attribute("Expression").Value, |
||
426 | DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value, |
||
427 | ATTRIBUTETYPE = item.Attribute("AttributeType").Value, |
||
428 | ATTRIBUTE = item.Attribute("Attribute").Value, |
||
429 | VALUE = item.Value |
||
430 | }); |
||
431 | } |
||
432 | } |
||
433 | |||
434 | private void SetAttributes(XElement node, List<Attribute> attributes) |
||
435 | { |
||
436 | foreach (XElement item in node.Elements("ATTRIBUTE")) |
||
437 | { |
||
438 | Attribute attribute = new Attribute() |
||
439 | { |
||
440 | UID = item.Attribute("UID").Value, |
||
441 | LENGTH = item.Attribute("Length").Value, |
||
442 | EXPRESSION = item.Attribute("Expression").Value, |
||
443 | DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value, |
||
444 | ATTRIBUTETYPE = item.Attribute("AttributeType").Value, |
||
445 | ATTRIBUTE = item.Attribute("Attribute").Value, |
||
446 | ATTRAT = item.Attribute("AttrAt").Value, |
||
447 | ASSOCITEM = item.Attribute("AssocItem").Value, |
||
448 | VALUE = item.Value |
||
449 | }; |
||
450 | |||
451 | attributes.Add(attribute); |
||
452 | 20dd244c | gaqhf | |
453 | if (!string.IsNullOrEmpty(attribute.ASSOCITEM) && attribute.ASSOCITEM != "None") |
||
454 | { |
||
455 | Text text = Texts.Find(x => x.UID == attribute.ASSOCITEM); |
||
456 | if (text != null) |
||
457 | text.ASSOCIATION = true; |
||
458 | } |
||
459 | 5aec7e24 | gaqhf | } |
460 | } |
||
461 | |||
462 | private void SetSpecBreakAttribute(SpecBreak specBreak) |
||
463 | { |
||
464 | string upStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "UpStream").VALUE; |
||
465 | string downStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "DownStream").VALUE; |
||
466 | |||
467 | specBreak.UpStreamUID = upStream; |
||
468 | specBreak.DownStreamUID = downStream; |
||
469 | } |
||
470 | |||
471 | private void SetLineNumberRuns(XElement node, List<LineRun> lineNumberRuns) |
||
472 | { |
||
473 | foreach (XElement item in node.Elements("RUN")) |
||
474 | { |
||
475 | LineRun run = new LineRun() |
||
476 | { |
||
477 | TYPE = item.Attribute("TYPE").Value |
||
478 | }; |
||
479 | |||
480 | foreach (XElement element in item.Elements()) |
||
481 | { |
||
482 | if (element.Name == "SYMBOL") |
||
483 | { |
||
484 | Symbol symbol = GetSymbolByUID(element.Element("UID").Value); |
||
485 | Equipment equipment = GetEquipmentByUID(element.Element("UID").Value); |
||
486 | ad983925 | gaqhf | OPC opc = GetOPCByUID(element.Element("UID").Value); |
487 | if (symbol == null && equipment == null && opc == null) |
||
488 | 5aec7e24 | gaqhf | { |
489 | validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value); |
||
490 | validationStringBuilder.AppendLine(); |
||
491 | validationResult = true; |
||
492 | } |
||
493 | if (symbol != null) |
||
494 | run.RUNITEMS.Add(symbol); |
||
495 | else if (equipment != null) |
||
496 | run.RUNITEMS.Add(equipment); |
||
497 | ad983925 | gaqhf | else if (opc != null) |
498 | run.RUNITEMS.Add(opc); |
||
499 | 5aec7e24 | gaqhf | } |
500 | else if (element.Name == "LINE") |
||
501 | { |
||
502 | Line line = GetLineByUID(element.Element("UID").Value); |
||
503 | if (line == null) |
||
504 | { |
||
505 | validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value); |
||
506 | validationStringBuilder.AppendLine(); |
||
507 | validationResult = true; |
||
508 | } |
||
509 | run.RUNITEMS.Add(line); |
||
510 | } |
||
511 | } |
||
512 | lineNumberRuns.Add(run); |
||
513 | } |
||
514 | } |
||
515 | |||
516 | private void SetChildSymbol(Symbol symbol) |
||
517 | { |
||
518 | List<ChildSymbol> childList = new List<ChildSymbol>(); |
||
519 | if (!string.IsNullOrEmpty(symbol.CHILD) && symbol.CHILD != "None") |
||
520 | { |
||
521 | string[] childArray = symbol.CHILD.Split(new char[] { '/' }); |
||
522 | foreach (string sChild in childArray) |
||
523 | { |
||
524 | string[] sChildInfo = sChild.Split(new char[] { ',' }); |
||
525 | childList.Add(new ChildSymbol() |
||
526 | { |
||
527 | ParentAt = Convert.ToInt32(sChildInfo[0]), |
||
528 | Direction = sChildInfo[1], |
||
529 | NAME = sChildInfo[2] |
||
530 | }); |
||
531 | } |
||
532 | |||
533 | foreach (ChildSymbol child in childList) |
||
534 | { |
||
535 | if (child.ParentAt == 0) |
||
536 | symbol.ChildSymbols.Add(child); |
||
537 | else |
||
538 | childList[child.ParentAt - 1].ChildSymbols.Add(child); |
||
539 | } |
||
540 | } |
||
541 | if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None") |
||
542 | { |
||
543 | // 현재 부모 Symbol에 자식 Connector까지 들어가 있음 |
||
544 | string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' }); |
||
545 | string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' }); |
||
546 | for (int i = 0; i < array.Length; i++) |
||
547 | { |
||
548 | string[] arrConn = array[i].Split(new char[] { ',' }); |
||
549 | int connIndex = Convert.ToInt32(arrConn[3]); |
||
550 | if (connIndex != 0) |
||
551 | { |
||
552 | childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]); |
||
553 | symbol.CONNECTORS[i].Index = connIndex; |
||
554 | } |
||
555 | } |
||
556 | dbac61ab | gaqhf | } |
557 | } |
||
558 | 0a8db7fe | gaqhf | |
559 | private void SetText(XElement node) |
||
560 | { |
||
561 | foreach (XElement item in node.Elements("ATTRIBUTE")) |
||
562 | { |
||
563 | Text text = new Text() |
||
564 | { |
||
565 | UID = item.Element("UID").Value, |
||
566 | OWNER = item.Element("OWNER").Value, |
||
567 | ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value, |
||
568 | NAME = item.Element("NAME").Value, |
||
569 | LOCATION = item.Element("LOCATION").Value, |
||
570 | VALUE = item.Element("VALUE").Value, |
||
571 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
572 | WIDTH = item.Element("WIDTH").Value, |
||
573 | HEIGHT = item.Element("HEIGHT").Value, |
||
574 | AREA = item.Element("AREA").Value, |
||
575 | SCENE = item.Element("SCENE").Value |
||
576 | }; |
||
577 | |||
578 | Texts.Add(text); |
||
579 | } |
||
580 | } |
||
581 | |||
582 | private void SetNote(XElement node) |
||
583 | { |
||
584 | foreach (XElement item in node.Elements("ATTRIBUTE")) |
||
585 | { |
||
586 | Note note = new Note() |
||
587 | { |
||
588 | UID = item.Element("UID").Value, |
||
589 | ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value, |
||
590 | NAME = item.Element("NAME").Value, |
||
591 | LOCATION = item.Element("LOCATION").Value, |
||
592 | VALUE = item.Element("VALUE").Value, |
||
593 | ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
||
594 | WIDTH = item.Element("WIDTH").Value, |
||
595 | HEIGHT = item.Element("HEIGHT").Value, |
||
596 | AREA = item.Element("AREA").Value, |
||
597 | SCENE = item.Element("SCENE").Value, |
||
598 | OWNER = item.Element("OWNER").Value |
||
599 | }; |
||
600 | |||
601 | Notes.Add(note); |
||
602 | } |
||
603 | } |
||
604 | 5aec7e24 | gaqhf | #endregion |
605 | |||
606 | public void SetAllConnectors() |
||
607 | { |
||
608 | foreach (var item in SYMBOLS) |
||
609 | foreach (var connector in item.CONNECTORS) |
||
610 | connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM); |
||
611 | |||
612 | ff4941b2 | gaqhf | foreach (var item in OPCs) |
613 | foreach (var connector in item.CONNECTORS) |
||
614 | connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM); |
||
615 | |||
616 | 5aec7e24 | gaqhf | foreach (var item in LINES) |
617 | foreach (var connector in item.CONNECTORS) |
||
618 | connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM); |
||
619 | |||
620 | foreach (var item in Equipments) |
||
621 | foreach (var connector in item.CONNECTORS) |
||
622 | connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM); |
||
623 | } |
||
624 | |||
625 | public Symbol GetSymbolByUID(string uid) |
||
626 | { |
||
627 | return SYMBOLS.Find(x => x.UID == uid); |
||
628 | } |
||
629 | |||
630 | ad983925 | gaqhf | public OPC GetOPCByUID(string uid) |
631 | { |
||
632 | return OPCs.Find(x => x.UID == uid); |
||
633 | } |
||
634 | |||
635 | 5aec7e24 | gaqhf | public Equipment GetEquipmentByUID(string uid) |
636 | { |
||
637 | return Equipments.Find(x => x.UID == uid); |
||
638 | } |
||
639 | |||
640 | public Line GetLineByUID(string uid) |
||
641 | { |
||
642 | return LINES.Find(x => x.UID == uid); |
||
643 | } |
||
644 | a999464f | gaqhf | |
645 | 9dab7146 | gaqhf | #region For Aveva |
646 | |||
647 | ff4941b2 | gaqhf | public bool SetAvevaInfo(DataTable symbolMappingTable, DataTable lineMappingTable, DataTable opcMappingTable) |
648 | a999464f | gaqhf | { |
649 | bool result = true; |
||
650 | foreach (var item in LINES) |
||
651 | { |
||
652 | DataRow[] rows = lineMappingTable.Select(string.Format("UID = '{0}'", item.TYPEUID)); |
||
653 | if (rows.Length == 1 && !DBNull.Value.Equals(rows[0]["APID_SYMBOL"]) && !string.IsNullOrEmpty((string)rows[0]["APID_SYMBOL"])) |
||
654 | { |
||
655 | item.Aveva = new AvevaLineInfo(); |
||
656 | item.Aveva.Name = (string)rows[0]["APID_SYMBOL"]; |
||
657 | f71d5768 | gaqhf | double startX = item.Start_X; |
658 | double startY = SIZE_HEIGHT - item.Start_Y; |
||
659 | double endX = item.End_X; |
||
660 | double endY = SIZE_HEIGHT - item.End_Y; |
||
661 | |||
662 | ConvertAvevaPoint(ref startX, ref startY); |
||
663 | ConvertAvevaPoint(ref endX, ref endY); |
||
664 | |||
665 | item.Aveva.Start_X = startX; |
||
666 | item.Aveva.Start_Y = startY; |
||
667 | item.Aveva.End_X = endX; |
||
668 | item.Aveva.End_Y = endY; |
||
669 | 9dab7146 | gaqhf | |
670 | 20dd244c | gaqhf | if (item.SlopeType == SlopeType.HORIZONTAL) |
671 | item.Aveva.End_Y = item.Aveva.Start_Y; |
||
672 | else if (item.SlopeType == SlopeType.VERTICAL) |
||
673 | item.Aveva.End_X = item.Aveva.Start_X; |
||
674 | |||
675 | 9dab7146 | gaqhf | if (!DBNull.Value.Equals(rows[0]["DATA1"])) |
676 | { |
||
677 | if (rows[0]["DATA1"].ToString() == "PIPE") |
||
678 | item.Aveva.Type = Type.Pipe; |
||
679 | else if (rows[0]["DATA1"].ToString() == "SIGNAL") |
||
680 | item.Aveva.Type = Type.Signal; |
||
681 | } |
||
682 | e7770ee1 | gaqhf | |
683 | item.Aveva.Start_X = Math.Round(item.Aveva.Start_X); |
||
684 | item.Aveva.Start_Y = Math.Round(item.Aveva.Start_Y); |
||
685 | item.Aveva.End_X = Math.Round(item.Aveva.End_X); |
||
686 | item.Aveva.End_Y = Math.Round(item.Aveva.End_Y); |
||
687 | a999464f | gaqhf | } |
688 | else |
||
689 | 98aa8635 | gaqhf | { |
690 | validationStringBuilder.AppendLine(string.Format("Need Mapping Line : {0}", item.TYPE)); |
||
691 | a999464f | gaqhf | result = false; |
692 | 98aa8635 | gaqhf | } |
693 | b90890eb | gaqhf | } |
694 | foreach (var item in SYMBOLS) |
||
695 | { |
||
696 | DataRow[] rows = symbolMappingTable.Select(string.Format("UID = '{0}'", item.DBUID)); |
||
697 | if (rows.Length == 1 && !DBNull.Value.Equals(rows[0]["APID_SYMBOL"]) && !string.IsNullOrEmpty((string)rows[0]["APID_SYMBOL"])) |
||
698 | { |
||
699 | item.Aveva = new AvevaSymbolInfo(); |
||
700 | f71d5768 | gaqhf | double x = item.X; |
701 | double y = SIZE_HEIGHT - item.Y; |
||
702 | |||
703 | ConvertAvevaPoint(ref x, ref y); |
||
704 | |||
705 | c6df982b | gaqhf | item.Aveva.X = Math.Round(x); |
706 | item.Aveva.Y = Math.Round(y); |
||
707 | f71d5768 | gaqhf | |
708 | 73152510 | gaqhf | item.Aveva.FullName = (string)rows[0]["APID_SYMBOL"]; |
709 | string[] split = item.Aveva.FullName.Split(new char[] { '\\' }); |
||
710 | item.Aveva.Name = split[split.Length - 1]; |
||
711 | a999464f | gaqhf | } |
712 | b90890eb | gaqhf | else |
713 | 98aa8635 | gaqhf | { |
714 | validationStringBuilder.AppendLine(string.Format("Need Mapping Symbol : {0}", item.NAME)); |
||
715 | b90890eb | gaqhf | result = false; |
716 | 98aa8635 | gaqhf | } |
717 | a999464f | gaqhf | } |
718 | a19bd6e2 | gaqhf | foreach (var item in OPCs) |
719 | { |
||
720 | ff4941b2 | gaqhf | DataRow[] rows = opcMappingTable.Select(string.Format("UID = '{0}'", item.DBUID)); |
721 | if (rows.Length == 1 && !DBNull.Value.Equals(rows[0]["IN_SYMBOL"]) && !string.IsNullOrEmpty((string)rows[0]["OUT_SYMBOL"])) |
||
722 | a19bd6e2 | gaqhf | { |
723 | item.Aveva = new AvevaSymbolInfo(); |
||
724 | double x = item.X; |
||
725 | double y = SIZE_HEIGHT - item.Y; |
||
726 | |||
727 | ConvertAvevaPoint(ref x, ref y); |
||
728 | |||
729 | c6df982b | gaqhf | item.Aveva.X = Math.Round(x); |
730 | item.Aveva.Y = Math.Round(y); |
||
731 | a19bd6e2 | gaqhf | |
732 | ff4941b2 | gaqhf | if (item.TYPE == "Piping OPC's") |
733 | item.OPCType = OPCType.Pipe; |
||
734 | else if (item.TYPE == "Instrument OPC's") |
||
735 | item.OPCType = OPCType.Signal; |
||
736 | a19bd6e2 | gaqhf | |
737 | ff4941b2 | gaqhf | Connector connector = item.CONNECTORS.Find(loop => |
738 | APIDUtils.FindObjectByUID(this, loop.CONNECTEDITEM) != null && |
||
739 | APIDUtils.FindObjectByUID(this, loop.CONNECTEDITEM).GetType() == typeof(Line)); |
||
740 | if (connector != null) |
||
741 | { |
||
742 | // out |
||
743 | if (item.CONNECTORS.IndexOf(connector) == 0) |
||
744 | { |
||
745 | item.Aveva.FullName = (string)rows[0]["OUT_SYMBOL"]; |
||
746 | string[] split = item.Aveva.FullName.Split(new char[] { '\\' }); |
||
747 | item.Aveva.Name = split[split.Length - 1]; |
||
748 | item.FlowType = FlowType.Out; |
||
749 | } |
||
750 | // in |
||
751 | else |
||
752 | { |
||
753 | item.Aveva.FullName = (string)rows[0]["IN_SYMBOL"]; |
||
754 | string[] split = item.Aveva.FullName.Split(new char[] { '\\' }); |
||
755 | item.Aveva.Name = split[split.Length - 1]; |
||
756 | item.FlowType = FlowType.In; |
||
757 | } |
||
758 | } |
||
759 | else |
||
760 | 98aa8635 | gaqhf | { |
761 | validationStringBuilder.AppendLine(string.Format("Check OPC's Connector : {0}", item.UID)); |
||
762 | ff4941b2 | gaqhf | result = false; |
763 | 98aa8635 | gaqhf | } |
764 | a19bd6e2 | gaqhf | } |
765 | else |
||
766 | 98aa8635 | gaqhf | { |
767 | validationStringBuilder.AppendLine(string.Format("Need Mapping Symbol : {0}", item.NAME)); |
||
768 | a19bd6e2 | gaqhf | result = false; |
769 | 98aa8635 | gaqhf | } |
770 | a19bd6e2 | gaqhf | } |
771 | 932933ed | gaqhf | foreach (var item in LINENUMBERS) |
772 | { |
||
773 | item.Aveva = new AvevaLabelInfo(); |
||
774 | double x = (item.X1 + item.X2) / 2; |
||
775 | double y = SIZE_HEIGHT - (item.Y1 + item.Y2) / 2; |
||
776 | |||
777 | ConvertAvevaPoint(ref x, ref y); |
||
778 | |||
779 | c6df982b | gaqhf | item.Aveva.X = Math.Round(x); |
780 | item.Aveva.Y = Math.Round(y); |
||
781 | 932933ed | gaqhf | item.Aveva.LabelType = LabelType.LineNumber; |
782 | 475071f2 | gaqhf | item.Aveva.Angle = RadianToDegree(item.ANGLE); |
783 | 932933ed | gaqhf | } |
784 | a19bd6e2 | gaqhf | |
785 | 6503fec8 | gaqhf | foreach (var item in Texts) |
786 | { |
||
787 | item.Aveva = new AvevaLabelInfo(); |
||
788 | |||
789 | 7a8645c9 | gaqhf | double x = item.X1; |
790 | double y = SIZE_HEIGHT - item.Y2; |
||
791 | ConvertAvevaPoint(ref x, ref y); |
||
792 | c6df982b | gaqhf | item.Aveva.X = Math.Round(x); |
793 | item.Aveva.Y = Math.Round(y); |
||
794 | 6503fec8 | gaqhf | |
795 | 7a8645c9 | gaqhf | if (item.TextAngle == TextAngle.Degree0 || item.TextAngle == TextAngle.Degree180) |
796 | { |
||
797 | double height = Math.Abs(item.Y1 - item.Y2); |
||
798 | ConvertAvevaPointY(ref height); |
||
799 | item.Aveva.Height = height; |
||
800 | 6503fec8 | gaqhf | } |
801 | 7a8645c9 | gaqhf | else if (item.TextAngle == TextAngle.Degree90 || item.TextAngle == TextAngle.Degree270) |
802 | 6503fec8 | gaqhf | { |
803 | 7a8645c9 | gaqhf | double height = Math.Abs(item.X1 - item.X2); |
804 | ConvertAvevaPointX(ref height); |
||
805 | item.Aveva.Height = height; |
||
806 | } |
||
807 | 6503fec8 | gaqhf | |
808 | 7a8645c9 | gaqhf | if (item.VALUE.Contains("\n")) |
809 | { |
||
810 | item.Aveva.LabelType = LabelType.MultiText; |
||
811 | int count = item.VALUE.Length - item.VALUE.Replace("\n", "").Length + 1; |
||
812 | item.Aveva.Height = item.Aveva.Height / count; |
||
813 | 6503fec8 | gaqhf | } |
814 | 7a8645c9 | gaqhf | else |
815 | item.Aveva.LabelType = LabelType.SingleText; |
||
816 | 6503fec8 | gaqhf | |
817 | a03f7b94 | gaqhf | item.Aveva.Angle = item.ANGLE; |
818 | 6503fec8 | gaqhf | } |
819 | foreach (var item in Notes) |
||
820 | { |
||
821 | item.Aveva = new AvevaLabelInfo(); |
||
822 | |||
823 | 7a8645c9 | gaqhf | double x = item.X1; |
824 | double y = SIZE_HEIGHT - item.Y2; |
||
825 | ConvertAvevaPoint(ref x, ref y); |
||
826 | c6df982b | gaqhf | item.Aveva.X = Math.Round(x); |
827 | item.Aveva.Y = Math.Round(y); |
||
828 | 6503fec8 | gaqhf | |
829 | 7a8645c9 | gaqhf | if (item.TextAngle == TextAngle.Degree0 || item.TextAngle == TextAngle.Degree180) |
830 | { |
||
831 | double height = Math.Abs(item.Y1 - item.Y2); |
||
832 | ConvertAvevaPointY(ref height); |
||
833 | item.Aveva.Height = height; |
||
834 | } |
||
835 | else if (item.TextAngle == TextAngle.Degree90 || item.TextAngle == TextAngle.Degree270) |
||
836 | { |
||
837 | double height = Math.Abs(item.X1 - item.X2); |
||
838 | ConvertAvevaPointX(ref height); |
||
839 | item.Aveva.Height = height; |
||
840 | } |
||
841 | 6503fec8 | gaqhf | |
842 | 7a8645c9 | gaqhf | if (item.VALUE.Contains(@"\n")) |
843 | { |
||
844 | 6503fec8 | gaqhf | item.Aveva.LabelType = LabelType.MultiNote; |
845 | 7a8645c9 | gaqhf | int count = item.VALUE.Length - item.VALUE.Replace("\n", "").Length + 1; |
846 | item.Aveva.Height = item.Aveva.Height / count; |
||
847 | 6503fec8 | gaqhf | } |
848 | else |
||
849 | item.Aveva.LabelType = LabelType.SingleNote; |
||
850 | |||
851 | a03f7b94 | gaqhf | item.Aveva.Angle = item.ANGLE; |
852 | 6503fec8 | gaqhf | } |
853 | |||
854 | 98aa8635 | gaqhf | if (!result) |
855 | ValidationMessage = validationStringBuilder.ToString(); |
||
856 | |||
857 | a999464f | gaqhf | return result; |
858 | } |
||
859 | 9dab7146 | gaqhf | |
860 | ff4941b2 | gaqhf | public void ConvertAvevaPoint(ref double x, ref double y) |
861 | f71d5768 | gaqhf | { |
862 | decimal drawingSizeWidth = Convert.ToDecimal(Properties.Settings.Default.DrawingX); |
||
863 | decimal drawingSizeHeight = Convert.ToDecimal(Properties.Settings.Default.DrawingY); |
||
864 | decimal id2Width = Convert.ToDecimal(SIZE_WIDTH); |
||
865 | decimal id2Height = Convert.ToDecimal(SIZE_HEIGHT); |
||
866 | |||
867 | x = Convert.ToDouble(drawingSizeWidth / id2Width * Convert.ToDecimal(x)); |
||
868 | y = Convert.ToDouble(drawingSizeHeight / id2Height * Convert.ToDecimal(y)); |
||
869 | } |
||
870 | 6503fec8 | gaqhf | public void ConvertAvevaPointX(ref double x) |
871 | { |
||
872 | decimal drawingSizeWidth = Convert.ToDecimal(Properties.Settings.Default.DrawingX); |
||
873 | decimal id2Width = Convert.ToDecimal(SIZE_WIDTH); |
||
874 | |||
875 | x = Convert.ToDouble(drawingSizeWidth / id2Width * Convert.ToDecimal(x)); |
||
876 | } |
||
877 | public void ConvertAvevaPointY(ref double y) |
||
878 | { |
||
879 | decimal drawingSizeHeight = Convert.ToDecimal(Properties.Settings.Default.DrawingY); |
||
880 | decimal id2Height = Convert.ToDecimal(SIZE_HEIGHT); |
||
881 | |||
882 | y = Convert.ToDouble(drawingSizeHeight / id2Height * Convert.ToDecimal(y)); |
||
883 | } |
||
884 | f71d5768 | gaqhf | |
885 | 475071f2 | gaqhf | private double RadianToDegree(double angle) |
886 | { |
||
887 | return angle * (180.0 / Math.PI); |
||
888 | } |
||
889 | |||
890 | 9dab7146 | gaqhf | #endregion |
891 | 6ec631d2 | gaqhf | } |
892 | } |