hytos / DTI_PID / SPPIDConverter / Main.vb @ 6a6d8ab4
이력 | 보기 | 이력해설 | 다운로드 (73.2 KB)
1 |
Imports System.IO |
---|---|
2 |
Imports System.Data.SqlClient |
3 |
Imports System.Data.SQLite |
4 |
Imports Plaice |
5 |
Imports Llama |
6 |
Imports PidA |
7 |
|
8 |
|
9 |
Imports System.Threading |
10 |
|
11 |
Public Class Main |
12 |
|
13 |
Dim _Mapping_DB As DataTable = New DataTable() |
14 |
Dim _Attribute_DB As DataTable = New DataTable() |
15 |
Dim _Placement As New Placement |
16 |
Dim _DWG_X = 0.84 '0.695 '1 ' |
17 |
Dim _DWG_Y = 0.594 '0.585 '0.8 ' |
18 |
|
19 |
Dim _IMG_X = 0 |
20 |
Dim _IMG_Y = 0 |
21 |
|
22 |
Dim _Unit As String |
23 |
|
24 |
'Drawing 전역변수 |
25 |
Dim _objPIDADrawing As Object |
26 |
'현재선택한 폴더경로 |
27 |
Dim _selectFolderPath As String |
28 |
|
29 |
Private _Main_trd As Thread |
30 |
|
31 |
Private _DrawingsList As List(Of Drawing) |
32 |
|
33 |
|
34 |
Private _iPipeLineNocnt As Integer |
35 |
Private _iPipecnt As Integer |
36 |
Private _iFittingcnt As Integer |
37 |
Private _iValvecnt As Integer |
38 |
Private _iInstrumentcnt As Integer |
39 |
Private _iEquipmentcnt As Integer |
40 |
Private _iNozzlecnt As Integer |
41 |
|
42 |
|
43 |
Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load |
44 |
|
45 |
If My.Settings.DBPath <> "" And My.Settings.Plant_Hierarchy <> "" Then |
46 |
Dim sDBPath As String = My.Settings.DBPath |
47 |
_Mapping_DB = Load_DB(sDBPath, _DB_TABLE_MAPPING) |
48 |
_Attribute_DB = Load_DB(sDBPath, _DB_TABLE_ATTRIBUTE) |
49 |
'TestPID() |
50 |
'OpenDrawing() |
51 |
Else |
52 |
MessageBox.Show("설정값을 먼저 확인해주세요") |
53 |
End If |
54 |
End Sub |
55 |
|
56 |
Public Function GetDrawingInfo(ByVal errorList As ArrayList) |
57 |
Dim ds As Llama.LMADataSource |
58 |
ds = New Llama.LMADataSource |
59 |
Dim lmaItem As Llama.LMAItem |
60 |
|
61 |
For i = 0 To errorList.Count - 1 |
62 |
lmaItem = ds.GetModelItem(errorList.Item(i).m_strSPID()).AsLMAItem |
63 |
Dim drawingInfo As DrawingInfo |
64 |
drawingInfo = GetDrawingName(lmaItem.ItemType, lmaItem.Id) |
65 |
errorList.Item(i).m_LMAItem = lmaItem |
66 |
errorList.Item(i).m_strDrawingName = drawingInfo.mDrawingName |
67 |
errorList.Item(i).m_strDrawingPath = drawingInfo.mPath |
68 |
Next |
69 |
End Function |
70 |
Private mDataSource As Object |
71 |
|
72 |
'Public Sub New() |
73 |
|
74 |
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName |
75 |
' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI |
76 |
' 'm_Information = SPPIDClass.Information.GetInstance() |
77 |
|
78 |
' 'If m_Information.InfoProject.ProjectVersion = SPPIDClass.InfoProject.SPPID_43 Then |
79 |
' ' 'SPPID4.3용 |
80 |
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName |
81 |
' 'Else |
82 |
' ' 'SPPID2007, SPPID2009용 |
83 |
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName |
84 |
' 'End If |
85 |
|
86 |
' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI |
87 |
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName |
88 |
' '#If LATE_BINDING Then |
89 |
' ' mInstruments = CreateObject("Llama.LMInstruments", "") |
90 |
' ' mPipingComps = CreateObject("Llama.LMPipingComps", "") |
91 |
' ' mVessels = CreateObject("Llama.LMVessels", "") |
92 |
' ' mDrawings = CreateObject("Llama.LMDrawings", "") |
93 |
' ' mEquipments = CreateObject("Llama.LMEquipments", "") |
94 |
' ' mExchangers = CreateObject("Llama.LMExchangers", "") |
95 |
' ' mMechanicals = CreateObject("Llama.LMMechanicals", "") |
96 |
' ' mNozzles = CreateObject("Llama.LMNozzles", "") |
97 |
' ' mPipeRuns = CreateObject("Llama.LMPipeRuns", "") |
98 |
' ' mEquipmentOthers = CreateObject("Llama.LMEquipmentOthers", "") |
99 |
' '#Else |
100 |
' ' mInstruments = New Llama.LMInstruments |
101 |
' ' mPipingComps = New Llama.LMPipingComps |
102 |
' ' mVessels = New Llama.LMVessels |
103 |
' ' mDrawings = New Llama.LMDrawings |
104 |
' ' mEquipments = New Llama.LMEquipments |
105 |
' ' mExchangers = New Llama.LMExchangers |
106 |
' ' mMechanicals = New Llama.LMMechanicals |
107 |
' ' mNozzles = New Llama.LMNozzles |
108 |
' ' mPipeRuns = New Llama.LMPipeRuns |
109 |
' ' mEquipmentOthers = New Llama.LMEquipmentOthers |
110 |
' '#End If |
111 |
'End Sub |
112 |
|
113 |
Function OpenDrawing() |
114 |
Dim datasource As LMADataSource |
115 |
Dim objPIDAutoApp As Object |
116 |
Dim objPIDADrawing As Object |
117 |
Dim objDrawing As LMDrawing |
118 |
Dim objDrawings As LMDrawings |
119 |
datasource = New Llama.LMADataSource |
120 |
|
121 |
objPIDAutoApp = CreateObject("PIDAutomation.Application") |
122 |
objDrawings = New Llama.LMDrawings 'New LMDrawings |
123 |
|
124 |
datasource.SiteNode = " \\desktop-9vlq0dp\Test03Site\smartplantv4.ini" |
125 |
datasource.ProjectNumber = "SBR_PBR" |
126 |
objDrawings.Collect(datasource) |
127 |
|
128 |
|
129 |
For Each objDrawing In objDrawings |
130 |
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
131 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
132 |
If Not objPIDADrawing Is Nothing Then |
133 |
'MsgBox "Drawing " & objDrawing.Attributes("Name").Value & " is opened!" |
134 |
objPIDADrawing.CloseDrawing |
135 |
End If |
136 |
End If |
137 |
Next |
138 |
objPIDAutoApp.Quit |
139 |
objPIDAutoApp = Nothing |
140 |
objPIDADrawing = Nothing |
141 |
objDrawing = Nothing |
142 |
objDrawings = Nothing |
143 |
End Function |
144 |
|
145 |
|
146 |
Public Function GetDrawingName(ByVal itemType As String, ByVal itemName As String) As DrawingInfo |
147 |
|
148 |
Dim objFilter As Object |
149 |
objFilter = CreateObject("Llama.LMAFilter", "") |
150 |
|
151 |
Dim drawingInfo As DrawingInfo |
152 |
drawingInfo = New DrawingInfo |
153 |
|
154 |
objFilter.Criteria.AddNew("FirstOne") |
155 |
objFilter.Criteria.Item("FirstOne").SourceAttributeName = "SP_ID" |
156 |
objFilter.Critedkria.Item("FirstOne").ValueAttribute = itemName |
157 |
|
158 |
objFilter.Criteria.Item("FirstOne").Operator = "=" |
159 |
objFilter.Criteria.AddNew("SecondOne") |
160 |
objFilter.Criteria.Item("SecondOne").SourceAttributeName = "ItemStatus" |
161 |
objFilter.Criteria.Item("SecondOne").ValueAttribute = 1 |
162 |
objFilter.Criteria.Item("SecondOne").Operator = "=" |
163 |
objFilter.Criteria.Item("SecondOne").Conjunctive = -1 |
164 |
objFilter.ItemType = itemType |
165 |
|
166 |
Dim PlantItems As Object |
167 |
PlantItems = CreateObject("Llama.LMPlantItems", "") |
168 |
PlantItems.Collect(mDataSource, Filter:=objFilter) |
169 |
|
170 |
If PlantItems.Count = 0 Then |
171 |
drawingInfo.mSpID = "PlantStockpile" |
172 |
End If |
173 |
|
174 |
For Each PlantItem In PlantItems |
175 |
|
176 |
'If Not PlantItem.Representations.Nth(1).DrawingID.Value.ToString().Equals("0") Then |
177 |
Try |
178 |
drawingInfo.mDrawingName = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Name").Value |
179 |
drawingInfo.mSpID = PlantItem.Representations.Nth(1).DrawingID |
180 |
drawingInfo.mPath = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Path").Value |
181 |
Debug.WriteLine("DrawingName : " & drawingInfo.mDrawingName & ", SPID : " & drawingInfo.mSpID & ", Path : " & drawingInfo.mPath) |
182 |
Catch ex As Exception |
183 |
|
184 |
End Try |
185 |
|
186 |
'End If |
187 |
|
188 |
Next |
189 |
|
190 |
Return drawingInfo |
191 |
|
192 |
End Function |
193 |
|
194 |
Private Sub TestPID() |
195 |
|
196 |
Try |
197 |
Const CONST_SPID_OPC As String = "426E89964A7F49208AD79E1F320DA251" |
198 |
Dim datasource As LMADataSource |
199 |
Dim objPIDAutoApp As Object |
200 |
Dim objPIDADrawing As Object |
201 |
Dim objDrawing As LMDrawing |
202 |
Dim objDrawings As LMDrawings |
203 |
datasource = New LMADataSource |
204 |
Dim objOPC As LMOPC |
205 |
Dim objpairOPC As LMOPC |
206 |
objOPC = datasource.GetOPC(CONST_SPID_OPC) |
207 |
objpairOPC = objOPC.pairedWithOPCObject |
208 |
|
209 |
Dim oObj As Object = Nothing |
210 |
objDrawing = datasource.GetDrawing(oObj) |
211 |
objDrawings = New LMDrawings |
212 |
objDrawings.Collect(datasource) |
213 |
objPIDAutoApp = GetObject(, "SmartPlantPID.Application") '// CreateObject("PIDAutomation.Application") |
214 |
For Each objDrawing In objDrawings |
215 |
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
216 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
217 |
If Not objPIDADrawing Is Nothing Then |
218 |
MessageBox.Show("Drawing " & objDrawing.Attributes("Name").Value & " is opened!") |
219 |
objPIDADrawing.CloseDrawing |
220 |
End If |
221 |
End If |
222 |
Next |
223 |
objPIDAutoApp.Quit |
224 |
objPIDAutoApp = Nothing |
225 |
objPIDADrawing = Nothing |
226 |
objDrawing = Nothing |
227 |
objDrawings = Nothing |
228 |
Catch ex As Exception |
229 |
|
230 |
End Try |
231 |
|
232 |
|
233 |
|
234 |
End Sub |
235 |
Public Function SetActiveSiteFromConfigInfo(ByVal strActiveSite As String) As Boolean |
236 |
|
237 |
On Error GoTo errHandler |
238 |
Dim objConfigInfo As Object 'interopigrConfigInfo412.igrConfigInfo |
239 |
objConfigInfo = CreateObject("interopigrConfigInfo412.igrConfigInfo", "") |
240 |
If Not objConfigInfo Is Nothing Then |
241 |
objConfigInfo.ApplicationName = "SmartPlantManager" |
242 |
objConfigInfo.SetConfigString(3, "SmartPlant Manager", "SiteServer", strActiveSite) |
243 |
SetActiveSiteFromConfigInfo = True |
244 |
End If |
245 |
objConfigInfo = Nothing |
246 |
|
247 |
Exit Function |
248 |
|
249 |
errHandler: |
250 |
' LogAndRaiseError ModuleName & "::GetConfigInfo " |
251 |
End Function |
252 |
|
253 |
Private Function CreateDwg(ByVal oDwgName As String) As Boolean |
254 |
Dim objPIDADrawing As Object = Nothing |
255 |
Dim objPIDAutoApp As Object = Nothing |
256 |
Dim datasource As LMADataSource = Nothing |
257 |
Try |
258 |
Dim DrawingNumber As String |
259 |
Dim DrawingName As String |
260 |
Dim sPlantGroupName As String = "Test" |
261 |
Dim sTemplateName As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\P&ID Reference Data\Template Files\Gazprom Project.pid" |
262 |
Dim objDrawing As LMDrawing |
263 |
Dim objDrawings As LMDrawings |
264 |
objDrawings = New LMDrawings |
265 |
datasource = New LMADataSource |
266 |
Debug.Print(datasource.ProjectNumber) |
267 |
Debug.Print(datasource.SiteNode) |
268 |
Debug.Print(datasource.IsSatellite) |
269 |
Debug.Print(datasource.GetSystemEditingToolbarSetting) |
270 |
objDrawings.Collect(datasource) |
271 |
Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid" |
272 |
objPIDAutoApp = CreateObject("PIDAutomation.Application") |
273 |
For Each objDrawing In objDrawings |
274 |
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
275 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(sPath) |
276 |
If Not objPIDADrawing Is Nothing Then |
277 |
|
278 |
objPIDADrawing.CloseDrawing |
279 |
End If |
280 |
End If |
281 |
Next |
282 |
|
283 |
Dim extension As String = Path.GetExtension(oDwgName) |
284 |
oDwgName = oDwgName.Replace(extension, "") |
285 |
|
286 |
objPIDAutoApp = CreateObject("PIDAutomation.Application") |
287 |
|
288 |
'For Each objDrawing In objPIDAutoApp.Drawings |
289 |
' objDrawing.CloseDrawing(True) |
290 |
'Next |
291 |
|
292 |
objPIDAutoApp.Drawings.OpenDrawing(oDwgName + ".pid") |
293 |
|
294 |
objPIDAutoApp.ActiveWindow.Fit() |
295 |
|
296 |
Return True |
297 |
Catch ex As Exception |
298 |
If objPIDADrawing IsNot Nothing Then |
299 |
objPIDADrawing.CloseDrawing |
300 |
End If |
301 |
If objPIDAutoApp IsNot Nothing Then |
302 |
objPIDAutoApp.Quit |
303 |
End If |
304 |
datasource = Nothing |
305 |
objPIDAutoApp = Nothing |
306 |
objPIDADrawing = Nothing |
307 |
Return False |
308 |
End Try |
309 |
If objPIDADrawing IsNot Nothing Then |
310 |
objPIDADrawing.CloseDrawing |
311 |
End If |
312 |
|
313 |
End Function |
314 |
|
315 |
|
316 |
Private Function GetDataFromMappingDB(ByVal sSymbolName As String, ByVal sColumn As String) As String |
317 |
Dim sValue As String = "" |
318 |
If _Mapping_DB.Rows.Count > 0 Then |
319 |
Dim oSelectRow() As DataRow = _Mapping_DB.Select("[pid_symbolname] = '" + sSymbolName + "'") |
320 |
If oSelectRow.Length = 1 Then |
321 |
sValue = oSelectRow(0).Item(sColumn).ToString() |
322 |
End If |
323 |
End If |
324 |
Return sValue |
325 |
End Function |
326 |
|
327 |
Private Function GetAttributeMapping(ByVal sAttributeName As String, ByVal sColumn As String) As String |
328 |
Dim sSPPIDAttribute As String = "" |
329 |
If _Attribute_DB.Rows.Count > 0 Then |
330 |
Dim oSelectRow() As DataRow = _Attribute_DB.Select("[pid_attribute] = '" + sAttributeName + "'") |
331 |
If oSelectRow.Length = 1 Then |
332 |
sSPPIDAttribute = oSelectRow(0).Item(sColumn).ToString() |
333 |
End If |
334 |
End If |
335 |
Return sSPPIDAttribute |
336 |
End Function |
337 |
|
338 |
Dim _TempSymbolDt As DataTable = Symbol_Dt() |
339 |
|
340 |
|
341 |
Private Function LoadSymbolInXml(ByVal sXmlPath As String) As Drawing |
342 |
_TempSymbolDt = Symbol_Dt() |
343 |
Dim CDrawing As Drawing = New Drawing() |
344 |
Dim oDt As DataTable = LoadSymbol_DT() |
345 |
Dim oElement As XElement = XElement.Load(sXmlPath) |
346 |
|
347 |
If oElement IsNot Nothing Then |
348 |
CDrawing.DwgName = oElement.Element(_XML_DWGNAME).Value |
349 |
CDrawing.Size = oElement.Element(_XML_DWGSIZE).Value |
350 |
SplitLocation(CDrawing.Size, _IMG_X, _IMG_Y) |
351 |
CDrawing.Unit = oElement.Element(_XML_UNIT).Value |
352 |
|
353 |
Dim oLineno_list As New List(Of Line_no) |
354 |
Dim oEqp_list As New List(Of Eqp_no) |
355 |
|
356 |
For Each oLineNo As Object In oElement.Elements(_XML_CATEGORY_LINENO) |
357 |
Dim CLineNo As Line_no = New Line_no() |
358 |
Try |
359 |
CLineNo.Uid = oLineNo.Element(_XML_LINENO_UID).Value |
360 |
CLineNo.Text = oLineNo.Element(_XML_LINENO_TEXT).Value |
361 |
CLineNo.Location = oLineNo.Element(_XML_LINENO_LOCATION).Value |
362 |
CLineNo.Angle = oLineNo.Element(_XML_LINENO_ANGLE).Value |
363 |
CLineNo.SystemPath = GetDataFromMappingDB(_XML_CATEGORY_LINENO, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
364 |
Catch ex As Exception |
365 |
CLineNo.Text = "PipeLineNo" |
366 |
CLineNo.Uid = "PipeLineNo" |
367 |
End Try |
368 |
|
369 |
|
370 |
Dim oLine_Dt As DataTable = Line_Dt() |
371 |
Dim oSymbol_Dt As DataTable = Symbol_Dt() |
372 |
Dim oAttribute_Dt As DataTable = Attribute_Dt() |
373 |
|
374 |
For Each oLine As Object In oLineNo.Elements(_XML_CATEGORY_LINE) |
375 |
Dim oAddrow As DataRow = oLine_Dt.NewRow() |
376 |
Dim oEleObj As XElement |
377 |
Dim sUid As String |
378 |
Dim sStartpoint As String |
379 |
Dim sEndpoint As String |
380 |
oEleObj = oLine.Element(_XML_LINE_UID) |
381 |
sUid = oEleObj.Value |
382 |
oEleObj = oLine.Element(_XML_LINE_STARTPOINT) |
383 |
sStartpoint = oEleObj.Value |
384 |
oEleObj = oLine.Element(_XML_LINE_ENDPOINT) |
385 |
sEndpoint = oEleObj.Value |
386 |
|
387 |
oAddrow(_XML_LINE_UID) = sUid |
388 |
oAddrow(_XML_LINE_STARTPOINT) = sStartpoint |
389 |
oAddrow(_XML_LINE_ENDPOINT) = sEndpoint |
390 |
oAddrow(_XML_LINE_SYSTEMPATH) = GetDataFromMappingDB(_XML_CATEGORY_LINE, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
391 |
oLine_Dt.Rows.Add(oAddrow) |
392 |
Next |
393 |
|
394 |
For Each oSymbol As Object In oLineNo.Elements(_XML_CATEGORY_SYMBOL) |
395 |
Dim oAddrow As DataRow = oSymbol_Dt.NewRow() |
396 |
Dim oEleObj As XElement |
397 |
Dim sUid As String |
398 |
Dim sName As String |
399 |
Dim sLocation As String |
400 |
Dim sSize As String |
401 |
Dim sAngle As String |
402 |
Dim sOriginalPoint As String = "" |
403 |
oEleObj = oSymbol.Element(_XML_SYMBOL_UID) |
404 |
sUid = oEleObj.Value |
405 |
oEleObj = oSymbol.Element(_XML_SYMBOL_NAME) |
406 |
sName = oEleObj.Value |
407 |
oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
408 |
sLocation = oEleObj.Value |
409 |
oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE) |
410 |
sSize = oEleObj.Value |
411 |
oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
412 |
sAngle = oEleObj.Value |
413 |
Try |
414 |
oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT) |
415 |
sOriginalPoint = oEleObj.Value |
416 |
Catch ex As Exception |
417 |
|
418 |
End Try |
419 |
|
420 |
|
421 |
|
422 |
oAddrow(_XML_SYMBOL_UID) = sUid |
423 |
oAddrow(_XML_SYMBOL_NAME) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME) |
424 |
oAddrow(_XML_SYMBOL_LOCATION) = sLocation |
425 |
oAddrow(_XML_SYMBOL_SIZE) = sSize |
426 |
oAddrow(_XML_SYMBOL_ANGLE) = sAngle |
427 |
oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
428 |
oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE) |
429 |
oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint |
430 |
|
431 |
oSymbol_Dt.Rows.Add(oAddrow) |
432 |
Next |
433 |
|
434 |
For Each oAtrribute As Object In oLineNo.Elements(_XML_CATEGORY_ATTRIBUTE) |
435 |
|
436 |
Dim oAddrow As DataRow = oAttribute_Dt.NewRow() |
437 |
Dim oEleObj As XElement |
438 |
Dim sUid As String |
439 |
Dim sName As String |
440 |
Dim sValue As String |
441 |
|
442 |
oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID) |
443 |
sUid = oEleObj.Value |
444 |
oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME) |
445 |
sName = oEleObj.Value |
446 |
oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE) |
447 |
sValue = oEleObj.Value |
448 |
|
449 |
oAddrow(_XML_ATTRIBUTE_UID) = sUid |
450 |
oAddrow(_XML_ATTRIBUTE_NAME) = sName |
451 |
oAddrow(_XML_ATTRIBUTE_VALUE) = sValue |
452 |
oAttribute_Dt.Rows.Add(oAddrow) |
453 |
Next |
454 |
CLineNo.Dt_Line = oLine_Dt |
455 |
CLineNo.Dt_Symbol = oSymbol_Dt |
456 |
CLineNo.Dt_Attribute = oAttribute_Dt |
457 |
oLineno_list.Add(CLineNo) |
458 |
Next |
459 |
|
460 |
For Each oSymbol As Object In oElement.Elements(_XML_CATEGORY_SYMBOL) |
461 |
Dim oAddrow As DataRow = _TempSymbolDt.NewRow() |
462 |
Dim oEleObj As XElement |
463 |
Dim sUid As String |
464 |
Dim sName As String |
465 |
Dim sLocation As String |
466 |
Dim sSize As String |
467 |
Dim sAngle As String |
468 |
Dim sOriginalPoint As String = "" |
469 |
oEleObj = oSymbol.Element(_XML_SYMBOL_UID) |
470 |
sUid = oEleObj.Value |
471 |
oEleObj = oSymbol.Element(_XML_SYMBOL_NAME) |
472 |
sName = oEleObj.Value |
473 |
oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
474 |
sLocation = oEleObj.Value |
475 |
oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE) |
476 |
sSize = oEleObj.Value |
477 |
oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
478 |
sAngle = oEleObj.Value |
479 |
Try |
480 |
oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT) |
481 |
sOriginalPoint = oEleObj.Value |
482 |
Catch ex As Exception |
483 |
|
484 |
End Try |
485 |
oAddrow(_XML_SYMBOL_UID) = sUid |
486 |
oAddrow(_XML_SYMBOL_NAME) = sName |
487 |
oAddrow(_XML_SYMBOL_LOCATION) = sLocation |
488 |
oAddrow(_XML_SYMBOL_SIZE) = sSize |
489 |
oAddrow(_XML_SYMBOL_ANGLE) = sAngle |
490 |
oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
491 |
oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE) |
492 |
oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint |
493 |
_TempSymbolDt.Rows.Add(oAddrow) |
494 |
Next |
495 |
|
496 |
|
497 |
For Each oEqpNo As Object In oElement.Elements(_XML_CATEGORY_EQUIPMENT) |
498 |
Dim CEqp_no As Eqp_no = New Eqp_no() |
499 |
'CEqp_no.Uid = oEqpNo.Element(_XML_EQP_UID).Value |
500 |
'CEqp_no.Text = oEqpNo.Element(_XML_EQP_TEXT).Value |
501 |
'CEqp_no.Location = oEqpNo.Element(_XML_EQP_LOCATION).Value |
502 |
'CEqp_no.Angle = oEqpNo.Element(_XML_EQP_ANGLE).Value |
503 |
'CEqp_no.SystemPath = GetDataFromMappingDB(_XML_CATEGORY_EQUIPMENT, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
504 |
|
505 |
Dim oSymbol_Dt As DataTable = Symbol_Dt() |
506 |
Dim oAttribute_Dt As DataTable = Attribute_Dt() |
507 |
|
508 |
|
509 |
For Each oSymbol As Object In oEqpNo.Elements(_XML_CATEGORY_SYMBOL) |
510 |
Dim oAddrow As DataRow = oSymbol_Dt.NewRow() |
511 |
Dim oEleObj As XElement |
512 |
Dim sUid As String |
513 |
Dim sName As String |
514 |
Dim sLocation As String |
515 |
Dim sSize As String |
516 |
Dim sAngle As String |
517 |
Dim sOriginalPoint As String = "" |
518 |
oEleObj = oSymbol.Element(_XML_SYMBOL_UID) |
519 |
sUid = oEleObj.Value |
520 |
oEleObj = oSymbol.Element(_XML_SYMBOL_NAME) |
521 |
sName = oEleObj.Value |
522 |
oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
523 |
sLocation = oEleObj.Value |
524 |
oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE) |
525 |
sSize = oEleObj.Value |
526 |
oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
527 |
sAngle = oEleObj.Value |
528 |
Try |
529 |
oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT) |
530 |
sOriginalPoint = oEleObj.Value |
531 |
Catch ex As Exception |
532 |
|
533 |
End Try |
534 |
|
535 |
|
536 |
|
537 |
oAddrow(_XML_SYMBOL_UID) = sUid |
538 |
oAddrow(_XML_SYMBOL_NAME) = sName |
539 |
oAddrow(_XML_SYMBOL_LOCATION) = sLocation |
540 |
oAddrow(_XML_SYMBOL_SIZE) = sSize |
541 |
oAddrow(_XML_SYMBOL_ANGLE) = sAngle |
542 |
oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
543 |
oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE) |
544 |
oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint |
545 |
|
546 |
oSymbol_Dt.Rows.Add(oAddrow) |
547 |
Next |
548 |
|
549 |
For Each oAtrribute As Object In oEqpNo.Elements(_XML_CATEGORY_ATTRIBUTE) |
550 |
|
551 |
Dim oAddrow As DataRow = oAttribute_Dt.NewRow() |
552 |
Dim oEleObj As XElement |
553 |
Dim sUid As String |
554 |
Dim sName As String |
555 |
Dim sValue As String |
556 |
|
557 |
oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID) |
558 |
sUid = oEleObj.Value |
559 |
oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME) |
560 |
sName = oEleObj.Value |
561 |
oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE) |
562 |
sValue = oEleObj.Value |
563 |
|
564 |
oAddrow(_XML_ATTRIBUTE_UID) = sUid |
565 |
oAddrow(_XML_ATTRIBUTE_NAME) = sName |
566 |
oAddrow(_XML_ATTRIBUTE_VALUE) = sValue |
567 |
oAttribute_Dt.Rows.Add(oAddrow) |
568 |
Next |
569 |
|
570 |
CEqp_no.Dt_Equipment = oSymbol_Dt |
571 |
CEqp_no.Dt_Attribute = oAttribute_Dt |
572 |
oEqp_list.Add(CEqp_no) |
573 |
|
574 |
|
575 |
Next |
576 |
|
577 |
CDrawing.Line_nos = oLineno_list |
578 |
CDrawing.Eqp_nos = oEqp_list |
579 |
End If |
580 |
Return CDrawing |
581 |
End Function |
582 |
|
583 |
|
584 |
|
585 |
'Private Function LoadPipeInXml(ByVal sXmlPath As String) As DataTable |
586 |
' Try |
587 |
' Dim oDt As DataTable = LoadPipe_DT() |
588 |
' Dim oElement As XElement = XElement.Load(sXmlPath) |
589 |
' If oElement IsNot Nothing Then |
590 |
' Dim DWGElement As XElement = oElement.Element("DWGNAME") |
591 |
' Dim DWGNAME = DWGElement.Value |
592 |
' Dim sXY As XElement = oElement.Element("SIZE") |
593 |
' Dim sSize = sXY.Value |
594 |
' Dim oSplitDWGPos As String() = sSize.Split(", ") |
595 |
|
596 |
' If IsNumeric(oSplitDWGPos(0)) Then |
597 |
' _IMG_X = Double.Parse(oSplitDWGPos(0)) |
598 |
' End If |
599 |
' If IsNumeric(oSplitDWGPos(1)) Then |
600 |
' _IMG_Y = Double.Parse(oSplitDWGPos(1)) |
601 |
' End If |
602 |
|
603 |
' For Each pipes As Object In oElement.Elements("IMGLINES") |
604 |
' For Each pipe As Object In pipes.Elements("IMGLINE") |
605 |
' Dim oAddrow As DataRow = oDt.NewRow() |
606 |
' Dim oObj As XElement = pipe.Element("ITEM") |
607 |
' Dim oItem = oObj.Value |
608 |
' ' Dim oSymbolPath As String = "\" + oSymbol + "\" + oClass + "\" + oType + "\" + oItem + ".sym" |
609 |
' Dim oSymbolPath As String = GetSystemPathFromMappingDB(oItem) |
610 |
' oObj = pipe.Element("START") |
611 |
' Dim oStartPoint = oObj.Value |
612 |
' Dim oSplitPos As String() = oStartPoint.Split(", ") |
613 |
' Dim oStartpos_X As Double = 0.0 |
614 |
' Dim oStartpos_Y As Double = 0.0 |
615 |
' If IsNumeric(oSplitPos(0)) Then |
616 |
' oStartpos_X = Double.Parse(oSplitPos(0)) |
617 |
' End If |
618 |
' If IsNumeric(oSplitPos(1)) Then |
619 |
' oStartpos_Y = Double.Parse(oSplitPos(1)) |
620 |
' End If |
621 |
|
622 |
' ConvertPoint(oStartpos_X, oStartpos_Y, _DWG_X, _DWG_Y) |
623 |
' oObj = pipe.Element("End") |
624 |
' Dim oEndPoint = oObj.Value |
625 |
' oSplitPos = oEndPoint.Split(", ") |
626 |
' Dim oEndpos_X As Double = 0.0 |
627 |
' Dim oEndpos_Y As Double = 0.0 |
628 |
' If IsNumeric(oSplitPos(0)) Then |
629 |
' oEndpos_X = Double.Parse(oSplitPos(0)) |
630 |
' End If |
631 |
' If IsNumeric(oSplitPos(1)) Then |
632 |
' oEndpos_Y = Double.Parse(oSplitPos(1)) |
633 |
' End If |
634 |
' ConvertPoint(oEndpos_X, oEndpos_Y, _DWG_X, _DWG_Y) |
635 |
|
636 |
' oAddrow("start_x") = oStartpos_X '+ 0.05 |
637 |
' oAddrow("start_y") = oStartpos_Y |
638 |
' oAddrow("end_x") = oEndpos_X |
639 |
' oAddrow("end_y") = oEndpos_Y |
640 |
' oAddrow("SystemPath") = oSymbolPath |
641 |
' oDt.Rows.Add(oAddrow) |
642 |
' Next |
643 |
' Next |
644 |
|
645 |
' End If |
646 |
|
647 |
|
648 |
' Return oDt |
649 |
' Catch ex As Exception |
650 |
' Return Nothing |
651 |
' End Try |
652 |
'End Function |
653 |
|
654 |
|
655 |
Private Sub ConvertPointByImage(ByRef dX As Double, ByRef dY As Double, ByVal dDwgX As Double, ByVal dDwgY As Double) |
656 |
|
657 |
Dim calcx As Double = 0 |
658 |
Dim calcy As Double = 0 |
659 |
calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2) |
660 |
calcy = _DWG_Y - ((dY * _DWG_Y) / dDwgY) '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2) |
661 |
dX = calcx |
662 |
dY = calcy |
663 |
End Sub |
664 |
|
665 |
|
666 |
'@brief Convert To SPPID |
667 |
'@author : Gyusu Park |
668 |
'@date : 2018-04-10 |
669 |
'@history: |
670 |
|
671 |
Private Sub SplitLocation(ByVal sLocation As String, ByRef dX As Double, ByRef dY As Double) |
672 |
|
673 |
Dim opointstr As String() = Split(sLocation, ",") |
674 |
If (opointstr.Length > 1) Then |
675 |
If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
676 |
dX = opointstr(0) |
677 |
dY = opointstr(1) |
678 |
End If |
679 |
End If |
680 |
|
681 |
End Sub |
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
Private Function AutoConverting(ByVal oPipe_Dt As DataTable, ByVal oSymbol_Dt As DataTable, ByVal oTreeNode As TreeNode) As Boolean |
689 |
Dim iTotalCount As Double = oPipe_Dt.Rows.Count + oSymbol_Dt.Rows.Count |
690 |
Dim iSymbolcount As Double = 0 |
691 |
|
692 |
Dim lobjDatasource As Object = _Placement.PIDDataSource |
693 |
|
694 |
' lobjDatasource.BeginTransaction() |
695 |
' datasource = objPlacement.PIDDataSource |
696 |
'Dim iPipecnt As Integer = 0 |
697 |
SetListBoxItems(ListBox_Result, " Auto converting 시작....") |
698 |
|
699 |
Dim iPipeCnt As Integer = 0 |
700 |
If oPipe_Dt IsNot Nothing Then |
701 |
For Each oRow As DataRow In oPipe_Dt.Rows |
702 |
Dim oposition As String = oRow("position").ToString() |
703 |
Dim oSymbol As String = oRow("SystemPath").ToString() |
704 |
|
705 |
Dim objConnector As LMConnector |
706 |
Dim objInputs As PlaceRunInputs |
707 |
objInputs = New PlaceRunInputs |
708 |
Dim oSplitStr As String() = Split(oposition, " ") |
709 |
For Each sposition As String In oSplitStr |
710 |
Dim opointstr As String() = Split(sposition, ", ") |
711 |
|
712 |
If (opointstr.Length > 1) Then |
713 |
If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
714 |
Dim ox As Double = opointstr(0) |
715 |
Dim oy As Double = opointstr(1) |
716 |
ConvertPointByImage(ox, oy, _IMG_X, _IMG_Y) |
717 |
objInputs.AddPoint(ox, oy) |
718 |
End If |
719 |
End If |
720 |
Next |
721 |
Dim objItem As LMAItem |
722 |
objItem = _Placement.PIDCreateItem(oSymbol) |
723 |
objConnector = _Placement.PIDPlaceRun(objItem, objInputs) |
724 |
SetListBoxItems(ListBox_Result, " Place PipeLine...." & "(" & (iPipeCnt + 1) & "/" & oPipe_Dt.Rows.Count) |
725 |
'Dim objPipeRun As LMPipeRun = datasource.GetPipeRun(objConnector.ModelItemID) |
726 |
'objPipeRun.Attributes("OperFluidCode").Value = "AFS" |
727 |
'objPipeRun.Commit() |
728 |
iSymbolcount = iSymbolcount + 1 |
729 |
iPipeCnt = iPipeCnt + 1 |
730 |
Next |
731 |
End If |
732 |
|
733 |
SetListBoxItems(ListBox_Result, " Place PipeLine....완료") |
734 |
|
735 |
Dim iAllInstrumentCnt As Integer = oSymbol_Dt.Select("Name = 'INSTRUMENTATION'").Length |
736 |
Dim iValveCnt As Integer = oSymbol_Dt.Select("Class = 'VALVES'").Length |
737 |
Dim iInstrumentCnt As Integer = 1 |
738 |
Dim iFittingsCnt As Integer = 1 |
739 |
|
740 |
Dim oInsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Instruments", True)(0) |
741 |
Dim oValveNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Valves", True)(0) |
742 |
Dim oFittingsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Fittings", True)(0) |
743 |
For Each oRow As DataRow In oSymbol_Dt.Rows |
744 |
|
745 |
Try |
746 |
|
747 |
Dim sSystemPath As String = oRow("SystemPath").ToString() |
748 |
Dim sName As String = oRow("Name").ToString() |
749 |
Dim sType As String = oRow("Type").ToString() |
750 |
Dim sText As String = oRow("Text").ToString() |
751 |
Dim sClass As String = oRow("Class").ToString() |
752 |
Dim sItem As String = oRow("Item").ToString() |
753 |
|
754 |
Dim oX As Double = 0.0 |
755 |
Dim oY As Double = 0.0 |
756 |
If IsNumeric(oRow("x").ToString()) Then |
757 |
oX = Double.Parse(oRow("x").ToString()) |
758 |
End If |
759 |
If IsNumeric(oRow("y").ToString()) Then |
760 |
oY = Double.Parse(oRow("y").ToString()) |
761 |
End If |
762 |
Dim oAngle As Double = 0.0 |
763 |
If IsNumeric(oRow("Angle").ToString()) Then |
764 |
oAngle = Double.Parse(oRow("Angle").ToString()) |
765 |
End If |
766 |
' oSymbol = "\INSTRUMENTation\SYSTEM FUNCTIONS\D C S\DCS FUNC ACCESS IN PRIME LOC.sym" |
767 |
If sSystemPath <> "" Then |
768 |
If sName = _TYPE_Instumentation Then |
769 |
|
770 |
Dim sTagsuffix As String = "" |
771 |
Dim sTagSequenceNo As String = "" |
772 |
Dim sMeasuredVariableCode As String = "" |
773 |
Dim sInstrumentTypeModifier As String = "" |
774 |
|
775 |
If sText <> "" Then |
776 |
If sText.Contains(",") Then |
777 |
Dim splitstr() As String = sText.Split(",") |
778 |
For i = 0 To splitstr.Count - 1 |
779 |
If i = 0 Then |
780 |
sMeasuredVariableCode = Mid(splitstr(i), 1, 1) |
781 |
sTagSequenceNo = Mid(splitstr(i), 2, Len(splitstr(i))) |
782 |
Else |
783 |
If Len(splitstr(i)) = 1 Then |
784 |
sInstrumentTypeModifier = splitstr(i) |
785 |
ElseIf Len(splitstr(i)) = 0 Then |
786 |
|
787 |
ElseIf Len(splitstr(i)) > 1 Then |
788 |
sInstrumentTypeModifier = Mid(splitstr(i), 1, 1) |
789 |
sTagsuffix = Mid(splitstr(i), 2, Len(splitstr(i))) |
790 |
End If |
791 |
End If |
792 |
Next |
793 |
Else |
794 |
sMeasuredVariableCode = Mid(sText, 1, 1) |
795 |
sTagSequenceNo = Mid(sText, 2, Len(sText)) |
796 |
End If |
797 |
|
798 |
End If |
799 |
|
800 |
Dim objInstrSym As LMSymbol |
801 |
objInstrSym = _Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
802 |
SetListBoxItems(ListBox_Result, " Place Instrument...." & "(" & (iInstrumentCnt + 1) & "/" & iAllInstrumentCnt & ")") |
803 |
|
804 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sTagSequenceNo) |
805 |
Dim action As Action = Sub() |
806 |
oInsNode.Nodes.Add(sClass & "-" & iInstrumentCnt) |
807 |
oInsNode.ExpandAll() |
808 |
End Sub |
809 |
oInsNode.TreeView.Invoke(action) |
810 |
|
811 |
|
812 |
Dim objInstr As LMInstrument |
813 |
objInstr = lobjDatasource.GetInstrument(objInstrSym.ModelItemID) |
814 |
|
815 |
Dim objItem As LMAItem |
816 |
objItem = _Placement.PIDCreateItem(sSystemPath) |
817 |
|
818 |
|
819 |
objInstr.Attributes("MeasuredVariableCode").Value = sMeasuredVariableCode |
820 |
objInstr.Attributes("InstrumentTypeModifier").Value = sInstrumentTypeModifier |
821 |
objInstr.Attributes("TagSuffix").Value = sTagsuffix |
822 |
objInstr.Attributes("TagSequenceNo").Value = sTagSequenceNo |
823 |
objInstr.Commit() |
824 |
iInstrumentCnt = iInstrumentCnt + 1 |
825 |
ElseIf sName = "GATE VALVE WITH PLUG" Then |
826 |
|
827 |
ElseIf sName = "MEDIUM 1D 1TO1" Then |
828 |
|
829 |
ElseIf sClass = "VALVES" Then |
830 |
Dim action As Action = Sub() |
831 |
oValveNode.ExpandAll() |
832 |
oValveNode.Nodes.Add(sClass & "-" & iValveCnt) |
833 |
End Sub |
834 |
oValveNode.TreeView.Invoke(action) |
835 |
|
836 |
_Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
837 |
|
838 |
iValveCnt = iValveCnt + 1 |
839 |
Else |
840 |
Dim action As Action = Sub() |
841 |
oFittingsNode.ExpandAll() |
842 |
oFittingsNode.Nodes.Add(sClass & "-" & iFittingsCnt) |
843 |
End Sub |
844 |
oFittingsNode.TreeView.Invoke(action) |
845 |
_Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
846 |
|
847 |
iFittingsCnt = iFittingsCnt + 1 |
848 |
|
849 |
End If |
850 |
iSymbolcount = iSymbolcount + 1 |
851 |
Else |
852 |
End If |
853 |
Catch ex As Exception |
854 |
|
855 |
End Try |
856 |
Dim dCalcProgressValue As Double = (iSymbolcount / iTotalCount) * 100 |
857 |
SetProgressbar(ProgressBar_Status, dCalcProgressValue) |
858 |
' ProgressBar_Status.Value = (iSymbolcount / iTotalCount) * 100 |
859 |
|
860 |
Next |
861 |
|
862 |
MsgBox("Complete AutoConverting") |
863 |
SetListBoxItems(ListBox_Result, "Place Instrument....변환완료") |
864 |
SetListBoxItems(ListBox_Result, "총 symbol: " & iSymbolcount & "개 변환완료") |
865 |
SetProgressbar(ProgressBar_Status, 100) |
866 |
' MsgBox("symbol: " & iSymbolcount & "개, pipe : " & iPipecnt & "개 변환완료") |
867 |
End Function |
868 |
|
869 |
|
870 |
Private Sub Tree_XMLFiles_AfterCheck(sender As Object, e As TreeViewEventArgs) |
871 |
If e.Node.Checked = True Then |
872 |
For Each oNode As TreeNode In e.Node.Nodes |
873 |
oNode.Checked = True |
874 |
Next |
875 |
Else |
876 |
For Each oNode As TreeNode In e.Node.Nodes |
877 |
oNode.Checked = False |
878 |
Next |
879 |
End If |
880 |
End Sub |
881 |
|
882 |
Private Function Load_DB(ByVal sDBPath As String, ByVal sTableName As String) As DataTable |
883 |
|
884 |
Try |
885 |
Dim oDt As New DataTable |
886 |
Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;" |
887 |
Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring) |
888 |
conn.Open() |
889 |
Dim sQuery As String = "Select * from " & sTableName |
890 |
Dim cmd As SQLiteCommand = conn.CreateCommand() |
891 |
Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn) |
892 |
Dim oDataSet As DataSet = New DataSet() |
893 |
adapter.Fill(oDataSet) |
894 |
oDt = oDataSet.Tables(0) |
895 |
Return oDt |
896 |
Catch ex As Exception |
897 |
Return Nothing |
898 |
End Try |
899 |
|
900 |
|
901 |
End Function |
902 |
|
903 |
Private Sub Load_AttributeDB(ByVal sDBPath As String) |
904 |
|
905 |
Try |
906 |
Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;" |
907 |
Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring) |
908 |
conn.Open() |
909 |
Dim sQuery As String = "Select * from Attribute" |
910 |
Dim cmd As SQLiteCommand = conn.CreateCommand() |
911 |
Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn) |
912 |
Dim oDataSet As DataSet = New DataSet() |
913 |
adapter.Fill(oDataSet) |
914 |
_Attribute_DB = oDataSet.Tables(0) |
915 |
Catch ex As Exception |
916 |
|
917 |
End Try |
918 |
|
919 |
|
920 |
End Sub |
921 |
|
922 |
'Private Sub Tree_XMLFiles_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterSelect |
923 |
' If first_start = False Then Exit Sub |
924 |
' Dim pa = e.Node.FullPath.ToString |
925 |
|
926 |
' printfilesfolders_here(pa, e.Node) |
927 |
|
928 |
' displayfiles(pa) |
929 |
|
930 |
' Dim coco As String = "" |
931 |
' coco = pa.ToString |
932 |
' coco = coco.Replace("\\", "\") |
933 |
' Me.Text = coco |
934 |
' folders_path = coco |
935 |
'End Sub |
936 |
|
937 |
Sub printfilesfolders_here(ByVal path As String, ByRef itree As TreeNode) |
938 |
|
939 |
Dim foldername As String |
940 |
Dim filename As String |
941 |
itree.Nodes.Clear() |
942 |
On Error GoTo eee |
943 |
For Each foldername In Directory.GetDirectories(path) |
944 |
On Error GoTo eee |
945 |
Dim jj = foldername.LastIndexOf("\") |
946 |
Dim jj1 = foldername.Length - jj |
947 |
Dim foldr = foldername.Substring((jj + 1), (jj1 - 1)) |
948 |
itree.Nodes.Add(foldr, foldr) |
949 |
Next ' if you put this next at the end of procedure recursive will be done on first folder only |
950 |
Exit Sub |
951 |
eee: |
952 |
End Sub |
953 |
|
954 |
|
955 |
|
956 |
' Private Sub Tree_XMLFiles_MouseMove(sender As Object, e As MouseEventArgs) Handles Tree_XMLFiles.MouseMove |
957 |
' first_start = True |
958 |
' End Sub |
959 |
|
960 |
' Private Sub ListView_File_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView_File.SelectedIndexChanged |
961 |
' Dim indexes As ListView.SelectedIndexCollection = |
962 |
' Me.ListView_File.SelectedIndices |
963 |
' Dim index As Integer |
964 |
|
965 |
' For Each index In indexes |
966 |
' 'On Error Resume Next |
967 |
' If folders_path.EndsWith("\") = True Then |
968 |
' Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text) |
969 |
' 'On Error Resume Next |
970 |
' Else |
971 |
' Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text) |
972 |
' End If |
973 |
|
974 |
' Dim infoReader As System.IO.FileInfo |
975 |
' infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text) |
976 |
' Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString |
977 |
' Next |
978 |
' End Sub |
979 |
|
980 |
' Private Sub Procees() |
981 |
' Dim indexes As ListView.SelectedIndexCollection = |
982 |
' Me.ListView_File.SelectedIndices |
983 |
' Dim index As Integer |
984 |
|
985 |
' For Each index In indexes |
986 |
' 'On Error Resume Next |
987 |
' If folders_path.EndsWith("\") = True Then |
988 |
' On Error GoTo out |
989 |
' Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text) |
990 |
' On Error GoTo out |
991 |
' 'On Error Resume Next |
992 |
' Else |
993 |
' Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text) |
994 |
' On Error GoTo out |
995 |
' End If |
996 |
|
997 |
' Dim infoReader As System.IO.FileInfo |
998 |
' infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text) |
999 |
' Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString |
1000 |
' On Error GoTo out |
1001 |
' MsgBox(Me.Status_Main.Items(0).Text + " is processed") |
1002 |
' On Error GoTo out |
1003 |
' Next |
1004 |
' Exit Sub |
1005 |
'out: |
1006 |
' MsgBox(Err.Description) |
1007 |
'End Sub |
1008 |
|
1009 |
Private Function LoadAllDrawing() As DataTable |
1010 |
|
1011 |
|
1012 |
SetListBoxItems(ListBox_Result, "도면정보 로드중....") |
1013 |
|
1014 |
Dim oDt As DataTable = Drawing_Dt() |
1015 |
Dim sHierarchy As String = My.Settings.Plant_Hierarchy |
1016 |
|
1017 |
|
1018 |
Dim files() As String |
1019 |
files = Directory.GetFiles(sHierarchy, "*.pid", SearchOption.AllDirectories) |
1020 |
For Each FileName As String In files |
1021 |
Dim sName As String = FileName |
1022 |
Dim oAddRow As DataRow = oDt.NewRow() |
1023 |
oAddRow("Name") = Path.GetFileNameWithoutExtension(sName) |
1024 |
oAddRow("Path") = FileName |
1025 |
oDt.Rows.Add(oAddRow) |
1026 |
Next |
1027 |
Return oDt |
1028 |
End Function |
1029 |
|
1030 |
Private Function LoadAllDrawing2() As DataTable |
1031 |
Dim datasource As LMADataSource |
1032 |
Dim objPIDAutoApp As Object |
1033 |
Dim objPIDADrawing As Object |
1034 |
Dim objDrawing As Object 'Drawing |
1035 |
'Dim objDrawing As LMDrawing |
1036 |
'Dim objDrawings As LMDrawings |
1037 |
|
1038 |
datasource = New LMADataSource |
1039 |
|
1040 |
' objDrawings = New LMDrawings |
1041 |
'objDrawings.Collect(datasource) |
1042 |
objPIDAutoApp = CreateObject("PIDAutomation.Application") |
1043 |
|
1044 |
For Each objDrawing In objPIDAutoApp.Drawings |
1045 |
objDrawing.CloseDrawing(True) |
1046 |
Next |
1047 |
Try |
1048 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("UY1-K-2000_P1_300dpi_0321_TEST_1") |
1049 |
Catch ex As Exception |
1050 |
Process.Start("\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid") |
1051 |
End Try |
1052 |
|
1053 |
|
1054 |
|
1055 |
Dim sType As Type = objPIDAutoApp.GetType() |
1056 |
Dim iCount As Integer = 0 |
1057 |
' Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid" |
1058 |
|
1059 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("1") |
1060 |
|
1061 |
For Each objDrawing In objPIDAutoApp.Drawings |
1062 |
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
1063 |
Try |
1064 |
|
1065 |
Dim sName As String = objDrawing.Attributes("Name").Value |
1066 |
|
1067 |
iCount = iCount + 1 |
1068 |
If sName = "UY1-K-2000_P1_300dpi_0321_TEST_1" Then |
1069 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
1070 |
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid") |
1071 |
If Not objPIDADrawing Is Nothing Then |
1072 |
objPIDADrawing.CloseDrawing() |
1073 |
End If |
1074 |
End If |
1075 |
|
1076 |
|
1077 |
Catch ex As Exception |
1078 |
|
1079 |
End Try |
1080 |
|
1081 |
End If |
1082 |
Next |
1083 |
objPIDAutoApp.Quit |
1084 |
objPIDAutoApp = Nothing |
1085 |
objPIDADrawing = Nothing |
1086 |
objDrawing = Nothing |
1087 |
' objDrawings = Nothing |
1088 |
End Function |
1089 |
|
1090 |
Dim _XMLList As ListView = New ListView() |
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
Private Function CheckOpenDrawing() As Boolean |
1098 |
Try |
1099 |
|
1100 |
Dim lobjDatasource As Object |
1101 |
_Placement = CreateObject("Plaice.Placement", "") |
1102 |
lobjDatasource = _Placement.PIDDataSource |
1103 |
Return True |
1104 |
Catch ex As Exception |
1105 |
Return False |
1106 |
End Try |
1107 |
|
1108 |
End Function |
1109 |
|
1110 |
|
1111 |
Private Sub Btn_Convert_Click(sender As Object, e As EventArgs) Handles Btn_Convert.Click |
1112 |
|
1113 |
Main_Tab.SelectedIndex = 1 |
1114 |
ListBox_Result.Items.Clear() |
1115 |
' DataGrid_Result.DataSource = New DataTable() |
1116 |
Me.ProgressBar_Status.Visible = True |
1117 |
ProgressBar_Status.Maximum = 100 |
1118 |
ProgressBar_Status.Value = 0 |
1119 |
' _selectFolderPath = Tree_XMLFiles.SelectedNode.FullPath.Replace("\\", "\") |
1120 |
_Main_trd = New Thread(AddressOf ThreadTask) |
1121 |
_Main_trd.IsBackground = True |
1122 |
_Main_trd.Start() |
1123 |
|
1124 |
End Sub |
1125 |
'Private Sub ThreadTask() |
1126 |
|
1127 |
|
1128 |
' If _XMLList.Items.Count > 0 Then |
1129 |
|
1130 |
' Dim oDwg_Dt As DataTable = LoadAllDrawing() |
1131 |
' Dim iDwgCnt As Integer = 0 |
1132 |
' Dim objPIDAutoApp As Object |
1133 |
' objPIDAutoApp = CreateObject("PIDAutomation.Application") |
1134 |
|
1135 |
|
1136 |
' Dim myList = DirectCast(Invoke(New GetListViewDelegate(AddressOf GetListViewItems), _XMLList), List(Of String)) |
1137 |
' For i = 0 To myList.Count - 1 |
1138 |
|
1139 |
' Dim sDwgName As String = Path.GetFileNameWithoutExtension(myList(i)) |
1140 |
' Txt_Status.Text = sDwgName & "..(" & i + 1 & "/" & myList.Count & ")" |
1141 |
' SetListBoxItems(ListBox_Result, Txt_Status.Text & " 처리중....") |
1142 |
' Dim sDwgNo As String = myList(i) |
1143 |
' Dim oDwgPath As String = "" |
1144 |
' oDwgPath = _selectFolderPath + "\" + sDwgNo |
1145 |
|
1146 |
' Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName) |
1147 |
' If sPath <> "" Then |
1148 |
|
1149 |
' Process.Start(sPath) |
1150 |
|
1151 |
' Dim bCheckOpenDrawing As Boolean = False |
1152 |
' While (True) |
1153 |
' bCheckOpenDrawing = CheckOpenDrawing() |
1154 |
' If bCheckOpenDrawing = True Then |
1155 |
' Exit While |
1156 |
' Else |
1157 |
' Thread.Sleep(2000) |
1158 |
' End If |
1159 |
' End While |
1160 |
|
1161 |
' If bCheckOpenDrawing Then |
1162 |
' SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....") |
1163 |
' Dim oPipe_Dt As DataTable = New DataTable() 'LoadPipeInXml(oDwgPath) |
1164 |
|
1165 |
' Dim oSymbol_Dt As DataTable = LoadSymbolInXml(oDwgPath) |
1166 |
' Dim oTreeNode As New TreeNode 'SetTreeViewItems(Tree_Result, Tree_Result.Nodes, sDwgName, sDwgName) |
1167 |
' 'oTreeNode = Tree_Result.Nodes.Find(sDwgName, True)(0) |
1168 |
' Dim action As Action = Sub() |
1169 |
' oTreeNode = Tree_Result.Nodes.Add(sDwgName, sDwgName) |
1170 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Instruments", "Instuments") |
1171 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Pipes", "Pipes") |
1172 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Valves", "Valves") |
1173 |
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Fittings", "Fittings") |
1174 |
' oTreeNode.ExpandAll() |
1175 |
' End Sub |
1176 |
' Tree_Result.Invoke(action) |
1177 |
|
1178 |
|
1179 |
' ' oTreeNode.Expand() |
1180 |
' SetListBoxItems(ListBox_Result, sDwgName & " Auto converting 대기....") |
1181 |
' AutoConverting(oPipe_Dt, oSymbol_Dt, oTreeNode) |
1182 |
|
1183 |
' End If |
1184 |
|
1185 |
' End If |
1186 |
' ''도면 생성 |
1187 |
' 'If CreateDwg(sDwgName) Then |
1188 |
' ' 'AutoConverting |
1189 |
|
1190 |
' 'End If |
1191 |
|
1192 |
' Next |
1193 |
' End If |
1194 |
'End Sub |
1195 |
|
1196 |
Dim _objPIDAutoApp As Object |
1197 |
|
1198 |
Private Function OpenSPPID(ByVal oDwg_Dt As DataTable, ByVal sDwgName As String) As Boolean |
1199 |
Dim bCheckOpen As Boolean = False |
1200 |
' Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgPath) |
1201 |
SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....") |
1202 |
_objPIDAutoApp = CreateObject("PIDAutomation.Application") |
1203 |
|
1204 |
Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName) |
1205 |
If sPath <> "" Then |
1206 |
Process.Start(sPath) |
1207 |
Else |
1208 |
Return bCheckOpen |
1209 |
End If |
1210 |
|
1211 |
Dim bCheckOpenDrawing As Boolean = False |
1212 |
While (True) |
1213 |
bCheckOpenDrawing = CheckOpenDrawing() |
1214 |
If bCheckOpenDrawing = True Then |
1215 |
bCheckOpen = True |
1216 |
Exit While |
1217 |
Else |
1218 |
Thread.Sleep(2000) |
1219 |
End If |
1220 |
End While |
1221 |
|
1222 |
|
1223 |
Return bCheckOpen |
1224 |
End Function |
1225 |
|
1226 |
Private Function GetDrawing(ByVal sDwgName As String) As Drawing |
1227 |
For Each CDrawing In _DrawingsList |
1228 |
If CDrawing.DwgName.ToUpper() = sDwgName.ToUpper() Then |
1229 |
Return CDrawing |
1230 |
End If |
1231 |
Next |
1232 |
Return Nothing |
1233 |
End Function |
1234 |
|
1235 |
Private Function GetLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no |
1236 |
For Each CLineNo In CDrawing.Line_nos |
1237 |
If CLineNo.Uid = sLineNoUid Then |
1238 |
Return CLineNo |
1239 |
End If |
1240 |
Next |
1241 |
Return Nothing |
1242 |
End Function |
1243 |
|
1244 |
Private Function GetOnlyPipeLineNo(ByVal CDrawing As Drawing, ByVal sPipeUid As String) As Line_no |
1245 |
For Each CLineNo In CDrawing.Line_nos |
1246 |
Dim odt As DataTable = CLineNo.Dt_Line |
1247 |
If odt.Rows.Count > 0 Then |
1248 |
If odt.Rows(0)(_XML_LINE_UID).ToString = sPipeUid Then |
1249 |
Return CLineNo |
1250 |
End If |
1251 |
End If |
1252 |
Next |
1253 |
Return Nothing |
1254 |
End Function |
1255 |
|
1256 |
|
1257 |
Private Function GetEqpNo(ByVal CDrawing As Drawing, ByVal sEqpUid As String) As Eqp_no |
1258 |
For Each CEqpNo In CDrawing.Eqp_nos |
1259 |
If CEqpNo.Uid = sEqpUid Then |
1260 |
Return CEqpNo |
1261 |
End If |
1262 |
Next |
1263 |
Return Nothing |
1264 |
End Function |
1265 |
Private Function ConvertPointBystring(ByVal sPoint As String, ByRef dX As Double, ByRef dY As Double) As Boolean |
1266 |
Try |
1267 |
Dim opointstr As String() = Split(sPoint, ",") |
1268 |
If (opointstr.Length > 1) Then |
1269 |
If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
1270 |
dX = opointstr(0) |
1271 |
dY = opointstr(1) |
1272 |
|
1273 |
Else |
1274 |
dX = 0 |
1275 |
dY = 0 |
1276 |
Return False |
1277 |
End If |
1278 |
End If |
1279 |
Return True |
1280 |
Catch ex As Exception |
1281 |
Return False |
1282 |
End Try |
1283 |
End Function |
1284 |
|
1285 |
Private Function DrawLine(ByVal sUid As String, ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable) As LMPipeRun |
1286 |
Try |
1287 |
Dim oPipeRun As LMPipeRun |
1288 |
Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" + sUid + "'") |
1289 |
Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'") |
1290 |
|
1291 |
If oPipeRow.Length > 0 Then |
1292 |
Dim oDatasource As Object = _Placement.PIDDataSource |
1293 |
Dim objItem As LMAItem |
1294 |
Dim objConnector As LMConnector |
1295 |
Dim objInputs As PlaceRunInputs |
1296 |
objInputs = New PlaceRunInputs |
1297 |
Dim dOriginalStart_x As Double = 0.0 |
1298 |
Dim dOriginalStart_y As Double = 0.0 |
1299 |
Dim dOriginalEnd_x As Double = 0.0 |
1300 |
Dim dOriginalEnd_y As Double = 0.0 |
1301 |
|
1302 |
Dim dStart_x As Double = 0.0 |
1303 |
Dim dStart_y As Double = 0.0 |
1304 |
Dim dEnd_x As Double = 0.0 |
1305 |
Dim dEnd_y As Double = 0.0 |
1306 |
Dim sSystempath As String = oPipeRow(0)(_XML_LINE_SYSTEMPATH).ToString() |
1307 |
Dim sStartpoint As String = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString() |
1308 |
Dim sEndpoint As String = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString() |
1309 |
ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y) |
1310 |
dStart_x = dOriginalStart_x |
1311 |
dStart_y = dOriginalStart_y |
1312 |
ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y) |
1313 |
If ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y) Then |
1314 |
dEnd_x = dOriginalEnd_x |
1315 |
dEnd_y = dOriginalEnd_y |
1316 |
ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y) |
1317 |
If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then |
1318 |
objInputs.AddPoint(dStart_x, dStart_y) |
1319 |
objInputs.AddPoint(dEnd_x, dEnd_y) |
1320 |
objItem = _Placement.PIDCreateItem(sSystempath) |
1321 |
_iPipecnt = _iPipecnt + 1 |
1322 |
SetListBoxItems(ListBox_Result, "Place PipeLine..(" & dOriginalStart_x & "," & dOriginalStart_y & ") - (" & dOriginalEnd_x & "," & dOriginalEnd_y & ").." & _iPipecnt & " count ") |
1323 |
objConnector = _Placement.PIDPlaceRun(objItem, objInputs) |
1324 |
oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID) |
1325 |
oPipeRun.Attributes("FlowDirection").Value = "End 1 is upstream (Inlet)" |
1326 |
If oAttributeRow.Length > 0 Then |
1327 |
For Each oAttribute In oAttributeRow |
1328 |
Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString() |
1329 |
Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString() |
1330 |
Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE) |
1331 |
oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue |
1332 |
|
1333 |
Next |
1334 |
oPipeRun.Commit() |
1335 |
End If |
1336 |
'Flow Direction |
1337 |
'Dim sFlowDirectionPath As String = GetDataFromMappingDB(_XML_CATEGORY_FLOWDIRECITON, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
1338 |
'Dim dFlowDirectionAngle As Double = 0.0 |
1339 |
'If dStart_y <> dEnd_y Then |
1340 |
' If dStart_y > dEnd_y Then |
1341 |
' dFlowDirectionAngle = -1.57 |
1342 |
' Else |
1343 |
' dFlowDirectionAngle = 1.57 |
1344 |
' End If |
1345 |
'End If |
1346 |
'If dStart_x <> dEnd_x Then |
1347 |
' If dStart_x > dEnd_x Then |
1348 |
' dFlowDirectionAngle = 3.14 |
1349 |
' Else |
1350 |
' dFlowDirectionAngle = 0 |
1351 |
' End If |
1352 |
'End If |
1353 |
|
1354 |
'_Placement.PIDPlaceSymbol(sFlowDirectionPath, dEnd_x, dEnd_y, , dFlowDirectionAngle) |
1355 |
End If |
1356 |
End If |
1357 |
|
1358 |
|
1359 |
End If |
1360 |
Return oPipeRun |
1361 |
Catch ex As Exception |
1362 |
Return Nothing |
1363 |
End Try |
1364 |
End Function |
1365 |
|
1366 |
Private Function DrawSymbol(ByVal sUid As String, ByVal sLineNoUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable) As Boolean |
1367 |
Try |
1368 |
|
1369 |
Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'") |
1370 |
Dim oAttributeRow() As DataRow |
1371 |
If oAttribute_Dt.Rows.Count > 0 Then |
1372 |
oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'") |
1373 |
End If |
1374 |
|
1375 |
If oSymbolRow.Length > 0 Then |
1376 |
Dim oDatasource As Object = _Placement.PIDDataSource |
1377 |
Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString() |
1378 |
Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString() |
1379 |
Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString() |
1380 |
Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString() |
1381 |
Dim dAngle As Double = 0.0 |
1382 |
If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then |
1383 |
dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) |
1384 |
End If |
1385 |
|
1386 |
Dim objSymbol As LMSymbol |
1387 |
Dim dLocationX As Double = 0.0 |
1388 |
Dim dLocationY As Double = 0.0 |
1389 |
Dim dX As Double = 0.0 |
1390 |
Dim dY As Double = 0.0 |
1391 |
|
1392 |
If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then |
1393 |
dX = dLocationX |
1394 |
dY = dLocationY |
1395 |
ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
1396 |
Dim oInstrument As LMInstrument |
1397 |
If sSymbolCompType = _SYMBOL_INSTUMENT Then |
1398 |
_iInstrumentcnt = _iInstrumentcnt + 1 |
1399 |
objSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1400 |
SetListBoxItems(ListBox_Result, "Place Instrument..(" & dLocationX & "," & dLocationY & ")..." & _iInstrumentcnt & " count ") |
1401 |
oInstrument = oDatasource.GetInstrument(objSymbol.ModelItemID) |
1402 |
Try |
1403 |
If oAttributeRow.Length > 0 Then |
1404 |
For Each oAttribute In oAttributeRow |
1405 |
Dim sPIDAttribute As String = oAttribute(0)(_XML_ATTRIBUTE_NAME).ToString() |
1406 |
Dim sPIDValue As String = oAttribute(0)(_XML_ATTRIBUTE_VALUE).ToString() |
1407 |
Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE) |
1408 |
oInstrument.Attributes(0)(sSPPIDAttribute).Value = sPIDValue |
1409 |
Next |
1410 |
oInstrument.Commit() |
1411 |
End If |
1412 |
Catch ex As Exception |
1413 |
|
1414 |
End Try |
1415 |
|
1416 |
|
1417 |
ElseIf sSymbolCompType = _SYMBOL_VALVES Then |
1418 |
_iValvecnt = _iValvecnt + 1 |
1419 |
_Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1420 |
SetListBoxItems(ListBox_Result, "Place Valve..(" & dLocationX & "," & dLocationY & ")..." & _iValvecnt & " count ") |
1421 |
|
1422 |
ElseIf sSymbolCompType = _SYMBOL_FITTINGS Then |
1423 |
_iFittingcnt = _iFittingcnt + 1 |
1424 |
_Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1425 |
SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ") |
1426 |
Else |
1427 |
_iFittingcnt = _iFittingcnt + 1 |
1428 |
_Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1429 |
SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ") |
1430 |
|
1431 |
End If |
1432 |
|
1433 |
End If |
1434 |
|
1435 |
End If |
1436 |
|
1437 |
Catch ex As Exception |
1438 |
Return False |
1439 |
End Try |
1440 |
End Function |
1441 |
|
1442 |
Private Function DrawLineNo(ByVal oPiperun As LMPipeRun, ByVal CLine_No As Line_no) As Boolean |
1443 |
Try |
1444 |
Dim oDatasource As Object = _Placement.PIDDataSource |
1445 |
Dim sLocation = CLine_No.Location |
1446 |
Dim dLocationx As Double = 0.0 |
1447 |
Dim dLocationy As Double = 0.0 |
1448 |
|
1449 |
Dim dX As Double = 0.0 |
1450 |
Dim dY As Double = 0.0 |
1451 |
If ConvertPointBystring(sLocation, dLocationx, dLocationy) Then |
1452 |
dX = dLocationx |
1453 |
dY = dLocationy |
1454 |
ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
1455 |
Dim dLineNoLocation(2) As Double |
1456 |
dLineNoLocation(1) = dX |
1457 |
dLineNoLocation(2) = dY |
1458 |
'Label |
1459 |
Dim sSystemPath As String = CLine_No.SystemPath |
1460 |
Dim dAngle As Double = CLine_No.Angle |
1461 |
Dim labelpersist As LMLabelPersist |
1462 |
|
1463 |
For Each representation In oPiperun.Representations |
1464 |
If representation.RepresentationType = "Connector" Then |
1465 |
labelpersist = _Placement.PIDPlaceLabel(sSystemPath, |
1466 |
dLineNoLocation,, dAngle, LabeledItem:=representation) |
1467 |
_iPipeLineNocnt = _iPipeLineNocnt + 1 |
1468 |
SetListBoxItems(ListBox_Result, "Place PipeLineNo Label..(" & dLocationx & "," & dLocationy & ")..." & _iPipeLineNocnt & " count ") |
1469 |
End If |
1470 |
Next |
1471 |
Return True |
1472 |
Else |
1473 |
Return False |
1474 |
End If |
1475 |
|
1476 |
Catch ex As Exception |
1477 |
Return False |
1478 |
End Try |
1479 |
End Function |
1480 |
|
1481 |
|
1482 |
Private Sub InitItemCount() |
1483 |
_iPipeLineNocnt = 0 |
1484 |
_iPipecnt = 0 |
1485 |
_iFittingcnt = 0 |
1486 |
_iValvecnt = 0 |
1487 |
_iInstrumentcnt = 0 |
1488 |
_iEquipmentcnt = 0 |
1489 |
_iNozzlecnt = 0 |
1490 |
End Sub |
1491 |
|
1492 |
Private Function AutoModeling() As Boolean |
1493 |
Try |
1494 |
|
1495 |
SetListBoxItems(ListBox_Result, " Auto converting 시작....") |
1496 |
Dim oDwg_Dt As DataTable = LoadAllDrawing() |
1497 |
For Each oDrwing As TreeNode In Tree_Result.Nodes |
1498 |
For Each oDwgNode As TreeNode In oDrwing.Nodes |
1499 |
|
1500 |
Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text) |
1501 |
Dim CDrawing As Drawing = GetDrawing(sDwgName) |
1502 |
If CDrawing IsNot Nothing Then |
1503 |
If OpenSPPID(oDwg_Dt, oDwgNode.Text) Then |
1504 |
InitItemCount() |
1505 |
Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode) |
1506 |
Dim iLineNoCount As Integer = 0 ' GetCheckNodeCount(oLinenoNode) |
1507 |
SetListBoxItems(ListBox_Result, "Place " & CDrawing.DwgName & "....") |
1508 |
|
1509 |
For Each oNode As TreeNode In oDwgNode.Nodes |
1510 |
|
1511 |
Dim sNodeUid As String = oNode.Name |
1512 |
If sNodeUid <> "PipeLineNo" Then |
1513 |
Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid) |
1514 |
If CLineNo IsNot Nothing Then |
1515 |
Dim oPipeRun As LMPipeRun |
1516 |
Dim oLine_Dt As DataTable = CLineNo.Dt_Line |
1517 |
Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol |
1518 |
Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute |
1519 |
Dim oDrawLinenoLabel As Boolean = False |
1520 |
For Each oLineNode As TreeNode In oNode.Nodes |
1521 |
Dim sLineUid As String = oLineNode.Name |
1522 |
If oLineNode.Checked Then |
1523 |
Dim sUid As String = oLineNode.Name |
1524 |
If oLine_Dt.Select("[" & _XML_LINE_UID & "]= '" & sUid & "'").Length = 1 Then |
1525 |
oPipeRun = DrawLine(sUid, sNodeUid, oLine_Dt, oAttribute_Dt) |
1526 |
If oDrawLinenoLabel = False Then |
1527 |
DrawLineNo(oPipeRun, CLineNo) |
1528 |
oDrawLinenoLabel = True |
1529 |
End If |
1530 |
End If |
1531 |
|
1532 |
|
1533 |
End If |
1534 |
Next |
1535 |
|
1536 |
For Each oSymbolNode As TreeNode In oNode.Nodes |
1537 |
If oSymbolNode.Checked Then |
1538 |
Dim sUid As String = oSymbolNode.Name |
1539 |
If oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sUid & "'").Length = 1 Then |
1540 |
DrawSymbol(sUid, sNodeUid, oSymbol_Dt, oAttribute_Dt) |
1541 |
End If |
1542 |
|
1543 |
End If |
1544 |
Next |
1545 |
iLineNoCount = iLineNoCount + 1 |
1546 |
End If |
1547 |
|
1548 |
Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid) |
1549 |
|
1550 |
If CEqpNo IsNot Nothing Then |
1551 |
Dim oSymbol_Dt As DataTable = CEqpNo.Dt_Equipment |
1552 |
Dim oAttribute_Dt As DataTable = CEqpNo.Dt_Attribute |
1553 |
For Each oSymbolNode As TreeNode In oNode.Nodes |
1554 |
If oSymbolNode.Checked Then |
1555 |
Dim sUid As String = oSymbolNode.Name |
1556 |
DrawSymbol(sUid, sNodeUid, oSymbol_Dt, oAttribute_Dt) |
1557 |
End If |
1558 |
Next |
1559 |
End If |
1560 |
|
1561 |
|
1562 |
|
1563 |
Else |
1564 |
|
1565 |
Dim oDrawLinenoLabel As Boolean = False |
1566 |
For Each oLineNode As TreeNode In oNode.Nodes |
1567 |
Dim CLineNo As Line_no = GetOnlyPipeLineNo(CDrawing, oLineNode.Name) |
1568 |
Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute |
1569 |
Dim oLine_Dt As DataTable = CLineNo.Dt_Line |
1570 |
Dim sLineUid As String = oLineNode.Name |
1571 |
If oLineNode.Checked Then |
1572 |
Dim sUid As String = oLineNode.Name |
1573 |
DrawLine(sUid, sNodeUid, oLine_Dt, oAttribute_Dt) |
1574 |
End If |
1575 |
Next |
1576 |
|
1577 |
|
1578 |
|
1579 |
|
1580 |
End If |
1581 |
|
1582 |
|
1583 |
' Dim dCalcProgressValue As Double = (iLineNoCount / iLineNoCount) * 100 |
1584 |
'SetProgressbar(ProgressBar_Status, dCalcProgressValue) |
1585 |
Next |
1586 |
|
1587 |
End If |
1588 |
End If |
1589 |
|
1590 |
Next |
1591 |
|
1592 |
|
1593 |
|
1594 |
Next |
1595 |
SetProgressbar(ProgressBar_Status, 100) |
1596 |
SetListBoxItems(ListBox_Result, " Auto converting 완료") |
1597 |
Return True |
1598 |
Catch ex As Exception |
1599 |
Return False |
1600 |
End Try |
1601 |
End Function |
1602 |
|
1603 |
|
1604 |
|
1605 |
Private Sub ThreadTask() |
1606 |
If _DrawingsList IsNot Nothing Then |
1607 |
If _DrawingsList.Count > 0 Then |
1608 |
AutoModeling() |
1609 |
End If |
1610 |
End If |
1611 |
|
1612 |
|
1613 |
End Sub |
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
Private Function OpenDrawing(ByVal oDt As DataTable, ByVal sDwgName As String) As String |
1619 |
Dim oRows As DataRow() = oDt.Select("[Name] = '" & sDwgName & "'") |
1620 |
Dim oPath As String = "" |
1621 |
If oRows.Length > 0 Then |
1622 |
oPath = oRows(0).Item("Path").ToString() |
1623 |
End If |
1624 |
Return oPath |
1625 |
End Function |
1626 |
|
1627 |
Private Sub LoadXmlToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadXmlToolStripMenuItem.Click |
1628 |
If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then |
1629 |
LoadXmlItem(FolderBrowserDialog1.SelectedPath) |
1630 |
End If |
1631 |
End Sub |
1632 |
Private Sub LoadXmlItem(ByVal sFolderPath As String) |
1633 |
_DrawingsList = New List(Of Drawing) |
1634 |
Dim sfileEntries As String() = Directory.GetFiles(sFolderPath) |
1635 |
If Tree_Result.Nodes.Count > 0 Then |
1636 |
Tree_Result.Nodes(0).Nodes.Clear() |
1637 |
For Each sfileName In sfileEntries |
1638 |
Dim sExtension As String = Path.GetExtension(sfileName) |
1639 |
If sExtension = ".xml" Then |
1640 |
Dim sDwgName As String = Path.GetFileNameWithoutExtension(sfileName) |
1641 |
Dim sDwgPath As String = sfileName |
1642 |
Dim oNode As TreeNode = Tree_Result.Nodes(0).Nodes.Add(sDwgPath, sDwgName, 15) |
1643 |
Dim oDwg As Drawing = AddSymbolItem(sDwgPath, oNode) |
1644 |
_DrawingsList.Add(oDwg) |
1645 |
End If |
1646 |
Next |
1647 |
Tree_Result.Nodes(0).Expand() |
1648 |
End If |
1649 |
End Sub |
1650 |
|
1651 |
|
1652 |
''' <summary> |
1653 |
''' XML Tree 구조 생성 |
1654 |
''' </summary> |
1655 |
''' <param name="sDwgPath"></param> |
1656 |
Private Function AddSymbolItem(ByVal sDwgPath As String, ByVal oParentNode As TreeNode) As Drawing |
1657 |
Dim oDwg_Ds As Drawing = LoadSymbolInXml(sDwgPath) |
1658 |
|
1659 |
Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos |
1660 |
|
1661 |
Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos |
1662 |
Dim oPipe As Boolean = False |
1663 |
Dim oFitting As Boolean = False |
1664 |
Dim oOnlyPipesNode As TreeNode |
1665 |
Dim oOnlyFittingsNode As TreeNode |
1666 |
'PipeLine 구분 |
1667 |
|
1668 |
For Each oLinelist In oLineLists |
1669 |
Dim sLineNoUid As String = oLinelist.Uid |
1670 |
Dim sLineNo As String = oLinelist.Text |
1671 |
If sLineNo <> "PipeLineNo" Then |
1672 |
Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo) |
1673 |
For Each oLineRow In oLinelist.Dt_Line.Rows |
1674 |
Dim sLineUid As String = oLineRow(_XML_LINE_UID) |
1675 |
Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe") |
1676 |
oPipeNode.Tag = sLineNoUid |
1677 |
Next |
1678 |
For Each oSymbolRow In oLinelist.Dt_Symbol.Rows |
1679 |
Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
1680 |
Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
1681 |
Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName) |
1682 |
oSymbolNode.Tag = sLineNoUid |
1683 |
Next |
1684 |
Else |
1685 |
If oPipe = False Then |
1686 |
oOnlyPipesNode = oParentNode.Nodes.Add("PipeLineNo", "PipeLineNo") |
1687 |
oPipe = True |
1688 |
End If |
1689 |
For Each oLineRow In oLinelist.Dt_Line.Rows |
1690 |
Dim sLineUid As String = oLineRow(_XML_SYMBOL_UID) |
1691 |
Dim oPipeNode As TreeNode = oOnlyPipesNode.Nodes.Add(sLineUid, "Pipe") |
1692 |
oPipeNode.Tag = sLineNoUid |
1693 |
Next |
1694 |
|
1695 |
|
1696 |
|
1697 |
|
1698 |
End If |
1699 |
Next |
1700 |
For Each oSymbolRow In _TempSymbolDt.Rows |
1701 |
If oFitting = False Then |
1702 |
oOnlyFittingsNode = oParentNode.Nodes.Add("Symbols", "Symbols") |
1703 |
oFitting = True |
1704 |
End If |
1705 |
Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
1706 |
Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
1707 |
Dim oSymbolNode As TreeNode = oOnlyFittingsNode.Nodes.Add(sSymbolUid, sSymbolName) |
1708 |
oSymbolNode.Tag = sSymbolUid |
1709 |
Next |
1710 |
For Each oEqplist In oEqpLists |
1711 |
Dim sEqpUid As String = oEqplist.Uid |
1712 |
Dim sEqpNo As String = "EQUIPMENT" |
1713 |
Dim oEqpNode As TreeNode = oParentNode.Nodes.Add(sEqpUid, sEqpNo) |
1714 |
|
1715 |
|
1716 |
For Each oSymbolRow In oEqplist.Dt_Equipment.Rows |
1717 |
Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
1718 |
Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
1719 |
Dim oSymbolNode As TreeNode = oEqpNode.Nodes.Add(sSymbolUid, sSymbolName) |
1720 |
oSymbolNode.Tag = sEqpUid |
1721 |
Next |
1722 |
Next |
1723 |
Return oDwg_Ds |
1724 |
End Function |
1725 |
Private Sub Tree_Result_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_Result.AfterCheck |
1726 |
If e.Node.Checked = True Then |
1727 |
For Each oNode As TreeNode In e.Node.Nodes |
1728 |
oNode.Checked = True |
1729 |
Next |
1730 |
Else |
1731 |
For Each oNode As TreeNode In e.Node.Nodes |
1732 |
oNode.Checked = False |
1733 |
Next |
1734 |
End If |
1735 |
End Sub |
1736 |
|
1737 |
Private Sub Btn_Setting_Click(sender As Object, e As EventArgs) Handles Btn_Setting.Click |
1738 |
Dim oSettings As Settings = New Settings() |
1739 |
oSettings.ShowDialog() |
1740 |
End Sub |
1741 |
End Class |
1742 |
|
1743 |
|
1744 |
Public Class DrawingInfo |
1745 |
Public mDrawingName As String |
1746 |
Public mSpID As String |
1747 |
Public mPath As String |
1748 |
End Class |
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|