프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / ID2PSN / Object / Item.cs @ 48870200

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

1
using DevExpress.XtraGrid.Views.Layout;
2
using System;
3
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
        Keyword
23
    }
24

    
25
    public class Item
26
    {
27
        public Item()
28
        {
29
            BranchItems = new List<Item>();
30
            Attributes = new List<Attribute>();
31
        }
32

    
33
        public string UID { get; set; }
34
        public string ID2DBCategory { get; set; }
35
        public string ID2DBType { get; set; }
36
        public string Name { get; set; }
37
        public string Owner { get; set; }
38
        public string ID2DBName { get; set; }
39
        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
        public string PSNPipeLineID { get; set; }
48
        public Topology Topology { get; set; }
49
        public Group Group { get; set; }
50
        public PSNItem PSNItem { get; set; }
51
        public LineNumber LineNumber { get; set; }
52
        public bool MissingLineNumber1 { get; set; }
53
        public bool MissingLineNumber2 { get; set; }
54
        public Equipment Equipment { get; set; }
55
        public Document Document { get; set; }
56
        public string Keyword { get; set; }
57
    }
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
    public class Attribute
66
    {
67
        public string UID { get; set; }
68
        public string Name { get; set; }
69
        public string DisplayName { get; set; }
70
        public string Value { get; set; }
71
    }
72
    public class Equipment
73
    {
74
        public Equipment()
75
        {
76
            POINT = new List<double[]>();
77
            Nozzles = new List<Item>();
78
            Attributes = new List<Attribute>();
79
        }
80
        public string Name { get; set; }
81
        public string UID { get; set; }
82
        public List<double[]> POINT { get; set; }
83
        public List<Item> Nozzles { get; set; }
84
        public List<Attribute> Attributes { get; set; }
85
        public string ItemTag { get; set; }
86
    }
87
    public class LineNumber
88
    {
89
        public LineNumber()
90
        {
91
            Attributes = new List<Attribute>();
92
        }
93
        public string UID { get; set; }
94
        public string Name { get; set; }
95
        public List<Attribute> Attributes { get; set; }
96
        public bool IsCopy { get; set; }
97

    
98
        public LineNumber Copy()
99
        {
100
            LineNumber copy = new LineNumber();
101
            copy.IsCopy = true;
102
            copy.UID = Guid.NewGuid().ToString();
103
            copy.Name = Name;
104
            foreach (Attribute attribute in Attributes)
105
            {
106
                copy.Attributes.Add(new Attribute()
107
                {
108
                    UID = attribute.UID,
109
                    Name = attribute.Name,
110
                    DisplayName = attribute.DisplayName,
111
                    Value = attribute.Value,
112
                });
113
            }
114
            Attribute seqAttr = copy.Attributes.Find(x => x.Name == "Tag Seq No");
115
            if (seqAttr != null)
116
            {
117
                copy.Name = copy.Name.Replace(seqAttr.Value, seqAttr.Value + "V");
118
                seqAttr.Value += "V"; 
119
            }
120
            else
121
                copy.Name += "V";
122

    
123
           
124

    
125
            return copy;
126
        }
127
    }
128

    
129
    public class RunInfo 
130
    { 
131
        public RunInfo()
132
        {
133
            Items = new List<Item>();
134
        }
135
        public string UID { get; set; }
136
        public int Index { get; set; }
137
        public List<Item> Items { get; set; }
138
    }
139

    
140
    public class Group
141
    {
142
        public Group(Document document)
143
        {
144
            _Document = document;
145
        }
146
        public Group StartGroup { get; set; }
147
        public Group EndGroup { get; set; }
148
        public string UID { get; set; }
149
        public List<Item> Items { get; set; }
150
        private Document _Document;
151
        public Document Document { get { return _Document; } }
152
        public void SortItems()
153
        {
154
            List<Item> sorted = new List<Item>();
155
            Item line = Items.Find(x => x.ItemType == ItemType.Line);
156
            if (line != null)
157
            {
158
                sorted.Add(line);
159
                Item startItem = line.Relations[0].Item;
160
                if (startItem != null)
161
                {
162
                    Stack<Item> stacks = new Stack<Item>();
163
                    stacks.Push(startItem);
164
                    while (stacks.Count > 0)
165
                    {
166
                        Item stack = stacks.Pop();
167
                        if (sorted.Contains(stack))
168
                            continue;
169

    
170
                        if (Items.Contains(stack))
171
                        {
172
                            sorted.Insert(0, stack); 
173
                            foreach (var relation in stack.Relations)
174
                            {
175
                                if (relation.Item == null || !Items.Contains(relation.Item))
176
                                    continue;
177
                                stacks.Push(relation.Item);
178
                            }
179
                        }
180
                    }
181
                }
182
                Item endItem = line.Relations[1].Item;
183
                if (endItem != null)
184
                {
185
                    Stack<Item> stacks = new Stack<Item>();
186
                    stacks.Push(endItem);
187
                    while (stacks.Count > 0)
188
                    {
189
                        Item stack = stacks.Pop();
190
                        if (sorted.Contains(stack))
191
                            continue;
192

    
193
                        if (Items.Contains(stack))
194
                        {
195
                            sorted.Add(stack);
196
                            foreach (var relation in stack.Relations)
197
                            {
198
                                if (relation.Item == null || !Items.Contains(relation.Item))
199
                                    continue;
200
                                stacks.Push(relation.Item);
201
                            }
202
                        }
203
                    }
204
                }
205

    
206
                if (!sorted.Count.Equals(Items.Count))
207
                    throw new Exception("logic error");
208

    
209
                Items = sorted;
210
            }
211
            else
212
            {
213

    
214
            }
215
        }
216
    }
217

    
218
    public class Topology
219
    {
220
        public Topology()
221
        {
222
            Items = new List<Item>();
223
        }
224
        public string ID { get; set; }
225
        public string Type { get; set; }
226
        public string Index { get; set; }
227
        public string FullName { get { return ID + "-" + Type + Index; } }
228
        public List<Item> Items { get; set; }
229
    }
230
}
클립보드 이미지 추가 (최대 크기: 500 MB)