프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

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

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

    
58
    public class Relation 
59
    { 
60
        public string UID { get; set; }
61
        public Item Item { get; set; }
62
        public double[] Point { get; set; }
63
    }
64
    public class Attribute
65
    {
66
        public string UID { get; set; }
67
        public string Name { get; set; }
68
        public string DisplayName { get; set; }
69
        public string Value { get; set; }
70
    }
71
    public class Equipment
72
    {
73
        public Equipment()
74
        {
75
            POINT = new List<double[]>();
76
            Nozzles = new List<Item>();
77
            Attributes = new List<Attribute>();
78
        }
79
        public string Name { get; set; }
80
        public string UID { get; set; }
81
        public List<double[]> POINT { get; set; }
82
        public List<Item> Nozzles { get; set; }
83
        public List<Attribute> Attributes { get; set; }
84
        public string ItemTag { get; set; }
85
    }
86
    public class LineNumber
87
    {
88
        public LineNumber()
89
        {
90
            Attributes = new List<Attribute>();
91
        }
92
        public string UID { get; set; }
93
        public string Name { get; set; }
94
        public List<Attribute> Attributes { get; set; }
95
        public bool IsCopy { get; set; }
96

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

    
122
           
123

    
124
            return copy;
125
        }
126
    }
127

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

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

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

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

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

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

    
213
            }
214
        }
215
    }
216

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