프로젝트

일반

사용자정보

개정판 5aec7e24

ID5aec7e241e3195e096e6679c47adfeca8c72d3dd
상위 5598104a
하위 cf41345a, fdb1367e

gaqhf 이(가) 5년 이상 전에 추가함

dev issue #1225 : Model 구현

Change-Id: I13ed32df82c5466c3f044fb26a3ca2d6eba85bb0

차이점 보기:

DTI_PID/APIDConverter/AVEVA.PID.CustomizationUtility_ACAD2018_x64.csproj
114 114
    <Compile Include="Form\ProjectForm.Designer.cs">
115 115
      <DependentUpon>ProjectForm.cs</DependentUpon>
116 116
    </Compile>
117
    <Compile Include="Model\APIDInfo.cs" />
117
    <Compile Include="Model\PlantItem\EndBreak.cs" />
118
    <Compile Include="Model\PlantItem\LineNumber.cs" />
119
    <Compile Include="Model\PlantItem\Other\APIDInfo.cs" />
118 120
    <Compile Include="Model\PlantItem\Other\Association.cs" />
119 121
    <Compile Include="Model\PlantItem\Other\Attribute.cs" />
120 122
    <Compile Include="Model\PlantItem\Other\ChildSymbol.cs" />
121 123
    <Compile Include="Model\PlantItem\Other\Connector.cs" />
122 124
    <Compile Include="Model\PlantItem\Document.cs" />
123 125
    <Compile Include="Model\PlantItem\Equipment.cs" />
126
    <Compile Include="Model\PlantItem\Other\LineRun.cs" />
124 127
    <Compile Include="Model\PlantItem\Other\Property.cs" />
125 128
    <Compile Include="Model\Project_Info.cs" />
129
    <Compile Include="Model\PlantItem\SpecBreak.cs" />
130
    <Compile Include="Model\PlantItem\TrimLine.cs" />
126 131
    <Compile Include="Properties\Settings.Designer.cs">
127 132
      <AutoGen>True</AutoGen>
128 133
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
DTI_PID/APIDConverter/Model/PlantItem/Document.cs
6 6
using System.Xml.Linq;
7 7
using System.IO;
8 8
using System.Data;
9
using System.Windows.Forms;
9 10

  
10 11
namespace AVEVA.PID.CustomizationUtility.Model
11 12
{
12 13
    public class Document
13 14
    {
14
        public bool Enabled = false;
15
        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;
15 32
        private DataTable ID2SymbolTypeDT;
16 33

  
17
        public List<Symbol> Symbols { get; set; }
18
        public List<Line> Lines { get; set; }
19
        public List<Equipment> Equipments { get; set; }
34
        public string ValidationMessage { get => _ValidationMessage; set => _ValidationMessage = value; }
35

  
36
        public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; }
37
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
38
        public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; }
39
        public List<EndBreak> EndBreaks { get => _EndBreaks; set => _EndBreaks = value; }
40
        public List<SpecBreak> SpecBreaks { get => _SpecBreaks; set => _SpecBreaks = value; }
41
        public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; }
42
        public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; }
43
        public string SIZE
44
        {
45
            get
46
            {
47
                return _SIZE;
48
            }
49
            set
50
            {
51
                _SIZE = value;
52
                string[] pointArr = _SIZE.Split(new char[] { ',' });
53
                if (pointArr.Length == 2)
54
                {
55
                    _SIZE_WIDTH = Convert.ToDouble(pointArr[0]);
56
                    _SIZE_HEIGHT = Convert.ToDouble(pointArr[1]);
57
                }
58
            }
59
        }
60
        public double SIZE_WIDTH { get => _SIZE_WIDTH; }
61
        public double SIZE_HEIGHT { get => _SIZE_HEIGHT; }
62
        public List<TrimLine> TRIMLINES { get => _TRIMLINES; set => _TRIMLINES = value; }
63
        public string PATH { get; set; }
64
        public bool Enable { get => _Enable; set => _Enable = value; }
65
        public bool Validation { get => _Validation; set => _Validation = value; }
66
        public bool MappingValidation { get => _MappingValidation; set => _MappingValidation = value; }
67
        public string UID { get => _UID; set => _UID = value; }
68

  
69
        StringBuilder validationStringBuilder = new StringBuilder();
70

  
71
        public List<PlantItem> PlantItems = new List<PlantItem>();
20 72

  
21 73
        public Document(string xmlPath, DataTable ID2SymbolTypeDT)
