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