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 _DB As DataTable = New DataTable()
|
14
|
Dim _Placement As New Placement
|
15
|
Dim _DWG_X = 0.84 '0.695 '1 '
|
16
|
Dim _DWG_Y = 0.594 '0.585 '0.8 '
|
17
|
|
18
|
Dim _IMG_X = 9933
|
19
|
Dim _IMG_Y = 7016
|
20
|
|
21
|
'Drawing 전역변수
|
22
|
Dim _objPIDADrawing As Object
|
23
|
'현재선택한 폴더경로
|
24
|
Dim _selectFolderPath As String
|
25
|
|
26
|
Private _Main_trd As Thread
|
27
|
|
28
|
|
29
|
Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
30
|
SetUpListViewColumns()
|
31
|
LoadTree()
|
32
|
If My.Settings.DBPath <> "" And My.Settings.Plant_Hierarchy <> "" Then
|
33
|
Dim sDBPath As String = My.Settings.DBPath
|
34
|
LoadDB(sDBPath)
|
35
|
'TestPID()
|
36
|
Else
|
37
|
MessageBox.Show("설정값을 먼저 확인해주세요")
|
38
|
End If
|
39
|
End Sub
|
40
|
|
41
|
Public Function GetDrawingInfo(ByVal errorList As ArrayList)
|
42
|
Dim ds As Llama.LMADataSource
|
43
|
ds = New Llama.LMADataSource
|
44
|
Dim lmaItem As Llama.LMAItem
|
45
|
|
46
|
For i = 0 To errorList.Count - 1
|
47
|
lmaItem = ds.GetModelItem(errorList.Item(i).m_strSPID()).AsLMAItem
|
48
|
Dim drawingInfo As DrawingInfo
|
49
|
drawingInfo = GetDrawingName(lmaItem.ItemType, lmaItem.Id)
|
50
|
errorList.Item(i).m_LMAItem = lmaItem
|
51
|
errorList.Item(i).m_strDrawingName = drawingInfo.mDrawingName
|
52
|
errorList.Item(i).m_strDrawingPath = drawingInfo.mPath
|
53
|
Next
|
54
|
End Function
|
55
|
Private mDataSource As Object
|
56
|
|
57
|
'Public Sub New()
|
58
|
|
59
|
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName
|
60
|
' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI
|
61
|
' 'm_Information = SPPIDClass.Information.GetInstance()
|
62
|
|
63
|
' 'If m_Information.InfoProject.ProjectVersion = SPPIDClass.InfoProject.SPPID_43 Then
|
64
|
' ' 'SPPID4.3용
|
65
|
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName
|
66
|
' 'Else
|
67
|
' ' 'SPPID2007, SPPID2009용
|
68
|
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName
|
69
|
' 'End If
|
70
|
|
71
|
' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI
|
72
|
' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName
|
73
|
' '#If LATE_BINDING Then
|
74
|
' ' mInstruments = CreateObject("Llama.LMInstruments", "")
|
75
|
' ' mPipingComps = CreateObject("Llama.LMPipingComps", "")
|
76
|
' ' mVessels = CreateObject("Llama.LMVessels", "")
|
77
|
' ' mDrawings = CreateObject("Llama.LMDrawings", "")
|
78
|
' ' mEquipments = CreateObject("Llama.LMEquipments", "")
|
79
|
' ' mExchangers = CreateObject("Llama.LMExchangers", "")
|
80
|
' ' mMechanicals = CreateObject("Llama.LMMechanicals", "")
|
81
|
' ' mNozzles = CreateObject("Llama.LMNozzles", "")
|
82
|
' ' mPipeRuns = CreateObject("Llama.LMPipeRuns", "")
|
83
|
' ' mEquipmentOthers = CreateObject("Llama.LMEquipmentOthers", "")
|
84
|
' '#Else
|
85
|
' ' mInstruments = New Llama.LMInstruments
|
86
|
' ' mPipingComps = New Llama.LMPipingComps
|
87
|
' ' mVessels = New Llama.LMVessels
|
88
|
' ' mDrawings = New Llama.LMDrawings
|
89
|
' ' mEquipments = New Llama.LMEquipments
|
90
|
' ' mExchangers = New Llama.LMExchangers
|
91
|
' ' mMechanicals = New Llama.LMMechanicals
|
92
|
' ' mNozzles = New Llama.LMNozzles
|
93
|
' ' mPipeRuns = New Llama.LMPipeRuns
|
94
|
' ' mEquipmentOthers = New Llama.LMEquipmentOthers
|
95
|
' '#End If
|
96
|
'End Sub
|
97
|
Public Function GetDrawingName(ByVal itemType As String, ByVal itemName As String) As DrawingInfo
|
98
|
|
99
|
Dim objFilter As Object
|
100
|
objFilter = CreateObject("Llama.LMAFilter", "")
|
101
|
|
102
|
Dim drawingInfo As DrawingInfo
|
103
|
drawingInfo = New DrawingInfo
|
104
|
|
105
|
objFilter.Criteria.AddNew("FirstOne")
|
106
|
objFilter.Criteria.Item("FirstOne").SourceAttributeName = "SP_ID"
|
107
|
objFilter.Critedkria.Item("FirstOne").ValueAttribute = itemName
|
108
|
|
109
|
objFilter.Criteria.Item("FirstOne").Operator = "="
|
110
|
objFilter.Criteria.AddNew("SecondOne")
|
111
|
objFilter.Criteria.Item("SecondOne").SourceAttributeName = "ItemStatus"
|
112
|
objFilter.Criteria.Item("SecondOne").ValueAttribute = 1
|
113
|
objFilter.Criteria.Item("SecondOne").Operator = "="
|
114
|
objFilter.Criteria.Item("SecondOne").Conjunctive = -1
|
115
|
objFilter.ItemType = itemType
|
116
|
|
117
|
Dim PlantItems As Object
|
118
|
PlantItems = CreateObject("Llama.LMPlantItems", "")
|
119
|
PlantItems.Collect(mDataSource, Filter:=objFilter)
|
120
|
|
121
|
If PlantItems.Count = 0 Then
|
122
|
drawingInfo.mSpID = "PlantStockpile"
|
123
|
End If
|
124
|
|
125
|
For Each PlantItem In PlantItems
|
126
|
|
127
|
'If Not PlantItem.Representations.Nth(1).DrawingID.Value.ToString().Equals("0") Then
|
128
|
Try
|
129
|
drawingInfo.mDrawingName = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Name").Value
|
130
|
drawingInfo.mSpID = PlantItem.Representations.Nth(1).DrawingID
|
131
|
drawingInfo.mPath = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Path").Value
|
132
|
Debug.WriteLine("DrawingName : " & drawingInfo.mDrawingName & ", SPID : " & drawingInfo.mSpID & ", Path : " & drawingInfo.mPath)
|
133
|
Catch ex As Exception
|
134
|
|
135
|
End Try
|
136
|
|
137
|
'End If
|
138
|
|
139
|
Next
|
140
|
|
141
|
Return drawingInfo
|
142
|
|
143
|
End Function
|
144
|
|
145
|
Private Sub TestPID()
|
146
|
|
147
|
Try
|
148
|
|
149
|
Dim datasource As LMADataSource
|
150
|
Dim objPIDAutoApp As Object
|
151
|
Dim objPIDADrawing As Object
|
152
|
Dim objDrawing As LMDrawing
|
153
|
Dim objDrawings As LMDrawings
|
154
|
datasource = New LMADataSource
|
155
|
|
156
|
|
157
|
Dim oObj As Object = Nothing
|
158
|
objDrawing = datasource.GetDrawing(oObj)
|
159
|
objDrawings = New LMDrawings
|
160
|
objDrawings.Collect(datasource)
|
161
|
objPIDAutoApp = GetObject(, "SmartPlantPID.Application") '// CreateObject("PIDAutomation.Application")
|
162
|
For Each objDrawing In objDrawings
|
163
|
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active
|
164
|
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name"))
|
165
|
If Not objPIDADrawing Is Nothing Then
|
166
|
MessageBox.Show("Drawing " & objDrawing.Attributes("Name").Value & " is opened!")
|
167
|
objPIDADrawing.CloseDrawing
|
168
|
End If
|
169
|
End If
|
170
|
Next
|
171
|
objPIDAutoApp.Quit
|
172
|
objPIDAutoApp = Nothing
|
173
|
objPIDADrawing = Nothing
|
174
|
objDrawing = Nothing
|
175
|
objDrawings = Nothing
|
176
|
Catch ex As Exception
|
177
|
|
178
|
End Try
|
179
|
|
180
|
|
181
|
|
182
|
End Sub
|
183
|
Public Function SetActiveSiteFromConfigInfo(ByVal strActiveSite As String) As Boolean
|
184
|
|
185
|
On Error GoTo errHandler
|
186
|
Dim objConfigInfo As Object 'interopigrConfigInfo412.igrConfigInfo
|
187
|
objConfigInfo = CreateObject("interopigrConfigInfo412.igrConfigInfo", "")
|
188
|
If Not objConfigInfo Is Nothing Then
|
189
|
objConfigInfo.ApplicationName = "SmartPlantManager"
|
190
|
objConfigInfo.SetConfigString(3, "SmartPlant Manager", "SiteServer", strActiveSite)
|
191
|
SetActiveSiteFromConfigInfo = True
|
192
|
End If
|
193
|
objConfigInfo = Nothing
|
194
|
|
195
|
Exit Function
|
196
|
|
197
|
errHandler:
|
198
|
' LogAndRaiseError ModuleName & "::GetConfigInfo "
|
199
|
End Function
|
200
|
Private Sub LoadTree()
|
201
|
|
202
|
Dim i As Integer
|
203
|
Dim j() As String
|
204
|
j = Directory.GetLogicalDrives
|
205
|
For i = 0 To UBound(j)
|
206
|
|
207
|
Dim cdrive As System.IO.DriveInfo
|
208
|
cdrive = My.Computer.FileSystem.GetDriveInfo(j(i).ToString)
|
209
|
|
210
|
Select Case cdrive.DriveType
|
211
|
Case DriveType.Fixed
|
212
|
Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 3)
|
213
|
Case DriveType.CDRom
|
214
|
Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 11)
|
215
|
Case DriveType.Network
|
216
|
Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 5)
|
217
|
Case DriveType.Removable
|
218
|
Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 12)
|
219
|
End Select
|
220
|
|
221
|
Next
|
222
|
End Sub
|
223
|
|
224
|
Private Sub SetUpListViewColumns()
|
225
|
' TODO: Add code to set up listview columns
|
226
|
ListView_File.Columns.Add(" Name ")
|
227
|
' ListView_File.Columns.Add(" Size ")
|
228
|
' ListView_File.Columns.Add(" Extension ")
|
229
|
ListView_File.Columns.Add(" Date Modified ")
|
230
|
SetView(View.Details)
|
231
|
End Sub
|
232
|
|
233
|
|
234
|
Private Sub SetView(ByVal View As System.Windows.Forms.View)
|
235
|
ListView_File.View = View.Details
|
236
|
End Sub
|
237
|
|
238
|
|
239
|
|
240
|
Private Sub InitXMLTree(ByVal sFolderPath As String)
|
241
|
Tree_XMLFiles.Nodes.Clear()
|
242
|
Dim oRootNode As TreeNode = Tree_XMLFiles.Nodes.Add("XML")
|
243
|
'.XML 만 로드
|
244
|
Dim sfileEntries As String() = Directory.GetFiles(sFolderPath, "*.xml")
|
245
|
' Process the list of files found in the directory.
|
246
|
Dim sfileName As String
|
247
|
For Each sfileName In sfileEntries
|
248
|
oRootNode.Nodes.Add(sfileName)
|
249
|
Next sfileName
|
250
|
oRootNode.ExpandAll()
|
251
|
End Sub
|
252
|
|
253
|
|
254
|
|
255
|
|
256
|
Private Function CreateDwg(ByVal oDwgName As String) As Boolean
|
257
|
Dim objPIDADrawing As Object = Nothing
|
258
|
Dim objPIDAutoApp As Object = Nothing
|
259
|
Dim datasource As LMADataSource = Nothing
|
260
|
Try
|
261
|
Dim DrawingNumber As String
|
262
|
Dim DrawingName As String
|
263
|
Dim sPlantGroupName As String = "Test"
|
264
|
Dim sTemplateName As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\P&ID Reference Data\Template Files\Gazprom Project.pid"
|
265
|
Dim objDrawing As LMDrawing
|
266
|
Dim objDrawings As LMDrawings
|
267
|
objDrawings = New LMDrawings
|
268
|
datasource = New LMADataSource
|
269
|
Debug.Print(datasource.ProjectNumber)
|
270
|
Debug.Print(datasource.SiteNode)
|
271
|
Debug.Print(datasource.IsSatellite)
|
272
|
Debug.Print(datasource.GetSystemEditingToolbarSetting)
|
273
|
objDrawings.Collect(datasource)
|
274
|
Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid"
|
275
|
objPIDAutoApp = CreateObject("PIDAutomation.Application")
|
276
|
For Each objDrawing In objDrawings
|
277
|
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active
|
278
|
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(sPath)
|
279
|
If Not objPIDADrawing Is Nothing Then
|
280
|
|
281
|
objPIDADrawing.CloseDrawing
|
282
|
End If
|
283
|
End If
|
284
|
Next
|
285
|
|
286
|
Dim extension As String = Path.GetExtension(oDwgName)
|
287
|
oDwgName = oDwgName.Replace(extension, "")
|
288
|
|
289
|
objPIDAutoApp = CreateObject("PIDAutomation.Application")
|
290
|
|
291
|
'For Each objDrawing In objPIDAutoApp.Drawings
|
292
|
' objDrawing.CloseDrawing(True)
|
293
|
'Next
|
294
|
|
295
|
objPIDAutoApp.Drawings.OpenDrawing(oDwgName + ".pid")
|
296
|
|
297
|
objPIDAutoApp.ActiveWindow.Fit()
|
298
|
|
299
|
Return True
|
300
|
Catch ex As Exception
|
301
|
If objPIDADrawing IsNot Nothing Then
|
302
|
objPIDADrawing.CloseDrawing
|
303
|
End If
|
304
|
If objPIDAutoApp IsNot Nothing Then
|
305
|
objPIDAutoApp.Quit
|
306
|
End If
|
307
|
datasource = Nothing
|
308
|
objPIDAutoApp = Nothing
|
309
|
objPIDADrawing = Nothing
|
310
|
Return False
|
311
|
End Try
|
312
|
If objPIDADrawing IsNot Nothing Then
|
313
|
objPIDADrawing.CloseDrawing
|
314
|
End If
|
315
|
|
316
|
End Function
|
317
|
|
318
|
|
319
|
|
320
|
|
321
|
|
322
|
Private Function GetSymbolMapping(ByVal oSymbolName As String) As String
|
323
|
Dim oSystemPath As String = ""
|
324
|
If _DB.Rows.Count > 0 Then
|
325
|
Dim oSelectRow() As DataRow = _DB.Select("[pid_symbolname] = '" + oSymbolName + "'")
|
326
|
If oSelectRow.Length = 1 Then
|
327
|
oSystemPath = oSelectRow(0).Item("sppid_systempath").ToString()
|
328
|
End If
|
329
|
End If
|
330
|
Return oSystemPath
|
331
|
End Function
|
332
|
|
333
|
|
334
|
Private Function LoadSymbolInXml(ByVal sXmlPath As String) As DataTable
|
335
|
Dim oDt As DataTable = LoadSymbol_DT()
|
336
|
Dim oElement As XElement = XElement.Load(sXmlPath)
|
337
|
If oElement IsNot Nothing Then
|
338
|
For Each symbols As Object In oElement.Elements("SYMBOLS")
|
339
|
For Each page As Object In symbols.Elements("SYMBOL")
|
340
|
Dim oAddrow As DataRow = oDt.NewRow()
|
341
|
Dim oObj As XElement = page.Element("NAME")
|
342
|
Dim oName = oObj.Value
|
343
|
oObj = page.Element("TEXT")
|
344
|
Dim oText = oObj.Value
|
345
|
oObj = page.Element("CLASS")
|
346
|
Dim oClass = oObj.Value
|
347
|
oObj = page.Element("TYPE")
|
348
|
Dim oType = oObj.Value
|
349
|
oObj = page.Element("ITEM")
|
350
|
Dim oItem = oObj.Value
|
351
|
' Dim oSymbolPath As String = "\" + oSymbol + "\" + oClass + "\" + oType + "\" + oItem + ".sym"
|
352
|
Dim oSymbolPath As String = GetSymbolMapping(oItem)
|
353
|
oObj = page.Element("ORIGINALPOINT")
|
354
|
Dim sOriginPoint = oObj.Value
|
355
|
oObj = page.Element("ANGLE")
|
356
|
Dim oAngle = oObj.Value
|
357
|
Dim oSplitPos As String() = sOriginPoint.Split(",")
|
358
|
Dim oX As Double = 0.0
|
359
|
Dim oY As Double = 0.0
|
360
|
If IsNumeric(oSplitPos(0)) Then
|
361
|
oX = Double.Parse(oSplitPos(0))
|
362
|
End If
|
363
|
If IsNumeric(oSplitPos(1)) Then
|
364
|
oY = Double.Parse(oSplitPos(1))
|
365
|
End If
|
366
|
ConvertPoint(oX, oY, _IMG_X, _IMG_Y)
|
367
|
oAddrow(_X) = oX '+ 0.05
|
368
|
oAddrow(_Y) = oY
|
369
|
oAddrow(_Class) = oClass
|
370
|
oAddrow(_Angle) = oAngle
|
371
|
oAddrow(_SystemPath) = oSymbolPath
|
372
|
oAddrow(_Text) = oText
|
373
|
oAddrow(_Name) = oName
|
374
|
oAddrow(_Item) = oItem
|
375
|
oAddrow(_Type) = oType
|
376
|
oDt.Rows.Add(oAddrow)
|
377
|
Next
|
378
|
Next
|
379
|
End If
|
380
|
Return oDt
|
381
|
End Function
|
382
|
|
383
|
|
384
|
|
385
|
Private Function LoadPipeInXml(ByVal sXmlPath As String) As DataTable
|
386
|
Try
|
387
|
Dim oDt As DataTable = LoadPipe_DT()
|
388
|
Dim oElement As XElement = XElement.Load(sXmlPath)
|
389
|
If oElement IsNot Nothing Then
|
390
|
Dim DWGElement As XElement = oElement.Element("DWGNAME")
|
391
|
Dim DWGNAME = DWGElement.Value
|
392
|
Dim sXY As XElement = oElement.Element("SIZE")
|
393
|
Dim sSize = sXY.Value
|
394
|
Dim oSplitDWGPos As String() = sSize.Split(",")
|
395
|
|
396
|
If IsNumeric(oSplitDWGPos(0)) Then
|
397
|
_IMG_X = Double.Parse(oSplitDWGPos(0))
|
398
|
End If
|
399
|
If IsNumeric(oSplitDWGPos(1)) Then
|
400
|
_IMG_Y = Double.Parse(oSplitDWGPos(1))
|
401
|
End If
|
402
|
|
403
|
For Each pipes As Object In oElement.Elements("IMGLINES")
|
404
|
For Each pipe As Object In pipes.Elements("IMGLINE")
|
405
|
Dim oAddrow As DataRow = oDt.NewRow()
|
406
|
Dim oObj As XElement = pipe.Element("ITEM")
|
407
|
Dim oItem = oObj.Value
|
408
|
' Dim oSymbolPath As String = "\" + oSymbol + "\" + oClass + "\" + oType + "\" + oItem + ".sym"
|
409
|
Dim oSymbolPath As String = GetSymbolMapping(oItem)
|
410
|
oObj = pipe.Element("START")
|
411
|
Dim oStartPoint = oObj.Value
|
412
|
Dim oSplitPos As String() = oStartPoint.Split(",")
|
413
|
Dim oStartpos_X As Double = 0.0
|
414
|
Dim oStartpos_Y As Double = 0.0
|
415
|
If IsNumeric(oSplitPos(0)) Then
|
416
|
oStartpos_X = Double.Parse(oSplitPos(0))
|
417
|
End If
|
418
|
If IsNumeric(oSplitPos(1)) Then
|
419
|
oStartpos_Y = Double.Parse(oSplitPos(1))
|
420
|
End If
|
421
|
|
422
|
ConvertPoint(oStartpos_X, oStartpos_Y, _DWG_X, _DWG_Y)
|
423
|
oObj = pipe.Element("END")
|
424
|
Dim oEndPoint = oObj.Value
|
425
|
oSplitPos = oEndPoint.Split(",")
|
426
|
Dim oEndpos_X As Double = 0.0
|
427
|
Dim oEndpos_Y As Double = 0.0
|
428
|
If IsNumeric(oSplitPos(0)) Then
|
429
|
oEndpos_X = Double.Parse(oSplitPos(0))
|
430
|
End If
|
431
|
If IsNumeric(oSplitPos(1)) Then
|
432
|
oEndpos_Y = Double.Parse(oSplitPos(1))
|
433
|
End If
|
434
|
ConvertPoint(oEndpos_X, oEndpos_Y, _DWG_X, _DWG_Y)
|
435
|
|
436
|
oAddrow("start_x") = oStartpos_X '+ 0.05
|
437
|
oAddrow("start_y") = oStartpos_Y
|
438
|
oAddrow("end_x") = oEndpos_X
|
439
|
oAddrow("end_y") = oEndpos_Y
|
440
|
oAddrow("SystemPath") = oSymbolPath
|
441
|
oDt.Rows.Add(oAddrow)
|
442
|
Next
|
443
|
Next
|
444
|
|
445
|
End If
|
446
|
|
447
|
|
448
|
Return oDt
|
449
|
Catch ex As Exception
|
450
|
Return Nothing
|
451
|
End Try
|
452
|
End Function
|
453
|
|
454
|
|
455
|
Private Sub ConvertPoint(ByRef dX As Double, ByRef dY As Double, ByVal dDwgX As Double, ByVal dDwgY As Double)
|
456
|
|
457
|
Dim calcx As Double = 0
|
458
|
Dim calcy As Double = 0
|
459
|
calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2)
|
460
|
calcy = _DWG_Y - (dY * _DWG_Y) / dDwgY '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2)
|
461
|
dX = calcx
|
462
|
dY = calcy
|
463
|
End Sub
|
464
|
|
465
|
|
466
|
'@brief Convert To SPPID
|
467
|
'@author : Gyusu Park
|
468
|
'@date : 2018-04-10
|
469
|
'@history:
|
470
|
|
471
|
Private Function AutoConverting(ByVal oPipe_Dt As DataTable, ByVal oSymbol_Dt As DataTable, ByVal oTreeNode As TreeNode) As Boolean
|
472
|
Dim iTotalCount As Double = oPipe_Dt.Rows.Count + oSymbol_Dt.Rows.Count
|
473
|
Dim iSymbolcount As Double = 0
|
474
|
|
475
|
Dim lobjDatasource As Object = _Placement.PIDDataSource
|
476
|
|
477
|
' lobjDatasource.BeginTransaction()
|
478
|
' datasource = objPlacement.PIDDataSource
|
479
|
'Dim iPipecnt As Integer = 0
|
480
|
SetListBoxItems(ListBox_Result, " Auto converting 시작....")
|
481
|
|
482
|
Dim iPipeCnt As Integer = 0
|
483
|
If oPipe_Dt IsNot Nothing Then
|
484
|
For Each oRow As DataRow In oPipe_Dt.Rows
|
485
|
Dim oposition As String = oRow("position").ToString()
|
486
|
Dim oSymbol As String = oRow(_SystemPath).ToString()
|
487
|
Dim oSplitStr As String() = Split(oposition, " ")
|
488
|
Dim objConnector As LMConnector
|
489
|
Dim objInputs As PlaceRunInputs
|
490
|
objInputs = New PlaceRunInputs
|
491
|
|
492
|
For Each sposition As String In oSplitStr
|
493
|
Dim opointstr As String() = Split(sposition, ",")
|
494
|
|
495
|
If (opointstr.Length > 1) Then
|
496
|
If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then
|
497
|
Dim ox As Double = opointstr(0)
|
498
|
Dim oy As Double = opointstr(1)
|
499
|
ConvertPoint(ox, oy, _IMG_X, _IMG_Y)
|
500
|
objInputs.AddPoint(ox, oy)
|
501
|
End If
|
502
|
End If
|
503
|
Next
|
504
|
Dim objItem As LMAItem
|
505
|
objItem = _Placement.PIDCreateItem(oSymbol)
|
506
|
objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
|
507
|
SetListBoxItems(ListBox_Result, " Place PipeLine...." & "(" & (iPipeCnt + 1) & "/" & oPipe_Dt.Rows.Count)
|
508
|
'Dim objPipeRun As LMPipeRun = datasource.GetPipeRun(objConnector.ModelItemID)
|
509
|
'objPipeRun.Attributes("OperFluidCode").Value = "AFS"
|
510
|
'objPipeRun.Commit()
|
511
|
iSymbolcount = iSymbolcount + 1
|
512
|
iPipeCnt = iPipeCnt + 1
|
513
|
Next
|
514
|
End If
|
515
|
|
516
|
SetListBoxItems(ListBox_Result, " Place PipeLine....완료")
|
517
|
|
518
|
|
519
|
|
520
|
Dim iAllInstrumentCnt As Integer = oSymbol_Dt.Select("Name = 'INSTRUMENTATION'").Length
|
521
|
Dim iValveCnt As Integer = oSymbol_Dt.Select("Class = 'VALVES'").Length
|
522
|
Dim iInstrumentCnt As Integer = 1
|
523
|
Dim iFittingsCnt As Integer = 1
|
524
|
|
525
|
Dim oInsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Instruments", True)(0)
|
526
|
Dim oValveNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Valves", True)(0)
|
527
|
Dim oFittingsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Fittings", True)(0)
|
528
|
For Each oRow As DataRow In oSymbol_Dt.Rows
|
529
|
|
530
|
Try
|
531
|
|
532
|
Dim sSystemPath As String = oRow(_SystemPath).ToString()
|
533
|
Dim sName As String = oRow(_Name).ToString()
|
534
|
Dim sType As String = oRow(_Type).ToString()
|
535
|
Dim sText As String = oRow(_Text).ToString()
|
536
|
Dim sClass As String = oRow(_Class).ToString()
|
537
|
Dim sItem As String = oRow(_Item).ToString()
|
538
|
|
539
|
Dim oX As Double = 0.0
|
540
|
Dim oY As Double = 0.0
|
541
|
If IsNumeric(oRow(_X).ToString()) Then
|
542
|
oX = Double.Parse(oRow(_X).ToString())
|
543
|
End If
|
544
|
If IsNumeric(oRow(_Y).ToString()) Then
|
545
|
oY = Double.Parse(oRow(_Y).ToString())
|
546
|
End If
|
547
|
Dim oAngle As Double = 0.0
|
548
|
If IsNumeric(oRow(_Angle).ToString()) Then
|
549
|
oAngle = Double.Parse(oRow(_Angle).ToString())
|
550
|
End If
|
551
|
' oSymbol = "\INSTRUMENTation\SYSTEM FUNCTIONS\D C S\DCS FUNC ACCESS IN PRIME LOC.sym"
|
552
|
If sSystemPath <> "" Then
|
553
|
If sName = _TYPE_Instumentation Then
|
554
|
|
555
|
Dim sTagsuffix As String = ""
|
556
|
Dim sTagSequenceNo As String = ""
|
557
|
Dim sMeasuredVariableCode As String = ""
|
558
|
Dim sInstrumentTypeModifier As String = ""
|
559
|
|
560
|
If sText <> "" Then
|
561
|
If sText.Contains(",") Then
|
562
|
Dim splitstr() As String = sText.Split(",")
|
563
|
For i = 0 To splitstr.Count - 1
|
564
|
If i = 0 Then
|
565
|
sMeasuredVariableCode = Mid(splitstr(i), 1, 1)
|
566
|
sTagSequenceNo = Mid(splitstr(i), 2, Len(splitstr(i)))
|
567
|
Else
|
568
|
If Len(splitstr(i)) = 1 Then
|
569
|
sInstrumentTypeModifier = splitstr(i)
|
570
|
ElseIf Len(splitstr(i)) = 0 Then
|
571
|
|
572
|
ElseIf Len(splitstr(i)) > 1 Then
|
573
|
sInstrumentTypeModifier = Mid(splitstr(i), 1, 1)
|
574
|
sTagsuffix = Mid(splitstr(i), 2, Len(splitstr(i)))
|
575
|
End If
|
576
|
End If
|
577
|
Next
|
578
|
Else
|
579
|
sMeasuredVariableCode = Mid(sText, 1, 1)
|
580
|
sTagSequenceNo = Mid(sText, 2, Len(sText))
|
581
|
End If
|
582
|
|
583
|
End If
|
584
|
|
585
|
Dim objInstrSym As LMSymbol
|
586
|
objInstrSym = _Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle)
|
587
|
SetListBoxItems(ListBox_Result, " Place Instrument...." & "(" & (iInstrumentCnt + 1) & "/" & iAllInstrumentCnt & ")")
|
588
|
|
589
|
' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sTagSequenceNo)
|
590
|
Dim action As Action = Sub()
|
591
|
oInsNode.Nodes.Add(sClass & "-" & iInstrumentCnt)
|
592
|
oInsNode.ExpandAll()
|
593
|
End Sub
|
594
|
oInsNode.TreeView.Invoke(action)
|
595
|
|
596
|
|
597
|
Dim objInstr As LMInstrument
|
598
|
objInstr = lobjDatasource.GetInstrument(objInstrSym.ModelItemID)
|
599
|
|
600
|
Dim objItem As LMAItem
|
601
|
objItem = _Placement.PIDCreateItem(sSystemPath)
|
602
|
|
603
|
|
604
|
objInstr.Attributes("MeasuredVariableCode").Value = sMeasuredVariableCode
|
605
|
objInstr.Attributes("InstrumentTypeModifier").Value = sInstrumentTypeModifier
|
606
|
objInstr.Attributes("TagSuffix").Value = sTagsuffix
|
607
|
objInstr.Attributes("TagSequenceNo").Value = sTagSequenceNo
|
608
|
objInstr.Commit()
|
609
|
iInstrumentCnt = iInstrumentCnt + 1
|
610
|
ElseIf sName = "GATE VALVE WITH PLUG" Then
|
611
|
|
612
|
ElseIf sName = "MEDIUM 1D 1TO1" Then
|
613
|
|
614
|
ElseIf sClass = "VALVES" Then
|
615
|
Dim action As Action = Sub()
|
616
|
oValveNode.ExpandAll()
|
617
|
oValveNode.Nodes.Add(sClass & "-" & iValveCnt)
|
618
|
End Sub
|
619
|
oValveNode.TreeView.Invoke(action)
|
620
|
|
621
|
_Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle)
|
622
|
|
623
|
iValveCnt = iValveCnt + 1
|
624
|
Else
|
625
|
Dim action As Action = Sub()
|
626
|
oFittingsNode.ExpandAll()
|
627
|
oFittingsNode.Nodes.Add(sClass & "-" & iFittingsCnt)
|
628
|
End Sub
|
629
|
oFittingsNode.TreeView.Invoke(action)
|
630
|
_Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle)
|
631
|
|
632
|
iFittingsCnt = iFittingsCnt + 1
|
633
|
|
634
|
End If
|
635
|
iSymbolcount = iSymbolcount + 1
|
636
|
Else
|
637
|
End If
|
638
|
Catch ex As Exception
|
639
|
|
640
|
End Try
|
641
|
Dim dCalcProgressValue As Double = (iSymbolcount / iTotalCount) * 100
|
642
|
SetProgressbar(ProgressBar_Status, dCalcProgressValue)
|
643
|
' ProgressBar_Status.Value = (iSymbolcount / iTotalCount) * 100
|
644
|
|
645
|
Next
|
646
|
|
647
|
MsgBox("Complete AutoConverting")
|
648
|
SetListBoxItems(ListBox_Result, "Place Instrument....변환완료")
|
649
|
SetListBoxItems(ListBox_Result, "총 symbol: " & iSymbolcount & "개 변환완료")
|
650
|
SetProgressbar(ProgressBar_Status, 100)
|
651
|
' MsgBox("symbol: " & iSymbolcount & "개, pipe : " & iPipecnt & "개 변환완료")
|
652
|
End Function
|
653
|
|
654
|
|
655
|
Private Sub Tree_XMLFiles_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterCheck
|
656
|
If e.Node.Checked = True Then
|
657
|
For Each oNode As TreeNode In e.Node.Nodes
|
658
|
oNode.Checked = True
|
659
|
Next
|
660
|
Else
|
661
|
For Each oNode As TreeNode In e.Node.Nodes
|
662
|
oNode.Checked = False
|
663
|
Next
|
664
|
End If
|
665
|
End Sub
|
666
|
|
667
|
Private Sub LoadDB(ByVal sDBPath As String)
|
668
|
|
669
|
Try
|
670
|
Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;"
|
671
|
Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring)
|
672
|
conn.Open()
|
673
|
Dim sQuery As String = "Select * from Mapping"
|
674
|
Dim cmd As SQLiteCommand = conn.CreateCommand()
|
675
|
Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn)
|
676
|
Dim oDataSet As DataSet = New DataSet()
|
677
|
adapter.Fill(oDataSet)
|
678
|
_DB = oDataSet.Tables(0)
|
679
|
Catch ex As Exception
|
680
|
|
681
|
End Try
|
682
|
|
683
|
|
684
|
End Sub
|
685
|
|
686
|
Dim first_start As Boolean = False
|
687
|
Dim folders_path As String
|
688
|
|
689
|
Private Sub Tree_XMLFiles_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterSelect
|
690
|
If first_start = False Then Exit Sub
|
691
|
Dim pa = e.Node.FullPath.ToString
|
692
|
|
693
|
printfilesfolders_here(pa, e.Node)
|
694
|
|
695
|
displayfiles(pa)
|
696
|
|
697
|
''be careful ! displayfils comes BEFORE you change // to / in pa !!!
|
698
|
Dim coco As String = ""
|
699
|
coco = pa.ToString
|
700
|
coco = coco.Replace("\\", "\")
|
701
|
Me.Text = coco
|
702
|
folders_path = coco
|
703
|
End Sub
|
704
|
|
705
|
Sub printfilesfolders_here(ByVal path As String, ByRef itree As TreeNode)
|
706
|
|
707
|
Dim foldername As String
|
708
|
Dim filename As String
|
709
|
itree.Nodes.Clear()
|
710
|
On Error GoTo eee
|
711
|
For Each foldername In Directory.GetDirectories(path)
|
712
|
On Error GoTo eee
|
713
|
Dim jj = foldername.LastIndexOf("\")
|
714
|
Dim jj1 = foldername.Length - jj
|
715
|
Dim foldr = foldername.Substring((jj + 1), (jj1 - 1))
|
716
|
itree.Nodes.Add(foldr, foldr)
|
717
|
Next ' if you put this next at the end of procedure recursive will be done on first folder only
|
718
|
Exit Sub
|
719
|
eee:
|
720
|
End Sub
|
721
|
|
722
|
Sub displayfiles(ByVal path As String)
|
723
|
|
724
|
Dim lvItem As ListViewItem
|
725
|
ListView_File.Items.Clear()
|
726
|
|
727
|
' lvItem = ListView.Items.Add("ListViewItem1")
|
728
|
' lvItem.SubItems.AddRange(New String() {"Size", "extention", "date modified"})
|
729
|
|
730
|
Dim filename As String
|
731
|
On Error GoTo wwq
|
732
|
' Directory.GetFiles(path).Length.
|
733
|
'Me.ProgressBar_Status.Maximum = Directory.GetFiles(path).Length + 1
|
734
|
'Me.ProgressBar_Status.Value = 0
|
735
|
For Each filename In Directory.GetFiles(path)
|
736
|
On Error GoTo wwq
|
737
|
Dim jj_ = filename.LastIndexOf("\")
|
738
|
Dim jj1_ = filename.Length - jj_
|
739
|
Dim fil = filename.Substring((jj_ + 1), (jj1_ - 1))
|
740
|
If fil.Contains(".xml") Then
|
741
|
' Me.ProgressBar_Status.Value = Me.ProgressBar_Status.Value + 1
|
742
|
' ListView.Items.Add(fil, 13) ''old 13 28
|
743
|
lvItem = ListView_File.Items.Add(fil, 13) '2 5 7 work, 0 alos
|
744
|
Dim infoReader As System.IO.FileInfo
|
745
|
infoReader = My.Computer.FileSystem.GetFileInfo(filename)
|
746
|
' lvItem.SubItems.AddRange(New String() {infoReader.Length.ToString + " Byte", infoReader.Extension.ToString, infoReader.LastWriteTime})
|
747
|
lvItem.SubItems.AddRange(New String() {infoReader.LastWriteTime})
|
748
|
ListView_File.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
|
749
|
End If
|
750
|
|
751
|
|
752
|
Next
|
753
|
Exit Sub
|
754
|
wwq:
|
755
|
MsgBox(Err.Description)
|
756
|
End Sub
|
757
|
|
758
|
Private Sub Tree_XMLFiles_MouseMove(sender As Object, e As MouseEventArgs) Handles Tree_XMLFiles.MouseMove
|
759
|
first_start = True
|
760
|
End Sub
|
761
|
|
762
|
Private Sub ListView_File_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView_File.SelectedIndexChanged
|
763
|
Dim indexes As ListView.SelectedIndexCollection =
|
764
|
Me.ListView_File.SelectedIndices
|
765
|
Dim index As Integer
|
766
|
|
767
|
For Each index In indexes
|
768
|
'On Error Resume Next
|
769
|
If folders_path.EndsWith("\") = True Then
|
770
|
Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text)
|
771
|
'On Error Resume Next
|
772
|
Else
|
773
|
Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text)
|
774
|
End If
|
775
|
|
776
|
Dim infoReader As System.IO.FileInfo
|
777
|
infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text)
|
778
|
Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString
|
779
|
Next
|
780
|
End Sub
|
781
|
|
782
|
Private Sub Procees()
|
783
|
Dim indexes As ListView.SelectedIndexCollection =
|
784
|
Me.ListView_File.SelectedIndices
|
785
|
Dim index As Integer
|
786
|
|
787
|
For Each index In indexes
|
788
|
'On Error Resume Next
|
789
|
If folders_path.EndsWith("\") = True Then
|
790
|
On Error GoTo out
|
791
|
Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text)
|
792
|
On Error GoTo out
|
793
|
'On Error Resume Next
|
794
|
Else
|
795
|
Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text)
|
796
|
On Error GoTo out
|
797
|
End If
|
798
|
|
799
|
Dim infoReader As System.IO.FileInfo
|
800
|
infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text)
|
801
|
Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString
|
802
|
On Error GoTo out
|
803
|
MsgBox(Me.Status_Main.Items(0).Text + " is processed")
|
804
|
On Error GoTo out
|
805
|
Next
|
806
|
Exit Sub
|
807
|
out:
|
808
|
MsgBox(Err.Description)
|
809
|
End Sub
|
810
|
|
811
|
Private Function LoadAllDrawing() As DataTable
|
812
|
|
813
|
|
814
|
SetListBoxItems(ListBox_Result, "도면정보 로드중....")
|
815
|
|
816
|
Dim oDt As DataTable = Drawing_Dt()
|
817
|
'Dim oDt As DataTable = Drawing_Dt()
|
818
|
'_objPIDADrawing = CreateObject("PIDAutomation.Application")
|
819
|
'For Each objDrawing In _objPIDADrawing.Drawings
|
820
|
' Dim sName As String = objDrawing.Attributes("Name").Value
|
821
|
' Dim sPath As String = objDrawing.Attributes("Path").Value
|
822
|
' Dim oAddRow As DataRow = oDt.NewRow()
|
823
|
' oAddRow("Name") = sName
|
824
|
' oAddRow("Path") = sPath
|
825
|
' oDt.Rows.Add(oAddRow)
|
826
|
'Next
|
827
|
Dim sHierarchy As String = My.Settings.Plant_Hierarchy
|
828
|
|
829
|
|
830
|
Dim files() As String
|
831
|
files = Directory.GetFiles(sHierarchy, "*.pid", SearchOption.AllDirectories)
|
832
|
For Each FileName As String In files
|
833
|
Dim sName As String = FileName
|
834
|
Dim oAddRow As DataRow = oDt.NewRow()
|
835
|
oAddRow("Name") = Path.GetFileNameWithoutExtension(sName)
|
836
|
oAddRow("Path") = FileName
|
837
|
oDt.Rows.Add(oAddRow)
|
838
|
' Console.WriteLine(FileName)
|
839
|
Next
|
840
|
|
841
|
|
842
|
|
843
|
'Dim datasource As LMADataSource
|
844
|
'Dim objPIDAutoApp As Object
|
845
|
'Dim objPIDADrawing As Object
|
846
|
'Dim objDrawing As LMDrawing
|
847
|
'Dim objDrawings As LMDrawings
|
848
|
'objPIDAutoApp = CreateObject("PIDAutomation.Application")
|
849
|
'objPIDAutoApp = GetObject(, "SmartPlantPID.Application")
|
850
|
|
851
|
'datasource = CreateObject("Llama.LMADataSource", "")
|
852
|
'Dim oObj As Object = Nothing
|
853
|
'objDrawings = New LMDrawings
|
854
|
'objDrawing = datasource.GetDrawing(oObj)
|
855
|
|
856
|
'objDrawings.Collect(datasource)
|
857
|
'' objPIDAutoApp = GetObject(, "SmartPlantPID.Application") '// CreateObject("PIDAutomation.Application")
|
858
|
'For Each objDrawing In objDrawings
|
859
|
' Dim sName As String = objDrawing.Attributes("Name").Value
|
860
|
' Dim sPath As String = objDrawing.Attributes("Path").Value
|
861
|
' Dim oAddRow As DataRow = oDt.NewRow()
|
862
|
' oAddRow("Name") = sName
|
863
|
' oAddRow("Path") = sHierarchy & "\" & sPath
|
864
|
' oDt.Rows.Add(oAddRow)
|
865
|
'Next
|
866
|
|
867
|
Return oDt
|
868
|
End Function
|
869
|
|
870
|
Private Function LoadAllDrawing2() As DataTable
|
871
|
Dim datasource As LMADataSource
|
872
|
Dim objPIDAutoApp As Object
|
873
|
Dim objPIDADrawing As Object
|
874
|
Dim objDrawing As Object 'Drawing
|
875
|
'Dim objDrawing As LMDrawing
|
876
|
'Dim objDrawings As LMDrawings
|
877
|
|
878
|
datasource = New LMADataSource
|
879
|
|
880
|
' objDrawings = New LMDrawings
|
881
|
'objDrawings.Collect(datasource)
|
882
|
objPIDAutoApp = CreateObject("PIDAutomation.Application")
|
883
|
|
884
|
For Each objDrawing In objPIDAutoApp.Drawings
|
885
|
objDrawing.CloseDrawing(True)
|
886
|
Next
|
887
|
Try
|
888
|
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("UY1-K-2000_P1_300dpi_0321_TEST_1")
|
889
|
Catch ex As Exception
|
890
|
Process.Start("\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid")
|
891
|
End Try
|
892
|
|
893
|
|
894
|
|
895
|
Dim sType As Type = objPIDAutoApp.GetType()
|
896
|
Dim iCount As Integer = 0
|
897
|
' Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid"
|
898
|
|
899
|
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("1")
|
900
|
|
901
|
For Each objDrawing In objPIDAutoApp.Drawings
|
902
|
If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active
|
903
|
Try
|
904
|
|
905
|
Dim sName As String = objDrawing.Attributes("Name").Value
|
906
|
|
907
|
iCount = iCount + 1
|
908
|
If sName = "UY1-K-2000_P1_300dpi_0321_TEST_1" Then
|
909
|
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name"))
|
910
|
objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid")
|
911
|
If Not objPIDADrawing Is Nothing Then
|
912
|
objPIDADrawing.CloseDrawing()
|
913
|
End If
|
914
|
End If
|
915
|
|
916
|
|
917
|
Catch ex As Exception
|
918
|
|
919
|
End Try
|
920
|
|
921
|
End If
|
922
|
Next
|
923
|
objPIDAutoApp.Quit
|
924
|
objPIDAutoApp = Nothing
|
925
|
objPIDADrawing = Nothing
|
926
|
objDrawing = Nothing
|
927
|
' objDrawings = Nothing
|
928
|
End Function
|
929
|
|
930
|
|
931
|
|
932
|
|
933
|
Private Sub ThreadTask()
|
934
|
If ListView_File.Items.Count > 0 Then
|
935
|
|
936
|
Dim oDwg_Dt As DataTable = LoadAllDrawing()
|
937
|
Dim iDwgCnt As Integer = 0
|
938
|
Dim objPIDAutoApp As Object
|
939
|
objPIDAutoApp = CreateObject("PIDAutomation.Application")
|
940
|
|
941
|
|
942
|
Dim myList = DirectCast(Invoke(New GetListViewDelegate(AddressOf GetListViewItems), ListView_File), List(Of String))
|
943
|
For i = 0 To myList.Count - 1
|
944
|
|
945
|
Dim sDwgName As String = Path.GetFileNameWithoutExtension(myList(i))
|
946
|
Txt_Status.Text = sDwgName & "..(" & i + 1 & "/" & myList.Count & ")"
|
947
|
SetListBoxItems(ListBox_Result, Txt_Status.Text & " 처리중....")
|
948
|
Dim sDwgNo As String = myList(i)
|
949
|
Dim oDwgPath As String = ""
|
950
|
oDwgPath = _selectFolderPath + "\" + sDwgNo
|
951
|
|
952
|
Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName)
|
953
|
If sPath <> "" Then
|
954
|
|
955
|
Process.Start(sPath)
|
956
|
|
957
|
Dim bCheckOpenDrawing As Boolean = False
|
958
|
While (True)
|
959
|
bCheckOpenDrawing = CheckOpenDrawing()
|
960
|
If bCheckOpenDrawing = True Then
|
961
|
Exit While
|
962
|
Else
|
963
|
Thread.Sleep(2000)
|
964
|
End If
|
965
|
End While
|
966
|
|
967
|
If bCheckOpenDrawing Then
|
968
|
SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....")
|
969
|
Dim oPipe_Dt As DataTable = New DataTable() 'LoadPipeInXml(oDwgPath)
|
970
|
|
971
|
Dim oSymbol_Dt As DataTable = LoadSymbolInXml(oDwgPath)
|
972
|
Dim oTreeNode As New TreeNode 'SetTreeViewItems(Tree_Result, Tree_Result.Nodes, sDwgName, sDwgName)
|
973
|
'oTreeNode = Tree_Result.Nodes.Find(sDwgName, True)(0)
|
974
|
Dim action As Action = Sub()
|
975
|
oTreeNode = Tree_Result.Nodes.Add(sDwgName, sDwgName)
|
976
|
SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Instruments", "Instuments")
|
977
|
SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Pipes", "Pipes")
|
978
|
SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Valves", "Valves")
|
979
|
SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Fittings", "Fittings")
|
980
|
oTreeNode.ExpandAll()
|
981
|
End Sub
|
982
|
Tree_Result.Invoke(action)
|
983
|
|
984
|
|
985
|
' oTreeNode.Expand()
|
986
|
SetListBoxItems(ListBox_Result, sDwgName & " Auto converting 대기....")
|
987
|
AutoConverting(oPipe_Dt, oSymbol_Dt, oTreeNode)
|
988
|
|
989
|
End If
|
990
|
|
991
|
End If
|
992
|
''도면 생성
|
993
|
'If CreateDwg(sDwgName) Then
|
994
|
' 'AutoConverting
|
995
|
|
996
|
'End If
|
997
|
|
998
|
Next
|
999
|
End If
|
1000
|
End Sub
|
1001
|
|
1002
|
|
1003
|
Private Function CheckOpenDrawing() As Boolean
|
1004
|
Try
|
1005
|
|
1006
|
Dim lobjDatasource As Object
|
1007
|
_Placement = CreateObject("Plaice.Placement", "")
|
1008
|
lobjDatasource = _Placement.PIDDataSource
|
1009
|
Return True
|
1010
|
Catch ex As Exception
|
1011
|
Return False
|
1012
|
End Try
|
1013
|
|
1014
|
End Function
|
1015
|
|
1016
|
|
1017
|
Private Sub Btn_Convert_Click(sender As Object, e As EventArgs) Handles Btn_Convert.Click
|
1018
|
|
1019
|
|
1020
|
Main_Tab.SelectedIndex = 1
|
1021
|
ListBox_Result.Items.Clear()
|
1022
|
DataGrid_Result.DataSource = New DataTable()
|
1023
|
Tree_Result.Nodes.Clear()
|
1024
|
Me.ProgressBar_Status.Visible = True
|
1025
|
ProgressBar_Status.Maximum = 100
|
1026
|
ProgressBar_Status.Value = 0
|
1027
|
_selectFolderPath = Tree_XMLFiles.SelectedNode.FullPath.Replace("\\", "\")
|
1028
|
_Main_trd = New Thread(AddressOf ThreadTask)
|
1029
|
_Main_trd.IsBackground = True
|
1030
|
_Main_trd.Start()
|
1031
|
|
1032
|
End Sub
|
1033
|
|
1034
|
|
1035
|
Private Function GetCheckList(ByVal listviewItem As ListViewItem)
|
1036
|
|
1037
|
End Function
|
1038
|
|
1039
|
Private Sub newThreadFunc(ByVal state As Object)
|
1040
|
|
1041
|
End Sub
|
1042
|
|
1043
|
Private Function OpenDrawing(ByVal oDt As DataTable, ByVal sDwgName As String) As String
|
1044
|
Dim oRows As DataRow() = oDt.Select("[Name] = '" & sDwgName & "'")
|
1045
|
Dim oPath As String = ""
|
1046
|
If oRows.Length > 0 Then
|
1047
|
oPath = oRows(0).Item("Path").ToString()
|
1048
|
End If
|
1049
|
Return oPath
|
1050
|
End Function
|
1051
|
|
1052
|
|
1053
|
Private Sub Btn_Setting_Click(sender As Object, e As EventArgs) Handles Btn_Setting.Click
|
1054
|
Dim oSettings As Settings = New Settings()
|
1055
|
oSettings.ShowDialog()
|
1056
|
End Sub
|
1057
|
|
1058
|
Private Sub Btn_Stop_Click(sender As Object, e As EventArgs) Handles Btn_Stop.Click
|
1059
|
Try
|
1060
|
_Main_trd.Abort()
|
1061
|
Catch ex As Exception
|
1062
|
|
1063
|
End Try
|
1064
|
End Sub
|
1065
|
|
1066
|
Private Sub DropDown_File_Click(sender As Object, e As EventArgs) Handles DropDown_File.Click
|
1067
|
|
1068
|
End Sub
|
1069
|
|
1070
|
Private Sub TestLineToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TestLineToolStripMenuItem.Click
|
1071
|
|
1072
|
Dim objPlacement As New Placement
|
1073
|
'PipeLine
|
1074
|
'Nominal diameter -fluidcode- tagseqno-piping material spec - insulation purpose
|
1075
|
Dim datasource As LMADataSource
|
1076
|
datasource = objPlacement.PIDDataSource
|
1077
|
Dim PipeRunLoc As String
|
1078
|
Dim objItem As LMAItem
|
1079
|
|
1080
|
Dim objConnector As LMConnector
|
1081
|
Dim objInputs As PlaceRunInputs
|
1082
|
Dim objSymbol As LMSymbol
|
1083
|
Dim InstrumentLoc As String
|
1084
|
PipeRunLoc = "\Piping\Routing\Process Lines\Primary Piping.sym"
|
1085
|
objInputs = New PlaceRunInputs
|
1086
|
objInputs.AddPoint(0.1, 0.1)
|
1087
|
objInputs.AddPoint(0.2, 0.1)
|
1088
|
objItem = objPlacement.PIDCreateItem(PipeRunLoc)
|
1089
|
objConnector = objPlacement.PIDPlaceRun(objItem, objInputs)
|
1090
|
Dim objPipeRun As LMPipeRun = datasource.GetPipeRun(objConnector.ModelItemID)
|
1091
|
objPipeRun.Attributes("NominalDiameter").Value = "250 mm"
|
1092
|
objPipeRun.Attributes("OperFluidCode").Value = "ADH"
|
1093
|
objPipeRun.Attributes("TagSequenceNo").Value = "0026"
|
1094
|
objPipeRun.Attributes("pipingmaterialsclass").Value = "NA1S"
|
1095
|
objPipeRun.Attributes("InsulPurpose").Value = "H"
|
1096
|
objPipeRun.Commit()
|
1097
|
Dim twopoints(2) As Double
|
1098
|
twopoints(1) = 0.12
|
1099
|
twopoints(2) = 0.11
|
1100
|
'Label
|
1101
|
Dim labelName1 As String = "\Piping\Labels - Piping Segments\Line Number.sym"
|
1102
|
Dim labelpersist As LMLabelPersist
|
1103
|
|
1104
|
For Each representation In objPipeRun.Representations
|
1105
|
If representation.RepresentationType = "Connector" Then
|
1106
|
labelpersist = objPlacement.PIDPlaceLabel(labelName1,
|
1107
|
twopoints,, 0, LabeledItem:=representation)
|
1108
|
End If
|
1109
|
Next
|
1110
|
'labelpersist = objPlacement.PIDPlaceLabel(labelName1,
|
1111
|
' twopoints, LabeledItem:=objPipeRun.Representations.Nth(0))
|
1112
|
'twopoints(1) = 0.17
|
1113
|
'twopoints(2) = 0.1
|
1114
|
'labelpersist = objPlacement.PIDPlaceLabel(labelName1,
|
1115
|
' twopoints, LabeledItem:=objPipeRun.Representations.Nth(0))
|
1116
|
|
1117
|
|
1118
|
'Instrument
|
1119
|
InstrumentLoc = "\Instrumentation\Off-Line\Without Implied Components\Single Function\Disc Single-Func Access in Prime Loc.sym"
|
1120
|
objSymbol = objPlacement.PIDPlaceSymbol(InstrumentLoc, 0.15, 0.3, , 0)
|
1121
|
|
1122
|
Dim objInstr As LMInstrument
|
1123
|
objInstr = datasource.GetInstrument(objSymbol.ModelItemID)
|
1124
|
objInstr.Attributes("MeasuredVariableCode").Value = "L"
|
1125
|
objInstr.Attributes("InstrumentTypeModifier").Value = "G"
|
1126
|
objInstr.Attributes("TagSuffix").Value = ""
|
1127
|
objInstr.Attributes("TagSequenceNo").Value = "4003"
|
1128
|
objInstr.Commit()
|
1129
|
|
1130
|
objInputs = New PlaceRunInputs
|
1131
|
objInputs.AddConnectorTarget(objConnector, 0.15, 0.1)
|
1132
|
objInputs.AddPoint(0.15, 0.15)
|
1133
|
objInputs.AddPoint(0.12, 0.15)
|
1134
|
objInputs.AddPoint(0.12, 0.2)
|
1135
|
objInputs.AddPoint(0.15, 0.2)
|
1136
|
objInputs.AddSymbolTarget(objSymbol, 0.15, 0.3)
|
1137
|
objItem = objPlacement.PIDCreateItem(PipeRunLoc)
|
1138
|
|
1139
|
objConnector = objPlacement.PIDPlaceRun(objItem, objInputs)
|
1140
|
objPipeRun = datasource.GetPipeRun(objConnector.ModelItemID)
|
1141
|
twopoints(1) = 0.14
|
1142
|
twopoints(2) = 0.22
|
1143
|
|
1144
|
For Each representation In objPipeRun.Representations
|
1145
|
If representation.RepresentationType = "Connector" Then
|
1146
|
labelpersist = objPlacement.PIDPlaceLabel(labelName1,
|
1147
|
twopoints,, 1.57, LabeledItem:=representation)
|
1148
|
End If
|
1149
|
Next
|
1150
|
|
1151
|
|
1152
|
|
1153
|
|
1154
|
|
1155
|
|
1156
|
|
1157
|
' Measured Variable Code, Instr Type Modifier
|
1158
|
' TagSeqNo, TagSuffix
|
1159
|
|
1160
|
|
1161
|
'OPC
|
1162
|
|
1163
|
|
1164
|
'Valve
|
1165
|
|
1166
|
|
1167
|
|
1168
|
|
1169
|
|
1170
|
End Sub
|
1171
|
End Class
|
1172
|
|
1173
|
|
1174
|
Public Class DrawingInfo
|
1175
|
Public mDrawingName As String
|
1176
|
Public mSpID As String
|
1177
|
Public mPath As String
|
1178
|
End Class
|
1179
|
|
1180
|
|
1181
|
|
1182
|
|
1183
|
|