22 74
        {
23 75
            this.ID2SymbolTypeDT = ID2SymbolTypeDT;
76
            validationStringBuilder.AppendLine("Document Path : " + xmlPath);
77
            validationStringBuilder.AppendLine("");
78
            try
79
            {
80
                if (xmlPath != null)
81
                {
82
                    PATH = xmlPath;
83
                    XElement xml = XElement.Load(xmlPath);
84
                    DWGNAME = xml.Element("DWGNAME").Value;
85
                    SIZE = xml.Element("SIZE").Value;
24 86

  
25
            Symbols = new List<Symbol>();
26
            Lines = new List<Line>();
27
            Equipments = new List<Equipment>();
87
                    validationStringBuilder.AppendLine("Drawing Name : " + DWGNAME);
88
                    validationStringBuilder.AppendLine("");
28 89

  
29
            if (File.Exists(xmlPath))
30
            {
90
                    SetSymbol(xml.Element("SYMBOLS"));
91
                    SetLine(xml.Element("LINEINFOS"));
92
                    SetLineNumber(xml.Element("LINENOS"));
93
                    SetTrimLine(xml.Element("TRIMLINENOS"));
31 94

  
95
                    SetAllConnectors();
96
                    Enable = true;
97
                }
98
            }
99
            catch (Exception ex)
100
            {
101
                Enable = false;
102
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
32 103
            }
33 104
        }
34 105

  
106
        #region READ XML
35 107
        private void SetSymbol(XElement node)
36 108
        {
37 109
            foreach (XElement item in node.Elements("SYMBOL"))
38 110
            {
39 111
                string sType = item.Element("TYPE").Value;
40 112

  
113
                DataRow[] rows = ID2SymbolTypeDT.Select(string.Format("Type = '{0}'", sType.Replace("'", "''")));
114
                string sCategory = rows[0]["Category"].ToString();
115

  
116
                if (sType == "Segment Breaks")
117
                {
118
                    SpecBreak specBreak = new SpecBreak()
119
                    {
120
                        UID = item.Element("UID").Value,
121
                        DBUID = item.Element("DBUID").Value,
122
                        NAME = item.Element("NAME").Value,
123
                        TYPE = item.Element("TYPE").Value,
124
                        OWNER = item.Element("OWNER").Value,
125
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
126
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
127
                        LOCATION = item.Element("LOCATION").Value,
128
                        SIZE = item.Element("SIZE").Value,
129
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
130
                        PARENT = item.Element("PARENT").Value,
131
                        CHILD = item.Element("CHILD").Value,
132
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
133
                        AREA = item.Element("AREA").Value,
134
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
135
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
136
                    };
137
                    SetAssociations(item.Element("ASSOCIATIONS"), specBreak.ASSOCIATIONS);
138
                    SetSymbolConnectors(item.Element("CONNECTORS"), specBreak.CONNECTORS, specBreak.CONNECTIONPOINT);
139
                    SetProperties(item.Element("PROPERTIES"), specBreak.PROPERTIES);
140
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), specBreak.ATTRIBUTES);
141
                    SetSpecBreakAttribute(specBreak);
142

  
143
                    SpecBreaks.Add(specBreak);
144
                }
145
                else if (sType == "End Break")
146
                {
147
                    EndBreak endBreak = new EndBreak()
148
                    {
149
                        UID = item.Element("UID").Value,
150
                        DBUID = item.Element("DBUID").Value,
151
                        NAME = item.Element("NAME").Value,
152
                        TYPE = item.Element("TYPE").Value,
153
                        OWNER = item.Element("OWNER").Value,
154
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
155
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
156
                        LOCATION = item.Element("LOCATION").Value,
157
                        SIZE = item.Element("SIZE").Value,
158
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
159
                        PARENT = item.Element("PARENT").Value,
160
                        CHILD = item.Element("CHILD").Value,
161
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
162
                        AREA = item.Element("AREA").Value,
163
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
164
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
165
                    };
166
                    SetAssociations(item.Element("ASSOCIATIONS"), endBreak.ASSOCIATIONS);
167
                    SetSymbolConnectors(item.Element("CONNECTORS"), endBreak.CONNECTORS, endBreak.CONNECTIONPOINT);
168
                    SetProperties(item.Element("PROPERTIES"), endBreak.PROPERTIES);
169
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), endBreak.ATTRIBUTES);
170

  
171
                    EndBreaks.Add(endBreak);
172
                }
173
                else if (sCategory == "Equipment" ||
174
                    sCategory == "Equipment Components")
175
                {
176
                    Equipment equipment = new Equipment()
177
                    {
178
                        UID = item.Element("UID").Value,
179
                        DBUID = item.Element("DBUID").Value,
180
                        NAME = item.Element("NAME").Value,
181
                        TYPE = item.Element("TYPE").Value,
182
                        OWNER = item.Element("OWNER").Value,
183
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
184
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
185
                        LOCATION = item.Element("LOCATION").Value,
186
                        SIZE = item.Element("SIZE").Value,
187
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
188
                        PARENT = item.Element("PARENT").Value,
189
                        CHILD = item.Element("CHILD").Value,
190
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
191
                        AREA = item.Element("AREA").Value,
192
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
193
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
194
                    };
195
                    SetAssociations(item.Element("ASSOCIATIONS"), equipment.ASSOCIATIONS);
196
                    SetSymbolConnectors(item.Element("CONNECTORS"), equipment.CONNECTORS, equipment.CONNECTIONPOINT);
197
                    SetProperties(item.Element("PROPERTIES"), equipment.PROPERTIES);
198
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), equipment.ATTRIBUTES);
199

  
200
                    Equipments.Add(equipment);
