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