프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / ID2PSN / Object / Item.cs @ 7d6d1693

이력 | 보기 | 이력해설 | 다운로드 (7.01 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
        
53
        public Equipment Equipment { get; set; }
54
        public Document Document { get; set; }
55
        public string Keyword { get; set; }
56
  
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

    
66
    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

    
74
    public class Equipment
75
    {
76
        public Equipment()
77
        {
78
            POINT = new List<double[]>();
79
            Nozzles = new List<Item>();
80
            Attributes = new List<Attribute>();
81
        }
82
        public string Name { get; set; }
83
        public string UID { get; set; }
84
        public List<double[]> POINT { get; set; }
85
        public List<Item> Nozzles { get; set; }
86
        public List<Attribute> Attributes { get; set; }
87
        public string ItemTag { get; set; }
88
    }
89

    
90
    public class LineNumber
91
    {
92
        public LineNumber()
93
        {
94
            Attributes = new List<Attribute>();
95
        }
96
        public string UID { get; set; }
97
        public string Name { get; set; }
98
        public List<Attribute> Attributes { get; set; }
99
        public bool IsCopy { get; set; }
100
        public bool MissingLineNumber1 { get; set; }
101
        public bool MissingLineNumber2 { get; set; }
102

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

    
128
           
129

    
130
            return copy;
131
        }
132
    }
133

    
134
    public class RunInfo 
135
    { 
136
        public RunInfo()
137
        {
138
            Items = new List<Item>();
139
        }
140
        public string UID { get; set; }
141
        public int Index { get; set; }
142
        public List<Item> Items { get; set; }
143
    }
144

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

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

    
198
                        if (Items.Contains(stack))
199
                        {
200
                            sorted.Add(stack);
201
                            foreach (var relation in stack.Relations)
202
                            {
203
                                if (relation.Item == null || !Items.Contains(relation.Item))
204
                                    continue;
205
                                stacks.Push(relation.Item);
206
                            }
207
                        }
208
                    }
209
                }
210

    
211
                if (!sorted.Count.Equals(Items.Count))
212
                    throw new Exception("logic error");
213

    
214
                Items = sorted;
215
            }
216
            else
217
            {
218

    
219
            }
220
        }
221
    }
222

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