201
                }
202
                else
203
                {
204
                    Symbol symbol = new Symbol()
205
                    {
206
                        UID = item.Element("UID").Value,
207
                        DBUID = item.Element("DBUID").Value,
208
                        NAME = item.Element("NAME").Value,
209
                        TYPE = item.Element("TYPE").Value,
210
                        OWNER = item.Element("OWNER").Value,
211
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
212
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
213
                        LOCATION = item.Element("LOCATION").Value,
214
                        SIZE = item.Element("SIZE").Value,
215
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
216
                        PARENT = item.Element("PARENT").Value,
217
                        CHILD = item.Element("CHILD").Value,
218
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
219
                        AREA = item.Element("AREA").Value,
220
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
221
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
222
                    };
223

  
224
                    SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS);
225
                    SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT);
226
                    SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES);
227
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES);
228
                    SetChildSymbol(symbol);
229

  
230
                    SYMBOLS.Add(symbol);
231
                }
232
            }
233

  
234
            PlantItems.AddRange(SpecBreaks);
235
            PlantItems.AddRange(EndBreaks);
236
            PlantItems.AddRange(Equipments);
237
            PlantItems.AddRange(SYMBOLS);
238
        }
239

  
240
        private void SetLine(XElement node)
241
        {
242
            foreach (XElement item in node.Elements("LINE"))
243
            {
244
                Line line = new Line()
245
                {
246
                    OWNER = item.Attribute("OWNER").Value,
247
                    UID = item.Element("UID").Value,
248
                    STARTPOINT = item.Element("STARTPOINT").Value,
249
                    ENDPOINT = item.Element("ENDPOINT").Value,
250
                    TYPE = item.Element("TYPE").Value,
251
                    TYPEUID = item.Element("TYPE").Attribute("TYPEUID").Value,
252
                    AREA = item.Element("AREA").Value,
253
                    THICKNESS = item.Element("THICKNESS").Value,
254
                };
255
                int flowMarkPercent = 0;
256
                if (int.TryParse(item.Element("FLOWMARK").Value, out flowMarkPercent))
257
                {
258
                    line.FLOWMARK = true;
259
                    line.FLOWMARK_PERCENT = flowMarkPercent;
260
                }
261
                else
262
                    line.FLOWMARK = false;
263

  
264
                SetAssociations(item.Element("ASSOCIATIONS"), line.ASSOCIATIONS);
265
                SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS);
266
                SetAttributes(item.Element("SYMBOLATTRIBUTES"), line.ATTRIBUTES);
267
                LINES.Add(line);
268
            }
269
            PlantItems.AddRange(LINES);
270
        }
271

  
272
        private void SetLineNumber(XElement node)
273
        {
274
            foreach (XElement item in node.Elements("LINE_NO"))
275
            {
276
                LineNumber lineNumber = new LineNumber()
277
                {
278
                    UID = item.Element("UID").Value,
279
                    TEXT = item.Element("TEXT").Value,
280
                    LOCATION = item.Element("LOCATION").Value,
281
                    WIDTH = item.Element("WIDTH").Value,
282
                    HEIGHT = item.Element("HEIGHT").Value,
283
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
284
                    AREA = item.Element("AREA").Value,
285
                    SCENE = item.Element("SCENE").Value
286
                };
287
                if (item.Element("CONNLINE") != null)
288
                    lineNumber.CONNLINE = item.Element("CONNLINE").Value;
289
                else
290
                {
291
                    validationStringBuilder.AppendLine("Not exist CONNLINE!" + "\r\nLineNumber UID : " + lineNumber.UID);
292
                    validationStringBuilder.AppendLine();
293
                    validationResult = true;
294
                }
295

  
296
                SetLineNumberRuns(item, lineNumber.RUNS);
297
                SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES);
298
                SetAttributes(item, lineNumber.ATTRIBUTES);
299
                LINENUMBERS.Add(lineNumber);
300
            }
301
            PlantItems.AddRange(LINENUMBERS);
302
        }
303

  
304
        private void SetTrimLine(XElement node)
305
        {
306
            foreach (XElement item in node.Elements("TRIM_LINE_NO"))
307
            {
308
                TrimLine trimLine = new TrimLine()
309
                {
310
                    UID = item.Element("UID").Value,
311
                };
312
                SetLineNumberRuns(item, trimLine.RUNS);
313
                TRIMLINES.Add(trimLine);
314
            }
315
            PlantItems.AddRange(TRIMLINES);
316
        }
