개정판 f1c9dbaa
dev issue #000 : ID2 Line Number 기준 모델링 및 Equipment, EndBreak 구별
Change-Id: Ifd40906e19bbee1579306fb7620cc739d4268916
DTI_PID/SPPIDConverter/Model/SPPID_Document.cs | ||
---|---|---|
3 | 3 |
using System.Linq; |
4 | 4 |
using System.Text; |
5 | 5 |
using System.Threading.Tasks; |
6 |
using System.Data; |
|
6 | 7 |
using Converter.BaseModel; |
7 | 8 |
using Converter.SPPID.Util; |
8 | 9 |
|
... | ... | |
12 | 13 |
{ |
13 | 14 |
public SPPID_Document(string xmlPath) : base(xmlPath) |
14 | 15 |
{ |
15 |
|
|
16 |
|
|
16 | 17 |
} |
17 | 18 |
|
18 | 19 |
private double testX = 0.855; |
... | ... | |
24 | 25 |
public List<AssociationMapping> AssociationMappings; |
25 | 26 |
public ETCSetting ETCSetting; |
26 | 27 |
|
27 |
private List<Group> GROUPS { get; set; }
|
|
28 |
public List<Group> GROUPS = new List<Group>();
|
|
28 | 29 |
|
29 | 30 |
public string DrawingName { get; set; } |
30 | 31 |
public string DrawingNumber { get; set; } |
... | ... | |
85 | 86 |
return true; |
86 | 87 |
} |
87 | 88 |
|
88 |
//#region Grouping Source |
|
89 |
//private void SetGrouping() |
|
90 |
//{ |
|
91 |
// try |
|
92 |
// { |
|
93 |
// // Line 기준으로 묶음 |
|
94 |
// foreach (Line item in LINES) |
|
95 |
// if (!item.SPPID.IsGroup) |
|
96 |
// SetGroupingByItem(item); |
|
97 |
// // End |
|
98 |
|
|
99 |
// // Symbol 기준으로 묶음 |
|
100 |
// foreach (Symbol item in SYMBOLS) |
|
101 |
// if (!item.SPPID.IsGroup) |
|
102 |
// SetGroupingByItem(item); |
|
103 |
// // End |
|
104 |
// } |
|
105 |
// catch (Exception ex) |
|
106 |
// { |
|
107 |
|
|
108 |
// } |
|
109 |
//} |
|
110 |
|
|
111 |
//private void SetGroupingByItem(object item) |
|
112 |
//{ |
|
113 |
// try |
|
114 |
// { |
|
115 |
// Group group = new Group(); |
|
116 |
// group.Items.Add(item); |
|
117 |
// bool forward = true; |
|
118 |
// SetGroupingByConnectedItem(item, group.Items, ref forward); |
|
119 |
|
|
120 |
// GROUPS.Add(group); |
|
121 |
// } |
|
122 |
// catch (Exception ex) |
|
123 |
// { |
|
124 |
|
|
125 |
// } |
|
126 |
//} |
|
127 |
|
|
128 |
//private void SetGroupingByConnectedItem(object item, List<object> list, ref bool IsForward) |
|
129 |
//{ |
|
130 |
// try |
|
131 |
// { |
|
132 |
// if (typeof(Line) == item.GetType()) |
|
133 |
// { |
|
134 |
// Line line = item as Line; |
|
135 |
// line.SPPID.IsGroup = true; |
|
136 |
// SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, line.CONNECTORS); |
|
137 |
// } |
|
138 |
// else if (typeof(Symbol) == item.GetType()) |
|
139 |
// { |
|
140 |
// Symbol symbol = item as Symbol; |
|
141 |
// symbol.SPPID.IsGroup = true; |
|
142 |
// // Symbol의 경우 BaseSymbol Connector가 2개 이하때 진행 / 나머지는 Grouping 종료 |
|
143 |
// if (symbol.CONNECTORS.Count <= 2) |
|
144 |
// { |
|
145 |
// SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, symbol.CONNECTORS); |
|
146 |
// } |
|
147 |
// } |
|
148 |
// IsForward = false; |
|
149 |
// } |
|
150 |
// catch (Exception ex) |
|
151 |
// { |
|
152 |
|
|
153 |
// } |
|
154 |
//} |
|
155 |
|
|
156 |
//private int GetChildConnectorCount(Symbol symbol) |
|
157 |
//{ |
|
158 |
// int count = 0; |
|
159 |
// foreach (var childSymbol in symbol.ChildSymbols) |
|
160 |
// { |
|
161 |
// GetChildConnectorCountLoop(childSymbol, ref count); |
|
162 |
// } |
|
163 |
|
|
164 |
// return count; |
|
165 |
//} |
|
166 |
|
|
167 |
//private void GetChildConnectorCountLoop(ChildSymbol childSymbol, ref int count) |
|
168 |
//{ |
|
169 |
// count = count + childSymbol.Connectors.Count; |
|
170 |
|
|
171 |
// foreach (var child in childSymbol.ChildSymbols) |
|
172 |
// { |
|
173 |
// GetChildConnectorCountLoop(child, ref count); |
|
174 |
// } |
|
175 |
//} |
|
176 |
|
|
177 |
//private void SetGroupingByConnectedItem_ConnectorsLogic(object item, List<object> list, ref bool IsForward, List<Connector> connectors) |
|
178 |
//{ |
|
179 |
// foreach (Connector connector in connectors) |
|
180 |
// { |
|
181 |
// object connItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM); |
|
182 |
// if (connItem != null) |
|
183 |
// { |
|
184 |
// bool result = false; |
|
185 |
// if (typeof(Line) == connItem.GetType()) |
|
186 |
// { |
|
187 |
// Line connLine = connItem as Line; |
|
188 |
// // 연결되는 Item이 전부 Line일 경우 Branch, Line Type을 확인 |
|
189 |
// if (item.GetType() == connLine.GetType() && |
|
190 |
// (SPPIDUtil.IsBranchLine(((Line)item).UID, connLine) || item.SPPIDMAPPINGNAME != connLine.SPPIDMAPPINGNAME)) |
|
191 |
// continue; |
|
192 |
|
|
193 |
// result = true; |
|
194 |
// } |
|
195 |
// else if (typeof(Symbol) == connItem.GetType()) |
|
196 |
// { |
|
197 |
// Symbol connSymbol = connItem as Symbol; |
|
198 |
// // 연결되는 Symbol의 Connector가 부가 심볼일 경우는 result = false |
|
199 |
// foreach (Connector symbolConnector in connSymbol.CONNECTORS) |
|
200 |
// { |
|
201 |
// if (symbolConnector.CONNECTEDITEM == item.UID) |
|
202 |
// { |
|
203 |
// if (symbolConnector.INDEX == 0) |
|
204 |
// result = true; |
|
205 |
// else |
|
206 |
// result = false; |
|
207 |
// break; |
|
208 |
// } |
|
209 |
// } |
|
210 |
// } |
|
211 |
|
|
212 |
// if (!connItem.GROUPING && result) |
|
213 |
// { |
|
214 |
// if (IsForward) |
|
215 |
// list.Add(connItem); |
|
216 |
// else |
|
217 |
// list.Insert(0, connItem); |
|
218 |
// SetGroupingByConnectedItem(connItem, list, ref IsForward); |
|
219 |
// } |
|
220 |
// } |
|
221 |
// } |
|
222 |
//} |
|
223 |
|
|
224 |
//private bool IsChildConnector(Symbol symol, Connector connector) |
|
225 |
//{ |
|
226 |
// bool result = false; |
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
// return result; |
|
232 |
//} |
|
233 |
//#endregion |
|
89 |
#region Grouping Source |
|
90 |
private bool SetGrouping() |
|
91 |
{ |
|
92 |
try |
|
93 |
{ |
|
94 |
// Line 기준으로 묶음 |
|
95 |
foreach (Line item in LINES) |
|
96 |
if (!item.SPPID.IsGroup) |
|
97 |
SetGroupingByItem(item); |
|
98 |
// End |
|
99 |
|
|
100 |
// Symbol 기준으로 묶음 |
|
101 |
foreach (Symbol item in SYMBOLS) |
|
102 |
if (!item.SPPID.IsGroup) |
|
103 |
SetGroupingByItem(item); |
|
104 |
// End |
|
105 |
} |
|
106 |
catch (Exception ex) |
|
107 |
{ |
|
108 |
return false; |
|
109 |
} |
|
110 |
return true; |
|
111 |
} |
|
112 |
|
|
113 |
private void SetGroupingByItem(object item) |
|
114 |
{ |
|
115 |
Group group = new Group(); |
|
116 |
group.Items.Add(item); |
|
117 |
bool forward = true; |
|
118 |
SetGroupingByConnectedItem(item, group.Items, ref forward); |
|
119 |
|
|
120 |
GROUPS.Add(group); |
|
121 |
} |
|
122 |
|
|
123 |
private void SetGroupingByConnectedItem(object item, List<object> list, ref bool IsForward) |
|
124 |
{ |
|
125 |
if (typeof(Line) == item.GetType()) |
|
126 |
{ |
|
127 |
Line line = item as Line; |
|
128 |
line.SPPID.IsGroup = true; |
|
129 |
SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, line.CONNECTORS); |
|
130 |
} |
|
131 |
else if (typeof(Symbol) == item.GetType()) |
|
132 |
{ |
|
133 |
Symbol symbol = item as Symbol; |
|
134 |
symbol.SPPID.IsGroup = true; |
|
135 |
// Symbol의 경우 BaseSymbol Connector가 2개 이하때 진행 / 나머지는 Grouping 종료 |
|
136 |
int baseSymbolCount = 0; |
|
137 |
if (symbol.CONNECTORS.Count > 0) |
|
138 |
{ |
|
139 |
foreach (Connector symbolConnector in symbol.CONNECTORS) |
|
140 |
if (symbolConnector.Index == 0) |
|
141 |
baseSymbolCount++; |
|
142 |
|
|
143 |
if (baseSymbolCount <= 2) |
|
144 |
SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, symbol.CONNECTORS); |
|
145 |
} |
|
146 |
} |
|
147 |
IsForward = false; |
|
148 |
} |
|
149 |
|
|
150 |
private void SetGroupingByConnectedItem_ConnectorsLogic(object item, List<object> list, ref bool IsForward, List<Connector> connectors) |
|
151 |
{ |
|
152 |
foreach (Connector connector in connectors) |
|
153 |
{ |
|
154 |
object connItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM); |
|
155 |
if (connItem != null) |
|
156 |
{ |
|
157 |
bool result = false; |
|
158 |
if (typeof(Line) == connItem.GetType()) |
|
159 |
{ |
|
160 |
Line connLine = connItem as Line; |
|
161 |
// 연결되는 Item이 전부 Line일 경우 Branch, Line Type을 확인 |
|
162 |
if (item.GetType() == connLine.GetType()) |
|
163 |
{ |
|
164 |
Line line = item as Line; |
|
165 |
if (SPPIDUtil.IsBranchLine(line.UID, connLine) || line.SPPID.MAPPINGNAME != connLine.SPPID.MAPPINGNAME) |
|
166 |
continue; |
|
167 |
} |
|
168 |
|
|
169 |
result = true; |
|
170 |
} |
|
171 |
else if (typeof(Symbol) == connItem.GetType()) |
|
172 |
{ |
|
173 |
Symbol connSymbol = connItem as Symbol; |
|
174 |
// 연결되는 Symbol의 Connector가 부가 심볼일 경우는 result = false |
|
175 |
foreach (Connector symbolConnector in connSymbol.CONNECTORS) |
|
176 |
{ |
|
177 |
string itemUID = item as Symbol != null ? ((Symbol)item).UID : ((Line)item).UID; |
|
178 |
|
|
179 |
if (symbolConnector.CONNECTEDITEM == itemUID) |
|
180 |
{ |
|
181 |
if (symbolConnector.Index == 0) |
|
182 |
result = true; |
|
183 |
else |
|
184 |
result = false; |
|
185 |
break; |
|
186 |
} |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
if (!(connItem as Symbol != null ? ((Symbol)connItem).SPPID.IsGroup : ((Line)connItem).SPPID.IsGroup) && result) |
|
191 |
{ |
|
192 |
if (IsForward) |
|
193 |
list.Add(connItem); |
|
194 |
else |
|
195 |
list.Insert(0, connItem); |
|
196 |
SetGroupingByConnectedItem(connItem, list, ref IsForward); |
|
197 |
} |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
201 |
#endregion |
|
234 | 202 |
} |
235 | 203 |
} |
내보내기 Unified diff