프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / ID2PSN / Object / Item.cs @ 4607ff67

이력 | 보기 | 이력해설 | 다운로드 (7 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 48870200 LJIYEON
        public bool MissingLineNumber1 { get; set; }
53
        public bool MissingLineNumber2 { get; set; }
54 4c76a67a gaqhf
        public Equipment Equipment { get; set; }
55 7881ec8f gaqhf
        public Document Document { get; set; }
56 879ce10b LJIYEON
        public string Keyword { get; set; }
57 6b9e7a56 gaqhf
    }
58
59
    public class Relation 
60
    { 
61
        public string UID { get; set; }
62
        public Item Item { get; set; }
63
        public double[] Point { get; set; }
64
    }
65 4a18cb33 LJIYEON
66 6b9e7a56 gaqhf
    public class Attribute
67
    {
68
        public string UID { get; set; }
69
        public string Name { get; set; }
70
        public string DisplayName { get; set; }
71
        public string Value { get; set; }
72
    }
73 4a18cb33 LJIYEON
74 6b9e7a56 gaqhf
    public class Equipment
75
    {
76
        public Equipment()
77
        {
78
            POINT = new List<double[]>();
79
            Nozzles = new List<Item>();
80 c6503eaa gaqhf
            Attributes = new List<Attribute>();
81 6b9e7a56 gaqhf
        }
82 4c76a67a gaqhf
        public string Name { get; set; }
83 6b9e7a56 gaqhf
        public string UID { get; set; }
84
        public List<double[]> POINT { get; set; }
85
        public List<Item> Nozzles { get; set; }
86 c6503eaa gaqhf
        public List<Attribute> Attributes { get; set; }
87
        public string ItemTag { get; set; }
88 6b9e7a56 gaqhf
    }
89 4a18cb33 LJIYEON
90 6b9e7a56 gaqhf
    public class LineNumber
91
    {
92 0f07fa34 gaqhf
        public LineNumber()
93
        {
94
            Attributes = new List<Attribute>();
95
        }
96 6b9e7a56 gaqhf
        public string UID { get; set; }
97
        public string Name { get; set; }
98
        public List<Attribute> Attributes { get; set; }
99 710a49f1 gaqhf
        public bool IsCopy { get; set; }
100
101
        public LineNumber Copy()
102
        {
103
            LineNumber copy = new LineNumber();
104
            copy.IsCopy = true;
105
            copy.UID = Guid.NewGuid().ToString();
106
            copy.Name = Name;
107
            foreach (Attribute attribute in Attributes)
108
            {
109
                copy.Attributes.Add(new Attribute()
110
                {
111
                    UID = attribute.UID,
112
                    Name = attribute.Name,
113
                    DisplayName = attribute.DisplayName,
114
                    Value = attribute.Value,
115
                });
116
            }
117
            Attribute seqAttr = copy.Attributes.Find(x => x.Name == "Tag Seq No");
118
            if (seqAttr != null)
119
            {
120
                copy.Name = copy.Name.Replace(seqAttr.Value, seqAttr.Value + "V");
121
                seqAttr.Value += "V"; 
122
            }
123
            else
124
                copy.Name += "V";
125
126 a2973aa3 LJIYEON
           
127
128 710a49f1 gaqhf
            return copy;
129
        }
130 6b9e7a56 gaqhf
    }
131
132
    public class RunInfo 
133
    { 
134
        public RunInfo()
135
        {
136
            Items = new List<Item>();
137
        }
138
        public string UID { get; set; }
139
        public int Index { get; set; }
140
        public List<Item> Items { get; set; }
141
    }
142
143
    public class Group
144
    {
145
        public Group(Document document)
146
        {
147
            _Document = document;
148
        }
149
        public Group StartGroup { get; set; }
150
        public Group EndGroup { get; set; }
151
        public string UID { get; set; }
152
        public List<Item> Items { get; set; }
153
        private Document _Document;
154
        public Document Document { get { return _Document; } }
155
        public void SortItems()
156
        {
157
            List<Item> sorted = new List<Item>();
158
            Item line = Items.Find(x => x.ItemType == ItemType.Line);
159
            if (line != null)
160
            {
161
                sorted.Add(line);
162
                Item startItem = line.Relations[0].Item;
163
                if (startItem != null)
164
                {
165
                    Stack<Item> stacks = new Stack<Item>();
166
                    stacks.Push(startItem);
167
                    while (stacks.Count > 0)
168
                    {
169
                        Item stack = stacks.Pop();
170
                        if (sorted.Contains(stack))
171
                            continue;
172
173
                        if (Items.Contains(stack))
174
                        {
175
                            sorted.Insert(0, stack); 
176
                            foreach (var relation in stack.Relations)
177
                            {
178
                                if (relation.Item == null || !Items.Contains(relation.Item))
179
                                    continue;
180
                                stacks.Push(relation.Item);
181
                            }
182
                        }
183
                    }
184
                }
185
                Item endItem = line.Relations[1].Item;
186
                if (endItem != null)
187
                {
188
                    Stack<Item> stacks = new Stack<Item>();
189
                    stacks.Push(endItem);
190
                    while (stacks.Count > 0)
191
                    {
192
                        Item stack = stacks.Pop();
193
                        if (sorted.Contains(stack))
194
                            continue;
195
196
                        if (Items.Contains(stack))
197
                        {
198
                            sorted.Add(stack);
199
                            foreach (var relation in stack.Relations)
200
                            {
201
                                if (relation.Item == null || !Items.Contains(relation.Item))
202
                                    continue;
203
                                stacks.Push(relation.Item);
204
                            }
205
                        }
206
                    }
207
                }
208
209
                if (!sorted.Count.Equals(Items.Count))
210
                    throw new Exception("logic error");
211
212
                Items = sorted;
213
            }
214
            else
215
            {
216
217
            }
218
        }
219
    }
220
221
    public class Topology
222
    {
223
        public Topology()
224
        {
225
            Items = new List<Item>();
226
        }
227
        public string ID { get; set; }
228
        public string Type { get; set; }
229
        public string Index { get; set; }
230
        public string FullName { get { return ID + "-" + Type + Index; } }
231
        public List<Item> Items { get; set; }
232
    }
233
}
클립보드 이미지 추가 (최대 크기: 500 MB)