317

  
318
        private void SetAssociations(XElement node, List<Association> associations)
319
        {
320
            foreach (XElement item in node.Elements("ASSOCIATION"))
321
            {
322
                Association association = new Association()
323
                {
324
                    TYPE = item.Attribute("TYPE").Value,
325
                    VALUE = item.Value
326
                };
327

  
328
                associations.Add(association);
329
            }
330
        }
331

  
332
        private void SetConnectors(XElement node, List<Connector> connectors)
333
        {
334
            foreach (XElement item in node.Elements("CONNECTOR"))
335
            {
336
                connectors.Add(new Connector()
337
                {
338
                    UID = item.Attribute("UID").Value,
339
                    CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
340
                    CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
341
                    CONNECTPOINT = item.Element("CONNECTPOINT").Value,
342
                    SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
343
                });
344
            }
345
        }
346

  
347
        private void SetSymbolConnectors(XElement node, List<Connector> connectors, string CONNECTIONPOINT)
348
        {
349
            foreach (XElement item in node.Elements("CONNECTOR"))
350
            {
351
                connectors.Add(new Connector()
352
                {
353
                    UID = item.Attribute("UID").Value,
354
                    CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
355
                    CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
356
                    CONNECTPOINT = item.Element("CONNECTPOINT").Value,
357
                    SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
358
                });
359
            }
360
        }
361

  
362
        private void SetProperties(XElement node, List<Property> properties)
363
        {
364
            foreach (XElement item in node.Elements("PROPERTY"))
365
            {
366
                properties.Add(new Property()
367
                {
368
                    UID = item.Attribute("UID").Value,
369
                    LENGTH = item.Attribute("Length").Value,
370
                    EXPRESSION = item.Attribute("Expression").Value,
371
                    DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
372
                    ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
373
                    ATTRIBUTE = item.Attribute("Attribute").Value,
374
                    VALUE = item.Value
375
                });
376
            }
377
        }
378

  
379
        private void SetAttributes(XElement node, List<Attribute> attributes)
380
        {
381
            foreach (XElement item in node.Elements("ATTRIBUTE"))
382
            {
383
                Attribute attribute = new Attribute()
384
                {
385
                    UID = item.Attribute("UID").Value,
386
                    LENGTH = item.Attribute("Length").Value,
387
                    EXPRESSION = item.Attribute("Expression").Value,
388
                    DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
389
                    ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
390
                    ATTRIBUTE = item.Attribute("Attribute").Value,
391
                    ATTRAT = item.Attribute("AttrAt").Value,
392
                    ASSOCITEM = item.Attribute("AssocItem").Value,
393
                    VALUE = item.Value
394
                };
395

  
396
                attributes.Add(attribute);
397
            }
398
        }
399

  
400
        private void SetSpecBreakAttribute(SpecBreak specBreak)
401
        {
402
            string upStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "UpStream").VALUE;
403
            string downStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "DownStream").VALUE;
404

  
405
            specBreak.UpStreamUID = upStream;
406
            specBreak.DownStreamUID = downStream;
407
        }
408

  
409
        private void SetLineNumberRuns(XElement node, List<LineRun> lineNumberRuns)
410
        {
411
            foreach (XElement item in node.Elements("RUN"))
412
            {
413
                LineRun run = new LineRun()
414
                {
415
                    TYPE = item.Attribute("TYPE").Value
416
                };
417

  
418
                foreach (XElement element in item.Elements())
419
                {
420
                    if (element.Name == "SYMBOL")
421
                    {
422
                        Symbol symbol = GetSymbolByUID(element.Element("UID").Value);
423
                        Equipment equipment = GetEquipmentByUID(element.Element("UID").Value);
424
                        if (symbol == null && equipment == null)
425
                        {
426
                            validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value);
427
                            validationStringBuilder.AppendLine();
428
                            validationResult = true;
429
                        }
430
                        if (symbol != null)
431
                            run.RUNITEMS.Add(symbol);
432
                        else if (equipment != null)
433
                            run.RUNITEMS.Add(equipment);
434
                    }
435
                    else if (element.Name == "LINE")
436
                    {
437
                        Line line = GetLineByUID(element.Element("UID").Value);
438
                        if (line == null)
439
                        {
440
                            validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value);
441
                            validationStringBuilder.AppendLine();
442
                            validationResult = true;
443
                        }
444
                        run.RUNITEMS.Add(line);
445
                    }
446
                }
447
                lineNumberRuns.Add(run);
448
            }
449
        }
450

  
451
        private void SetChildSymbol(Symbol symbol)
