프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / ID2PSN / Object / Item.cs @ 8487ecb2

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

1 6b9e7a56 gaqhf
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
7
namespace ID2PSN
8
{
9
    public enum ItemType
10
    {
11
        None,
12
        Symbol,
13
        Line
14
    }
15
    public enum SubItemType
16
    {
17
        None,
18
        OPC,
19
        Header,
20
        Nozzle,
21
    }
22
23
    public class Item
24
    {
25
        public Item()
26
        {
27
            BranchItems = new List<Item>();
28
        }
29
30
        public string UID { get; set; }
31
        public string Type { get; set; }
32
        public string Name { get; set; }
33
        public string Owner { get; set; }
34
        public string Parent { get; set; }
35
        public string ANGLE { get; set; }
36
        public double[] POINT { get; set; }
37
        public List<Relation> Relations { get; set; }
38
        public List<Attribute> Attributes { get; set; }
39
        public ItemType ItemType { get; set; }
40
        public SubItemType SubItemType { get; set; }
41
        public List<Item> BranchItems { get; set; }
42
        public string TopologyData { get; set; }
43 8f24b438 gaqhf
        public string PSNPipeLineID { get; set; }
44 6b9e7a56 gaqhf
        public Topology Topology { get; set; }
45
        public LineNumber LineNumber { get; set; }
46 4c76a67a gaqhf
        public Equipment Equipment { get; set; }
47 6b9e7a56 gaqhf
    }
48
49
    public class Relation 
50
    { 
51
        public string UID { get; set; }
52
        public Item Item { get; set; }
53
        public double[] Point { get; set; }
54
    }
55
    public class Attribute
56
    {
57
        public string UID { get; set; }
58
        public string Name { get; set; }
59
        public string DisplayName { get; set; }
60
        public string Value { get; set; }
61
    }
62
    public class Equipment
63
    {
64
        public Equipment()
65
        {
66
            POINT = new List<double[]>();
67
            Nozzles = new List<Item>();
68
        }
69 4c76a67a gaqhf
        public string Name { get; set; }
70 6b9e7a56 gaqhf
        public string UID { get; set; }
71
        public List<double[]> POINT { get; set; }
72
        public List<Item> Nozzles { get; set; }
73
    }
74
    public class LineNumber
75
    {
76
        public string UID { get; set; }
77
        public string Name { get; set; }
78
        public List<Attribute> Attributes { get; set; }
79
    }
80
81
    public class RunInfo 
82
    { 
83
        public RunInfo()
84
        {
85
            Items = new List<Item>();
86
        }
87
        public string UID { get; set; }
88
        public int Index { get; set; }
89
        public List<Item> Items { get; set; }
90
    }
91
92
    public class Group
93
    {
94
        public Group(Document document)
95
        {
96
            _Document = document;
97
        }
98
        public Group StartGroup { get; set; }
99
        public Group EndGroup { get; set; }
100
        public string UID { get; set; }
101
        public List<Item> Items { get; set; }
102
        private Document _Document;
103
        public Document Document { get { return _Document; } }
104
        public void SortItems()
105
        {
106
            List<Item> sorted = new List<Item>();
107
            Item line = Items.Find(x => x.ItemType == ItemType.Line);
108
            if (line != null)
109
            {
110
                sorted.Add(line);
111
                Item startItem = line.Relations[0].Item;
112
                if (startItem != null)
113
                {
114
                    Stack<Item> stacks = new Stack<Item>();
115
                    stacks.Push(startItem);
116
                    while (stacks.Count > 0)
117
                    {
118
                        Item stack = stacks.Pop();
119
                        if (sorted.Contains(stack))
120
                            continue;
121
122
                        if (Items.Contains(stack))
123
                        {
124
                            sorted.Insert(0, stack); 
125
                            foreach (var relation in stack.Relations)
126
                            {
127
                                if (relation.Item == null || !Items.Contains(relation.Item))
128
                                    continue;
129
                                stacks.Push(relation.Item);
130
                            }
131
                        }
132
                    }
133
                }
134
                Item endItem = line.Relations[1].Item;
135
                if (endItem != null)
136
                {
137
                    Stack<Item> stacks = new Stack<Item>();
138
                    stacks.Push(endItem);
139
                    while (stacks.Count > 0)
140
                    {
141
                        Item stack = stacks.Pop();
142
                        if (sorted.Contains(stack))
143
                            continue;
144
145
                        if (Items.Contains(stack))
146
                        {
147
                            sorted.Add(stack);
148
                            foreach (var relation in stack.Relations)
149
                            {
150
                                if (relation.Item == null || !Items.Contains(relation.Item))
151
                                    continue;
152
                                stacks.Push(relation.Item);
153
                            }
154
                        }
155
                    }
156
                }
157
158
                if (!sorted.Count.Equals(Items.Count))
159
                    throw new Exception("logic error");
160
161
                Items = sorted;
162
            }
163
            else
164
            {
165
166
            }
167
        }
168
    }
169
170
    public class Topology
171
    {
172
        public Topology()
173
        {
174
            Items = new List<Item>();
175
        }
176
        public string ID { get; set; }
177
        public string Type { get; set; }
178
        public string Index { get; set; }
179
        public string FullName { get { return ID + "-" + Type + Index; } }
180
        public List<Item> Items { get; set; }
181
    }
182
}
클립보드 이미지 추가 (최대 크기: 500 MB)