프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / ID2PSN / Object / Item.cs @ 7979a015

이력 | 보기 | 이력해설 | 다운로드 (8.83 KB)

1 0f07fa34 gaqhf
using DevExpress.XtraGrid.Views.Layout;
2
using System;
3 6b9e7a56 gaqhf
using System.Collections.Generic;
4
using System.Linq;
5
using System.Text;
6
using System.Threading.Tasks;
7
8
namespace ID2PSN
9
{
10
    public enum ItemType
11
    {
12
        None,
13
        Symbol,
14
        Line
15
    }
16
    public enum SubItemType
17
    {
18
        None,
19
        OPC,
20
        Header,
21
        Nozzle,
22 879ce10b LJIYEON
        Keyword
23 6b9e7a56 gaqhf
    }
24
25
    public class Item
26
    {
27
        public Item()
28
        {
29
            BranchItems = new List<Item>();
30 0f07fa34 gaqhf
            Attributes = new List<Attribute>();
31 6b9e7a56 gaqhf
        }
32
33
        public string UID { get; set; }
34 7881ec8f gaqhf
        public string ID2DBCategory { get; set; }
35
        public string ID2DBType { get; set; }
36 6b9e7a56 gaqhf
        public string Name { get; set; }
37
        public string Owner { get; set; }
38 7881ec8f gaqhf
        public string ID2DBName { get; set; }
39 6b9e7a56 gaqhf
        public string ANGLE { get; set; }
40
        public double[] POINT { get; set; }
41
        public List<Relation> Relations { get; set; }
42
        public List<Attribute> Attributes { get; set; }
43
        public ItemType ItemType { get; set; }
44
        public SubItemType SubItemType { get; set; }
45
        public List<Item> BranchItems { get; set; }
46
        public string TopologyData { get; set; }
47 8f24b438 gaqhf
        public string PSNPipeLineID { get; set; }
48 6b9e7a56 gaqhf
        public Topology Topology { get; set; }
49 36a45f13 gaqhf
        public Group Group { get; set; }
50
        public PSNItem PSNItem { get; set; }
51 6b9e7a56 gaqhf
        public LineNumber LineNumber { get; set; }
52 85eeb2be 이지연
        
53 4c76a67a gaqhf
        public Equipment Equipment { get; set; }
54 7881ec8f gaqhf
        public Document Document { get; set; }
55 879ce10b LJIYEON
        public string Keyword { get; set; }
56 4f02de16 이지연
57
        public Item pairItem { get; set; }
58
        public Item LineItemCopy()
59
        {
60
            Item newItem = new Item();
61
62
            newItem.UID = Guid.NewGuid().ToString();
63
64
            newItem.Name = this.Name;
65
            newItem.ID2DBType = this.ID2DBType;
66
            newItem.Owner = this.Owner;
67
            newItem.ItemType = ItemType.Line;
68
69
            List<Attribute> attributes = new List<Attribute>();
70
            foreach (var attr in this.Attributes)
71
            {
72
                attributes.Add(new Attribute()
73
                {
74
                    UID = attr.UID,
75
                    Name = attr.Name,
76
                    DisplayName = attr.DisplayName,
77
                    Value = attr.Value
78
                });
79
            }
80
            newItem.Attributes = attributes;
81
82
            List<Relation> relations = new List<Relation>();
83
            foreach (var _relation in this.Relations)
84
            {
85
                relations.Add(new Relation()
86
                {
87
                    UID = "None",
88
                    Point = (double[])_relation.Point.Clone()
89
                });
90
            }
91
            newItem.Relations = relations;
92
93
            return newItem;
94
        }
95
96
        public string GetAttributeByName(string name)
97
        {
98
            Attribute attribute = this.Attributes.Find(x => x.Name.ToUpper() == name.ToUpper());
99
            if (attribute != null && !string.IsNullOrEmpty(attribute.Value) && attribute.Value != "None")
100
            {
101
                return attribute.Value;
102
            }
103
104
            if (this.LineNumber != null)
105
            {
106
                attribute = this.LineNumber.Attributes.Find(x => x.Name.ToUpper() == name.ToUpper());
107
                if (attribute != null)
108
                {
109
                    return attribute.Value;
110
                }
111
            }
112
113
            return null;
114
        }
115
116 6b9e7a56 gaqhf
    }
117
118
    public class Relation 
119
    { 
120
        public string UID { get; set; }
121
        public Item Item { get; set; }
122
        public double[] Point { get; set; }
123
    }
124 4a18cb33 LJIYEON
125 6b9e7a56 gaqhf
    public class Attribute
126
    {
127
        public string UID { get; set; }
128
        public string Name { get; set; }
129
        public string DisplayName { get; set; }
130
        public string Value { get; set; }
131
    }
132 4a18cb33 LJIYEON
133 6b9e7a56 gaqhf
    public class Equipment
134
    {
135
        public Equipment()
136
        {
137
            POINT = new List<double[]>();
138
            Nozzles = new List<Item>();
139 c6503eaa gaqhf
            Attributes = new List<Attribute>();
140 6b9e7a56 gaqhf
        }
141 4c76a67a gaqhf
        public string Name { get; set; }
142 6b9e7a56 gaqhf
        public string UID { get; set; }
143
        public List<double[]> POINT { get; set; }
144
        public List<Item> Nozzles { get; set; }
145 c6503eaa gaqhf
        public List<Attribute> Attributes { get; set; }
146
        public string ItemTag { get; set; }
147 6b9e7a56 gaqhf
    }
148 4a18cb33 LJIYEON
149 6b9e7a56 gaqhf
    public class LineNumber
150
    {
151 0f07fa34 gaqhf
        public LineNumber()
152
        {
153
            Attributes = new List<Attribute>();
154
        }
155 6b9e7a56 gaqhf
        public string UID { get; set; }
156
        public string Name { get; set; }
157
        public List<Attribute> Attributes { get; set; }
158 710a49f1 gaqhf
        public bool IsCopy { get; set; }
159 7d6d1693 이지연
        public bool MissingLineNumber1 { get; set; }
160
        public bool MissingLineNumber2 { get; set; }
161 85eeb2be 이지연
162 710a49f1 gaqhf
        public LineNumber Copy()
163
        {
164
            LineNumber copy = new LineNumber();
165
            copy.IsCopy = true;
166
            copy.UID = Guid.NewGuid().ToString();
167
            copy.Name = Name;
168
            foreach (Attribute attribute in Attributes)
169
            {
170
                copy.Attributes.Add(new Attribute()
171
                {
172
                    UID = attribute.UID,
173
                    Name = attribute.Name,
174
                    DisplayName = attribute.DisplayName,
175
                    Value = attribute.Value,
176
                });
177
            }
178
            Attribute seqAttr = copy.Attributes.Find(x => x.Name == "Tag Seq No");
179
            if (seqAttr != null)
180
            {
181
                copy.Name = copy.Name.Replace(seqAttr.Value, seqAttr.Value + "V");
182
                seqAttr.Value += "V"; 
183
            }
184
            else
185
                copy.Name += "V";
186
187 a2973aa3 LJIYEON
           
188
189 710a49f1 gaqhf
            return copy;
190
        }
191 6b9e7a56 gaqhf
    }
192
193
    public class RunInfo 
194
    { 
195
        public RunInfo()
196
        {
197
            Items = new List<Item>();
198
        }
199
        public string UID { get; set; }
200
        public int Index { get; set; }
201
        public List<Item> Items { get; set; }
202
    }
203
204
    public class Group
205
    {
206
        public Group(Document document)
207
        {
208
            _Document = document;
209
        }
210
        public Group StartGroup { get; set; }
211
        public Group EndGroup { get; set; }
212
        public string UID { get; set; }
213
        public List<Item> Items { get; set; }
214
        private Document _Document;
215
        public Document Document { get { return _Document; } }
216
        public void SortItems()
217
        {
218
            List<Item> sorted = new List<Item>();
219
            Item line = Items.Find(x => x.ItemType == ItemType.Line);
220
            if (line != null)
221
            {
222
                sorted.Add(line);
223
                Item startItem = line.Relations[0].Item;
224
                if (startItem != null)
225
                {
226
                    Stack<Item> stacks = new Stack<Item>();
227
                    stacks.Push(startItem);
228
                    while (stacks.Count > 0)
229
                    {
230
                        Item stack = stacks.Pop();
231
                        if (sorted.Contains(stack))
232
                            continue;
233
234
                        if (Items.Contains(stack))
235
                        {
236
                            sorted.Insert(0, stack); 
237
                            foreach (var relation in stack.Relations)
238
                            {
239
                                if (relation.Item == null || !Items.Contains(relation.Item))
240
                                    continue;
241
                                stacks.Push(relation.Item);
242
                            }
243
                        }
244
                    }
245
                }
246
                Item endItem = line.Relations[1].Item;
247
                if (endItem != null)
248
                {
249
                    Stack<Item> stacks = new Stack<Item>();
250
                    stacks.Push(endItem);
251
                    while (stacks.Count > 0)
252
                    {
253
                        Item stack = stacks.Pop();
254
                        if (sorted.Contains(stack))
255
                            continue;
256
257
                        if (Items.Contains(stack))
258
                        {
259
                            sorted.Add(stack);
260
                            foreach (var relation in stack.Relations)
261
                            {
262
                                if (relation.Item == null || !Items.Contains(relation.Item))
263
                                    continue;
264
                                stacks.Push(relation.Item);
265
                            }
266
                        }
267
                    }
268
                }
269
270
                if (!sorted.Count.Equals(Items.Count))
271
                    throw new Exception("logic error");
272
273
                Items = sorted;
274
            }
275
            else
276
            {
277
278
            }
279
        }
280
    }
281
282
    public class Topology
283
    {
284
        public Topology()
285
        {
286
            Items = new List<Item>();
287
        }
288
        public string ID { get; set; }
289
        public string Type { get; set; }
290
        public string Index { get; set; }
291
        public string FullName { get { return ID + "-" + Type + Index; } }
292
        public List<Item> Items { get; set; }
293
    }
294
}
클립보드 이미지 추가 (최대 크기: 500 MB)