452
        {
453
            List<ChildSymbol> childList = new List<ChildSymbol>();
454
            if (!string.IsNullOrEmpty(symbol.CHILD) && symbol.CHILD != "None")
455
            {
456
                string[] childArray = symbol.CHILD.Split(new char[] { '/' });
457
                foreach (string sChild in childArray)
458
                {
459
                    string[] sChildInfo = sChild.Split(new char[] { ',' });
460
                    childList.Add(new ChildSymbol()
461
                    {
462
                        ParentAt = Convert.ToInt32(sChildInfo[0]),
463
                        Direction = sChildInfo[1],
464
                        NAME = sChildInfo[2]
465
                    });
466
                }
467

  
468
                foreach (ChildSymbol child in childList)
469
                {
470
                    if (child.ParentAt == 0)
471
                        symbol.ChildSymbols.Add(child);
472
                    else
473
                        childList[child.ParentAt - 1].ChildSymbols.Add(child);
474
                }
475
            }
476
            if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None")
477
            {
478
                // 현재 부모 Symbol에 자식 Connector까지 들어가 있음
479
                string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
480
                string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
481
                for (int i = 0; i < array.Length; i++)
482
                {
483
                    string[] arrConn = array[i].Split(new char[] { ',' });
484
                    int connIndex = Convert.ToInt32(arrConn[3]);
485
                    if (connIndex != 0)
486
                    {
487
                        childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]);
488
                        symbol.CONNECTORS[i].Index = connIndex;
489
                    }
490
                }
41 491
            }
42 492
        }
493
        #endregion
494

  
495
        public void SetAllConnectors()
496
        {
497
            foreach (var item in SYMBOLS)
498
                foreach (var connector in item.CONNECTORS)
499
                    connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM);
500

  
501
            foreach (var item in LINES)
502
                foreach (var connector in item.CONNECTORS)
503
                    connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM);
504

  
505
            foreach (var item in Equipments)
506
                foreach (var connector in item.CONNECTORS)
507
                    connector.ConnectedObject = APIDUtils.FindObjectByUID(this, connector.CONNECTEDITEM);
508
        }
509

  
510
        public Symbol GetSymbolByUID(string uid)
511
        {
512
            return SYMBOLS.Find(x => x.UID == uid);
513
        }
514

  
515
        public Equipment GetEquipmentByUID(string uid)
516
        {
517
            return Equipments.Find(x => x.UID == uid);
518
        }
519

  
520
        public Line GetLineByUID(string uid)
521
        {
522
            return LINES.Find(x => x.UID == uid);
523
        }
43 524
    }
44 525
}
DTI_PID/APIDConverter/Model/PlantItem/EndBreak.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace AVEVA.PID.CustomizationUtility.Model
8
{
9
    public class EndBreak : Symbol
10
    {
11
    }
12
}
DTI_PID/APIDConverter/Model/PlantItem/Equipment.cs
6 6

  
7 7
namespace AVEVA.PID.CustomizationUtility.Model
8 8
{
9
    public class Equipment : PlantItem
9
    public class Equipment : Symbol
10 10
    {
11 11

  
12 12
    }
DTI_PID/APIDConverter/Model/PlantItem/Line.cs
6 6

  
7 7
namespace AVEVA.PID.CustomizationUtility.Model
8 8
{
9
    public enum SlopeType
10
    {
11
        None,
12
        Slope,
13
        HORIZONTAL,
14
        VERTICAL
15
    }
16

  
9 17
    public class Line : PlantItem
10 18
    {
19
        private string _OWNER;
20
        private string _UID;
21
        private string _TYPEUID;
22
        private string _STARTPOINT;
23
        private string _ENDPOINT;
24
        private string _TYPE;
25
        private string _AREA;
26
        private string _THICKNESS;
27
        private bool _FLOWMARK;
28
        private int _FLOWMARK_PERCENT;
29
        public SlopeType SlopeType { get; set; }
30
        private List<Connector> _CONNECTORS = new List<Connector>();
31
        private List<Association> _ASSOCIATIONS = new List<Association>();
32
        private List<Attribute> _ATTRIBUTES = new List<Attribute>();
11 33

  
34
        public string OWNER { get => _OWNER; set => _OWNER = value; }
35
        public string UID { get => _UID; set => _UID = value; }
36
        public string STARTPOINT { get => _STARTPOINT; set => _STARTPOINT = value; }
37
        public string ENDPOINT { get => _ENDPOINT; set => _ENDPOINT = value; }
38
        public string TYPE { get => _TYPE; set => _TYPE = value; }
39
        public string AREA { get => _AREA; set => _AREA = value; }
40
        public string THICKNESS { get => _THICKNESS; set => _THICKNESS = value; }
41
        public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; }
42
        public string TYPEUID { get => _TYPEUID; set => _TYPEUID = value; }
43
        public bool FLOWMARK { get => _FLOWMARK; set => _FLOWMARK = value; }
44
        public int FLOWMARK_PERCENT { get => _FLOWMARK_PERCENT; set => _FLOWMARK_PERCENT = value; }
45
        public List<Association> ASSOCIATIONS { get => _ASSOCIATIONS; set => _ASSOCIATIONS = value; }
46
        public List<Attribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; }
12 47
    }
