hytos / DTI_PID / SPPIDConverter / Main.vb @ 14297268
이력 | 보기 | 이력해설 | 다운로드 (135 KB)
1 | 4f359afa | Gyusu | Imports System.IO |
---|---|---|---|
2 | Imports System.Data.SqlClient |
||
3 | Imports System.Data.SQLite |
||
4 | Imports Plaice |
||
5 | Imports Llama |
||
6 | Imports PidA |
||
7 | 962b2464 | Gyusu | |
8 | e282643f | Gyusu | |
9 | Imports System.Threading |
||
10 | |||
11 | 4f359afa | Gyusu | Public Class Main |
12 | |||
13 | 54b98e09 | Gyusu | 'Dim _Mapping_DB As DataTable = New DataTable() |
14 | Dim _Mapping_DB As DataSet = New DataSet() |
||
15 | 171ac39d | Gyusu | Dim _Attribute_DB As DataTable = New DataTable() |
16 | 39d43554 | Gyusu | Dim _PIDSymbol_DB As DataTable = New DataTable() |
17 | e4000111 | Gyusu | Dim _ResultModeling_DT As DataTable = New DataTable() |
18 | |||
19 | |||
20 | 4f359afa | Gyusu | Dim _Placement As New Placement |
21 | e4000111 | Gyusu | Dim _DWG_X = 0.875 '0.695 '1 ' |
22 | Dim _DWG_Y = 0.617 '0.585 '0.8 ' |
||
23 | c2c36314 | Gyusu | 'Dim _DWG_X = 0.842 '0.695 '1 ' |
24 | 'Dim _DWG_Y = 0.614 '0.585 '0.8 ' |
||
25 | 171ac39d | Gyusu | Dim _IMG_X = 0 |
26 | Dim _IMG_Y = 0 |
||
27 | |||
28 | Dim _Unit As String |
||
29 | 4f359afa | Gyusu | |
30 | 31d47a80 | Gyusu | 'Drawing 전역변수 |
31 | Dim _objPIDADrawing As Object |
||
32 | e282643f | Gyusu | '현재선택한 폴더경로 |
33 | Dim _selectFolderPath As String |
||
34 | |||
35 | Private _Main_trd As Thread |
||
36 | 54b98e09 | Gyusu | Private _Opc_trd As Thread |
37 | |||
38 | Private _CompleteConvert As Boolean = False |
||
39 | e282643f | Gyusu | |
40 | 171ac39d | Gyusu | Private _DrawingsList As List(Of Drawing) |
41 | 272662f9 | Gyusu | |
42 | |||
43 | 9e1e7135 | Gyusu | Private _iPipeLineNocnt As Integer |
44 | Private _iPipecnt As Integer |
||
45 | Private _iFittingcnt As Integer |
||
46 | Private _iValvecnt As Integer |
||
47 | Private _iInstrumentcnt As Integer |
||
48 | Private _iEquipmentcnt As Integer |
||
49 | Private _iNozzlecnt As Integer |
||
50 | e4000111 | Gyusu | Private _iPipintOpccnt As Integer |
51 | 9e1e7135 | Gyusu | |
52 | 54b98e09 | Gyusu | Dim _Gembox As New CGembox() |
53 | 41e4023e | Gyusu | |
54 | |||
55 | Private _allItem As Integer |
||
56 | Private _Itemcnt As Integer |
||
57 | 4f359afa | Gyusu | Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load |
58 | 54b98e09 | Gyusu | LoadDB() |
59 | End Sub |
||
60 | 272662f9 | Gyusu | |
61 | 54b98e09 | Gyusu | Private Sub LoadDB() |
62 | e282643f | Gyusu | If My.Settings.DBPath <> "" And My.Settings.Plant_Hierarchy <> "" Then |
63 | Dim sDBPath As String = My.Settings.DBPath |
||
64 | 54b98e09 | Gyusu | |
65 | _Gembox.isLoadFile(My.Settings.SymbolLibrary) |
||
66 | _Mapping_DB = _Gembox.LoadFileFunc() |
||
67 | ' _Mapping_DB = Load_DB(sDBPath, _DB_TABLE_MAPPING) |
||
68 | 171ac39d | Gyusu | _Attribute_DB = Load_DB(sDBPath, _DB_TABLE_ATTRIBUTE) |
69 | 39d43554 | Gyusu | _PIDSymbol_DB = Load_DB(sDBPath, _DB_TABLE_SYMBOLNAME) |
70 | e4000111 | Gyusu | _ResultModeling_DT = ModelingResult_Dt() |
71 | 6a6d8ab4 | Gyusu | 'TestPID() |
72 | 'OpenDrawing() |
||
73 | e282643f | Gyusu | Else |
74 | MessageBox.Show("설정값을 먼저 확인해주세요") |
||
75 | End If |
||
76 | End Sub |
||
77 | 41e4023e | Gyusu | |
78 | e282643f | Gyusu | Public Function GetDrawingInfo(ByVal errorList As ArrayList) |
79 | Dim ds As Llama.LMADataSource |
||
80 | ds = New Llama.LMADataSource |
||
81 | Dim lmaItem As Llama.LMAItem |
||
82 | For i = 0 To errorList.Count - 1 |
||
83 | lmaItem = ds.GetModelItem(errorList.Item(i).m_strSPID()).AsLMAItem |
||
84 | Dim drawingInfo As DrawingInfo |
||
85 | drawingInfo = GetDrawingName(lmaItem.ItemType, lmaItem.Id) |
||
86 | errorList.Item(i).m_LMAItem = lmaItem |
||
87 | errorList.Item(i).m_strDrawingName = drawingInfo.mDrawingName |
||
88 | errorList.Item(i).m_strDrawingPath = drawingInfo.mPath |
||
89 | Next |
||
90 | End Function |
||
91 | Private mDataSource As Object |
||
92 | |||
93 | 'Public Sub New() |
||
94 | |||
95 | ' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName |
||
96 | ' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI |
||
97 | ' 'm_Information = SPPIDClass.Information.GetInstance() |
||
98 | |||
99 | ' 'If m_Information.InfoProject.ProjectVersion = SPPIDClass.InfoProject.SPPID_43 Then |
||
100 | ' ' 'SPPID4.3용 |
||
101 | ' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName |
||
102 | ' 'Else |
||
103 | ' ' 'SPPID2007, SPPID2009용 |
||
104 | ' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName |
||
105 | ' 'End If |
||
106 | |||
107 | ' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI |
||
108 | ' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName |
||
109 | ' '#If LATE_BINDING Then |
||
110 | ' ' mInstruments = CreateObject("Llama.LMInstruments", "") |
||
111 | ' ' mPipingComps = CreateObject("Llama.LMPipingComps", "") |
||
112 | ' ' mVessels = CreateObject("Llama.LMVessels", "") |
||
113 | ' ' mDrawings = CreateObject("Llama.LMDrawings", "") |
||
114 | ' ' mEquipments = CreateObject("Llama.LMEquipments", "") |
||
115 | ' ' mExchangers = CreateObject("Llama.LMExchangers", "") |
||
116 | ' ' mMechanicals = CreateObject("Llama.LMMechanicals", "") |
||
117 | ' ' mNozzles = CreateObject("Llama.LMNozzles", "") |
||
118 | ' ' mPipeRuns = CreateObject("Llama.LMPipeRuns", "") |
||
119 | ' ' mEquipmentOthers = CreateObject("Llama.LMEquipmentOthers", "") |
||
120 | ' '#Else |
||
121 | ' ' mInstruments = New Llama.LMInstruments |
||
122 | ' ' mPipingComps = New Llama.LMPipingComps |
||
123 | ' ' mVessels = New Llama.LMVessels |
||
124 | ' ' mDrawings = New Llama.LMDrawings |
||
125 | ' ' mEquipments = New Llama.LMEquipments |
||
126 | ' ' mExchangers = New Llama.LMExchangers |
||
127 | ' ' mMechanicals = New Llama.LMMechanicals |
||
128 | ' ' mNozzles = New Llama.LMNozzles |
||
129 | ' ' mPipeRuns = New Llama.LMPipeRuns |
||
130 | ' ' mEquipmentOthers = New Llama.LMEquipmentOthers |
||
131 | ' '#End If |
||
132 | 'End Sub |
||
133 | 559daf6d | Gyusu | |
134 | Function OpenDrawing() |
||
135 | Dim datasource As LMADataSource |
||
136 | Dim objPIDAutoApp As Object |
||
137 | Dim objPIDADrawing As Object |
||
138 | Dim objDrawing As LMDrawing |
||
139 | Dim objDrawings As LMDrawings |
||
140 | datasource = New Llama.LMADataSource |
||
141 | objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
142 | objDrawings = New Llama.LMDrawings 'New LMDrawings |
||
143 | b6996671 | Gyusu | datasource.SiteNode = "\\desktop-9vlq0dp\Test03Site\smartplantv4.ini" |
144 | 559daf6d | Gyusu | datasource.ProjectNumber = "SBR_PBR" |
145 | objDrawings.Collect(datasource) |
||
146 | |||
147 | For Each objDrawing In objDrawings |
||
148 | If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
||
149 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
||
150 | If Not objPIDADrawing Is Nothing Then |
||
151 | 'MsgBox "Drawing " & objDrawing.Attributes("Name").Value & " is opened!" |
||
152 | objPIDADrawing.CloseDrawing |
||
153 | End If |
||
154 | End If |
||
155 | Next |
||
156 | objPIDAutoApp.Quit |
||
157 | objPIDAutoApp = Nothing |
||
158 | objPIDADrawing = Nothing |
||
159 | objDrawing = Nothing |
||
160 | objDrawings = Nothing |
||
161 | End Function |
||
162 | |||
163 | |||
164 | e282643f | Gyusu | Public Function GetDrawingName(ByVal itemType As String, ByVal itemName As String) As DrawingInfo |
165 | |||
166 | Dim objFilter As Object |
||
167 | objFilter = CreateObject("Llama.LMAFilter", "") |
||
168 | |||
169 | Dim drawingInfo As DrawingInfo |
||
170 | drawingInfo = New DrawingInfo |
||
171 | |||
172 | objFilter.Criteria.AddNew("FirstOne") |
||
173 | objFilter.Criteria.Item("FirstOne").SourceAttributeName = "SP_ID" |
||
174 | objFilter.Critedkria.Item("FirstOne").ValueAttribute = itemName |
||
175 | |||
176 | objFilter.Criteria.Item("FirstOne").Operator = "=" |
||
177 | objFilter.Criteria.AddNew("SecondOne") |
||
178 | objFilter.Criteria.Item("SecondOne").SourceAttributeName = "ItemStatus" |
||
179 | objFilter.Criteria.Item("SecondOne").ValueAttribute = 1 |
||
180 | objFilter.Criteria.Item("SecondOne").Operator = "=" |
||
181 | objFilter.Criteria.Item("SecondOne").Conjunctive = -1 |
||
182 | objFilter.ItemType = itemType |
||
183 | |||
184 | Dim PlantItems As Object |
||
185 | PlantItems = CreateObject("Llama.LMPlantItems", "") |
||
186 | PlantItems.Collect(mDataSource, Filter:=objFilter) |
||
187 | |||
188 | If PlantItems.Count = 0 Then |
||
189 | drawingInfo.mSpID = "PlantStockpile" |
||
190 | End If |
||
191 | |||
192 | For Each PlantItem In PlantItems |
||
193 | |||
194 | 'If Not PlantItem.Representations.Nth(1).DrawingID.Value.ToString().Equals("0") Then |
||
195 | Try |
||
196 | drawingInfo.mDrawingName = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Name").Value |
||
197 | drawingInfo.mSpID = PlantItem.Representations.Nth(1).DrawingID |
||
198 | drawingInfo.mPath = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Path").Value |
||
199 | Debug.WriteLine("DrawingName : " & drawingInfo.mDrawingName & ", SPID : " & drawingInfo.mSpID & ", Path : " & drawingInfo.mPath) |
||
200 | Catch ex As Exception |
||
201 | |||
202 | End Try |
||
203 | |||
204 | 'End If |
||
205 | |||
206 | Next |
||
207 | |||
208 | Return drawingInfo |
||
209 | |||
210 | End Function |
||
211 | |||
212 | Private Sub TestPID() |
||
213 | Try |
||
214 | 6a6d8ab4 | Gyusu | Const CONST_SPID_OPC As String = "426E89964A7F49208AD79E1F320DA251" |
215 | e282643f | Gyusu | Dim datasource As LMADataSource |
216 | Dim objPIDAutoApp As Object |
||
217 | Dim objPIDADrawing As Object |
||
218 | Dim objDrawing As LMDrawing |
||
219 | Dim objDrawings As LMDrawings |
||
220 | datasource = New LMADataSource |
||
221 | 6a6d8ab4 | Gyusu | Dim objOPC As LMOPC |
222 | Dim objpairOPC As LMOPC |
||
223 | objOPC = datasource.GetOPC(CONST_SPID_OPC) |
||
224 | objpairOPC = objOPC.pairedWithOPCObject |
||
225 | e282643f | Gyusu | Dim oObj As Object = Nothing |
226 | objDrawing = datasource.GetDrawing(oObj) |
||
227 | objDrawings = New LMDrawings |
||
228 | objDrawings.Collect(datasource) |
||
229 | objPIDAutoApp = GetObject(, "SmartPlantPID.Application") '// CreateObject("PIDAutomation.Application") |
||
230 | For Each objDrawing In objDrawings |
||
231 | If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
||
232 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
||
233 | If Not objPIDADrawing Is Nothing Then |
||
234 | MessageBox.Show("Drawing " & objDrawing.Attributes("Name").Value & " is opened!") |
||
235 | objPIDADrawing.CloseDrawing |
||
236 | End If |
||
237 | End If |
||
238 | Next |
||
239 | objPIDAutoApp.Quit |
||
240 | objPIDAutoApp = Nothing |
||
241 | objPIDADrawing = Nothing |
||
242 | objDrawing = Nothing |
||
243 | objDrawings = Nothing |
||
244 | Catch ex As Exception |
||
245 | End Try |
||
246 | 962b2464 | Gyusu | End Sub |
247 | e282643f | Gyusu | |
248 | b6996671 | Gyusu | Public Function SetActiveSiteFromConfigInfo(ByVal strActiveSite As String) As Boolean |
249 | e282643f | Gyusu | On Error GoTo errHandler |
250 | Dim objConfigInfo As Object 'interopigrConfigInfo412.igrConfigInfo |
||
251 | objConfigInfo = CreateObject("interopigrConfigInfo412.igrConfigInfo", "") |
||
252 | If Not objConfigInfo Is Nothing Then |
||
253 | objConfigInfo.ApplicationName = "SmartPlantManager" |
||
254 | objConfigInfo.SetConfigString(3, "SmartPlant Manager", "SiteServer", strActiveSite) |
||
255 | SetActiveSiteFromConfigInfo = True |
||
256 | End If |
||
257 | objConfigInfo = Nothing |
||
258 | Exit Function |
||
259 | errHandler: |
||
260 | ' LogAndRaiseError ModuleName & "::GetConfigInfo " |
||
261 | End Function |
||
262 | 4f359afa | Gyusu | |
263 | 1229ad76 | Gyusu | Private Function CreateDwg(ByVal oDwgName As String) As Boolean |
264 | Dim objPIDADrawing As Object = Nothing |
||
265 | Dim objPIDAutoApp As Object = Nothing |
||
266 | Dim datasource As LMADataSource = Nothing |
||
267 | 4f359afa | Gyusu | Try |
268 | Dim DrawingNumber As String |
||
269 | Dim DrawingName As String |
||
270 | 1229ad76 | Gyusu | Dim sPlantGroupName As String = "Test" |
271 | Dim sTemplateName As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\P&ID Reference Data\Template Files\Gazprom Project.pid" |
||
272 | Dim objDrawing As LMDrawing |
||
273 | Dim objDrawings As LMDrawings |
||
274 | objDrawings = New LMDrawings |
||
275 | datasource = New LMADataSource |
||
276 | Debug.Print(datasource.ProjectNumber) |
||
277 | Debug.Print(datasource.SiteNode) |
||
278 | Debug.Print(datasource.IsSatellite) |
||
279 | Debug.Print(datasource.GetSystemEditingToolbarSetting) |
||
280 | objDrawings.Collect(datasource) |
||
281 | Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid" |
||
282 | objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
283 | 54b98e09 | Gyusu | |
284 | 1229ad76 | Gyusu | For Each objDrawing In objDrawings |
285 | If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
||
286 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(sPath) |
||
287 | If Not objPIDADrawing Is Nothing Then |
||
288 | objPIDADrawing.CloseDrawing |
||
289 | End If |
||
290 | End If |
||
291 | Next |
||
292 | 4f359afa | Gyusu | |
293 | Dim extension As String = Path.GetExtension(oDwgName) |
||
294 | oDwgName = oDwgName.Replace(extension, "") |
||
295 | 1229ad76 | Gyusu | |
296 | 4f359afa | Gyusu | objPIDAutoApp = CreateObject("PIDAutomation.Application") |
297 | 1229ad76 | Gyusu | |
298 | 'For Each objDrawing In objPIDAutoApp.Drawings |
||
299 | ' objDrawing.CloseDrawing(True) |
||
300 | 'Next |
||
301 | |||
302 | objPIDAutoApp.Drawings.OpenDrawing(oDwgName + ".pid") |
||
303 | |||
304 | objPIDAutoApp.ActiveWindow.Fit() |
||
305 | |||
306 | Return True |
||
307 | Catch ex As Exception |
||
308 | If objPIDADrawing IsNot Nothing Then |
||
309 | 4f359afa | Gyusu | objPIDADrawing.CloseDrawing |
310 | End If |
||
311 | 1229ad76 | Gyusu | If objPIDAutoApp IsNot Nothing Then |
312 | objPIDAutoApp.Quit |
||
313 | End If |
||
314 | datasource = Nothing |
||
315 | 4f359afa | Gyusu | objPIDAutoApp = Nothing |
316 | objPIDADrawing = Nothing |
||
317 | Return False |
||
318 | End Try |
||
319 | 1229ad76 | Gyusu | If objPIDADrawing IsNot Nothing Then |
320 | objPIDADrawing.CloseDrawing |
||
321 | End If |
||
322 | 4f359afa | Gyusu | |
323 | End Function |
||
324 | |||
325 | 1229ad76 | Gyusu | |
326 | 171ac39d | Gyusu | Private Function GetDataFromMappingDB(ByVal sSymbolName As String, ByVal sColumn As String) As String |
327 | Dim sValue As String = "" |
||
328 | 54b98e09 | Gyusu | For Each oDt As DataTable In _Mapping_DB.Tables |
329 | If oDt.Rows.Count > 0 Then |
||
330 | Dim oSelectRow() As DataRow = oDt.Select("[img_symbolname] = '" + sSymbolName + "'") |
||
331 | If oSelectRow.Length = 1 Then |
||
332 | If sColumn = _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME Then |
||
333 | sValue = oSelectRow(0).Item("SYM FILE NAME").ToString() |
||
334 | ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH Then |
||
335 | sValue = "\" & oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString() |
||
336 | ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_COMPTPYE Then |
||
337 | sValue = oSelectRow(0).Item("ITEM TYPE").ToString() |
||
338 | ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_CLASS Then |
||
339 | sValue = oSelectRow(0).Item("CLASS").ToString() |
||
340 | Else |
||
341 | sValue = oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString() |
||
342 | End If |
||
343 | |||
344 | End If |
||
345 | e282643f | Gyusu | End If |
346 | 54b98e09 | Gyusu | Next |
347 | |||
348 | 171ac39d | Gyusu | Return sValue |
349 | 4f359afa | Gyusu | End Function |
350 | |||
351 | 171ac39d | Gyusu | Private Function GetAttributeMapping(ByVal sAttributeName As String, ByVal sColumn As String) As String |
352 | Dim sSPPIDAttribute As String = "" |
||
353 | If _Attribute_DB.Rows.Count > 0 Then |
||
354 | Dim oSelectRow() As DataRow = _Attribute_DB.Select("[pid_attribute] = '" + sAttributeName + "'") |
||
355 | If oSelectRow.Length = 1 Then |
||
356 | sSPPIDAttribute = oSelectRow(0).Item(sColumn).ToString() |
||
357 | End If |
||
358 | End If |
||
359 | Return sSPPIDAttribute |
||
360 | End Function |
||
361 | e282643f | Gyusu | |
362 | d039e347 | Gyusu | ' Dim _TempSymbolDt As DataTable = Symbol_Dt() |
363 | 6a6d8ab4 | Gyusu | |
364 | |||
365 | 171ac39d | Gyusu | Private Function LoadSymbolInXml(ByVal sXmlPath As String) As Drawing |
366 | 54b98e09 | Gyusu | Try |
367 | '' _TempSymbolDt = Symbol_Dt() |
||
368 | Dim CDrawing As Drawing = New Drawing() |
||
369 | Dim oDt As DataTable = LoadSymbol_DT() |
||
370 | Dim oElement As XElement = XElement.Load(sXmlPath) |
||
371 | 6a6d8ab4 | Gyusu | |
372 | 54b98e09 | Gyusu | If oElement IsNot Nothing Then |
373 | CDrawing.DwgName = oElement.Element(_XML_DWGNAME).Value |
||
374 | CDrawing.Size = oElement.Element(_XML_DWGSIZE).Value |
||
375 | SplitLocation(CDrawing.Size, _IMG_X, _IMG_Y) |
||
376 | CDrawing.Unit = oElement.Element(_XML_UNIT).Value |
||
377 | 171ac39d | Gyusu | |
378 | 54b98e09 | Gyusu | Dim oLineno_list As New List(Of Line_no) |
379 | Dim oEqp_list As New List(Of Eqp_no) |
||
380 | 3acffcee | Gyusu | Dim oTrim_Lineno_list As New List(Of Line_no) |
381 | oLineno_list = LoadLineNo(oElement, _XML_CATEGORY_LINENO) |
||
382 | 54b98e09 | Gyusu | For Each oEqpNo As Object In oElement.Elements(_XML_CATEGORY_EQUIPMENT) |
383 | Dim CEqp_no As Eqp_no = New Eqp_no() |
||
384 | Dim oSymbol_Dt As DataTable = Symbol_Dt() |
||
385 | Dim oAttribute_Dt As DataTable = Attribute_Dt() |
||
386 | 41e4023e | Gyusu | Dim sUid As String |
387 | 54b98e09 | Gyusu | For Each oSymbol As Object In oEqpNo.Elements(_XML_CATEGORY_SYMBOL) |
388 | Try |
||
389 | Dim oAddrow As DataRow = oSymbol_Dt.NewRow() |
||
390 | Dim oEleObj As XElement |
||
391 | Dim sName As String |
||
392 | Dim sLocation As String |
||
393 | Dim sSize As String |
||
394 | Dim sAngle As String |
||
395 | Dim sOriginalPoint As String = "" |
||
396 | e4000111 | Gyusu | Dim sConnectionPoint As String = "" |
397 | 54b98e09 | Gyusu | oEleObj = oSymbol.Element(_XML_SYMBOL_UID) |
398 | sUid = oEleObj.Value |
||
399 | oEleObj = oSymbol.Element(_XML_SYMBOL_NAME) |
||
400 | sName = oEleObj.Value |
||
401 | oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
||
402 | sLocation = oEleObj.Value |
||
403 | oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE) |
||
404 | sSize = oEleObj.Value |
||
405 | oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
||
406 | sAngle = oEleObj.Value |
||
407 | e4000111 | Gyusu | oEleObj = oSymbol.Element(_XML_SYMBOL_CONNECTIONPOINT) |
408 | sConnectionPoint = oEleObj.Value |
||
409 | 54b98e09 | Gyusu | Try |
410 | oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT) |
||
411 | sOriginalPoint = oEleObj.Value |
||
412 | Catch ex As Exception |
||
413 | End Try |
||
414 | oAddrow(_XML_SYMBOL_UID) = sUid |
||
415 | oAddrow(_XML_SYMBOL_NAME) = sName |
||
416 | oAddrow(_XML_SYMBOL_LOCATION) = sLocation |
||
417 | oAddrow(_XML_SYMBOL_SIZE) = sSize |
||
418 | oAddrow(_XML_SYMBOL_ANGLE) = sAngle |
||
419 | oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
420 | oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE) |
||
421 | oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint |
||
422 | e4000111 | Gyusu | oAddrow(_XML_SYMBOL_CONNECTIONPOINT) = sConnectionPoint |
423 | oAddrow(_XML_SYMBOL_DRAWING_TF) = "FALSE" |
||
424 | 54b98e09 | Gyusu | oSymbol_Dt.Rows.Add(oAddrow) |
425 | Catch ex As Exception |
||
426 | |||
427 | End Try |
||
428 | d039e347 | Gyusu | Next |
429 | 54b98e09 | Gyusu | For Each oAtrribute As Object In oEqpNo.Elements(_XML_CATEGORY_ATTRIBUTE) |
430 | Try |
||
431 | Dim oAddrow As DataRow = oAttribute_Dt.NewRow() |
||
432 | Dim oEleObj As XElement |
||
433 | 41e4023e | Gyusu | Dim sAttUid As String |
434 | 54b98e09 | Gyusu | Dim sName As String |
435 | Dim sValue As String |
||
436 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID) |
||
437 | 41e4023e | Gyusu | sAttUid = oEleObj.Value |
438 | 54b98e09 | Gyusu | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME) |
439 | sName = oEleObj.Value |
||
440 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE) |
||
441 | sValue = oEleObj.Value |
||
442 | 41e4023e | Gyusu | oAddrow(_XML_ATTRIBUTE_UID) = sAttUid |
443 | 54b98e09 | Gyusu | oAddrow(_XML_ATTRIBUTE_NAME) = sName |
444 | oAddrow(_XML_ATTRIBUTE_VALUE) = sValue |
||
445 | oAttribute_Dt.Rows.Add(oAddrow) |
||
446 | Catch ex As Exception |
||
447 | End Try |
||
448 | Next |
||
449 | 41e4023e | Gyusu | CEqp_no.Uid = sUid |
450 | 54b98e09 | Gyusu | CEqp_no.Dt_Equipment = oSymbol_Dt |
451 | CEqp_no.Dt_Attribute = oAttribute_Dt |
||
452 | oEqp_list.Add(CEqp_no) |
||
453 | 4f359afa | Gyusu | Next |
454 | 3acffcee | Gyusu | oTrim_Lineno_list = LoadLineNo(oElement, _XML_CATEGORY_TRIM_LINENO) |
455 | 54b98e09 | Gyusu | CDrawing.Line_nos = oLineno_list |
456 | CDrawing.Eqp_nos = oEqp_list |
||
457 | 3acffcee | Gyusu | CDrawing.TrimLine_nos = oTrim_Lineno_list |
458 | |||
459 | 54b98e09 | Gyusu | End If |
460 | Return CDrawing |
||
461 | Catch ex As Exception |
||
462 | Return Nothing |
||
463 | End Try |
||
464 | |||
465 | 4f359afa | Gyusu | End Function |
466 | |||
467 | |||
468 | 3acffcee | Gyusu | Private Function LoadLineNo(ByVal oElement As XElement, ByVal sLineType As String) As List(Of Line_no) |
469 | |||
470 | Dim oLineno_list As New List(Of Line_no) |
||
471 | |||
472 | For Each oLineNo As Object In oElement.Elements(sLineType) |
||
473 | |||
474 | Dim CLineNo As Line_no = New Line_no() |
||
475 | Try |
||
476 | CLineNo.Uid = oLineNo.Element(_XML_LINENO_UID).Value |
||
477 | CLineNo.Text = oLineNo.Element(_XML_LINENO_TEXT).Value |
||
478 | CLineNo.Location = oLineNo.Element(_XML_LINENO_LOCATION).Value |
||
479 | CLineNo.Angle = oLineNo.Element(_XML_LINENO_ANGLE).Value |
||
480 | CLineNo.SystemPath = "\Piping\Labels - Piping Segments\Kemya Line Number.sym" 'GetDataFromMappingDB(_XML_CATEGORY_LINENO, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
481 | Catch ex As Exception |
||
482 | 'CLineNo.Text = "PipeLineNo" |
||
483 | 'CLineNo.Uid = "PipeLineNo" |
||
484 | End Try |
||
485 | |||
486 | |||
487 | Dim oLine_Dt As DataTable = Line_Dt() |
||
488 | Dim oSymbol_Dt As DataTable = Symbol_Dt() |
||
489 | Dim oAttribute_Dt As DataTable = Attribute_Dt() |
||
490 | |||
491 | For Each oRun As Object In oLineNo.Elements(_XML_CATEGORY_RUN) |
||
492 | For Each oLine As Object In oRun.Elements(_XML_CATEGORY_LINE) |
||
493 | Try |
||
494 | Dim oAddrow As DataRow = oLine_Dt.NewRow() |
||
495 | Dim oEleObj As XElement |
||
496 | Dim sUid As String |
||
497 | Dim sStartpoint As String |
||
498 | Dim sEndpoint As String |
||
499 | c2c36314 | Gyusu | Dim sType As String |
500 | 3acffcee | Gyusu | oEleObj = oLine.Element(_XML_LINE_UID) |
501 | sUid = oEleObj.Value |
||
502 | e4000111 | Gyusu | If oLine_Dt.Select(_XML_LINE_UID & "='" & sUid & "'").Length = 0 Then |
503 | oEleObj = oLine.Element(_XML_LINE_STARTPOINT) |
||
504 | sStartpoint = oEleObj.Value |
||
505 | oEleObj = oLine.Element(_XML_LINE_ENDPOINT) |
||
506 | sEndpoint = oEleObj.Value |
||
507 | oEleObj = oLine.Element(_XML_LINE_TYPE) |
||
508 | sType = oEleObj.Value |
||
509 | oAddrow(_XML_LINE_UID) = sUid |
||
510 | oAddrow(_XML_LINE_STARTPOINT) = sStartpoint |
||
511 | oAddrow(_XML_LINE_ENDPOINT) = sEndpoint |
||
512 | oAddrow(_XML_LINE_SYSTEMPATH) = GetDataFromMappingDB(_XML_CATEGORY_LINE, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
513 | oAddrow(_XML_LINE_DRAWING_TF) = "FALSE" |
||
514 | oAddrow(_XML_LINE_TYPE) = sType |
||
515 | oLine_Dt.Rows.Add(oAddrow) |
||
516 | Else |
||
517 | |||
518 | End If |
||
519 | |||
520 | 3acffcee | Gyusu | Catch ex As Exception |
521 | |||
522 | End Try |
||
523 | |||
524 | Next |
||
525 | |||
526 | For Each oSymbol As Object In oRun.Elements(_XML_CATEGORY_SYMBOL) |
||
527 | Try |
||
528 | Dim oAddrow As DataRow = oSymbol_Dt.NewRow() |
||
529 | Dim oEleObj As XElement |
||
530 | Dim sUid As String |
||
531 | Dim sName As String |
||
532 | Dim sLocation As String |
||
533 | Dim sSize As String |
||
534 | Dim sAngle As String |
||
535 | Dim sOriginalPoint As String = "" |
||
536 | oEleObj = oSymbol.Element(_XML_SYMBOL_UID) |
||
537 | sUid = oEleObj.Value |
||
538 | oEleObj = oSymbol.Element(_XML_SYMBOL_PARENT) |
||
539 | sName = oEleObj.Value |
||
540 | oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
||
541 | sLocation = oEleObj.Value |
||
542 | oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE) |
||
543 | sSize = oEleObj.Value |
||
544 | oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
||
545 | sAngle = oEleObj.Value |
||
546 | Try |
||
547 | oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT) |
||
548 | sOriginalPoint = oEleObj.Value |
||
549 | Catch ex As Exception |
||
550 | |||
551 | End Try |
||
552 | |||
553 | oAddrow(_XML_SYMBOL_UID) = sUid |
||
554 | oAddrow(_XML_SYMBOL_NAME) = IO.Path.GetFileNameWithoutExtension(GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME)) |
||
555 | oAddrow(_XML_SYMBOL_LOCATION) = sLocation |
||
556 | oAddrow(_XML_SYMBOL_SIZE) = sSize |
||
557 | oAddrow(_XML_SYMBOL_ANGLE) = sAngle |
||
558 | oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
559 | oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE) |
||
560 | oAddrow(_XML_SYMBOL_CLASS) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_CLASS) |
||
561 | oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint |
||
562 | e4000111 | Gyusu | oAddrow(_XML_SYMBOL_DRAWING_TF) = "FALSE" |
563 | 3acffcee | Gyusu | oSymbol_Dt.Rows.Add(oAddrow) |
564 | Catch ex As Exception |
||
565 | |||
566 | End Try |
||
567 | |||
568 | Next |
||
569 | |||
570 | For Each oAtrribute As Object In oRun.Elements(_XML_CATEGORY_ATTRIBUTE) |
||
571 | Try |
||
572 | Dim oAddrow As DataRow = oAttribute_Dt.NewRow() |
||
573 | Dim oEleObj As XElement |
||
574 | Dim sUid As String |
||
575 | Dim sName As String |
||
576 | Dim sValue As String |
||
577 | |||
578 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID) |
||
579 | sUid = oEleObj.Value |
||
580 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME) |
||
581 | sName = oEleObj.Value |
||
582 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE) |
||
583 | sValue = oEleObj.Value |
||
584 | |||
585 | oAddrow(_XML_ATTRIBUTE_UID) = sUid |
||
586 | oAddrow(_XML_ATTRIBUTE_NAME) = sName |
||
587 | oAddrow(_XML_ATTRIBUTE_VALUE) = sValue |
||
588 | oAttribute_Dt.Rows.Add(oAddrow) |
||
589 | Catch ex As Exception |
||
590 | |||
591 | End Try |
||
592 | |||
593 | Next |
||
594 | |||
595 | Next |
||
596 | 'Line No Attribute |
||
597 | For Each oAtrribute As Object In oLineNo.Elements(_XML_CATEGORY_ATTRIBUTE) |
||
598 | Try |
||
599 | Dim oAddrow As DataRow = oAttribute_Dt.NewRow() |
||
600 | Dim oEleObj As XElement |
||
601 | Dim sUid As String = "" |
||
602 | Dim sName As String |
||
603 | Dim sValue As String |
||
604 | |||
605 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID) |
||
606 | sUid = oEleObj.Value |
||
607 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME) |
||
608 | sName = oEleObj.Value |
||
609 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE) |
||
610 | sValue = oEleObj.Value |
||
611 | oAddrow(_XML_ATTRIBUTE_UID) = sUid |
||
612 | oAddrow(_XML_ATTRIBUTE_NAME) = sName |
||
613 | oAddrow(_XML_ATTRIBUTE_VALUE) = sValue |
||
614 | oAttribute_Dt.Rows.Add(oAddrow) |
||
615 | Catch ex As Exception |
||
616 | End Try |
||
617 | Next |
||
618 | CLineNo.Dt_Line = oLine_Dt |
||
619 | CLineNo.Dt_Symbol = oSymbol_Dt |
||
620 | CLineNo.Dt_Attribute = oAttribute_Dt |
||
621 | oLineno_list.Add(CLineNo) |
||
622 | Next |
||
623 | Return oLineno_list |
||
624 | End Function |
||
625 | |||
626 | 4f359afa | Gyusu | |
627 | 171ac39d | Gyusu | 'Private Function LoadPipeInXml(ByVal sXmlPath As String) As DataTable |
628 | ' Try |
||
629 | ' Dim oDt As DataTable = LoadPipe_DT() |
||
630 | ' Dim oElement As XElement = XElement.Load(sXmlPath) |
||
631 | ' If oElement IsNot Nothing Then |
||
632 | ' Dim DWGElement As XElement = oElement.Element("DWGNAME") |
||
633 | ' Dim DWGNAME = DWGElement.Value |
||
634 | ' Dim sXY As XElement = oElement.Element("SIZE") |
||
635 | ' Dim sSize = sXY.Value |
||
636 | ' Dim oSplitDWGPos As String() = sSize.Split(", ") |
||
637 | 4f359afa | Gyusu | |
638 | 171ac39d | Gyusu | ' If IsNumeric(oSplitDWGPos(0)) Then |
639 | ' _IMG_X = Double.Parse(oSplitDWGPos(0)) |
||
640 | ' End If |
||
641 | ' If IsNumeric(oSplitDWGPos(1)) Then |
||
642 | ' _IMG_Y = Double.Parse(oSplitDWGPos(1)) |
||
643 | ' End If |
||
644 | 4f359afa | Gyusu | |
645 | 171ac39d | Gyusu | ' For Each pipes As Object In oElement.Elements("IMGLINES") |
646 | ' For Each pipe As Object In pipes.Elements("IMGLINE") |
||
647 | ' Dim oAddrow As DataRow = oDt.NewRow() |
||
648 | ' Dim oObj As XElement = pipe.Element("ITEM") |
||
649 | ' Dim oItem = oObj.Value |
||
650 | ' ' Dim oSymbolPath As String = "\" + oSymbol + "\" + oClass + "\" + oType + "\" + oItem + ".sym" |
||
651 | ' Dim oSymbolPath As String = GetSystemPathFromMappingDB(oItem) |
||
652 | ' oObj = pipe.Element("START") |
||
653 | ' Dim oStartPoint = oObj.Value |
||
654 | ' Dim oSplitPos As String() = oStartPoint.Split(", ") |
||
655 | ' Dim oStartpos_X As Double = 0.0 |
||
656 | ' Dim oStartpos_Y As Double = 0.0 |
||
657 | ' If IsNumeric(oSplitPos(0)) Then |
||
658 | ' oStartpos_X = Double.Parse(oSplitPos(0)) |
||
659 | ' End If |
||
660 | ' If IsNumeric(oSplitPos(1)) Then |
||
661 | ' oStartpos_Y = Double.Parse(oSplitPos(1)) |
||
662 | ' End If |
||
663 | 4f359afa | Gyusu | |
664 | 171ac39d | Gyusu | ' ConvertPoint(oStartpos_X, oStartpos_Y, _DWG_X, _DWG_Y) |
665 | ' oObj = pipe.Element("End") |
||
666 | ' Dim oEndPoint = oObj.Value |
||
667 | ' oSplitPos = oEndPoint.Split(", ") |
||
668 | ' Dim oEndpos_X As Double = 0.0 |
||
669 | ' Dim oEndpos_Y As Double = 0.0 |
||
670 | ' If IsNumeric(oSplitPos(0)) Then |
||
671 | ' oEndpos_X = Double.Parse(oSplitPos(0)) |
||
672 | ' End If |
||
673 | ' If IsNumeric(oSplitPos(1)) Then |
||
674 | ' oEndpos_Y = Double.Parse(oSplitPos(1)) |
||
675 | ' End If |
||
676 | ' ConvertPoint(oEndpos_X, oEndpos_Y, _DWG_X, _DWG_Y) |
||
677 | 4f359afa | Gyusu | |
678 | 171ac39d | Gyusu | ' oAddrow("start_x") = oStartpos_X '+ 0.05 |
679 | ' oAddrow("start_y") = oStartpos_Y |
||
680 | ' oAddrow("end_x") = oEndpos_X |
||
681 | ' oAddrow("end_y") = oEndpos_Y |
||
682 | ' oAddrow("SystemPath") = oSymbolPath |
||
683 | ' oDt.Rows.Add(oAddrow) |
||
684 | ' Next |
||
685 | ' Next |
||
686 | |||
687 | ' End If |
||
688 | 4f359afa | Gyusu | |
689 | 171ac39d | Gyusu | |
690 | ' Return oDt |
||
691 | ' Catch ex As Exception |
||
692 | ' Return Nothing |
||
693 | ' End Try |
||
694 | 'End Function |
||
695 | 4f359afa | Gyusu | |
696 | |||
697 | 9e1e7135 | Gyusu | Private Sub ConvertPointByImage(ByRef dX As Double, ByRef dY As Double, ByVal dDwgX As Double, ByVal dDwgY As Double) |
698 | 4f359afa | Gyusu | |
699 | Dim calcx As Double = 0 |
||
700 | Dim calcy As Double = 0 |
||
701 | calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2) |
||
702 | 171ac39d | Gyusu | calcy = _DWG_Y - ((dY * _DWG_Y) / dDwgY) '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2) |
703 | 4f359afa | Gyusu | dX = calcx |
704 | dY = calcy |
||
705 | End Sub |
||
706 | |||
707 | e1cde8f2 | Gyusu | |
708 | '@brief Convert To SPPID |
||
709 | '@author : Gyusu Park |
||
710 | '@date : 2018-04-10 |
||
711 | '@history: |
||
712 | |||
713 | 171ac39d | Gyusu | Private Sub SplitLocation(ByVal sLocation As String, ByRef dX As Double, ByRef dY As Double) |
714 | |||
715 | Dim opointstr As String() = Split(sLocation, ",") |
||
716 | If (opointstr.Length > 1) Then |
||
717 | If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
||
718 | dX = opointstr(0) |
||
719 | dY = opointstr(1) |
||
720 | End If |
||
721 | End If |
||
722 | |||
723 | End Sub |
||
724 | |||
725 | |||
726 | |||
727 | |||
728 | |||
729 | |||
730 | e1cde8f2 | Gyusu | Private Function AutoConverting(ByVal oPipe_Dt As DataTable, ByVal oSymbol_Dt As DataTable, ByVal oTreeNode As TreeNode) As Boolean |
731 | e282643f | Gyusu | Dim iTotalCount As Double = oPipe_Dt.Rows.Count + oSymbol_Dt.Rows.Count |
732 | Dim iSymbolcount As Double = 0 |
||
733 | |||
734 | e1cde8f2 | Gyusu | Dim lobjDatasource As Object = _Placement.PIDDataSource |
735 | e282643f | Gyusu | |
736 | e1cde8f2 | Gyusu | ' lobjDatasource.BeginTransaction() |
737 | e282643f | Gyusu | ' datasource = objPlacement.PIDDataSource |
738 | 'Dim iPipecnt As Integer = 0 |
||
739 | e1cde8f2 | Gyusu | SetListBoxItems(ListBox_Result, " Auto converting 시작....") |
740 | e282643f | Gyusu | |
741 | e1cde8f2 | Gyusu | Dim iPipeCnt As Integer = 0 |
742 | e282643f | Gyusu | If oPipe_Dt IsNot Nothing Then |
743 | For Each oRow As DataRow In oPipe_Dt.Rows |
||
744 | Dim oposition As String = oRow("position").ToString() |
||
745 | 20c84e05 | Gyusu | Dim oSymbol As String = oRow("SystemPath").ToString() |
746 | 171ac39d | Gyusu | |
747 | e282643f | Gyusu | Dim objConnector As LMConnector |
748 | Dim objInputs As PlaceRunInputs |
||
749 | objInputs = New PlaceRunInputs |
||
750 | 171ac39d | Gyusu | Dim oSplitStr As String() = Split(oposition, " ") |
751 | e282643f | Gyusu | For Each sposition As String In oSplitStr |
752 | 20c84e05 | Gyusu | Dim opointstr As String() = Split(sposition, ", ") |
753 | e282643f | Gyusu | |
754 | If (opointstr.Length > 1) Then |
||
755 | If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
||
756 | Dim ox As Double = opointstr(0) |
||
757 | Dim oy As Double = opointstr(1) |
||
758 | 9e1e7135 | Gyusu | ConvertPointByImage(ox, oy, _IMG_X, _IMG_Y) |
759 | e282643f | Gyusu | objInputs.AddPoint(ox, oy) |
760 | End If |
||
761 | 4f359afa | Gyusu | End If |
762 | e282643f | Gyusu | Next |
763 | Dim objItem As LMAItem |
||
764 | e1cde8f2 | Gyusu | objItem = _Placement.PIDCreateItem(oSymbol) |
765 | objConnector = _Placement.PIDPlaceRun(objItem, objInputs) |
||
766 | SetListBoxItems(ListBox_Result, " Place PipeLine...." & "(" & (iPipeCnt + 1) & "/" & oPipe_Dt.Rows.Count) |
||
767 | e282643f | Gyusu | 'Dim objPipeRun As LMPipeRun = datasource.GetPipeRun(objConnector.ModelItemID) |
768 | 'objPipeRun.Attributes("OperFluidCode").Value = "AFS" |
||
769 | 'objPipeRun.Commit() |
||
770 | iSymbolcount = iSymbolcount + 1 |
||
771 | e1cde8f2 | Gyusu | iPipeCnt = iPipeCnt + 1 |
772 | e282643f | Gyusu | Next |
773 | End If |
||
774 | 4f359afa | Gyusu | |
775 | e1cde8f2 | Gyusu | SetListBoxItems(ListBox_Result, " Place PipeLine....완료") |
776 | |||
777 | Dim iAllInstrumentCnt As Integer = oSymbol_Dt.Select("Name = 'INSTRUMENTATION'").Length |
||
778 | 20c84e05 | Gyusu | Dim iValveCnt As Integer = oSymbol_Dt.Select("Class = 'VALVES'").Length |
779 | e1cde8f2 | Gyusu | Dim iInstrumentCnt As Integer = 1 |
780 | Dim iFittingsCnt As Integer = 1 |
||
781 | |||
782 | Dim oInsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Instruments", True)(0) |
||
783 | Dim oValveNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Valves", True)(0) |
||
784 | Dim oFittingsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Fittings", True)(0) |
||
785 | e282643f | Gyusu | For Each oRow As DataRow In oSymbol_Dt.Rows |
786 | 4f359afa | Gyusu | |
787 | e282643f | Gyusu | Try |
788 | e1cde8f2 | Gyusu | |
789 | 20c84e05 | Gyusu | Dim sSystemPath As String = oRow("SystemPath").ToString() |
790 | Dim sName As String = oRow("Name").ToString() |
||
791 | Dim sType As String = oRow("Type").ToString() |
||
792 | Dim sText As String = oRow("Text").ToString() |
||
793 | Dim sClass As String = oRow("Class").ToString() |
||
794 | Dim sItem As String = oRow("Item").ToString() |
||
795 | e1cde8f2 | Gyusu | |
796 | e282643f | Gyusu | Dim oX As Double = 0.0 |
797 | Dim oY As Double = 0.0 |
||
798 | 20c84e05 | Gyusu | If IsNumeric(oRow("x").ToString()) Then |
799 | oX = Double.Parse(oRow("x").ToString()) |
||
800 | e282643f | Gyusu | End If |
801 | 20c84e05 | Gyusu | If IsNumeric(oRow("y").ToString()) Then |
802 | oY = Double.Parse(oRow("y").ToString()) |
||
803 | e282643f | Gyusu | End If |
804 | Dim oAngle As Double = 0.0 |
||
805 | 20c84e05 | Gyusu | If IsNumeric(oRow("Angle").ToString()) Then |
806 | oAngle = Double.Parse(oRow("Angle").ToString()) |
||
807 | e282643f | Gyusu | End If |
808 | ' oSymbol = "\INSTRUMENTation\SYSTEM FUNCTIONS\D C S\DCS FUNC ACCESS IN PRIME LOC.sym" |
||
809 | e1cde8f2 | Gyusu | If sSystemPath <> "" Then |
810 | If sName = _TYPE_Instumentation Then |
||
811 | |||
812 | e282643f | Gyusu | Dim sTagsuffix As String = "" |
813 | Dim sTagSequenceNo As String = "" |
||
814 | Dim sMeasuredVariableCode As String = "" |
||
815 | Dim sInstrumentTypeModifier As String = "" |
||
816 | e1cde8f2 | Gyusu | |
817 | If sText <> "" Then |
||
818 | If sText.Contains(",") Then |
||
819 | Dim splitstr() As String = sText.Split(",") |
||
820 | e282643f | Gyusu | For i = 0 To splitstr.Count - 1 |
821 | If i = 0 Then |
||
822 | sMeasuredVariableCode = Mid(splitstr(i), 1, 1) |
||
823 | sTagSequenceNo = Mid(splitstr(i), 2, Len(splitstr(i))) |
||
824 | Else |
||
825 | If Len(splitstr(i)) = 1 Then |
||
826 | sInstrumentTypeModifier = splitstr(i) |
||
827 | ElseIf Len(splitstr(i)) = 0 Then |
||
828 | |||
829 | ElseIf Len(splitstr(i)) > 1 Then |
||
830 | sInstrumentTypeModifier = Mid(splitstr(i), 1, 1) |
||
831 | sTagsuffix = Mid(splitstr(i), 2, Len(splitstr(i))) |
||
832 | End If |
||
833 | End If |
||
834 | Next |
||
835 | Else |
||
836 | e1cde8f2 | Gyusu | sMeasuredVariableCode = Mid(sText, 1, 1) |
837 | sTagSequenceNo = Mid(sText, 2, Len(sText)) |
||
838 | e282643f | Gyusu | End If |
839 | 4f359afa | Gyusu | |
840 | e282643f | Gyusu | End If |
841 | 4f359afa | Gyusu | |
842 | e282643f | Gyusu | Dim objInstrSym As LMSymbol |
843 | e1cde8f2 | Gyusu | objInstrSym = _Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
844 | SetListBoxItems(ListBox_Result, " Place Instrument...." & "(" & (iInstrumentCnt + 1) & "/" & iAllInstrumentCnt & ")") |
||
845 | |||
846 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sTagSequenceNo) |
||
847 | Dim action As Action = Sub() |
||
848 | oInsNode.Nodes.Add(sClass & "-" & iInstrumentCnt) |
||
849 | oInsNode.ExpandAll() |
||
850 | End Sub |
||
851 | oInsNode.TreeView.Invoke(action) |
||
852 | |||
853 | |||
854 | e282643f | Gyusu | Dim objInstr As LMInstrument |
855 | objInstr = lobjDatasource.GetInstrument(objInstrSym.ModelItemID) |
||
856 | 4f359afa | Gyusu | |
857 | e282643f | Gyusu | Dim objItem As LMAItem |
858 | e1cde8f2 | Gyusu | objItem = _Placement.PIDCreateItem(sSystemPath) |
859 | |||
860 | 4f359afa | Gyusu | |
861 | e282643f | Gyusu | objInstr.Attributes("MeasuredVariableCode").Value = sMeasuredVariableCode |
862 | objInstr.Attributes("InstrumentTypeModifier").Value = sInstrumentTypeModifier |
||
863 | objInstr.Attributes("TagSuffix").Value = sTagsuffix |
||
864 | objInstr.Attributes("TagSequenceNo").Value = sTagSequenceNo |
||
865 | objInstr.Commit() |
||
866 | e1cde8f2 | Gyusu | iInstrumentCnt = iInstrumentCnt + 1 |
867 | ElseIf sName = "GATE VALVE WITH PLUG" Then |
||
868 | 4f359afa | Gyusu | |
869 | e1cde8f2 | Gyusu | ElseIf sName = "MEDIUM 1D 1TO1" Then |
870 | 4f359afa | Gyusu | |
871 | e1cde8f2 | Gyusu | ElseIf sClass = "VALVES" Then |
872 | Dim action As Action = Sub() |
||
873 | oValveNode.ExpandAll() |
||
874 | oValveNode.Nodes.Add(sClass & "-" & iValveCnt) |
||
875 | End Sub |
||
876 | oValveNode.TreeView.Invoke(action) |
||
877 | |||
878 | _Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
||
879 | |||
880 | iValveCnt = iValveCnt + 1 |
||
881 | e282643f | Gyusu | Else |
882 | e1cde8f2 | Gyusu | Dim action As Action = Sub() |
883 | oFittingsNode.ExpandAll() |
||
884 | oFittingsNode.Nodes.Add(sClass & "-" & iFittingsCnt) |
||
885 | End Sub |
||
886 | oFittingsNode.TreeView.Invoke(action) |
||
887 | _Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
||
888 | |||
889 | iFittingsCnt = iFittingsCnt + 1 |
||
890 | 4f359afa | Gyusu | |
891 | e282643f | Gyusu | End If |
892 | iSymbolcount = iSymbolcount + 1 |
||
893 | Else |
||
894 | 4f359afa | Gyusu | End If |
895 | e282643f | Gyusu | Catch ex As Exception |
896 | 4f359afa | Gyusu | |
897 | e282643f | Gyusu | End Try |
898 | Dim dCalcProgressValue As Double = (iSymbolcount / iTotalCount) * 100 |
||
899 | SetProgressbar(ProgressBar_Status, dCalcProgressValue) |
||
900 | ' ProgressBar_Status.Value = (iSymbolcount / iTotalCount) * 100 |
||
901 | e1cde8f2 | Gyusu | |
902 | 4f359afa | Gyusu | Next |
903 | |||
904 | e1cde8f2 | Gyusu | MsgBox("Complete AutoConverting") |
905 | SetListBoxItems(ListBox_Result, "Place Instrument....변환완료") |
||
906 | SetListBoxItems(ListBox_Result, "총 symbol: " & iSymbolcount & "개 변환완료") |
||
907 | SetProgressbar(ProgressBar_Status, 100) |
||
908 | 41e4023e | Gyusu | |
909 | e282643f | Gyusu | ' MsgBox("symbol: " & iSymbolcount & "개, pipe : " & iPipecnt & "개 변환완료") |
910 | 4f359afa | Gyusu | End Function |
911 | |||
912 | |||
913 | 272662f9 | Gyusu | Private Sub Tree_XMLFiles_AfterCheck(sender As Object, e As TreeViewEventArgs) |
914 | 4f359afa | Gyusu | If e.Node.Checked = True Then |
915 | For Each oNode As TreeNode In e.Node.Nodes |
||
916 | oNode.Checked = True |
||
917 | Next |
||
918 | Else |
||
919 | For Each oNode As TreeNode In e.Node.Nodes |
||
920 | oNode.Checked = False |
||
921 | Next |
||
922 | End If |
||
923 | End Sub |
||
924 | |||
925 | 171ac39d | Gyusu | Private Function Load_DB(ByVal sDBPath As String, ByVal sTableName As String) As DataTable |
926 | 4f359afa | Gyusu | |
927 | Try |
||
928 | 171ac39d | Gyusu | Dim oDt As New DataTable |
929 | 4f359afa | Gyusu | Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;" |
930 | Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring) |
||
931 | conn.Open() |
||
932 | 171ac39d | Gyusu | Dim sQuery As String = "Select * from " & sTableName |
933 | 4f359afa | Gyusu | Dim cmd As SQLiteCommand = conn.CreateCommand() |
934 | Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn) |
||
935 | Dim oDataSet As DataSet = New DataSet() |
||
936 | adapter.Fill(oDataSet) |
||
937 | 171ac39d | Gyusu | oDt = oDataSet.Tables(0) |
938 | Return oDt |
||
939 | 4f359afa | Gyusu | Catch ex As Exception |
940 | 171ac39d | Gyusu | Return Nothing |
941 | 4f359afa | Gyusu | End Try |
942 | |||
943 | |||
944 | 171ac39d | Gyusu | End Function |
945 | 4f359afa | Gyusu | |
946 | 171ac39d | Gyusu | Private Sub Load_AttributeDB(ByVal sDBPath As String) |
947 | |||
948 | Try |
||
949 | Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;" |
||
950 | Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring) |
||
951 | conn.Open() |
||
952 | Dim sQuery As String = "Select * from Attribute" |
||
953 | Dim cmd As SQLiteCommand = conn.CreateCommand() |
||
954 | Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn) |
||
955 | Dim oDataSet As DataSet = New DataSet() |
||
956 | adapter.Fill(oDataSet) |
||
957 | _Attribute_DB = oDataSet.Tables(0) |
||
958 | Catch ex As Exception |
||
959 | |||
960 | End Try |
||
961 | 962b2464 | Gyusu | |
962 | |||
963 | 171ac39d | Gyusu | End Sub |
964 | |||
965 | 272662f9 | Gyusu | 'Private Sub Tree_XMLFiles_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterSelect |
966 | ' If first_start = False Then Exit Sub |
||
967 | ' Dim pa = e.Node.FullPath.ToString |
||
968 | 962b2464 | Gyusu | |
969 | 272662f9 | Gyusu | ' printfilesfolders_here(pa, e.Node) |
970 | 962b2464 | Gyusu | |
971 | 272662f9 | Gyusu | ' displayfiles(pa) |
972 | |||
973 | ' Dim coco As String = "" |
||
974 | ' coco = pa.ToString |
||
975 | ' coco = coco.Replace("\\", "\") |
||
976 | ' Me.Text = coco |
||
977 | ' folders_path = coco |
||
978 | 'End Sub |
||
979 | 962b2464 | Gyusu | |
980 | Sub printfilesfolders_here(ByVal path As String, ByRef itree As TreeNode) |
||
981 | |||
982 | Dim foldername As String |
||
983 | Dim filename As String |
||
984 | itree.Nodes.Clear() |
||
985 | On Error GoTo eee |
||
986 | For Each foldername In Directory.GetDirectories(path) |
||
987 | On Error GoTo eee |
||
988 | Dim jj = foldername.LastIndexOf("\") |
||
989 | Dim jj1 = foldername.Length - jj |
||
990 | Dim foldr = foldername.Substring((jj + 1), (jj1 - 1)) |
||
991 | itree.Nodes.Add(foldr, foldr) |
||
992 | Next ' if you put this next at the end of procedure recursive will be done on first folder only |
||
993 | Exit Sub |
||
994 | eee: |
||
995 | End Sub |
||
996 | |||
997 | e282643f | Gyusu | |
998 | 962b2464 | Gyusu | |
999 | 272662f9 | Gyusu | ' Private Sub Tree_XMLFiles_MouseMove(sender As Object, e As MouseEventArgs) Handles Tree_XMLFiles.MouseMove |
1000 | ' first_start = True |
||
1001 | ' End Sub |
||
1002 | |||
1003 | ' Private Sub ListView_File_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView_File.SelectedIndexChanged |
||
1004 | ' Dim indexes As ListView.SelectedIndexCollection = |
||
1005 | ' Me.ListView_File.SelectedIndices |
||
1006 | ' Dim index As Integer |
||
1007 | |||
1008 | ' For Each index In indexes |
||
1009 | ' 'On Error Resume Next |
||
1010 | ' If folders_path.EndsWith("\") = True Then |
||
1011 | ' Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text) |
||
1012 | ' 'On Error Resume Next |
||
1013 | ' Else |
||
1014 | ' Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text) |
||
1015 | ' End If |
||
1016 | |||
1017 | ' Dim infoReader As System.IO.FileInfo |
||
1018 | ' infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text) |
||
1019 | ' Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString |
||
1020 | ' Next |
||
1021 | ' End Sub |
||
1022 | |||
1023 | ' Private Sub Procees() |
||
1024 | ' Dim indexes As ListView.SelectedIndexCollection = |
||
1025 | ' Me.ListView_File.SelectedIndices |
||
1026 | ' Dim index As Integer |
||
1027 | |||
1028 | ' For Each index In indexes |
||
1029 | ' 'On Error Resume Next |
||
1030 | ' If folders_path.EndsWith("\") = True Then |
||
1031 | ' On Error GoTo out |
||
1032 | ' Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text) |
||
1033 | ' On Error GoTo out |
||
1034 | ' 'On Error Resume Next |
||
1035 | ' Else |
||
1036 | ' Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text) |
||
1037 | ' On Error GoTo out |
||
1038 | ' End If |
||
1039 | |||
1040 | ' Dim infoReader As System.IO.FileInfo |
||
1041 | ' infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text) |
||
1042 | ' Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString |
||
1043 | ' On Error GoTo out |
||
1044 | ' MsgBox(Me.Status_Main.Items(0).Text + " is processed") |
||
1045 | ' On Error GoTo out |
||
1046 | ' Next |
||
1047 | ' Exit Sub |
||
1048 | 'out: |
||
1049 | ' MsgBox(Err.Description) |
||
1050 | 'End Sub |
||
1051 | 962b2464 | Gyusu | |
1052 | 31d47a80 | Gyusu | Private Function LoadAllDrawing() As DataTable |
1053 | e282643f | Gyusu | |
1054 | |||
1055 | e1cde8f2 | Gyusu | SetListBoxItems(ListBox_Result, "도면정보 로드중....") |
1056 | e282643f | Gyusu | |
1057 | 31d47a80 | Gyusu | Dim oDt As DataTable = Drawing_Dt() |
1058 | e282643f | Gyusu | Dim sHierarchy As String = My.Settings.Plant_Hierarchy |
1059 | |||
1060 | |||
1061 | Dim files() As String |
||
1062 | files = Directory.GetFiles(sHierarchy, "*.pid", SearchOption.AllDirectories) |
||
1063 | For Each FileName As String In files |
||
1064 | Dim sName As String = FileName |
||
1065 | 31d47a80 | Gyusu | Dim oAddRow As DataRow = oDt.NewRow() |
1066 | e282643f | Gyusu | oAddRow("Name") = Path.GetFileNameWithoutExtension(sName) |
1067 | oAddRow("Path") = FileName |
||
1068 | 31d47a80 | Gyusu | oDt.Rows.Add(oAddRow) |
1069 | Next |
||
1070 | Return oDt |
||
1071 | End Function |
||
1072 | |||
1073 | e282643f | Gyusu | Private Function LoadAllDrawing2() As DataTable |
1074 | 31d47a80 | Gyusu | Dim datasource As LMADataSource |
1075 | Dim objPIDAutoApp As Object |
||
1076 | Dim objPIDADrawing As Object |
||
1077 | Dim objDrawing As Object 'Drawing |
||
1078 | 'Dim objDrawing As LMDrawing |
||
1079 | 'Dim objDrawings As LMDrawings |
||
1080 | |||
1081 | datasource = New LMADataSource |
||
1082 | |||
1083 | ' objDrawings = New LMDrawings |
||
1084 | 'objDrawings.Collect(datasource) |
||
1085 | objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
1086 | |||
1087 | For Each objDrawing In objPIDAutoApp.Drawings |
||
1088 | objDrawing.CloseDrawing(True) |
||
1089 | Next |
||
1090 | Try |
||
1091 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("UY1-K-2000_P1_300dpi_0321_TEST_1") |
||
1092 | Catch ex As Exception |
||
1093 | Process.Start("\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid") |
||
1094 | End Try |
||
1095 | |||
1096 | |||
1097 | |||
1098 | Dim sType As Type = objPIDAutoApp.GetType() |
||
1099 | Dim iCount As Integer = 0 |
||
1100 | ' Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid" |
||
1101 | |||
1102 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("1") |
||
1103 | |||
1104 | For Each objDrawing In objPIDAutoApp.Drawings |
||
1105 | If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
||
1106 | Try |
||
1107 | |||
1108 | Dim sName As String = objDrawing.Attributes("Name").Value |
||
1109 | |||
1110 | iCount = iCount + 1 |
||
1111 | If sName = "UY1-K-2000_P1_300dpi_0321_TEST_1" Then |
||
1112 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
||
1113 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid") |
||
1114 | If Not objPIDADrawing Is Nothing Then |
||
1115 | objPIDADrawing.CloseDrawing() |
||
1116 | End If |
||
1117 | End If |
||
1118 | |||
1119 | |||
1120 | Catch ex As Exception |
||
1121 | |||
1122 | End Try |
||
1123 | |||
1124 | End If |
||
1125 | Next |
||
1126 | objPIDAutoApp.Quit |
||
1127 | objPIDAutoApp = Nothing |
||
1128 | objPIDADrawing = Nothing |
||
1129 | objDrawing = Nothing |
||
1130 | ' objDrawings = Nothing |
||
1131 | e282643f | Gyusu | End Function |
1132 | |||
1133 | 272662f9 | Gyusu | Dim _XMLList As ListView = New ListView() |
1134 | e282643f | Gyusu | |
1135 | 272662f9 | Gyusu | |
1136 | |||
1137 | e1cde8f2 | Gyusu | |
1138 | 171ac39d | Gyusu | |
1139 | |||
1140 | Private Function CheckOpenDrawing() As Boolean |
||
1141 | Try |
||
1142 | |||
1143 | Dim lobjDatasource As Object |
||
1144 | _Placement = CreateObject("Plaice.Placement", "") |
||
1145 | lobjDatasource = _Placement.PIDDataSource |
||
1146 | Return True |
||
1147 | Catch ex As Exception |
||
1148 | Return False |
||
1149 | End Try |
||
1150 | |||
1151 | End Function |
||
1152 | |||
1153 | |||
1154 | Private Sub Btn_Convert_Click(sender As Object, e As EventArgs) Handles Btn_Convert.Click |
||
1155 | |||
1156 | Main_Tab.SelectedIndex = 1 |
||
1157 | ListBox_Result.Items.Clear() |
||
1158 | 9e1e7135 | Gyusu | ' DataGrid_Result.DataSource = New DataTable() |
1159 | 171ac39d | Gyusu | Me.ProgressBar_Status.Visible = True |
1160 | ProgressBar_Status.Maximum = 100 |
||
1161 | ProgressBar_Status.Value = 0 |
||
1162 | ' _selectFolderPath = Tree_XMLFiles.SelectedNode.FullPath.Replace("\\", "\") |
||
1163 | 54b98e09 | Gyusu | _Main_trd = New Thread(AddressOf ThreadConvert) |
1164 | 171ac39d | Gyusu | _Main_trd.IsBackground = True |
1165 | _Main_trd.Start() |
||
1166 | 54b98e09 | Gyusu | FineOPCForm() |
1167 | End Sub |
||
1168 | 171ac39d | Gyusu | |
1169 | 54b98e09 | Gyusu | Private Sub FineOPCForm() |
1170 | _Opc_trd = New Thread(AddressOf ThreadOPCRemove) |
||
1171 | _Opc_trd.IsBackground = True |
||
1172 | _Opc_trd.Start() |
||
1173 | 171ac39d | Gyusu | End Sub |
1174 | 54b98e09 | Gyusu | |
1175 | 7824381a | Gyusu | 'Private Sub ThreadTask() |
1176 | e1cde8f2 | Gyusu | |
1177 | e282643f | Gyusu | |
1178 | 7824381a | Gyusu | ' If _XMLList.Items.Count > 0 Then |
1179 | 31d47a80 | Gyusu | |
1180 | 7824381a | Gyusu | ' Dim oDwg_Dt As DataTable = LoadAllDrawing() |
1181 | ' Dim iDwgCnt As Integer = 0 |
||
1182 | ' Dim objPIDAutoApp As Object |
||
1183 | ' objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
1184 | e282643f | Gyusu | |
1185 | e1cde8f2 | Gyusu | |
1186 | 7824381a | Gyusu | ' Dim myList = DirectCast(Invoke(New GetListViewDelegate(AddressOf GetListViewItems), _XMLList), List(Of String)) |
1187 | ' For i = 0 To myList.Count - 1 |
||
1188 | e1cde8f2 | Gyusu | |
1189 | 7824381a | Gyusu | ' Dim sDwgName As String = Path.GetFileNameWithoutExtension(myList(i)) |
1190 | ' Txt_Status.Text = sDwgName & "..(" & i + 1 & "/" & myList.Count & ")" |
||
1191 | ' SetListBoxItems(ListBox_Result, Txt_Status.Text & " 처리중....") |
||
1192 | ' Dim sDwgNo As String = myList(i) |
||
1193 | ' Dim oDwgPath As String = "" |
||
1194 | ' oDwgPath = _selectFolderPath + "\" + sDwgNo |
||
1195 | e1cde8f2 | Gyusu | |
1196 | 7824381a | Gyusu | ' Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName) |
1197 | ' If sPath <> "" Then |
||
1198 | e1cde8f2 | Gyusu | |
1199 | 7824381a | Gyusu | ' Process.Start(sPath) |
1200 | e1cde8f2 | Gyusu | |
1201 | 7824381a | Gyusu | ' Dim bCheckOpenDrawing As Boolean = False |
1202 | ' While (True) |
||
1203 | ' bCheckOpenDrawing = CheckOpenDrawing() |
||
1204 | ' If bCheckOpenDrawing = True Then |
||
1205 | ' Exit While |
||
1206 | ' Else |
||
1207 | ' Thread.Sleep(2000) |
||
1208 | ' End If |
||
1209 | ' End While |
||
1210 | e1cde8f2 | Gyusu | |
1211 | 7824381a | Gyusu | ' If bCheckOpenDrawing Then |
1212 | ' SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....") |
||
1213 | ' Dim oPipe_Dt As DataTable = New DataTable() 'LoadPipeInXml(oDwgPath) |
||
1214 | e282643f | Gyusu | |
1215 | 7824381a | Gyusu | ' Dim oSymbol_Dt As DataTable = LoadSymbolInXml(oDwgPath) |
1216 | ' Dim oTreeNode As New TreeNode 'SetTreeViewItems(Tree_Result, Tree_Result.Nodes, sDwgName, sDwgName) |
||
1217 | ' 'oTreeNode = Tree_Result.Nodes.Find(sDwgName, True)(0) |
||
1218 | ' Dim action As Action = Sub() |
||
1219 | ' oTreeNode = Tree_Result.Nodes.Add(sDwgName, sDwgName) |
||
1220 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Instruments", "Instuments") |
||
1221 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Pipes", "Pipes") |
||
1222 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Valves", "Valves") |
||
1223 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Fittings", "Fittings") |
||
1224 | ' oTreeNode.ExpandAll() |
||
1225 | ' End Sub |
||
1226 | ' Tree_Result.Invoke(action) |
||
1227 | e1cde8f2 | Gyusu | |
1228 | e282643f | Gyusu | |
1229 | 7824381a | Gyusu | ' ' oTreeNode.Expand() |
1230 | ' SetListBoxItems(ListBox_Result, sDwgName & " Auto converting 대기....") |
||
1231 | ' AutoConverting(oPipe_Dt, oSymbol_Dt, oTreeNode) |
||
1232 | 4f359afa | Gyusu | |
1233 | 7824381a | Gyusu | ' End If |
1234 | |||
1235 | ' End If |
||
1236 | ' ''도면 생성 |
||
1237 | ' 'If CreateDwg(sDwgName) Then |
||
1238 | ' ' 'AutoConverting |
||
1239 | |||
1240 | ' 'End If |
||
1241 | |||
1242 | ' Next |
||
1243 | ' End If |
||
1244 | 'End Sub |
||
1245 | e282643f | Gyusu | |
1246 | 171ac39d | Gyusu | Dim _objPIDAutoApp As Object |
1247 | e282643f | Gyusu | |
1248 | 171ac39d | Gyusu | Private Function OpenSPPID(ByVal oDwg_Dt As DataTable, ByVal sDwgName As String) As Boolean |
1249 | Dim bCheckOpen As Boolean = False |
||
1250 | ' Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgPath) |
||
1251 | SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....") |
||
1252 | _objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
1253 | e1cde8f2 | Gyusu | |
1254 | 171ac39d | Gyusu | Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName) |
1255 | If sPath <> "" Then |
||
1256 | Process.Start(sPath) |
||
1257 | Else |
||
1258 | Return bCheckOpen |
||
1259 | End If |
||
1260 | |||
1261 | Dim bCheckOpenDrawing As Boolean = False |
||
1262 | While (True) |
||
1263 | bCheckOpenDrawing = CheckOpenDrawing() |
||
1264 | If bCheckOpenDrawing = True Then |
||
1265 | bCheckOpen = True |
||
1266 | Exit While |
||
1267 | Else |
||
1268 | Thread.Sleep(2000) |
||
1269 | End If |
||
1270 | End While |
||
1271 | |||
1272 | |||
1273 | Return bCheckOpen |
||
1274 | End Function |
||
1275 | |||
1276 | Private Function GetDrawing(ByVal sDwgName As String) As Drawing |
||
1277 | For Each CDrawing In _DrawingsList |
||
1278 | 559daf6d | Gyusu | If CDrawing.DwgName.ToUpper() = sDwgName.ToUpper() Then |
1279 | 171ac39d | Gyusu | Return CDrawing |
1280 | End If |
||
1281 | Next |
||
1282 | Return Nothing |
||
1283 | End Function |
||
1284 | |||
1285 | Private Function GetLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no |
||
1286 | For Each CLineNo In CDrawing.Line_nos |
||
1287 | If CLineNo.Uid = sLineNoUid Then |
||
1288 | Return CLineNo |
||
1289 | End If |
||
1290 | Next |
||
1291 | Return Nothing |
||
1292 | End Function |
||
1293 | |||
1294 | 3acffcee | Gyusu | Private Function GetTrimLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no |
1295 | For Each CLineNo In CDrawing.TrimLine_nos |
||
1296 | If CLineNo.Uid = sLineNoUid Then |
||
1297 | Return CLineNo |
||
1298 | End If |
||
1299 | Next |
||
1300 | Return Nothing |
||
1301 | End Function |
||
1302 | |||
1303 | |||
1304 | 6a6d8ab4 | Gyusu | Private Function GetOnlyPipeLineNo(ByVal CDrawing As Drawing, ByVal sPipeUid As String) As Line_no |
1305 | For Each CLineNo In CDrawing.Line_nos |
||
1306 | Dim odt As DataTable = CLineNo.Dt_Line |
||
1307 | If odt.Rows.Count > 0 Then |
||
1308 | If odt.Rows(0)(_XML_LINE_UID).ToString = sPipeUid Then |
||
1309 | Return CLineNo |
||
1310 | End If |
||
1311 | End If |
||
1312 | Next |
||
1313 | Return Nothing |
||
1314 | End Function |
||
1315 | |||
1316 | |||
1317 | Private Function GetEqpNo(ByVal CDrawing As Drawing, ByVal sEqpUid As String) As Eqp_no |
||
1318 | For Each CEqpNo In CDrawing.Eqp_nos |
||
1319 | If CEqpNo.Uid = sEqpUid Then |
||
1320 | Return CEqpNo |
||
1321 | End If |
||
1322 | Next |
||
1323 | Return Nothing |
||
1324 | End Function |
||
1325 | 9e1e7135 | Gyusu | Private Function ConvertPointBystring(ByVal sPoint As String, ByRef dX As Double, ByRef dY As Double) As Boolean |
1326 | 171ac39d | Gyusu | Try |
1327 | Dim opointstr As String() = Split(sPoint, ",") |
||
1328 | If (opointstr.Length > 1) Then |
||
1329 | If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
||
1330 | dX = opointstr(0) |
||
1331 | dY = opointstr(1) |
||
1332 | 9e1e7135 | Gyusu | |
1333 | 171ac39d | Gyusu | Else |
1334 | dX = 0 |
||
1335 | dY = 0 |
||
1336 | Return False |
||
1337 | End If |
||
1338 | End If |
||
1339 | e1cde8f2 | Gyusu | Return True |
1340 | Catch ex As Exception |
||
1341 | Return False |
||
1342 | End Try |
||
1343 | 171ac39d | Gyusu | End Function |
1344 | |||
1345 | 54b98e09 | Gyusu | |
1346 | Dim _DrawLine_Dt As DataTable = DrawLind_Dt() |
||
1347 | |||
1348 | 3acffcee | Gyusu | Private Function DrawLine(ByVal sUid As String, ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable, |
1349 | ByVal oAttribute_Dt As DataTable, ByRef oPiperun_Dt As DataTable) As LMPipeRun |
||
1350 | 171ac39d | Gyusu | Try |
1351 | 3acffcee | Gyusu | Dim oPipeRun As LMPipeRun = Nothing |
1352 | 171ac39d | Gyusu | Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" + sUid + "'") |
1353 | Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'") |
||
1354 | |||
1355 | If oPipeRow.Length > 0 Then |
||
1356 | Dim oDatasource As Object = _Placement.PIDDataSource |
||
1357 | Dim objItem As LMAItem |
||
1358 | Dim objConnector As LMConnector |
||
1359 | Dim objInputs As PlaceRunInputs |
||
1360 | objInputs = New PlaceRunInputs |
||
1361 | 9e1e7135 | Gyusu | Dim dOriginalStart_x As Double = 0.0 |
1362 | Dim dOriginalStart_y As Double = 0.0 |
||
1363 | Dim dOriginalEnd_x As Double = 0.0 |
||
1364 | Dim dOriginalEnd_y As Double = 0.0 |
||
1365 | 171ac39d | Gyusu | Dim dStart_x As Double = 0.0 |
1366 | Dim dStart_y As Double = 0.0 |
||
1367 | Dim dEnd_x As Double = 0.0 |
||
1368 | Dim dEnd_y As Double = 0.0 |
||
1369 | c2c36314 | Gyusu | |
1370 | Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString() |
||
1371 | |||
1372 | 54b98e09 | Gyusu | Dim sSystempath As String = "\Piping\Routing\Process Lines\Primary Piping.sym" ' oPipeRow(0)(_XML_LINE_SYSTEMPATH).ToString() |
1373 | c2c36314 | Gyusu | If sType.ToUpper() = "ELECTRIC" Then |
1374 | sSystempath = "\Instrumentation\Signal Line\Electric.sym" |
||
1375 | ElseIf sType.ToUpper() = "CONNECT TO PROCESS" Then |
||
1376 | sSystempath = "\Instrumentation\Signal Line\Connect to Process.sym" |
||
1377 | Else |
||
1378 | End If |
||
1379 | 171ac39d | Gyusu | Dim sStartpoint As String = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString() |
1380 | Dim sEndpoint As String = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString() |
||
1381 | 460d6abd | Gyusu | Dim sPipeUid As String = oPipeRow(0)(_XML_LINE_UID).ToString() |
1382 | |||
1383 | 3acffcee | Gyusu | Dim oAddPiperunRow As DataRow = oPiperun_Dt.NewRow() |
1384 | 9e1e7135 | Gyusu | ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y) |
1385 | dStart_x = dOriginalStart_x |
||
1386 | dStart_y = dOriginalStart_y |
||
1387 | 460d6abd | Gyusu | |
1388 | 9e1e7135 | Gyusu | If ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y) Then |
1389 | dEnd_x = dOriginalEnd_x |
||
1390 | dEnd_y = dOriginalEnd_y |
||
1391 | 54b98e09 | Gyusu | |
1392 | e4000111 | Gyusu | '라인보정(oLine_Dt, sPipeUid, dStart_x, dStart_y, dEnd_x, dEnd_y) |
1393 | 460d6abd | Gyusu | '//Overlap 보정 |
1394 | 54b98e09 | Gyusu | 'If FindOverlapLine(oLine_Dt, sPipeUid, dStart_x, dStart_y, dEnd_x, dEnd_y) = False Then |
1395 | ' '//떨어진 라인 보정 |
||
1396 | ' Dim dSeperate_start_x As Double = dStart_x |
||
1397 | ' Dim dSeperate_start_y As Double = dStart_y |
||
1398 | ' Dim dSeperate_end_x As Double = dEnd_x |
||
1399 | ' Dim dSeperate_end_y As Double = dEnd_y |
||
1400 | ' CalcSperateLine(dSeperate_start_x, dSeperate_start_y, dSeperate_end_x, dSeperate_end_y) |
||
1401 | ' If (FindOverlapLine(oLine_Dt, sPipeUid, dSeperate_start_x, dSeperate_start_y, dSeperate_end_x, dSeperate_end_y)) Then |
||
1402 | ' dStart_x = dSeperate_start_x |
||
1403 | ' dStart_y = dSeperate_start_y |
||
1404 | ' dEnd_x = dSeperate_end_x |
||
1405 | ' dEnd_y = dSeperate_end_y |
||
1406 | ' End If |
||
1407 | 'End If |
||
1408 | 460d6abd | Gyusu | |
1409 | ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y) |
||
1410 | 9e1e7135 | Gyusu | ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y) |
1411 | 171ac39d | Gyusu | If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then |
1412 | 460d6abd | Gyusu | |
1413 | 41e4023e | Gyusu | Dim iConnType As Integer = ModelingLine(dStart_x, dStart_y, dEnd_x, dEnd_y, sUid) |
1414 | If iConnType = 1 Then |
||
1415 | objInputs.AddLocatedTarget(dStart_x, dStart_y) |
||
1416 | objInputs.AddPoint(dEnd_x, dEnd_y) |
||
1417 | ElseIf iConnType = 2 Then |
||
1418 | objInputs.AddLocatedTarget(dEnd_x, dEnd_y) |
||
1419 | objInputs.AddPoint(dStart_x, dStart_y) |
||
1420 | ElseIf iConnType = 3 Then |
||
1421 | objInputs.AddLocatedTarget(dEnd_x, dEnd_y) |
||
1422 | objInputs.AddPoint(dStart_x, dStart_y) |
||
1423 | ElseIf iConnType = 4 Then |
||
1424 | objInputs.AddLocatedTarget(dStart_x, dStart_y) |
||
1425 | objInputs.AddPoint(dEnd_x, dEnd_y) |
||
1426 | Else |
||
1427 | objInputs.AddPoint(dStart_x, dStart_y) |
||
1428 | objInputs.AddPoint(dEnd_x, dEnd_y) |
||
1429 | End If |
||
1430 | 171ac39d | Gyusu | objInputs.AddPoint(dStart_x, dStart_y) |
1431 | objInputs.AddPoint(dEnd_x, dEnd_y) |
||
1432 | 41e4023e | Gyusu | AddModelingLine(dStart_x, dStart_y, dEnd_x, dEnd_y, sUid) |
1433 | 171ac39d | Gyusu | objItem = _Placement.PIDCreateItem(sSystempath) |
1434 | 9e1e7135 | Gyusu | _iPipecnt = _iPipecnt + 1 |
1435 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place PipeLine..(" & dOriginalStart_x & "," & dOriginalStart_y & ") - (" & dOriginalEnd_x & "," & dOriginalEnd_y & ").." & _iPipecnt & " count ") |
1436 | 171ac39d | Gyusu | objConnector = _Placement.PIDPlaceRun(objItem, objInputs) |
1437 | oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID) |
||
1438 | 559daf6d | Gyusu | oPipeRun.Attributes("FlowDirection").Value = "End 1 is upstream (Inlet)" |
1439 | 171ac39d | Gyusu | If oAttributeRow.Length > 0 Then |
1440 | For Each oAttribute In oAttributeRow |
||
1441 | 54b98e09 | Gyusu | Try |
1442 | Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString() |
||
1443 | Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString() |
||
1444 | e4000111 | Gyusu | If sPIDValue.Contains("'") Then |
1445 | sPIDValue = sPIDValue.Replace("'", """") |
||
1446 | End If |
||
1447 | |||
1448 | 54b98e09 | Gyusu | Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE) |
1449 | oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue |
||
1450 | Catch ex As Exception |
||
1451 | |||
1452 | End Try |
||
1453 | |||
1454 | 559daf6d | Gyusu | |
1455 | 171ac39d | Gyusu | Next |
1456 | oPipeRun.Commit() |
||
1457 | End If |
||
1458 | 6a6d8ab4 | Gyusu | 'Flow Direction |
1459 | e4000111 | Gyusu | 'Dim sFlowDirectionPath As String = "\Piping\Labels - Piping Segments\Flow Direction.sym" 'GetDataFromMappingDB(_XML_CATEGORY_FLOWDIRECITON, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
1460 | 'Dim dFlowDirectionAngle As Double = 0.0 |
||
1461 | 'If dStart_y <> dEnd_y Then |
||
1462 | ' If dStart_y > dEnd_y Then |
||
1463 | ' dFlowDirectionAngle = -1.57 |
||
1464 | ' Else |
||
1465 | ' dFlowDirectionAngle = 1.57 |
||
1466 | ' End If |
||
1467 | 'End If |
||
1468 | 'If dStart_x <> dEnd_x Then |
||
1469 | ' If dStart_x > dEnd_x Then |
||
1470 | ' dFlowDirectionAngle = 3.14 |
||
1471 | ' Else |
||
1472 | ' dFlowDirectionAngle = 0 |
||
1473 | ' End If |
||
1474 | 'End If |
||
1475 | |||
1476 | '_Placement.PIDPlaceSymbol(sFlowDirectionPath, dEnd_x, dEnd_y, , dFlowDirectionAngle) |
||
1477 | 171ac39d | Gyusu | End If |
1478 | End If |
||
1479 | 41e4023e | Gyusu | _Itemcnt = _Itemcnt + 1 |
1480 | Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100 |
||
1481 | SetProgressbar(ProgressBar_Status, dCalcProgressValue) |
||
1482 | Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%" |
||
1483 | 3acffcee | Gyusu | |
1484 | oAddPiperunRow("Piperun") = oPipeRun |
||
1485 | oAddPiperunRow("startx") = dOriginalStart_x |
||
1486 | oAddPiperunRow("starty") = dOriginalStart_y |
||
1487 | oAddPiperunRow("endx") = dOriginalEnd_x |
||
1488 | oAddPiperunRow("endy") = dOriginalEnd_y |
||
1489 | oPiperun_Dt.Rows.Add(oAddPiperunRow) |
||
1490 | |||
1491 | 171ac39d | Gyusu | End If |
1492 | Return oPipeRun |
||
1493 | Catch ex As Exception |
||
1494 | Return Nothing |
||
1495 | End Try |
||
1496 | e1cde8f2 | Gyusu | End Function |
1497 | |||
1498 | 41e4023e | Gyusu | Private Sub AddModelingLine(ByVal dStart_x As Double, ByVal dStart_y As Double, ByVal dEnd_x As Double, ByVal dEnd_y As Double, ByVal sUid As String) |
1499 | 54b98e09 | Gyusu | Dim oAddRow = _DrawLine_Dt.NewRow() |
1500 | 41e4023e | Gyusu | oAddRow(_XML_LINE_UID) = sUid |
1501 | 54b98e09 | Gyusu | oAddRow(_XML_LINE_STARTPOINT_X) = dStart_x |
1502 | oAddRow(_XML_LINE_STARTPOINT_Y) = dStart_y |
||
1503 | oAddRow(_XML_LINE_ENDPOINT_X) = dEnd_x |
||
1504 | oAddRow(_XML_LINE_ENDPOINT_Y) = dEnd_y |
||
1505 | _DrawLine_Dt.Rows.Add(oAddRow) |
||
1506 | End Sub |
||
1507 | |||
1508 | |||
1509 | 41e4023e | Gyusu | Private Function ModelingLine(ByVal dStart_x As Double, ByVal dStart_y As Double, ByVal dEnd_x As Double, ByVal dEnd_y As Double, ByVal sUid As String) As Integer |
1510 | 'Dim oFindRows_1 As DataRow() = _DrawLine_Dt.Select("start_x = '" & dStart_x & "' and start_y = '" & dStart_y & "' and uid <> '" & sUid & "'") |
||
1511 | 54b98e09 | Gyusu | |
1512 | 41e4023e | Gyusu | 'Dim oFindRows_2 As DataRow() = _DrawLine_Dt.Select("end_x = '" & dEnd_x & "' and end_y = '" & dEnd_y & "' and uid <> '" & sUid & "'") |
1513 | 54b98e09 | Gyusu | |
1514 | 41e4023e | Gyusu | 'Dim oFindRows_3 As DataRow() = _DrawLine_Dt.Select("start_x = '" & dEnd_x & "' and start_y = '" & dEnd_y & "' and uid <> '" & sUid & "'") |
1515 | 54b98e09 | Gyusu | |
1516 | 41e4023e | Gyusu | 'Dim oFindRows_4 As DataRow() = _DrawLine_Dt.Select("end_x = '" & dStart_x & "' and end_y = '" & dStart_y & "' and uid <> '" & sUid & "'") |
1517 | 54b98e09 | Gyusu | |
1518 | 41e4023e | Gyusu | 'If oFindRows_1.Length > 0 Then |
1519 | ' Return 1 |
||
1520 | 'ElseIf oFindRows_2.Length > 0 Then |
||
1521 | ' Return 2 |
||
1522 | 'ElseIf oFindRows_3.Length > 0 Then |
||
1523 | ' Return 3 |
||
1524 | 'ElseIf oFindRows_4.Length > 0 Then |
||
1525 | ' Return 4 |
||
1526 | 'Else |
||
1527 | ' Return 0 |
||
1528 | 'End If |
||
1529 | Return 0 |
||
1530 | 54b98e09 | Gyusu | End Function |
1531 | |||
1532 | Private Function FindConnectionPoint(ByVal dX As Double, ByVal dY As Double) |
||
1533 | |||
1534 | |||
1535 | End Function |
||
1536 | |||
1537 | 41e4023e | Gyusu | Private Sub PlaceEquipment(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable) |
1538 | Try |
||
1539 | Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'") |
||
1540 | Dim oAttributeRow() As DataRow |
||
1541 | If oAttribute_Dt.Rows.Count > 0 Then |
||
1542 | oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'") |
||
1543 | End If |
||
1544 | If oSymbolRow.Length > 0 Then |
||
1545 | Dim oDatasource As Object = _Placement.PIDDataSource |
||
1546 | Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString() |
||
1547 | Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString() |
||
1548 | Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString() |
||
1549 | Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString() |
||
1550 | Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString() |
||
1551 | Dim dAngle As Double = 0.0 |
||
1552 | If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then |
||
1553 | dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) |
||
1554 | End If |
||
1555 | Dim dLocationX As Double = 0.0 |
||
1556 | Dim dLocationY As Double = 0.0 |
||
1557 | Dim dX As Double = 0.0 |
||
1558 | Dim dY As Double = 0.0 |
||
1559 | |||
1560 | If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then |
||
1561 | dX = dLocationX |
||
1562 | dY = dLocationY |
||
1563 | ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
||
1564 | _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
||
1565 | SetListBoxItems(ListBox_Result, "Place Equipment..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ") |
||
1566 | End If |
||
1567 | End If |
||
1568 | Catch ex As Exception |
||
1569 | |||
1570 | End Try |
||
1571 | |||
1572 | |||
1573 | End Sub |
||
1574 | 54b98e09 | Gyusu | |
1575 | e4000111 | Gyusu | Private Sub PlacePipingOPC(ByVal sUid As String, ByVal sLineUid As String, ByVal oOPCRow As DataRow, ByVal oAttribute_Dt As DataTable) |
1576 | Try |
||
1577 | Dim oAttributeRow() As DataRow |
||
1578 | If oAttribute_Dt.Rows.Count > 0 Then |
||
1579 | oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'") |
||
1580 | End If |
||
1581 | Dim oDatasource As Object = _Placement.PIDDataSource |
||
1582 | Dim sSymbolCompType As String = oOPCRow(_XML_SYMBOL_TYPE).ToString() |
||
1583 | Dim sSystemPath As String = oOPCRow(_XML_SYMBOL_SYSTEMPATH).ToString() |
||
1584 | Dim sClass As String = oOPCRow(_XML_SYMBOL_CLASS).ToString() |
||
1585 | Dim sLocation As String = oOPCRow(_XML_SYMBOL_LOCATION).ToString() |
||
1586 | Dim sOriginalPoint As String = oOPCRow(_XML_SYMBOL_ORIGINALPOINT).ToString() |
||
1587 | Dim dAngle As Double = 0.0 |
||
1588 | If IsNumeric(oOPCRow(_XML_SYMBOL_ANGLE).ToString()) Then |
||
1589 | dAngle = Double.Parse(oOPCRow(_XML_SYMBOL_ANGLE).ToString()) |
||
1590 | End If |
||
1591 | |||
1592 | Dim dLocationX As Double = 0.0 |
||
1593 | Dim dLocationY As Double = 0.0 |
||
1594 | Dim dX As Double = 0.0 |
||
1595 | Dim dY As Double = 0.0 |
||
1596 | |||
1597 | If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then |
||
1598 | dX = dLocationX |
||
1599 | dY = dLocationY |
||
1600 | ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
||
1601 | _iPipintOpccnt = _iPipintOpccnt + 1 |
||
1602 | Dim oLMSymbol As LMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
||
1603 | '모델링된 형상은 Drawing True 로 처리 |
||
1604 | oOPCRow(_XML_SYMBOL_DRAWING_TF) = "True" |
||
1605 | SetListBoxItems(ListBox_Result, "Place Piping OPC..(" & dLocationX & "," & dLocationY & ")..." & _iPipintOpccnt & " count ") |
||
1606 | |||
1607 | Dim dConn_X1 As Double, dConn_Y1 As Double, dConn_X2 As Double, dConn_Y2 As Double |
||
1608 | _Placement.PIDConnectPointLocation(oLMSymbol, 1, dConn_X1, dConn_Y1) |
||
1609 | _Placement.PIDConnectPointLocation(oLMSymbol, 2, dConn_X2, dConn_Y2) |
||
1610 | |||
1611 | Dim oAddrow As DataRow = _ResultModeling_DT.NewRow() |
||
1612 | oAddrow(_Modeling_Uid) = sUid |
||
1613 | oAddrow(_Modeling_Location_X) = dLocationX |
||
1614 | oAddrow(_Modeling_Location_Y) = dLocationY |
||
1615 | oAddrow(_Modeling_LineNoUid) = sLineUid |
||
1616 | oAddrow(_Modeling_Type) = sSymbolCompType |
||
1617 | oAddrow(_Modeling_Connection1_X) = dConn_X1 |
||
1618 | oAddrow(_Modeling_Connection1_Y) = dConn_Y1 |
||
1619 | oAddrow(_Modeling_Connection2_X) = dConn_X2 |
||
1620 | oAddrow(_Modeling_Connection2_X) = dConn_Y2 |
||
1621 | oAddrow(_Modeling_LMSymbol) = oLMSymbol |
||
1622 | _ResultModeling_DT.Rows.Add(oAddrow) |
||
1623 | End If |
||
1624 | _Itemcnt = _Itemcnt + 1 |
||
1625 | Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100 |
||
1626 | SetProgressbar(ProgressBar_Status, dCalcProgressValue) |
||
1627 | Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%" |
||
1628 | |||
1629 | Catch ex As Exception |
||
1630 | |||
1631 | End Try |
||
1632 | |||
1633 | |||
1634 | End Sub |
||
1635 | |||
1636 | |||
1637 | Private Function DrawSymbol(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oLine_Dt As DataTable) As Boolean |
||
1638 | 171ac39d | Gyusu | Try |
1639 | e282643f | Gyusu | |
1640 | 171ac39d | Gyusu | Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'") |
1641 | 6a6d8ab4 | Gyusu | Dim oAttributeRow() As DataRow |
1642 | If oAttribute_Dt.Rows.Count > 0 Then |
||
1643 | 460d6abd | Gyusu | oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'") |
1644 | 6a6d8ab4 | Gyusu | End If |
1645 | |||
1646 | 171ac39d | Gyusu | If oSymbolRow.Length > 0 Then |
1647 | Dim oDatasource As Object = _Placement.PIDDataSource |
||
1648 | Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString() |
||
1649 | Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString() |
||
1650 | 54b98e09 | Gyusu | Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString() |
1651 | 171ac39d | Gyusu | Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString() |
1652 | 9e1e7135 | Gyusu | Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString() |
1653 | 171ac39d | Gyusu | Dim dAngle As Double = 0.0 |
1654 | If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then |
||
1655 | dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) |
||
1656 | End If |
||
1657 | |||
1658 | Dim objSymbol As LMSymbol |
||
1659 | 9e1e7135 | Gyusu | Dim dLocationX As Double = 0.0 |
1660 | Dim dLocationY As Double = 0.0 |
||
1661 | 171ac39d | Gyusu | Dim dX As Double = 0.0 |
1662 | Dim dY As Double = 0.0 |
||
1663 | |||
1664 | 9e1e7135 | Gyusu | If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then |
1665 | dX = dLocationX |
||
1666 | dY = dLocationY |
||
1667 | 54b98e09 | Gyusu | If sSymbolCompType = "" Or sSymbolCompType = "Piping OPC's" Then |
1668 | FindConnectionLine(oLine_Dt, dX, dY) |
||
1669 | End If |
||
1670 | |||
1671 | 9e1e7135 | Gyusu | ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
1672 | e4000111 | Gyusu | Dim oInstrument As LMInstrument |
1673 | 54b98e09 | Gyusu | If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then |
1674 | 9e1e7135 | Gyusu | _iInstrumentcnt = _iInstrumentcnt + 1 |
1675 | 171ac39d | Gyusu | objSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1676 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place Instrument..(" & dLocationX & "," & dLocationY & ")..." & _iInstrumentcnt & " count ") |
1677 | 171ac39d | Gyusu | oInstrument = oDatasource.GetInstrument(objSymbol.ModelItemID) |
1678 | 6a6d8ab4 | Gyusu | Try |
1679 | If oAttributeRow.Length > 0 Then |
||
1680 | For Each oAttribute In oAttributeRow |
||
1681 | 54b98e09 | Gyusu | Try |
1682 | Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString() |
||
1683 | Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString() |
||
1684 | Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE) |
||
1685 | oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue |
||
1686 | Catch ex As Exception |
||
1687 | |||
1688 | End Try |
||
1689 | |||
1690 | 6a6d8ab4 | Gyusu | Next |
1691 | oInstrument.Commit() |
||
1692 | End If |
||
1693 | Catch ex As Exception |
||
1694 | End Try |
||
1695 | 54b98e09 | Gyusu | ElseIf sSymbolCompType.ToUpper() = _DB_FITTINGS.ToUpper() Then |
1696 | 9e1e7135 | Gyusu | _iValvecnt = _iValvecnt + 1 |
1697 | 171ac39d | Gyusu | _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1698 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place Valve..(" & dLocationX & "," & dLocationY & ")..." & _iValvecnt & " count ") |
1699 | 171ac39d | Gyusu | |
1700 | 54b98e09 | Gyusu | ElseIf sSymbolCompType.ToUpper() = _SYMBOL_FITTINGS.ToUpper() Then |
1701 | 9e1e7135 | Gyusu | _iFittingcnt = _iFittingcnt + 1 |
1702 | d039e347 | Gyusu | If sSystemPath.Contains(",") Then |
1703 | |||
1704 | Dim sDuplicatePath As String() = sSystemPath.Split(",") |
||
1705 | Dim sMainSymbol As String = "" |
||
1706 | Dim sSubSymbol As String = "" |
||
1707 | For Each sPath In sDuplicatePath |
||
1708 | If sMainSymbol = "" Then |
||
1709 | sMainSymbol = sPath.Replace(vbLf, "") |
||
1710 | Else |
||
1711 | sSubSymbol = sPath.Replace(vbLf, "") |
||
1712 | End If |
||
1713 | Next |
||
1714 | Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle) |
||
1715 | Dim dConnpos_x As Double = 0.0 |
||
1716 | Dim dConnpos_y As Double = 0.0 |
||
1717 | _Placement.PIDConnectPointLocation(oSymbolObj, 2, dConnpos_x, dConnpos_y) |
||
1718 | ' _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y, dAngle, TargetItem:=oSymbolObj.AsLMRepresentation) |
||
1719 | _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y,, dAngle) |
||
1720 | |||
1721 | Else |
||
1722 | _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
||
1723 | End If |
||
1724 | |||
1725 | |||
1726 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ") |
1727 | 54b98e09 | Gyusu | ElseIf sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() And sClass.ToUpper() = _SYMBOL_ACTUATORS.ToUpper() Then |
1728 | d039e347 | Gyusu | _iFittingcnt = _iFittingcnt + 1 |
1729 | Dim sDuplicatePath As String() = sSystemPath.Split(",") |
||
1730 | Dim sMainSymbol As String = "" |
||
1731 | Dim sSubSymbol As String = "" |
||
1732 | For Each sPath In sDuplicatePath |
||
1733 | If sMainSymbol = "" Then |
||
1734 | sMainSymbol = sPath.Replace(vbLf, "") |
||
1735 | Else |
||
1736 | sSubSymbol = sPath.Replace(vbLf, "") |
||
1737 | End If |
||
1738 | Next |
||
1739 | Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle) |
||
1740 | Dim dSymbolpos_x As Double = oSymbolObj.XCoordinate |
||
1741 | Dim dSymbolpos_y As Double = oSymbolObj.YCoordinate |
||
1742 | _Placement.PIDPlaceSymbol(sSubSymbol, dSymbolpos_x, dSymbolpos_y, , dAngle, TargetItem:=oSymbolObj.AsLMAItem) |
||
1743 | |||
1744 | 171ac39d | Gyusu | Else |
1745 | 9e1e7135 | Gyusu | _iFittingcnt = _iFittingcnt + 1 |
1746 | 171ac39d | Gyusu | _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1747 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ") |
1748 | 171ac39d | Gyusu | End If |
1749 | e4000111 | Gyusu | |
1750 | End If |
||
1751 | 41e4023e | Gyusu | _Itemcnt = _Itemcnt + 1 |
1752 | Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100 |
||
1753 | SetProgressbar(ProgressBar_Status, dCalcProgressValue) |
||
1754 | Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%" |
||
1755 | End If |
||
1756 | 171ac39d | Gyusu | |
1757 | 54b98e09 | Gyusu | Catch ex As Exception |
1758 | Return False |
||
1759 | End Try |
||
1760 | End Function |
||
1761 | |||
1762 | |||
1763 | Private Sub FindConnectionLine(ByVal oLine_Dt As DataTable, ByRef dx As Double, ByRef dy As Double) |
||
1764 | |||
1765 | Try |
||
1766 | For Each oRow In oLine_Dt.Rows |
||
1767 | Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString() |
||
1768 | Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString() |
||
1769 | Dim d기준s_x As Double = 0 |
||
1770 | Dim d기준s_y As Double = 0 |
||
1771 | Dim d기준e_x As Double = 0 |
||
1772 | Dim d기준e_y As Double = 0 |
||
1773 | ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y) |
||
1774 | ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y) |
||
1775 | If dx + 300 > d기준s_x And dx - 300 < d기준s_x And dy + 300 > d기준s_y And dy - 300 < d기준s_y Then |
||
1776 | dx = d기준s_x |
||
1777 | dy = d기준s_y |
||
1778 | ElseIf dx + 300 > d기준e_x And dx - 300 < d기준e_x And dy + 300 > d기준e_y And dy - 300 < d기준e_y Then |
||
1779 | dx = d기준e_x |
||
1780 | dy = d기준e_y |
||
1781 | End If |
||
1782 | Next |
||
1783 | Catch ex As Exception |
||
1784 | End Try |
||
1785 | End Sub |
||
1786 | |||
1787 | |||
1788 | Dim _라인보정기준값 As Integer = 10 |
||
1789 | |||
1790 | Private Function 라인보정(ByRef oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double, |
||
1791 | ByRef dex As Double, ByRef dey As Double) |
||
1792 | Try |
||
1793 | Dim bCheck라인 As Boolean = False |
||
1794 | '일치하는 Line 찾기 |
||
1795 | For Each oRow In oLine_Dt.Rows |
||
1796 | Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString() |
||
1797 | Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString() |
||
1798 | Dim sBUid As String = oRow(_XML_LINE_UID).ToString() |
||
1799 | If sBUid <> sUid Then |
||
1800 | Dim d기준s_x As Double = 0 |
||
1801 | Dim d기준s_y As Double = 0 |
||
1802 | Dim d기준e_x As Double = 0 |
||
1803 | Dim d기준e_y As Double = 0 |
||
1804 | ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y) |
||
1805 | ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y) |
||
1806 | |||
1807 | If (dsx = d기준s_x And dsy = d기준s_y) Or (dsx = d기준e_x And dsy = d기준e_y) Or |
||
1808 | (dex = d기준s_x And dey = d기준s_y) Or (dex = d기준e_x And dey = d기준e_y) Then |
||
1809 | bCheck라인 = True |
||
1810 | End If |
||
1811 | End If |
||
1812 | Next |
||
1813 | |||
1814 | If bCheck라인 = False Then |
||
1815 | For Each oRow In oLine_Dt.Rows |
||
1816 | Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString() |
||
1817 | Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString() |
||
1818 | Dim sBUid As String = oRow(_XML_LINE_UID).ToString() |
||
1819 | If sBUid <> sUid Then |
||
1820 | Dim d기준s_x As Double = 0 |
||
1821 | Dim d기준s_y As Double = 0 |
||
1822 | Dim d기준e_x As Double = 0 |
||
1823 | Dim d기준e_y As Double = 0 |
||
1824 | ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y) |
||
1825 | ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y) |
||
1826 | If ((dsx - _라인보정기준값 <= d기준s_x And dsx + _라인보정기준값 >= d기준s_x) And (dsy - _라인보정기준값 <= d기준s_y And dsy + _라인보정기준값 >= d기준s_y)) Then |
||
1827 | oRow(_XML_LINE_STARTPOINT) = dsx & "," & dsy |
||
1828 | bCheck라인 = True |
||
1829 | Exit For |
||
1830 | ElseIf ((dsx - _라인보정기준값 <= d기준e_x And dsx + _라인보정기준값 >= d기준e_x) And (dsy - _라인보정기준값 <= d기준e_y And dsy + _라인보정기준값 >= d기준e_y)) Then |
||
1831 | oRow(_XML_LINE_ENDPOINT) = dsx & "," & dsy |
||
1832 | bCheck라인 = True |
||
1833 | Exit For |
||
1834 | ElseIf ((dex - _라인보정기준값 <= d기준s_x And dex + _라인보정기준값 >= d기준s_x) And (dey - _라인보정기준값 <= d기준s_y And dey + _라인보정기준값 >= d기준s_y)) Then |
||
1835 | oRow(_XML_LINE_STARTPOINT) = dex & "," & dey |
||
1836 | bCheck라인 = True |
||
1837 | Exit For |
||
1838 | ElseIf ((dex - _라인보정기준값 <= d기준e_x And dex + _라인보정기준값 >= d기준e_x) And (dey - _라인보정기준값 <= d기준e_y And dey + _라인보정기준값 >= d기준e_y)) Then |
||
1839 | oRow(_XML_LINE_ENDPOINT) = dex & "," & dey |
||
1840 | bCheck라인 = True |
||
1841 | Exit For |
||
1842 | End If |
||
1843 | |||
1844 | End If |
||
1845 | Next |
||
1846 | 171ac39d | Gyusu | End If |
1847 | |||
1848 | 54b98e09 | Gyusu | Return bCheck라인 |
1849 | 171ac39d | Gyusu | Catch ex As Exception |
1850 | Return False |
||
1851 | End Try |
||
1852 | 54b98e09 | Gyusu | |
1853 | |||
1854 | 171ac39d | Gyusu | End Function |
1855 | |||
1856 | 460d6abd | Gyusu | Private Function FindOverlapLine(ByVal oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double, |
1857 | ByRef dex As Double, ByRef dey As Double) |
||
1858 | Try |
||
1859 | Dim bCheckOverlap As Boolean = False |
||
1860 | For Each oRow In oLine_Dt.Rows |
||
1861 | Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString() |
||
1862 | Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString() |
||
1863 | Dim sBUid As String = oRow(_XML_LINE_UID).ToString() |
||
1864 | If sBUid <> sUid Then |
||
1865 | Dim d기준s_x As Double = 0 |
||
1866 | Dim d기준s_y As Double = 0 |
||
1867 | Dim d기준e_x As Double = 0 |
||
1868 | Dim d기준e_y As Double = 0 |
||
1869 | ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y) |
||
1870 | ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y) |
||
1871 | 54b98e09 | Gyusu | If (d기준s_x <= dsx And d기준e_x >= dex And |
1872 | d기준s_y <= dsy And d기준e_y >= dey) Then |
||
1873 | 460d6abd | Gyusu | '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정 |
1874 | If dsy - d기준s_y > d기준e_y - dey Then |
||
1875 | Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100 |
||
1876 | If dResultCalc < 10 Then |
||
1877 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1878 | Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y) |
||
1879 | Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x) |
||
1880 | Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX |
||
1881 | If dCalcStartY = 0 Then |
||
1882 | dey = d기준e_y |
||
1883 | Else |
||
1884 | dey = dCalcStartY |
||
1885 | End If |
||
1886 | End If |
||
1887 | Else |
||
1888 | abb01e6c | Gyusu | ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100 |
1889 | Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100 |
||
1890 | 460d6abd | Gyusu | If dResultCalc < 10 Then |
1891 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1892 | Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y) |
||
1893 | Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x) |
||
1894 | Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX |
||
1895 | If dCalcStartY = 0 Then |
||
1896 | dsy = d기준s_y |
||
1897 | Else |
||
1898 | dsy = dCalcStartY |
||
1899 | End If |
||
1900 | End If |
||
1901 | End If |
||
1902 | bCheckOverlap = True |
||
1903 | ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And |
||
1904 | d기준s_y <= dey And d기준e_y >= dsy Then |
||
1905 | '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정 |
||
1906 | If dey - d기준s_y > d기준e_y - dsy Then |
||
1907 | Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100 |
||
1908 | If dResultCalc < 10 Then |
||
1909 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1910 | Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y) |
||
1911 | Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x) |
||
1912 | Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX |
||
1913 | If dCalcStartY = 0 Then |
||
1914 | abb01e6c | Gyusu | dsy = d기준e_y |
1915 | 460d6abd | Gyusu | Else |
1916 | abb01e6c | Gyusu | dsy = dCalcStartY |
1917 | 460d6abd | Gyusu | End If |
1918 | |||
1919 | End If |
||
1920 | '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정 |
||
1921 | Else |
||
1922 | abb01e6c | Gyusu | ' Dim dResultCalc As Double = (Math.Abs((dsy - d기준s_y)) / Math.Abs((d기준e_y - dey))) * 100 |
1923 | Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100 |
||
1924 | 460d6abd | Gyusu | If dResultCalc < 10 Then |
1925 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1926 | Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y) |
||
1927 | Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x) |
||
1928 | Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX |
||
1929 | If dCalcStartY = 0 Then |
||
1930 | abb01e6c | Gyusu | dey = d기준e_y |
1931 | 460d6abd | Gyusu | Else |
1932 | abb01e6c | Gyusu | dey = dCalcStartY |
1933 | 460d6abd | Gyusu | End If |
1934 | End If |
||
1935 | End If |
||
1936 | bCheckOverlap = True |
||
1937 | ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And |
||
1938 | d기준s_y <= dey And d기준e_y >= dsy Then |
||
1939 | |||
1940 | If dsx - d기준s_x > d기준e_x - dex Then |
||
1941 | Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100 |
||
1942 | If dResultCalc < 10 Then |
||
1943 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1944 | Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y) |
||
1945 | Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y) |
||
1946 | Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY |
||
1947 | If dCalcStartX = 0 Then |
||
1948 | dex = d기준e_x |
||
1949 | Else |
||
1950 | dex = dCalcStartX |
||
1951 | End If |
||
1952 | End If |
||
1953 | Else |
||
1954 | abb01e6c | Gyusu | ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100 |
1955 | Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100 |
||
1956 | 460d6abd | Gyusu | If dResultCalc < 10 Then |
1957 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1958 | Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y) |
||
1959 | Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y) |
||
1960 | Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY |
||
1961 | If dCalcStartX = 0 Then |
||
1962 | dsx = d기준s_x |
||
1963 | Else |
||
1964 | dsx = dCalcStartX |
||
1965 | End If |
||
1966 | End If |
||
1967 | End If |
||
1968 | bCheckOverlap = True |
||
1969 | ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And |
||
1970 | d기준s_y <= dey And d기준e_y >= dsy Then |
||
1971 | |||
1972 | If dex - d기준s_x > d기준e_x - dsx Then |
||
1973 | Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100 |
||
1974 | If dResultCalc < 10 Then |
||
1975 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1976 | Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y) |
||
1977 | Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y) |
||
1978 | Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY |
||
1979 | If dCalcStartX = 0 Then |
||
1980 | abb01e6c | Gyusu | dsx = d기준e_x |
1981 | 460d6abd | Gyusu | Else |
1982 | abb01e6c | Gyusu | dsx = dCalcStartX |
1983 | 460d6abd | Gyusu | End If |
1984 | End If |
||
1985 | Else |
||
1986 | abb01e6c | Gyusu | ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100 |
1987 | Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100 |
||
1988 | 460d6abd | Gyusu | If dResultCalc < 10 Then |
1989 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1990 | Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y) |
||
1991 | Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y) |
||
1992 | Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY |
||
1993 | If dCalcStartX = 0 Then |
||
1994 | abb01e6c | Gyusu | dex = d기준s_x |
1995 | 460d6abd | Gyusu | Else |
1996 | abb01e6c | Gyusu | dex = dCalcStartX |
1997 | 460d6abd | Gyusu | End If |
1998 | End If |
||
1999 | |||
2000 | End If |
||
2001 | bCheckOverlap = True |
||
2002 | End If |
||
2003 | End If |
||
2004 | Next |
||
2005 | 3acffcee | Gyusu | |
2006 | 460d6abd | Gyusu | Return bCheckOverlap |
2007 | Catch ex As Exception |
||
2008 | Return False |
||
2009 | End Try |
||
2010 | End Function |
||
2011 | |||
2012 | Private Sub CalcSperateLine(ByRef dStartX As Double, ByRef dStartY As Double, |
||
2013 | ByRef dEndX As Double, ByRef dEndY As Double) |
||
2014 | Try |
||
2015 | 54b98e09 | Gyusu | Dim dRange As Double = 1 'Line 전체 길이의 10%씩 늘이기 |
2016 | 460d6abd | Gyusu | If Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then |
2017 | 54b98e09 | Gyusu | Dim dCalc_x As Double = Math.Abs(dStartX - dEndX) * 0.1 |
2018 | 460d6abd | Gyusu | If dStartX > dEndX Then |
2019 | dStartX = dStartX + dCalc_x |
||
2020 | dEndX = dEndX - dCalc_x |
||
2021 | Else |
||
2022 | dEndX = dEndX + dCalc_x |
||
2023 | dStartX = dStartX - dCalc_x |
||
2024 | End If |
||
2025 | Else |
||
2026 | 54b98e09 | Gyusu | Dim dCalc_y As Double = Math.Abs(dStartY - dEndY) * 0.1 |
2027 | 460d6abd | Gyusu | If dStartY > dEndY Then |
2028 | dStartY = dStartY + dCalc_y |
||
2029 | dEndY = dEndY - dCalc_y |
||
2030 | Else |
||
2031 | dEndY = dEndY + dCalc_y |
||
2032 | dStartY = dStartY - dCalc_y |
||
2033 | End If |
||
2034 | End If |
||
2035 | |||
2036 | Catch ex As Exception |
||
2037 | |||
2038 | End Try |
||
2039 | |||
2040 | |||
2041 | End Sub |
||
2042 | |||
2043 | 3acffcee | Gyusu | Private Function DrawLineNo(ByVal oPipeRun_Dt As DataTable, ByVal CLine_No As Line_no) As Boolean |
2044 | 171ac39d | Gyusu | Try |
2045 | Dim oDatasource As Object = _Placement.PIDDataSource |
||
2046 | Dim sLocation = CLine_No.Location |
||
2047 | 9e1e7135 | Gyusu | Dim dLocationx As Double = 0.0 |
2048 | Dim dLocationy As Double = 0.0 |
||
2049 | |||
2050 | 171ac39d | Gyusu | Dim dX As Double = 0.0 |
2051 | Dim dY As Double = 0.0 |
||
2052 | 9e1e7135 | Gyusu | If ConvertPointBystring(sLocation, dLocationx, dLocationy) Then |
2053 | dX = dLocationx |
||
2054 | dY = dLocationy |
||
2055 | 3acffcee | Gyusu | |
2056 | For Each oRow In oPipeRun_Dt.Rows |
||
2057 | Dim dStartx As Double = Double.Parse(oRow("startx").ToString()) |
||
2058 | Dim dStarty As Double = Double.Parse(oRow("starty").ToString()) |
||
2059 | Dim dEndx As Double = Double.Parse(oRow("endx").ToString()) |
||
2060 | Dim dEndy As Double = Double.Parse(oRow("endy").ToString()) |
||
2061 | |||
2062 | Dim dStartSum As Double = Math.Abs(dStartx - dLocationx) + Math.Abs(dStarty - dLocationy) |
||
2063 | Dim dEndSum As Double = Math.Abs(dEndx - dLocationx) + Math.Abs(dEndy - dLocationy) |
||
2064 | If dStartSum > dEndSum Then |
||
2065 | oRow("value") = dEndSum |
||
2066 | Else |
||
2067 | oRow("value") = dStartSum |
||
2068 | 171ac39d | Gyusu | End If |
2069 | 3acffcee | Gyusu | |
2070 | 171ac39d | Gyusu | Next |
2071 | 3acffcee | Gyusu | Dim dataView As New DataView(oPipeRun_Dt) |
2072 | dataView.Sort = " value asc" |
||
2073 | Dim oDt As DataTable = dataView.ToTable() |
||
2074 | If oDt.Rows.Count > 0 Then |
||
2075 | Try |
||
2076 | Dim oPiperun As LMPipeRun = CType(oDt.Rows(0)("Piperun"), LMPipeRun) |
||
2077 | ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
||
2078 | Dim dLineNoLocation(2) As Double |
||
2079 | dLineNoLocation(1) = dX |
||
2080 | dLineNoLocation(2) = dY |
||
2081 | 'Label |
||
2082 | Dim sSystemPath As String = CLine_No.SystemPath |
||
2083 | Dim dAngle As Double = CLine_No.Angle |
||
2084 | Dim labelpersist As LMLabelPersist |
||
2085 | |||
2086 | For Each representation In oPiperun.Representations |
||
2087 | If representation.RepresentationType = "Connector" Then |
||
2088 | labelpersist = _Placement.PIDPlaceLabel(sSystemPath, |
||
2089 | dLineNoLocation,, dAngle, LabeledItem:=representation) |
||
2090 | _iPipeLineNocnt = _iPipeLineNocnt + 1 |
||
2091 | SetListBoxItems(ListBox_Result, "Place PipeLineNo Label..(" & dLocationx & "," & dLocationy & ")..." & _iPipeLineNocnt & " count ") |
||
2092 | End If |
||
2093 | Next |
||
2094 | Catch ex As Exception |
||
2095 | |||
2096 | End Try |
||
2097 | |||
2098 | |||
2099 | End If |
||
2100 | |||
2101 | |||
2102 | |||
2103 | 171ac39d | Gyusu | Return True |
2104 | Else |
||
2105 | Return False |
||
2106 | End If |
||
2107 | |||
2108 | Catch ex As Exception |
||
2109 | Return False |
||
2110 | End Try |
||
2111 | End Function |
||
2112 | |||
2113 | 9e1e7135 | Gyusu | |
2114 | Private Sub InitItemCount() |
||
2115 | _iPipeLineNocnt = 0 |
||
2116 | _iPipecnt = 0 |
||
2117 | _iFittingcnt = 0 |
||
2118 | _iValvecnt = 0 |
||
2119 | _iInstrumentcnt = 0 |
||
2120 | _iEquipmentcnt = 0 |
||
2121 | 3acffcee | Gyusu | _iNozzlecnt = 1 |
2122 | e4000111 | Gyusu | _iPipintOpccnt = 0 |
2123 | 3acffcee | Gyusu | |
2124 | 9e1e7135 | Gyusu | End Sub |
2125 | 171ac39d | Gyusu | |
2126 | 41e4023e | Gyusu | Private Function GetAllCheckNodeCount() As Integer |
2127 | _allItem = 0 |
||
2128 | For i = 0 To Tree_Result.Nodes.Count - 1 |
||
2129 | For j = 0 To Tree_Result.Nodes(i).Nodes.Count - 1 |
||
2130 | For k = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes.Count - 1 |
||
2131 | For l = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes.Count - 1 |
||
2132 | If Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes(l).Checked = True Then |
||
2133 | _allItem = _allItem + 1 |
||
2134 | End If |
||
2135 | Next |
||
2136 | Next |
||
2137 | Next |
||
2138 | Next |
||
2139 | Return _allItem |
||
2140 | End Function |
||
2141 | 54b98e09 | Gyusu | |
2142 | |||
2143 | e4000111 | Gyusu | ''' <summary> |
2144 | ''' Equipment 모델링 |
||
2145 | ''' </summary> |
||
2146 | Private Sub EquipmentModeling(ByVal oDwg_Dt As DataTable) |
||
2147 | For Each oDrwing As TreeNode In Tree_Result.Nodes |
||
2148 | For Each oDwgNode As TreeNode In oDrwing.Nodes |
||
2149 | Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text) |
||
2150 | Dim CDrawing As Drawing = GetDrawing(sDwgName) |
||
2151 | If CDrawing IsNot Nothing Then |
||
2152 | If OpenSPPID(oDwg_Dt, oDwgNode.Text) Then |
||
2153 | InitItemCount() |
||
2154 | SetListBoxItems(ListBox_Result, "Place " & CDrawing.DwgName & "....") |
||
2155 | For Each oNode As TreeNode In oDwgNode.Nodes |
||
2156 | Dim iItemcnt As Integer = 0 |
||
2157 | Dim sNodeUid As String = oNode.Name |
||
2158 | Dim oPipeRun_Dt As DataTable = PipeRun_Dt() |
||
2159 | '1.Equipment |
||
2160 | '2.Piping OPC |
||
2161 | '3.OPC 시작되는 Line |
||
2162 | 'Equipment 생성 |
||
2163 | Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid) |
||
2164 | If CEqpNo IsNot Nothing Then |
||
2165 | Dim oSymbol_Dt As DataTable = CEqpNo.Dt_Equipment |
||
2166 | Dim oAttribute_Dt As DataTable = CEqpNo.Dt_Attribute |
||
2167 | For Each oSymbolNode As TreeNode In oNode.Nodes |
||
2168 | If oSymbolNode.Checked Then |
||
2169 | Dim sUid As String = oSymbolNode.Name |
||
2170 | PlaceEquipment(sUid, oSymbol_Dt, oAttribute_Dt) |
||
2171 | End If |
||
2172 | Next |
||
2173 | End If |
||
2174 | Next |
||
2175 | End If |
||
2176 | End If |
||
2177 | Next |
||
2178 | Next |
||
2179 | End Sub |
||
2180 | |||
2181 | Private Sub PipingOPCModeling(ByVal oDwg_Dt As DataTable) |
||
2182 | |||
2183 | 171ac39d | Gyusu | Try |
2184 | For Each oDrwing As TreeNode In Tree_Result.Nodes |
||
2185 | For Each oDwgNode As TreeNode In oDrwing.Nodes |
||
2186 | Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text) |
||
2187 | 54b98e09 | Gyusu | Dim CDrawing As Drawing = GetDrawing(sDwgName) |
2188 | If CDrawing IsNot Nothing Then |
||
2189 | e4000111 | Gyusu | Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode) |
2190 | Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode) |
||
2191 | SetListBoxItems(ListBox_Result, "Place " & CDrawing.DwgName & "....") |
||
2192 | For Each oNode As TreeNode In oDwgNode.Nodes |
||
2193 | Dim iItemcnt As Integer = 0 |
||
2194 | Dim sNodeUid As String = oNode.Name |
||
2195 | Dim oPipeRun_Dt As DataTable = PipeRun_Dt() |
||
2196 | '1.Equipment |
||
2197 | '2.Piping OPC |
||
2198 | '3.OPC 시작되는 Line |
||
2199 | 'Equipment 생성 |
||
2200 | 'If sNodeUid <> "PipeLineNo" Then |
||
2201 | Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid) |
||
2202 | If CLineNo IsNot Nothing Then |
||
2203 | Dim oLine_Dt As DataTable = CLineNo.Dt_Line |
||
2204 | Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol |
||
2205 | Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute |
||
2206 | Dim oDrawLinenoLabel As Boolean = False |
||
2207 | |||
2208 | For Each oSymbolNode As TreeNode In oNode.Nodes |
||
2209 | If oSymbolNode.Checked Then |
||
2210 | Dim sUid As String = oSymbolNode.Name |
||
2211 | Dim oOpc_Rows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sUid & "'") |
||
2212 | If oOpc_Rows.Length = 1 Then |
||
2213 | If oOpc_Rows(0)(_XML_SYMBOL_TYPE) = _XML_PIPINGOPC Then |
||
2214 | PlacePipingOPC(sUid, CLineNo.Uid, oOpc_Rows(0), oAttribute_Dt) |
||
2215 | iPipingOPC_count = iPipingOPC_count + 1 |
||
2216 | 41e4023e | Gyusu | End If |
2217 | |||
2218 | e4000111 | Gyusu | End If |
2219 | 6a6d8ab4 | Gyusu | End If |
2220 | e4000111 | Gyusu | Next |
2221 | 3acffcee | Gyusu | |
2222 | e4000111 | Gyusu | End If |
2223 | Next |
||
2224 | End If |
||
2225 | Next |
||
2226 | Next |
||
2227 | Catch ex As Exception |
||
2228 | 3acffcee | Gyusu | |
2229 | e4000111 | Gyusu | End Try |
2230 | End Sub |
||
2231 | 3acffcee | Gyusu | |
2232 | e4000111 | Gyusu | Private Function CheckOPCConnectionLine(ByVal oOpcRow As DataRow, ByVal oLine_Dt As DataTable) As String |
2233 | Dim sLineUid As String = "" |
||
2234 | Try |
||
2235 | |||
2236 | For Each oLinerow In oLine_Dt.Rows |
||
2237 | |||
2238 | Dim oOpcConn_x1 As Double = oOpcRow(_Modeling_Connection1_X) |
||
2239 | Dim oOpcConn_y1 As Double = oOpcRow(_Modeling_Connection1_Y) |
||
2240 | Dim oOpcConn_x2 As Double = oOpcRow(_Modeling_Connection2_X) |
||
2241 | Dim oOpcConn_y2 As Double = oOpcRow(_Modeling_Connection2_Y) |
||
2242 | Dim oAngle As Double = oOpcRow(_Modeling_Angle) |
||
2243 | Dim dOriginalStart_x As Double = 0.0 |
||
2244 | Dim dOriginalStart_y As Double = 0.0 |
||
2245 | Dim dOriginalEnd_x As Double = 0.0 |
||
2246 | Dim dOriginalEnd_y As Double = 0.0 |
||
2247 | Dim dStart_x As Double = 0.0 |
||
2248 | Dim dStart_y As Double = 0.0 |
||
2249 | Dim dEnd_x As Double = 0.0 |
||
2250 | Dim dEnd_y As Double = 0.0 |
||
2251 | Dim sStartpoint As String = oLinerow(_XML_LINE_STARTPOINT).ToString() |
||
2252 | Dim sEndpoint As String = oLinerow(_XML_LINE_ENDPOINT).ToString() |
||
2253 | Dim sPipeUid As String = oLinerow(_XML_LINE_UID).ToString() |
||
2254 | |||
2255 | ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y) |
||
2256 | dStart_x = dOriginalStart_x |
||
2257 | dStart_y = dOriginalStart_y |
||
2258 | |||
2259 | ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y) |
||
2260 | dEnd_x = dOriginalEnd_x |
||
2261 | dEnd_y = dOriginalEnd_y |
||
2262 | |||
2263 | |||
2264 | If Math.Abs(oOpcConn_x1 - oOpcConn_x2) > Math.Abs(oOpcConn_y1 - oOpcConn_y2) Then |
||
2265 | '가로 OPC |
||
2266 | Dim dCalcY As Double = (oOpcConn_y1 + oOpcConn_y2) / 2 |
||
2267 | If (dStart_x >= oOpcConn_x2 And dStart_x <= oOpcConn_x1 And |
||
2268 | dStart_y < dCalcY + 100 And dStart_y > dCalcY - 100) Or |
||
2269 | (dStart_x >= oOpcConn_x1 And dStart_x <= oOpcConn_x2 And |
||
2270 | dStart_y < dCalcY + 100 And dStart_y > dCalcY - 100) Then |
||
2271 | 'OPC기준 Start점 End 점중 가까운곳을 시작점으로 지정 |
||
2272 | |||
2273 | If Math.Abs(dStart_x - oOpcConn_x1) > Math.Abs(dStart_x - oOpcConn_x2) Then |
||
2274 | dStart_x = oOpcConn_x2 |
||
2275 | oOpcRow(_Modeling_ConnType) = "2" |
||
2276 | Else |
||
2277 | dStart_x = oOpcConn_x1 |
||
2278 | oOpcRow(_Modeling_ConnType) = "1" |
||
2279 | End If |
||
2280 | sLineUid = oLinerow(_XML_LINE_UID).ToString() |
||
2281 | oLinerow(_XML_LINE_STARTPOINT) = dStart_x & "," & dStart_y |
||
2282 | |||
2283 | If dStart_y <> dEnd_y Then |
||
2284 | dEnd_y = dStart_y |
||
2285 | oLinerow(_XML_LINE_ENDPOINT) = dEnd_x & "," & dEnd_y |
||
2286 | End If |
||
2287 | ElseIf (dEnd_x >= oOpcConn_x2 And dEnd_x <= oOpcConn_x1 And |
||
2288 | dEnd_y < dCalcY + 100 And dEnd_y > dCalcY - 100) Or |
||
2289 | (dEnd_x >= oOpcConn_x1 And dEnd_x <= oOpcConn_x2 And |
||
2290 | dEnd_y < dCalcY + 100 And dEnd_y > dCalcY - 100) Then |
||
2291 | 'OPC기준 Start점 End 점중 가까운곳을 시작점으로 지정 |
||
2292 | sLineUid = oLinerow(_XML_LINE_UID).ToString() |
||
2293 | If Math.Abs(dEnd_x - oOpcConn_x1) > Math.Abs(dEnd_x - oOpcConn_x2) Then |
||
2294 | dEnd_x = oOpcConn_x2 |
||
2295 | Else |
||
2296 | dEnd_x = oOpcConn_x1 |
||
2297 | End If |
||
2298 | sLineUid = oLinerow(_XML_LINE_UID).ToString() |
||
2299 | oLinerow(_XML_LINE_ENDPOINT) = dEnd_x & "," & dEnd_y |
||
2300 | |||
2301 | If dStart_y <> dEnd_y Then |
||
2302 | dStart_y = dEnd_y |
||
2303 | oLinerow(_XML_LINE_STARTPOINT) = dStart_x & "," & dStart_y |
||
2304 | End If |
||
2305 | End If |
||
2306 | Else |
||
2307 | '세로 OPC |
||
2308 | Dim dCalcX As Double = (oOpcConn_x1 + oOpcConn_x2) / 2 |
||
2309 | If (dStart_y >= oOpcConn_y2 And dStart_y <= oOpcConn_y1 And |
||
2310 | dStart_x < dCalcX + 100 And dStart_x > dCalcX - 100) Or |
||
2311 | (dStart_y >= oOpcConn_y1 And dStart_y <= oOpcConn_y2 And |
||
2312 | dStart_x < dCalcX + 100 And dStart_x > dCalcX - 100) Then |
||
2313 | 'OPC기준 Start점 End 점중 가까운곳을 시작점으로 지정 |
||
2314 | If Math.Abs(dStart_y - oOpcConn_y1) > Math.Abs(dStart_y - oOpcConn_y2) Then |
||
2315 | dStart_y = oOpcConn_y2 |
||
2316 | oOpcRow(_Modeling_ConnType) = "2" |
||
2317 | Else |
||
2318 | dStart_y = oOpcConn_y1 |
||
2319 | oOpcRow(_Modeling_ConnType) = "1" |
||
2320 | End If |
||
2321 | sLineUid = oLinerow(_XML_LINE_UID).ToString() |
||
2322 | oLinerow(_XML_LINE_STARTPOINT) = dStart_x & "," & dStart_y |
||
2323 | |||
2324 | If dStart_x <> dEnd_x Then |
||
2325 | dEnd_x = dStart_x |
||
2326 | oLinerow(_XML_LINE_ENDPOINT) = dEnd_x & "," & dEnd_y |
||
2327 | End If |
||
2328 | ElseIf (dEnd_y >= oOpcConn_y2 And dEnd_y <= oOpcConn_y1 And |
||
2329 | dEnd_x < dCalcX + 100 And dEnd_x > dCalcX - 100) Or |
||
2330 | (dEnd_y >= oOpcConn_y1 And dEnd_y <= oOpcConn_y2 And |
||
2331 | dEnd_x < dCalcX + 100 And dEnd_x > dCalcX - 100) Then |
||
2332 | 'OPC기준 Start점 End 점중 가까운곳을 시작점으로 지정 |
||
2333 | If Math.Abs(dEnd_y - oOpcConn_y1) > Math.Abs(dEnd_y - oOpcConn_y2) Then |
||
2334 | dEnd_y = oOpcConn_y2 |
||
2335 | Else |
||
2336 | dEnd_y = oOpcConn_y1 |
||
2337 | End If |
||
2338 | sLineUid = oLinerow(_XML_LINE_UID).ToString() |
||
2339 | oLinerow(_XML_LINE_ENDPOINT) = dEnd_x & "," & dEnd_y |
||
2340 | If dStart_x <> dEnd_x Then |
||
2341 | dStart_x = dEnd_x |
||
2342 | oLinerow(_XML_LINE_STARTPOINT) = dStart_x & "," & dStart_y |
||
2343 | End If |
||
2344 | End If |
||
2345 | |||
2346 | |||
2347 | |||
2348 | End If |
||
2349 | |||
2350 | |||
2351 | Next |
||
2352 | |||
2353 | |||
2354 | Catch ex As Exception |
||
2355 | Return sLineUid |
||
2356 | End Try |
||
2357 | Return sLineUid |
||
2358 | |||
2359 | End Function |
||
2360 | |||
2361 | Private Sub PlazeConnectionLine(ByVal oLine_Dt As DataTable, ByVal sLineUid As String, ByVal oRow As DataRow) |
||
2362 | Try |
||
2363 | Dim oOPCLineRow As DataRow() = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sLineUid & "'") |
||
2364 | If oOPCLineRow.Length = 1 Then |
||
2365 | Dim dOriginalStart_x As Double = 0.0 |
||
2366 | Dim dOriginalStart_y As Double = 0.0 |
||
2367 | Dim dOriginalEnd_x As Double = 0.0 |
||
2368 | Dim dOriginalEnd_y As Double = 0.0 |
||
2369 | Dim oOpcConnType As String = oRow(_Modeling_ConnType) |
||
2370 | Dim dStart_x As Double = 0.0 |
||
2371 | Dim dStart_y As Double = 0.0 |
||
2372 | Dim dEnd_x As Double = 0.0 |
||
2373 | Dim dEnd_y As Double = 0.0 |
||
2374 | Dim sStartpoint As String = oOPCLineRow(0)(_XML_LINE_STARTPOINT).ToString() |
||
2375 | Dim sEndpoint As String = oOPCLineRow(0)(_XML_LINE_ENDPOINT).ToString() |
||
2376 | Dim sPipeUid As String = oOPCLineRow(0)(_XML_LINE_UID).ToString() |
||
2377 | |||
2378 | ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y) |
||
2379 | dStart_x = dOriginalStart_x |
||
2380 | dStart_y = dOriginalStart_y |
||
2381 | |||
2382 | ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y) |
||
2383 | dEnd_x = dOriginalEnd_x |
||
2384 | dEnd_y = dOriginalEnd_y |
||
2385 | |||
2386 | Dim objInputs As PlaceRunInputs |
||
2387 | objInputs = New PlaceRunInputs |
||
2388 | If oOpcConnType = "1" Then |
||
2389 | |||
2390 | |||
2391 | ElseIf oOpcConnType = "2" Then |
||
2392 | |||
2393 | |||
2394 | End If |
||
2395 | |||
2396 | |||
2397 | |||
2398 | |||
2399 | |||
2400 | End If |
||
2401 | Catch ex As Exception |
||
2402 | |||
2403 | End Try |
||
2404 | |||
2405 | End Sub |
||
2406 | Private Sub PipeLine_Fitting_Modeling() |
||
2407 | For Each oDrwing As TreeNode In Tree_Result.Nodes |
||
2408 | For Each oDwgNode As TreeNode In oDrwing.Nodes |
||
2409 | |||
2410 | Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text) |
||
2411 | Dim CDrawing As Drawing = GetDrawing(sDwgName) |
||
2412 | If CDrawing IsNot Nothing Then |
||
2413 | Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode) |
||
2414 | Dim iLineNoCount As Integer = 0 ' GetCheckNodeCount(oLinenoNode) |
||
2415 | For Each oNode As TreeNode In oDwgNode.Nodes |
||
2416 | Dim iItemcnt As Integer = 0 |
||
2417 | Dim sNodeUid As String = oNode.Name |
||
2418 | Dim oPipeRun_Dt As DataTable = PipeRun_Dt() |
||
2419 | |||
2420 | Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid) |
||
2421 | If CLineNo IsNot Nothing Then |
||
2422 | |||
2423 | Dim oLine_Dt As DataTable = CLineNo.Dt_Line |
||
2424 | Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol |
||
2425 | Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute |
||
2426 | Dim oDrawLinenoLabel As Boolean = False |
||
2427 | |||
2428 | Dim oOpcRows() As DataRow = _ResultModeling_DT.Select("[" & _Modeling_LineNoUid & "] = '" & sNodeUid & "' and " & |
||
2429 | "[" & _Modeling_Type & "] = '" & _SYMBOL_OPC & "'") |
||
2430 | Dim bPlaceOpcLine As Boolean = False |
||
2431 | 'For Each oOpcrow In oOpcRows |
||
2432 | ' 'OPC 와 접하는 Line구하기 |
||
2433 | ' Dim sLineUid As String = CheckOPCConnectionLine(oOpcrow, oLine_Dt) |
||
2434 | |||
2435 | |||
2436 | ' For Each oLinerow In oLine_Dt.Rows |
||
2437 | ' Dim dOriginalStart_x As Double = 0.0 |
||
2438 | ' Dim dOriginalStart_y As Double = 0.0 |
||
2439 | ' Dim dOriginalEnd_x As Double = 0.0 |
||
2440 | ' Dim dOriginalEnd_y As Double = 0.0 |
||
2441 | ' Dim dStart_x As Double = 0.0 |
||
2442 | ' Dim dStart_y As Double = 0.0 |
||
2443 | ' Dim dEnd_x As Double = 0.0 |
||
2444 | ' Dim dEnd_y As Double = 0.0 |
||
2445 | ' Dim sStartpoint As String = oLinerow(_XML_LINE_STARTPOINT).ToString() |
||
2446 | ' Dim sEndpoint As String = oLinerow(_XML_LINE_ENDPOINT).ToString() |
||
2447 | ' Dim sPipeUid As String = oLinerow(_XML_LINE_UID).ToString() |
||
2448 | |||
2449 | ' Dim oAddPiperunRow As DataRow = oPipeRun_Dt.NewRow() |
||
2450 | ' ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y) |
||
2451 | ' dStart_x = dOriginalStart_x |
||
2452 | ' dStart_y = dOriginalStart_y |
||
2453 | ' ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y) |
||
2454 | ' dEnd_x = dOriginalEnd_x |
||
2455 | ' dEnd_y = dOriginalEnd_y |
||
2456 | ' Dim objItem As LMAItem |
||
2457 | ' Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString() |
||
2458 | ' Dim sSystempath As String = "\Piping\Routing\Process Lines\Primary Piping.sym" ' oPipeRow(0)(_XML_LINE_SYSTEMPATH).ToString() |
||
2459 | ' If sType.ToUpper() = "ELECTRIC" Then |
||
2460 | ' sSystempath = "\Instrumentation\Signal Line\Electric.sym" |
||
2461 | ' ElseIf sType.ToUpper() = "CONNECT TO PROCESS" Then |
||
2462 | ' sSystempath = "\Instrumentation\Signal Line\Connect to Process.sym" |
||
2463 | ' Else |
||
2464 | ' End If |
||
2465 | |||
2466 | ' objItem = _Placement.PIDCreateItem(PipeRunLocation) |
||
2467 | ' objConnector = _Placement.PIDPlaceRun(objItem, objInputs) |
||
2468 | |||
2469 | |||
2470 | |||
2471 | ' Next |
||
2472 | |||
2473 | 'Next |
||
2474 | |||
2475 | |||
2476 | For Each oLineNode As TreeNode In oNode.Nodes |
||
2477 | iItemcnt = iItemcnt + 1 |
||
2478 | Dim sLineUid As String = oLineNode.Name |
||
2479 | If oLineNode.Checked Then |
||
2480 | Dim sUid As String = oLineNode.Name |
||
2481 | If oLine_Dt.Select("[" & _XML_LINE_UID & "]= '" & sUid & "'").Length = 1 Then |
||
2482 | DrawLine(sUid, sNodeUid, oLine_Dt, oAttribute_Dt, oPipeRun_Dt) |
||
2483 | 6a6d8ab4 | Gyusu | End If |
2484 | e4000111 | Gyusu | oDrawLinenoLabel = True |
2485 | 9e1e7135 | Gyusu | End If |
2486 | e4000111 | Gyusu | If oNode.Nodes.Count - 1 = iItemcnt And oDrawLinenoLabel Then |
2487 | Try |
||
2488 | DrawLineNo(oPipeRun_Dt, CLineNo) |
||
2489 | Catch ex As Exception |
||
2490 | End Try |
||
2491 | End If |
||
2492 | Next |
||
2493 | For Each oSymbolNode As TreeNode In oNode.Nodes |
||
2494 | If oSymbolNode.Checked Then |
||
2495 | Dim sUid As String = oSymbolNode.Name |
||
2496 | If oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False'").Length = 1 Then |
||
2497 | DrawSymbol(sUid, oSymbol_Dt, oAttribute_Dt, CLineNo.Dt_Line) |
||
2498 | End If |
||
2499 | End If |
||
2500 | Next |
||
2501 | iLineNoCount = iLineNoCount + 1 |
||
2502 | End If |
||
2503 | 41e4023e | Gyusu | |
2504 | |||
2505 | e4000111 | Gyusu | Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid) |
2506 | If CTrimLineNo IsNot Nothing Then |
||
2507 | Dim oLine_Dt As DataTable = CTrimLineNo.Dt_Line |
||
2508 | Dim oSymbol_Dt As DataTable = CTrimLineNo.Dt_Symbol |
||
2509 | Dim oAttribute_Dt As DataTable = CTrimLineNo.Dt_Attribute |
||
2510 | Dim oDrawLinenoLabel As Boolean = False |
||
2511 | |||
2512 | For Each oLineNode As TreeNode In oNode.Nodes |
||
2513 | iItemcnt = iItemcnt + 1 |
||
2514 | Dim sLineUid As String = oLineNode.Name |
||
2515 | If oLineNode.Checked Then |
||
2516 | Dim sUid As String = oLineNode.Name |
||
2517 | If oLine_Dt.Select("[" & _XML_LINE_UID & "]= '" & sUid & "'").Length = 1 Then |
||
2518 | DrawLine(sUid, sNodeUid, oLine_Dt, oAttribute_Dt, oPipeRun_Dt) |
||
2519 | End If |
||
2520 | oDrawLinenoLabel = True |
||
2521 | End If |
||
2522 | 9e1e7135 | Gyusu | Next |
2523 | e4000111 | Gyusu | For Each oSymbolNode As TreeNode In oNode.Nodes |
2524 | If oSymbolNode.Checked Then |
||
2525 | Dim sUid As String = oSymbolNode.Name |
||
2526 | If oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False'").Length = 1 Then |
||
2527 | DrawSymbol(sUid, oSymbol_Dt, oAttribute_Dt, CTrimLineNo.Dt_Line) |
||
2528 | End If |
||
2529 | End If |
||
2530 | Next |
||
2531 | iLineNoCount = iLineNoCount + 1 |
||
2532 | 171ac39d | Gyusu | End If |
2533 | e4000111 | Gyusu | |
2534 | |||
2535 | 'Else |
||
2536 | ' Dim oDrawLinenoLabel As Boolean = False |
||
2537 | ' For Each oLineNode As TreeNode In oNode.Nodes |
||
2538 | ' Dim CLineNo As Line_no = GetOnlyPipeLineNo(CDrawing, oLineNode.Name) |
||
2539 | ' Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute |
||
2540 | ' Dim oLine_Dt As DataTable = CLineNo.Dt_Line |
||
2541 | ' Dim sLineUid As String = oLineNode.Name |
||
2542 | ' If oLineNode.Checked Then |
||
2543 | ' Dim sUid As String = oLineNode.Name |
||
2544 | ' DrawLine(sUid, sNodeUid, oLine_Dt, oAttribute_Dt, oPipeRun_Dt) |
||
2545 | ' End If |
||
2546 | ' Next |
||
2547 | 'End If |
||
2548 | |||
2549 | |||
2550 | |||
2551 | Next |
||
2552 | End If |
||
2553 | 171ac39d | Gyusu | Next |
2554 | e4000111 | Gyusu | Next |
2555 | End Sub |
||
2556 | |||
2557 | Private Function AutoModeling() As Boolean |
||
2558 | Try |
||
2559 | _CompleteConvert = False |
||
2560 | Label_Progress.Text = "0%" |
||
2561 | SetListBoxItems(ListBox_Result, " Auto converting 시작....") |
||
2562 | Dim oDwg_Dt As DataTable = LoadAllDrawing() |
||
2563 | _allItem = GetAllCheckNodeCount() |
||
2564 | '1.Equipment |
||
2565 | '2.Piping OPC |
||
2566 | '3.OPC 시작되는 Line |
||
2567 | EquipmentModeling(oDwg_Dt) |
||
2568 | PipingOPCModeling(oDwg_Dt) |
||
2569 | PipeLine_Fitting_Modeling() |
||
2570 | |||
2571 | 171ac39d | Gyusu | SetProgressbar(ProgressBar_Status, 100) |
2572 | 41e4023e | Gyusu | Label_Progress.Text = "100%" |
2573 | 171ac39d | Gyusu | SetListBoxItems(ListBox_Result, " Auto converting 완료") |
2574 | 54b98e09 | Gyusu | _CompleteConvert = True |
2575 | 171ac39d | Gyusu | Return True |
2576 | Catch ex As Exception |
||
2577 | Return False |
||
2578 | End Try |
||
2579 | End Function |
||
2580 | |||
2581 | |||
2582 | |||
2583 | 54b98e09 | Gyusu | Private Sub ThreadConvert() |
2584 | 559daf6d | Gyusu | If _DrawingsList IsNot Nothing Then |
2585 | If _DrawingsList.Count > 0 Then |
||
2586 | AutoModeling() |
||
2587 | End If |
||
2588 | 171ac39d | Gyusu | End If |
2589 | e282643f | Gyusu | End Sub |
2590 | |||
2591 | 54b98e09 | Gyusu | Private Sub ThreadOPCRemove() |
2592 | While _CompleteConvert = False |
||
2593 | Dim oFindOPC As New FindOpc |
||
2594 | oFindOPC.RemoveOPCDlg() |
||
2595 | End While |
||
2596 | e282643f | Gyusu | |
2597 | 54b98e09 | Gyusu | End Sub |
2598 | 171ac39d | Gyusu | |
2599 | e282643f | Gyusu | |
2600 | Private Function OpenDrawing(ByVal oDt As DataTable, ByVal sDwgName As String) As String |
||
2601 | Dim oRows As DataRow() = oDt.Select("[Name] = '" & sDwgName & "'") |
||
2602 | Dim oPath As String = "" |
||
2603 | If oRows.Length > 0 Then |
||
2604 | oPath = oRows(0).Item("Path").ToString() |
||
2605 | End If |
||
2606 | Return oPath |
||
2607 | End Function |
||
2608 | |||
2609 | 272662f9 | Gyusu | Private Sub LoadXmlToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadXmlToolStripMenuItem.Click |
2610 | 171ac39d | Gyusu | If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then |
2611 | 54b98e09 | Gyusu | LoadDB() |
2612 | 171ac39d | Gyusu | LoadXmlItem(FolderBrowserDialog1.SelectedPath) |
2613 | End If |
||
2614 | End Sub |
||
2615 | Private Sub LoadXmlItem(ByVal sFolderPath As String) |
||
2616 | _DrawingsList = New List(Of Drawing) |
||
2617 | Dim sfileEntries As String() = Directory.GetFiles(sFolderPath) |
||
2618 | If Tree_Result.Nodes.Count > 0 Then |
||
2619 | Tree_Result.Nodes(0).Nodes.Clear() |
||
2620 | For Each sfileName In sfileEntries |
||
2621 | Dim sExtension As String = Path.GetExtension(sfileName) |
||
2622 | If sExtension = ".xml" Then |
||
2623 | Dim sDwgName As String = Path.GetFileNameWithoutExtension(sfileName) |
||
2624 | Dim sDwgPath As String = sfileName |
||
2625 | Dim oNode As TreeNode = Tree_Result.Nodes(0).Nodes.Add(sDwgPath, sDwgName, 15) |
||
2626 | Dim oDwg As Drawing = AddSymbolItem(sDwgPath, oNode) |
||
2627 | _DrawingsList.Add(oDwg) |
||
2628 | End If |
||
2629 | Next |
||
2630 | Tree_Result.Nodes(0).Expand() |
||
2631 | End If |
||
2632 | End Sub |
||
2633 | 272662f9 | Gyusu | |
2634 | |||
2635 | e4000111 | Gyusu | |
2636 | |||
2637 | |||
2638 | |||
2639 | |||
2640 | |||
2641 | |||
2642 | Private Sub GenerateRelation(ByRef oDwg_Ds As Drawing) |
||
2643 | Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos |
||
2644 | Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos |
||
2645 | Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos |
||
2646 | Dim oRelation As New GenerateRelation() |
||
2647 | For Each oLinelist In oLineLists |
||
2648 | |||
2649 | oRelation.CalcLineConnectionItem_Equal(oLinelist.Dt_Line, oLinelist.Dt_Symbol) |
||
2650 | |||
2651 | 'For Each oLineRow In oLinelist.Dt_Line.Rows |
||
2652 | ' Dim sLineUid As String = oLineRow(_XML_LINE_UID) |
||
2653 | ' Dim dLineStart_x As Double = 0.0 |
||
2654 | ' Dim dLineStart_y As Double = 0.0 |
||
2655 | ' Dim dLineEnd_x As Double = 0.0 |
||
2656 | ' Dim dLineEnd_y As Double = 0.0 |
||
2657 | |||
2658 | ' Dim sStartpoint As String = oLineRow(_XML_LINE_STARTPOINT).ToString() |
||
2659 | ' Dim sEndpoint As String = oLineRow(_XML_LINE_ENDPOINT).ToString() |
||
2660 | |||
2661 | ' ConvertPointBystring(sStartpoint, dLineStart_x, dLineStart_y) |
||
2662 | ' ConvertPointBystring(sEndpoint, dLineEnd_x, dLineEnd_y) |
||
2663 | |||
2664 | ' Dim sConn1_Uid As String = "" |
||
2665 | ' Dim sConn2_Uid As String = "" |
||
2666 | ' For Each oConnLineRow In oLinelist.Dt_Line.Rows |
||
2667 | ' Dim sConnLineUid As String = oLineRow(_XML_LINE_UID) |
||
2668 | ' If sLineUid <> sConnLineUid Then |
||
2669 | ' If sConn1_Uid <> "" And sConn2_Uid <> "" Then |
||
2670 | ' Exit For |
||
2671 | ' End If |
||
2672 | ' Dim dConnLineStart_x As Double = 0.0 |
||
2673 | ' Dim dConnLineStart_y As Double = 0.0 |
||
2674 | ' Dim dConnLineEnd_x As Double = 0.0 |
||
2675 | ' Dim dConnLineEnd_y As Double = 0.0 |
||
2676 | ' Dim sConnStartpoint As String = oConnLineRow(_XML_LINE_STARTPOINT).ToString() |
||
2677 | ' Dim sConnEndpoint As String = oConnLineRow(_XML_LINE_ENDPOINT).ToString() |
||
2678 | ' ConvertPointBystring(sConnStartpoint, dConnLineStart_x, dConnLineStart_y) |
||
2679 | ' ConvertPointBystring(sConnEndpoint, dConnLineEnd_x, dConnLineEnd_y) |
||
2680 | |||
2681 | ' If CheckDuplicatePoint(dLineStart_x, dLineStart_y, dLineEnd_x, dLineEnd_y, |
||
2682 | ' dConnLineStart_x, dConnLineStart_y, dConnLineEnd_x, dConnLineEnd_y) Then |
||
2683 | ' If dLineStart_x = dConnLineStart_x And dLineStart_y = dConnLineStart_y Then |
||
2684 | ' sConn1_Uid = sConnLineUid |
||
2685 | ' ElseIf dLineStart_x = dConnLineEnd_x And dLineStart_y = dConnLineEnd_y Then |
||
2686 | ' sConn1_Uid = sConnLineUid |
||
2687 | ' ElseIf dLineEnd_x = dConnLineStart_x And dLineEnd_y = dConnLineStart_y Then |
||
2688 | ' sConn2_Uid = sConnLineUid |
||
2689 | ' ElseIf dLineEnd_x = dConnLineEnd_x And dLineEnd_y = dConnLineEnd_y Then |
||
2690 | ' sConn2_Uid = sConnLineUid |
||
2691 | ' End If |
||
2692 | ' End If |
||
2693 | ' End If |
||
2694 | |||
2695 | ' Next |
||
2696 | ' For Each oConnSymbolRow In oLinelist.Dt_Symbol.Rows |
||
2697 | ' Dim sSymbolUid As String = oConnSymbolRow(_XML_SYMBOL_UID) |
||
2698 | ' Dim sSymbolName As String = oConnSymbolRow(_XML_SYMBOL_NAME) |
||
2699 | ' Dim sSymbolConnPoint As String = oConnSymbolRow(_XML_SYMBOL_CONNECTIONPOINT) |
||
2700 | ' Dim sConnSplit As String() = sSymbolConnPoint.Split("/") |
||
2701 | ' If sSymbolConnPoint <> "" Then |
||
2702 | ' Dim dSymbolConn1_x As Double = 0.0 |
||
2703 | ' Dim dSymbolConn1_y As Double = 0.0 |
||
2704 | ' Dim dSymbolConn2_x As Double = 0.0 |
||
2705 | ' Dim dSymbolConn2_y As Double = 0.0 |
||
2706 | ' Dim dSymbolConn3_x As Double = 0.0 |
||
2707 | ' Dim dSymbolConn3_y As Double = 0.0 |
||
2708 | ' Dim dSymbolConn4_x As Double = 0.0 |
||
2709 | ' Dim dSymbolConn4_y As Double = 0.0 |
||
2710 | |||
2711 | ' Dim sConn1Point As String = "" |
||
2712 | ' Dim sConn2Point As String = "" |
||
2713 | ' Dim sConn3Point As String = "" |
||
2714 | ' Dim sConn4Point As String = "" |
||
2715 | |||
2716 | ' sConn1Point = sConnSplit(0) |
||
2717 | |||
2718 | ' If sConnSplit.Length > 1 Then |
||
2719 | ' sConn2Point = sConnSplit(1) |
||
2720 | ' If sConnSplit.Length > 2 Then |
||
2721 | ' sConn3Point = sConnSplit(2) |
||
2722 | ' If sConnSplit.Length > 3 Then |
||
2723 | ' sConn4Point = sConnSplit(3) |
||
2724 | ' End If |
||
2725 | ' End If |
||
2726 | ' End If |
||
2727 | |||
2728 | ' ConvertPointBystring(sConn1Point, dSymbolConn1_x, dSymbolConn1_y) |
||
2729 | ' If sConn2Point <> "" Then |
||
2730 | ' ConvertPointBystring(sConn2Point, dSymbolConn2_x, dSymbolConn2_y) |
||
2731 | ' End If |
||
2732 | ' If sConn3Point <> "" Then |
||
2733 | ' ConvertPointBystring(sConn3Point, dSymbolConn3_x, dSymbolConn3_y) |
||
2734 | ' End If |
||
2735 | ' If sConn4Point <> "" Then |
||
2736 | ' ConvertPointBystring(sConn4Point, dSymbolConn4_x, dSymbolConn4_y) |
||
2737 | ' End If |
||
2738 | |||
2739 | ' If dLineStart_x = dSymbolConn1_x And dLineStart_y = dSymbolConn1_y Then |
||
2740 | ' sConn1_Uid = sSymbolUid |
||
2741 | ' ElseIf dLineStart_x = dSymbolConn2_x And dLineStart_y = dSymbolConn2_y Then |
||
2742 | ' sConn1_Uid = sSymbolUid |
||
2743 | ' ElseIf dLineStart_x = dSymbolConn3_x And dLineStart_y = dSymbolConn3_y Then |
||
2744 | ' sConn1_Uid = sSymbolUid |
||
2745 | ' ElseIf dLineStart_x = dSymbolConn4_x And dLineStart_y = dSymbolConn4_y Then |
||
2746 | ' sConn1_Uid = sSymbolUid |
||
2747 | ' End If |
||
2748 | |||
2749 | ' If dLineEnd_x = dSymbolConn1_x And dLineEnd_y = dSymbolConn1_y Then |
||
2750 | ' sConn2_Uid = sSymbolUid |
||
2751 | ' ElseIf dLineEnd_x = dSymbolConn2_x And dLineEnd_y = dSymbolConn2_y Then |
||
2752 | ' sConn2_Uid = sSymbolUid |
||
2753 | ' ElseIf dLineEnd_x = dSymbolConn3_x And dLineEnd_y = dSymbolConn3_y Then |
||
2754 | ' sConn2_Uid = sSymbolUid |
||
2755 | ' ElseIf dLineEnd_x = dSymbolConn4_x And dLineEnd_y = dSymbolConn4_y Then |
||
2756 | ' sConn2_Uid = sSymbolUid |
||
2757 | ' End If |
||
2758 | ' Else |
||
2759 | ' Dim dConnSymbolStart_x As Double = 0.0 |
||
2760 | ' Dim dConnSymbolStart_y As Double = 0.0 |
||
2761 | ' Dim sConnStartpoint As String = oConnSymbolRow(_XML_LINE_STARTPOINT).ToString() |
||
2762 | ' ConvertPointBystring(sConnStartpoint, dConnSymbolStart_x, dConnSymbolStart_y) |
||
2763 | |||
2764 | |||
2765 | ' End If |
||
2766 | |||
2767 | |||
2768 | |||
2769 | |||
2770 | ' Next |
||
2771 | '연결된 Connection point 가 없을때 |
||
2772 | '1/100만큼 Line Length 길이의 오차범위를 줘서 다시계산 |
||
2773 | |||
2774 | '1/10만큼 Symbol Size 만큼의 오차범위를 줘서 다시계산 |
||
2775 | |||
2776 | |||
2777 | |||
2778 | |||
2779 | 'Next |
||
2780 | |||
2781 | Next |
||
2782 | |||
2783 | |||
2784 | |||
2785 | End Sub |
||
2786 | |||
2787 | |||
2788 | 20c84e05 | Gyusu | ''' <summary> |
2789 | ''' XML Tree 구조 생성 |
||
2790 | ''' </summary> |
||
2791 | ''' <param name="sDwgPath"></param> |
||
2792 | 171ac39d | Gyusu | Private Function AddSymbolItem(ByVal sDwgPath As String, ByVal oParentNode As TreeNode) As Drawing |
2793 | Dim oDwg_Ds As Drawing = LoadSymbolInXml(sDwgPath) |
||
2794 | e4000111 | Gyusu | |
2795 | |||
2796 | |||
2797 | |||
2798 | |||
2799 | 54b98e09 | Gyusu | If oDwg_Ds IsNot Nothing Then |
2800 | Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos |
||
2801 | |||
2802 | Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos |
||
2803 | 3acffcee | Gyusu | |
2804 | Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos |
||
2805 | |||
2806 | 54b98e09 | Gyusu | Dim oPipe As Boolean = False |
2807 | Dim oFitting As Boolean = False |
||
2808 | Dim oOnlyPipesNode As TreeNode |
||
2809 | Dim oOnlyFittingsNode As TreeNode |
||
2810 | 'PipeLine 구분 |
||
2811 | |||
2812 | For Each oLinelist In oLineLists |
||
2813 | Dim sLineNoUid As String = oLinelist.Uid |
||
2814 | Dim sLineNo As String = oLinelist.Text |
||
2815 | Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo) |
||
2816 | For Each oLineRow In oLinelist.Dt_Line.Rows |
||
2817 | Dim sLineUid As String = oLineRow(_XML_LINE_UID) |
||
2818 | Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe") |
||
2819 | oPipeNode.Tag = sLineNoUid |
||
2820 | Next |
||
2821 | For Each oSymbolRow In oLinelist.Dt_Symbol.Rows |
||
2822 | Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
||
2823 | Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
||
2824 | Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName) |
||
2825 | oSymbolNode.Tag = sLineNoUid |
||
2826 | Next |
||
2827 | Next |
||
2828 | 3acffcee | Gyusu | |
2829 | 54b98e09 | Gyusu | For Each oEqplist In oEqpLists |
2830 | Dim sEqpUid As String = oEqplist.Uid |
||
2831 | Dim sEqpNo As String = "EQUIPMENT" |
||
2832 | Dim oEqpNode As TreeNode = oParentNode.Nodes.Add(sEqpUid, sEqpNo) |
||
2833 | d039e347 | Gyusu | |
2834 | 54b98e09 | Gyusu | |
2835 | For Each oSymbolRow In oEqplist.Dt_Equipment.Rows |
||
2836 | Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
||
2837 | Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
||
2838 | Dim oSymbolNode As TreeNode = oEqpNode.Nodes.Add(sSymbolUid, sSymbolName) |
||
2839 | oSymbolNode.Tag = sEqpUid |
||
2840 | Next |
||
2841 | 171ac39d | Gyusu | Next |
2842 | 3acffcee | Gyusu | Dim sTrimLine As String = "TrimLineNos" |
2843 | Dim iTrimLinecnt As Integer = 1 |
||
2844 | For Each oTrimLinelist In oTrimLineLists |
||
2845 | Dim sLineNoUid As String = oTrimLinelist.Uid |
||
2846 | Dim sLineNo As String = sTrimLine & "_" & iTrimLinecnt |
||
2847 | Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo) |
||
2848 | For Each oLineRow In oTrimLinelist.Dt_Line.Rows |
||
2849 | Dim sLineUid As String = oLineRow(_XML_LINE_UID) |
||
2850 | Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe") |
||
2851 | oPipeNode.Tag = sLineNoUid |
||
2852 | Next |
||
2853 | For Each oSymbolRow In oTrimLinelist.Dt_Symbol.Rows |
||
2854 | Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
||
2855 | Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
||
2856 | Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName) |
||
2857 | oSymbolNode.Tag = sLineNoUid |
||
2858 | Next |
||
2859 | iTrimLinecnt = iTrimLinecnt + 1 |
||
2860 | Next |
||
2861 | |||
2862 | 54b98e09 | Gyusu | End If |
2863 | |||
2864 | 171ac39d | Gyusu | Return oDwg_Ds |
2865 | End Function |
||
2866 | 272662f9 | Gyusu | Private Sub Tree_Result_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_Result.AfterCheck |
2867 | If e.Node.Checked = True Then |
||
2868 | For Each oNode As TreeNode In e.Node.Nodes |
||
2869 | oNode.Checked = True |
||
2870 | Next |
||
2871 | Else |
||
2872 | For Each oNode As TreeNode In e.Node.Nodes |
||
2873 | oNode.Checked = False |
||
2874 | Next |
||
2875 | End If |
||
2876 | End Sub |
||
2877 | 171ac39d | Gyusu | |
2878 | 559daf6d | Gyusu | Private Sub Btn_Setting_Click(sender As Object, e As EventArgs) Handles Btn_Setting.Click |
2879 | Dim oSettings As Settings = New Settings() |
||
2880 | oSettings.ShowDialog() |
||
2881 | End Sub |
||
2882 | 42c0013c | Gyusu | |
2883 | Private Sub Btn_TestNozzle_Click(sender As Object, e As EventArgs) Handles Btn_TestNozzle.Click |
||
2884 | |||
2885 | Dim sVessel_ID As String = "841D5E640AE5421B9A017DDC2E87FF11" |
||
2886 | Dim objVessel As LMVessel |
||
2887 | objVessel = _Placement.PIDDataSource.GetVessel(sVessel_ID) |
||
2888 | Dim oVesselLocation As LMLocations = objVessel.Locations |
||
2889 | Dim symVessel As LMSymbol = _Placement.PIDDataSource.GetSymbol(objVessel.Representations.Nth(1).Id) |
||
2890 | Dim XCoordinate As String = symVessel.Attributes("XCoordinate").Value |
||
2891 | Dim YCoordinate As String = symVessel.Attributes("YCoordinate").Value |
||
2892 | symVessel.Attributes("XCoordinate").Value = XCoordinate + 0.01 |
||
2893 | symVessel.Attributes("YCoordinate").Value = YCoordinate + 0.01 |
||
2894 | symVessel.Commit() |
||
2895 | Dim sValve_ID As String = "DB7B0CA8A2664A6BA7A9615764BA62B0" |
||
2896 | Dim objValve As LMSymbol |
||
2897 | Dim objValves As LMPipingComp = _Placement.PIDDataSource.GetPipingComp(sValve_ID) |
||
2898 | |||
2899 | objValve = _Placement.PIDDataSource.GetSymbol(objValves.Representations.Nth(1).Id) |
||
2900 | objValve.Commit() |
||
2901 | Dim dVesselX As Double = XCoordinate |
||
2902 | Dim dVesselY As Double = YCoordinate |
||
2903 | Dim X1 As Double, Y1 As Double, X2 As Double, Y2 As Double |
||
2904 | |||
2905 | _Placement.PIDConnectPointLocation(objValve, 1, X1, Y1) |
||
2906 | |||
2907 | _Placement.PIDConnectPointLocation(objValve, 2, X2, Y2) |
||
2908 | |||
2909 | Dim nozzlename As String = "\Equipment Components\Nozzles\Flanged Nozzle.sym" |
||
2910 | Dim dCalc_x As Double = 0 |
||
2911 | Dim dCalc_y As Double = 0 |
||
2912 | |||
2913 | If dVesselX - X2 > 0 Then |
||
2914 | dCalc_x = dVesselX - (dVesselX - X2) |
||
2915 | Else |
||
2916 | dCalc_x = dVesselX + (X2 - dVesselX) |
||
2917 | End If |
||
2918 | If dVesselY - Y2 > 0 Then |
||
2919 | dCalc_y = dVesselY - (dVesselY - Y2) |
||
2920 | Else |
||
2921 | dCalc_y = dVesselY + (Y2 - dVesselY) |
||
2922 | End If |
||
2923 | |||
2924 | Dim objNozzle As LMSymbol = _Placement.PIDPlaceSymbol(nozzlename, dCalc_x, dCalc_y, |
||
2925 | TargetItem:=symVessel.AsLMRepresentation) |
||
2926 | |||
2927 | Dim blnSuccess As Boolean = _Placement.PIDConnectPointLocation(objNozzle, 1, X1, Y1) |
||
2928 | blnSuccess = _Placement.PIDConnectPointLocation(objNozzle, 2, X1, Y1) |
||
2929 | |||
2930 | objValve = _Placement.PIDPlaceSymbol(objValve.FileName, X1, Y1, ExistingItem:=objValve.AsLMAItem, |
||
2931 | TargetItem:=objNozzle.AsLMRepresentation) |
||
2932 | |||
2933 | |||
2934 | |||
2935 | End Sub |
||
2936 | 39d43554 | Gyusu | |
2937 | Private Sub Btn_SymbolLibrary_Click(sender As Object, e As EventArgs) Handles Btn_SymbolLibrary.Click |
||
2938 | Dim oMapping As New Mapping(_PIDSymbol_DB) |
||
2939 | oMapping.Show() |
||
2940 | End Sub |
||
2941 | 41e4023e | Gyusu | |
2942 | Private Sub Btn_Stop_Click(sender As Object, e As EventArgs) Handles Btn_Stop.Click |
||
2943 | Try |
||
2944 | SetListBoxItems(ListBox_Result, " Auto converting 중지....") |
||
2945 | _Main_trd.Abort() |
||
2946 | _Opc_trd.Abort() |
||
2947 | Catch ex As Exception |
||
2948 | |||
2949 | End Try |
||
2950 | End Sub |
||
2951 | e282643f | Gyusu | End Class |
2952 | |||
2953 | |||
2954 | Public Class DrawingInfo |
||
2955 | Public mDrawingName As String |
||
2956 | Public mSpID As String |
||
2957 | Public mPath As String |
||
2958 | 4f359afa | Gyusu | End Class |
2959 | e282643f | Gyusu | |
2960 | |||
2961 | |||
2962 |