13 48
}
DTI_PID/APIDConverter/Model/PlantItem/LineNumber.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace AVEVA.PID.CustomizationUtility.Model
8
{
9
    public class LineNumber : PlantItem
10
    {
11
        private string _TEXT;
12
        private string _LOCATION;
13
        private string _WIDTH;
14
        private string _HEIGHT;
15
        private double _ANGLE;
16
        private string _AREA;
17
        private string _CONNLINE;
18
        private string _SCENE;
19
        private List<LineRun> _RUNS = new List<LineRun>();
20
        private List<Property> _PROPERTIES = new List<Property>();
21
        private List<Attribute> _ATTRIBUTES = new List<Attribute>();
22
        public string TEXT { get => _TEXT; set => _TEXT = value; }
23
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
24
        public string WIDTH { get => _WIDTH; set => _WIDTH = value; }
25
        public string HEIGHT { get => _HEIGHT; set => _HEIGHT = value; }
26
        public double ANGLE
27
        {
28
            get
29
            {
30
                return _ANGLE;
31
            }
32
            set
33
            {
34
                double gap = 0.05;
35
                if (value < gap)
36
                    value = 0;
37
                else if (1.57 - gap < value && value < 1.57 + gap)
38
                    value = 90 * Math.PI / 180;
39
                else if (3.14 - gap < value && value < 3.14 + gap)
40
                    value = Math.PI;
41
                else if (4.71 - gap < value && value < 4.71 + gap)
42
                    value = 270 * Math.PI / 180;
43

  
44
                _ANGLE = value;
45
            }
46
        }
47
        public string AREA { get => _AREA; set => _AREA = value; }
48
        public List<LineRun> RUNS { get => _RUNS; set => _RUNS = value; }
49
        public List<Property> PROPERTIES { get => _PROPERTIES; set => _PROPERTIES = value; }
50
        public List<Attribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; }
51
        public string CONNLINE { get => _CONNLINE; set => _CONNLINE = value; }
52

  
53
        public string SCENE
54
        {
55
            get
56
            {
57
                return _SCENE;
58
            }
59
            set
60
            {
61
                string[] split = value.Split(',');
62
                X1 = Convert.ToDouble(split[0]);
63
                Y1 = Convert.ToDouble(split[1]);
64
                X2 = X1 + Convert.ToDouble(split[2]);
65
                Y2 = Y1 + Convert.ToDouble(split[3]);
66
            }
67
        }
68
        public double X1 { get; set; }
69
        public double X2 { get; set; }
70
        public double Y1 { get; set; }
71
        public double Y2 { get; set; }
72
    }
73
}
DTI_PID/APIDConverter/Model/PlantItem/Other/Association.cs
8 8
{
9 9
    public class Association
10 10
    {
11
        private string _TYPE;
12
        private string _VALUE;
13

  
14
        public string TYPE { get => _TYPE; set => _TYPE = value; }
15
        public string VALUE { get => _VALUE; set => _VALUE = value; }
11 16
    }
12 17
}
DTI_PID/APIDConverter/Model/PlantItem/Other/Attribute.cs
8 8
{
9 9
    public class Attribute
10 10
    {
11
        private string _UID;
12
        private string _LENGTH;
13
        private string _EXPRESSION;
14
        private string _DISPLAYATTRIBUTE;
15
        private string _ATTRIBUTETYPE;
16
        private string _ATTRIBUTE;
17
        private string _VALUE;
18
        private string _ATTRAT;
19
        private string _ASSOCITEM;
20

  
21
        public string UID { get => _UID; set => _UID = value; }
22
        public string LENGTH { get => _LENGTH; set => _LENGTH = value; }
23
        public string EXPRESSION { get => _EXPRESSION; set => _EXPRESSION = value; }
24
        public string DISPLAYATTRIBUTE { get => _DISPLAYATTRIBUTE; set => _DISPLAYATTRIBUTE = value; }
25
        public string ATTRIBUTETYPE { get => _ATTRIBUTETYPE; set => _ATTRIBUTETYPE = value; }
26
        public string ATTRIBUTE { get => _ATTRIBUTE; set => _ATTRIBUTE = value; }
27
        public string VALUE { get => _VALUE; set => _VALUE = value; }
28
        public string ATTRAT { get => _ATTRAT; set => _ATTRAT = value; }
29
        public string ASSOCITEM { get => _ASSOCITEM; set => _ASSOCITEM = value; }
11 30
    }
12 31
}
DTI_PID/APIDConverter/Model/PlantItem/Other/ChildSymbol.cs
8 8
{
9 9
    public class ChildSymbol
10 10
    {
11
        private int _ParentAt;
12
        private string _Direction;
13
        private string _NAME;
14
        private List<ChildSymbol> _ChildSymbols = new List<ChildSymbol>();
15
        private List<Connector> _Connectors = new List<Connector>();
16

  
17
        public string NAME { get => _NAME; set => _NAME = value; }
18
        public List<ChildSymbol> ChildSymbols { get => _ChildSymbols; set => _ChildSymbols = value; }
19
        public int ParentAt { get => _ParentAt; set => _ParentAt = value; }
20
        public string Direction { get => _Direction; set => _Direction = value; }
21
        public List<Connector> Connectors { get => _Connectors; set => _Connectors = value; }
11 22
    }
12 23
}
DTI_PID/APIDConverter/Model/PlantItem/Other/Connector.cs
8 8
{
9 9
    public class Connector
10 10
    {
11
        private string _UID;
12
        private int _CONNECTED_AT;
13
        private string _CONNECTEDITEM;
14
        private string _CONNECTPOINT;
15
        private string _SCENECONNECTPOINT;
16
        private object _ConnectedObject;
17

  
18
        public string UID { get => _UID; set => _UID = value; }
19
        public int CONNECTED_AT { get => _CONNECTED_AT; set => _CONNECTED_AT = value; }
20
        public string CONNECTEDITEM { get => _CONNECTEDITEM; set => _CONNECTEDITEM = value; }
21
        public string CONNECTPOINT { get => _CONNECTPOINT; set => _CONNECTPOINT = value; }
22
        public string SCENECONNECTPOINT { get => _SCENECONNECTPOINT; set => _SCENECONNECTPOINT = value; }
23

  
24
        public int Index { get; set; }
25
        public object ConnectedObject { get => _ConnectedObject; set => _ConnectedObject = value; }
11 26
    }
12 27
}
DTI_PID/APIDConverter/Model/PlantItem/Other/LineRun.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace AVEVA.PID.CustomizationUtility.Model
8
{
9
    public class LineRun
10
    {
11
        private string _TYPE;
12
        private List<object> _RUNITEMS = new List<object>();
13

  
14
        public string TYPE { get => _TYPE; set => _TYPE = value; }
15
        public List<object> RUNITEMS { get => _RUNITEMS; set => _RUNITEMS = value; }
16
    }
17
}
DTI_PID/APIDConverter/Model/PlantItem/Other/Property.cs
8 8
{
9 9
    public class Property
10 10
    {
11
        private string _UID;
12
        private string _LENGTH;
13
        private string _EXPRESSION;
14
        private string _DISPLAYATTRIBUTE;
15
        private string _ATTRIBUTETYPE;
16
        private string _ATTRIBUTE;
17
        private string _VALUE;
18

  
19
        public string UID { get => _UID; set => _UID = value; }
20
        public string LENGTH { get => _LENGTH; set => _LENGTH = value; }
21
        public string EXPRESSION { get => _EXPRESSION; set => _EXPRESSION = value; }
22
        public string DISPLAYATTRIBUTE { get => _DISPLAYATTRIBUTE; set => _DISPLAYATTRIBUTE = value; }
23
        public string ATTRIBUTETYPE { get => _ATTRIBUTETYPE; set => _ATTRIBUTETYPE = value; }
24
        public string ATTRIBUTE { get => _ATTRIBUTE; set => _ATTRIBUTE = value; }
25
        public string VALUE { get => _VALUE; set => _VALUE = value; }
11 26
    }
12 27
}
DTI_PID/APIDConverter/Model/PlantItem/SpecBreak.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace AVEVA.PID.CustomizationUtility.Model
8
{
9
    public class SpecBreak : Symbol
10
    {
11
        public string UpStreamUID { get; set; }
12
        public string DownStreamUID { get; set; }
13
    }
14
}
DTI_PID/APIDConverter/Model/PlantItem/Symbol.cs
8 8
{
9 9
    public class Symbol : PlantItem
10 10
    {
11
        private string _DBUID;
12
        private string _NAME;
13
        private List<Association> _ASSOCIATIONS = new List<Association>();
14
        private string _TYPE;
15
        private string _OWNER;
16
        private string _ORIGINALPOINT;
17
        private List<Connector> _CONNECTOR = new List<Connector>();
18
        private string _CONNECTIONPOINT;
19
        private string _LOCATION;
20
        private string _SIZE;
21
        private double _ANGLE;
22
        private string _PARENT;
23
        private string _CHILD;
24
        private string _HASINSTRUMENTLABEL;
25
        private string _AREA;
26
        private int _FLIP;
27
        private List<Property> _PROPERTIES = new List<Property>();
28
        private List<Attribute> _ATTRIBUTES = new List<Attribute>();
29
        private int _CURRENTPOINTMODEINDEX;
30
        private List<ChildSymbol> _ChildSymbols = new List<ChildSymbol>();
11 31

  
32
        public string NAME { get => _NAME; set => _NAME = value; }
33
        public List<Association> ASSOCIATIONS { get => _ASSOCIATIONS; set => _ASSOCIATIONS = value; }
34
        public string TYPE { get => _TYPE; set => _TYPE = value; }
35
        public string OWNER { get => _OWNER; set => _OWNER = value; }
36
        public string ORIGINALPOINT { get => _ORIGINALPOINT; set => _ORIGINALPOINT = value; }
37
        public List<Connector> CONNECTORS { get => _CONNECTOR; set => _CONNECTOR = value; }
38
        public string CONNECTIONPOINT { get => _CONNECTIONPOINT; set => _CONNECTIONPOINT = value; }
39
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
40
        public string SIZE { get => _SIZE; set => _SIZE = value; }
41
        public double ANGLE
42
        {
43
            get
44
            {
45
                return _ANGLE;
46
            }
47
            set
48
            {
49
                double gap = 0.05;
50
                if (value < gap)
51
                    value = 0;
52
                else if (1.57 - gap < value && value < 1.57 + gap)
53
                    value = 90 * Math.PI / 180;
54
                else if (3.14 - gap < value && value < 3.14 + gap)
55
                    value = Math.PI;
56
                else if (4.71 - gap < value && value < 4.71 + gap)
57
                    value = 270 * Math.PI / 180;
58

  
59
                _ANGLE = value;
60
            }
61
        }
62
        public string PARENT { get => _PARENT; set => _PARENT = value; }
63
        public string CHILD { get => _CHILD; set => _CHILD = value; }
64
        public string HASINSTRUMENTLABEL { get => _HASINSTRUMENTLABEL; set => _HASINSTRUMENTLABEL = value; }
65
        public string AREA { get => _AREA; set => _AREA = value; }
66
        public int FLIP { get => _FLIP; set => _FLIP = value; }
67
        public List<Property> PROPERTIES { get => _PROPERTIES; set => _PROPERTIES = value; }
68
        public List<Attribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; }
69
        public int CURRENTPOINTMODEINDEX { get => _CURRENTPOINTMODEINDEX; set => _CURRENTPOINTMODEINDEX = value; }
70
        public List<ChildSymbol> ChildSymbols { get => _ChildSymbols; set => _ChildSymbols = value; }
71
        public string DBUID { get => _DBUID; set => _DBUID = value; }
12 72
    }
13 73
}
DTI_PID/APIDConverter/Model/PlantItem/TrimLine.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace AVEVA.PID.CustomizationUtility.Model
8
{
9
    public class TrimLine : PlantItem
10
    {
11
        private string _TEXT;
12
        private string _LOCATION;
13
        private string _WIDTH;
14
        private string _HEIGHT;
15
        private double _ANGLE;
16
        private string _AREA;
17
        private List<LineRun> _RUNS = new List<LineRun>();
18
        private List<Property> _PROPERTIES = new List<Property>();
19
        private List<Attribute> _ATTRIBUTES = new List<Attribute>();
20

  
21
        public string TEXT { get => _TEXT; set => _TEXT = value; }
22
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
23
        public string WIDTH { get => _WIDTH; set => _WIDTH = value; }
24
        public string HEIGHT { get => _HEIGHT; set => _HEIGHT = value; }
25
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
26
        public string AREA { get => _AREA; set => _AREA = value; }
27
        public List<LineRun> RUNS { get => _RUNS; set => _RUNS = value; }
28
        public List<Property> PROPERTIES { get => _PROPERTIES; set => _PROPERTIES = value; }
29
        public List<Attribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; }
30
    }
31
}
DTI_PID/APIDConverter/Utils/APIDUtils.cs
4 4
using System.Text;
5 5
using System.Threading.Tasks;
6 6

  
7
using AVEVA.PID.CustomizationUtility.DB;
8
using AVEVA.PID.CustomizationUtility.Model;
9
using AVEVA.PID.CustomizationUtility.Properties;
10

  
7 11
namespace AVEVA.PID.CustomizationUtility
8 12
{
9 13
    public class APIDUtils
10 14
    {
15
        public static object FindObjectByUID(Document document, string UID)
16
        {
17
            if (!string.IsNullOrEmpty(UID) && UID != "None")
18
            {
19
                foreach (PlantItem item in document.PlantItems)
20
                {
21
                    if (item.UID == UID)
22
                        return item;
23
                }
24
            }
11 25

  
26
            return null;
27
        }
12 28
    }
13 29
}

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)