hytos / DTI_PID / SPPIDConverter / Main.vb @ e6b6b13d
이력 | 보기 | 이력해설 | 다운로드 (104 KB)
1 | 4f359afa | Gyusu | Imports System.IO |
---|---|---|---|
2 | Imports System.Data.SqlClient |
||
3 | Imports System.Data.SQLite |
||
4 | Imports Plaice |
||
5 | Imports Llama |
||
6 | Imports PidA |
||
7 | 962b2464 | Gyusu | |
8 | e282643f | Gyusu | |
9 | Imports System.Threading |
||
10 | |||
11 | 4f359afa | Gyusu | Public Class Main |
12 | |||
13 | 54b98e09 | Gyusu | 'Dim _Mapping_DB As DataTable = New DataTable() |
14 | Dim _Mapping_DB As DataSet = New DataSet() |
||
15 | 171ac39d | Gyusu | Dim _Attribute_DB As DataTable = New DataTable() |
16 | 39d43554 | Gyusu | Dim _PIDSymbol_DB As DataTable = New DataTable() |
17 | 4f359afa | Gyusu | Dim _Placement As New Placement |
18 | Dim _DWG_X = 0.84 '0.695 '1 ' |
||
19 | Dim _DWG_Y = 0.594 '0.585 '0.8 ' |
||
20 | |||
21 | 171ac39d | Gyusu | Dim _IMG_X = 0 |
22 | Dim _IMG_Y = 0 |
||
23 | |||
24 | Dim _Unit As String |
||
25 | 4f359afa | Gyusu | |
26 | 31d47a80 | Gyusu | 'Drawing 전역변수 |
27 | Dim _objPIDADrawing As Object |
||
28 | e282643f | Gyusu | '현재선택한 폴더경로 |
29 | Dim _selectFolderPath As String |
||
30 | |||
31 | Private _Main_trd As Thread |
||
32 | 54b98e09 | Gyusu | Private _Opc_trd As Thread |
33 | |||
34 | Private _CompleteConvert As Boolean = False |
||
35 | e282643f | Gyusu | |
36 | 171ac39d | Gyusu | Private _DrawingsList As List(Of Drawing) |
37 | 272662f9 | Gyusu | |
38 | |||
39 | 9e1e7135 | Gyusu | Private _iPipeLineNocnt As Integer |
40 | Private _iPipecnt As Integer |
||
41 | Private _iFittingcnt As Integer |
||
42 | Private _iValvecnt As Integer |
||
43 | Private _iInstrumentcnt As Integer |
||
44 | Private _iEquipmentcnt As Integer |
||
45 | Private _iNozzlecnt As Integer |
||
46 | |||
47 | 54b98e09 | Gyusu | Dim _Gembox As New CGembox() |
48 | 4f359afa | Gyusu | Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load |
49 | 54b98e09 | Gyusu | LoadDB() |
50 | |||
51 | End Sub |
||
52 | 272662f9 | Gyusu | |
53 | 54b98e09 | Gyusu | Private Sub LoadDB() |
54 | e282643f | Gyusu | If My.Settings.DBPath <> "" And My.Settings.Plant_Hierarchy <> "" Then |
55 | Dim sDBPath As String = My.Settings.DBPath |
||
56 | 54b98e09 | Gyusu | |
57 | _Gembox.isLoadFile(My.Settings.SymbolLibrary) |
||
58 | _Mapping_DB = _Gembox.LoadFileFunc() |
||
59 | ' _Mapping_DB = Load_DB(sDBPath, _DB_TABLE_MAPPING) |
||
60 | 171ac39d | Gyusu | _Attribute_DB = Load_DB(sDBPath, _DB_TABLE_ATTRIBUTE) |
61 | 39d43554 | Gyusu | _PIDSymbol_DB = Load_DB(sDBPath, _DB_TABLE_SYMBOLNAME) |
62 | 6a6d8ab4 | Gyusu | 'TestPID() |
63 | 'OpenDrawing() |
||
64 | e282643f | Gyusu | Else |
65 | MessageBox.Show("설정값을 먼저 확인해주세요") |
||
66 | End If |
||
67 | End Sub |
||
68 | Public Function GetDrawingInfo(ByVal errorList As ArrayList) |
||
69 | Dim ds As Llama.LMADataSource |
||
70 | ds = New Llama.LMADataSource |
||
71 | Dim lmaItem As Llama.LMAItem |
||
72 | For i = 0 To errorList.Count - 1 |
||
73 | lmaItem = ds.GetModelItem(errorList.Item(i).m_strSPID()).AsLMAItem |
||
74 | Dim drawingInfo As DrawingInfo |
||
75 | drawingInfo = GetDrawingName(lmaItem.ItemType, lmaItem.Id) |
||
76 | errorList.Item(i).m_LMAItem = lmaItem |
||
77 | errorList.Item(i).m_strDrawingName = drawingInfo.mDrawingName |
||
78 | errorList.Item(i).m_strDrawingPath = drawingInfo.mPath |
||
79 | Next |
||
80 | End Function |
||
81 | Private mDataSource As Object |
||
82 | |||
83 | 'Public Sub New() |
||
84 | |||
85 | ' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName |
||
86 | ' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI |
||
87 | ' 'm_Information = SPPIDClass.Information.GetInstance() |
||
88 | |||
89 | ' 'If m_Information.InfoProject.ProjectVersion = SPPIDClass.InfoProject.SPPID_43 Then |
||
90 | ' ' 'SPPID4.3용 |
||
91 | ' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName |
||
92 | ' 'Else |
||
93 | ' ' 'SPPID2007, SPPID2009용 |
||
94 | ' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName |
||
95 | ' 'End If |
||
96 | |||
97 | ' ' mDataSource.SiteNode = m_Information.InfoProject.ProjectINI |
||
98 | ' ' mDataSource.ProjectNumber = m_Information.InfoSite.SiteName & "!" & m_Information.InfoSite.SiteName |
||
99 | ' '#If LATE_BINDING Then |
||
100 | ' ' mInstruments = CreateObject("Llama.LMInstruments", "") |
||
101 | ' ' mPipingComps = CreateObject("Llama.LMPipingComps", "") |
||
102 | ' ' mVessels = CreateObject("Llama.LMVessels", "") |
||
103 | ' ' mDrawings = CreateObject("Llama.LMDrawings", "") |
||
104 | ' ' mEquipments = CreateObject("Llama.LMEquipments", "") |
||
105 | ' ' mExchangers = CreateObject("Llama.LMExchangers", "") |
||
106 | ' ' mMechanicals = CreateObject("Llama.LMMechanicals", "") |
||
107 | ' ' mNozzles = CreateObject("Llama.LMNozzles", "") |
||
108 | ' ' mPipeRuns = CreateObject("Llama.LMPipeRuns", "") |
||
109 | ' ' mEquipmentOthers = CreateObject("Llama.LMEquipmentOthers", "") |
||
110 | ' '#Else |
||
111 | ' ' mInstruments = New Llama.LMInstruments |
||
112 | ' ' mPipingComps = New Llama.LMPipingComps |
||
113 | ' ' mVessels = New Llama.LMVessels |
||
114 | ' ' mDrawings = New Llama.LMDrawings |
||
115 | ' ' mEquipments = New Llama.LMEquipments |
||
116 | ' ' mExchangers = New Llama.LMExchangers |
||
117 | ' ' mMechanicals = New Llama.LMMechanicals |
||
118 | ' ' mNozzles = New Llama.LMNozzles |
||
119 | ' ' mPipeRuns = New Llama.LMPipeRuns |
||
120 | ' ' mEquipmentOthers = New Llama.LMEquipmentOthers |
||
121 | ' '#End If |
||
122 | 'End Sub |
||
123 | 559daf6d | Gyusu | |
124 | Function OpenDrawing() |
||
125 | Dim datasource As LMADataSource |
||
126 | Dim objPIDAutoApp As Object |
||
127 | Dim objPIDADrawing As Object |
||
128 | Dim objDrawing As LMDrawing |
||
129 | Dim objDrawings As LMDrawings |
||
130 | datasource = New Llama.LMADataSource |
||
131 | objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
132 | objDrawings = New Llama.LMDrawings 'New LMDrawings |
||
133 | b6996671 | Gyusu | datasource.SiteNode = "\\desktop-9vlq0dp\Test03Site\smartplantv4.ini" |
134 | 559daf6d | Gyusu | datasource.ProjectNumber = "SBR_PBR" |
135 | objDrawings.Collect(datasource) |
||
136 | |||
137 | For Each objDrawing In objDrawings |
||
138 | If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
||
139 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
||
140 | If Not objPIDADrawing Is Nothing Then |
||
141 | 'MsgBox "Drawing " & objDrawing.Attributes("Name").Value & " is opened!" |
||
142 | objPIDADrawing.CloseDrawing |
||
143 | End If |
||
144 | End If |
||
145 | Next |
||
146 | objPIDAutoApp.Quit |
||
147 | objPIDAutoApp = Nothing |
||
148 | objPIDADrawing = Nothing |
||
149 | objDrawing = Nothing |
||
150 | objDrawings = Nothing |
||
151 | End Function |
||
152 | |||
153 | |||
154 | e282643f | Gyusu | Public Function GetDrawingName(ByVal itemType As String, ByVal itemName As String) As DrawingInfo |
155 | |||
156 | Dim objFilter As Object |
||
157 | objFilter = CreateObject("Llama.LMAFilter", "") |
||
158 | |||
159 | Dim drawingInfo As DrawingInfo |
||
160 | drawingInfo = New DrawingInfo |
||
161 | |||
162 | objFilter.Criteria.AddNew("FirstOne") |
||
163 | objFilter.Criteria.Item("FirstOne").SourceAttributeName = "SP_ID" |
||
164 | objFilter.Critedkria.Item("FirstOne").ValueAttribute = itemName |
||
165 | |||
166 | objFilter.Criteria.Item("FirstOne").Operator = "=" |
||
167 | objFilter.Criteria.AddNew("SecondOne") |
||
168 | objFilter.Criteria.Item("SecondOne").SourceAttributeName = "ItemStatus" |
||
169 | objFilter.Criteria.Item("SecondOne").ValueAttribute = 1 |
||
170 | objFilter.Criteria.Item("SecondOne").Operator = "=" |
||
171 | objFilter.Criteria.Item("SecondOne").Conjunctive = -1 |
||
172 | objFilter.ItemType = itemType |
||
173 | |||
174 | Dim PlantItems As Object |
||
175 | PlantItems = CreateObject("Llama.LMPlantItems", "") |
||
176 | PlantItems.Collect(mDataSource, Filter:=objFilter) |
||
177 | |||
178 | If PlantItems.Count = 0 Then |
||
179 | drawingInfo.mSpID = "PlantStockpile" |
||
180 | End If |
||
181 | |||
182 | For Each PlantItem In PlantItems |
||
183 | |||
184 | 'If Not PlantItem.Representations.Nth(1).DrawingID.Value.ToString().Equals("0") Then |
||
185 | Try |
||
186 | drawingInfo.mDrawingName = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Name").Value |
||
187 | drawingInfo.mSpID = PlantItem.Representations.Nth(1).DrawingID |
||
188 | drawingInfo.mPath = PlantItem.Representations.Nth(1).DrawingObject.Attributes("Path").Value |
||
189 | Debug.WriteLine("DrawingName : " & drawingInfo.mDrawingName & ", SPID : " & drawingInfo.mSpID & ", Path : " & drawingInfo.mPath) |
||
190 | Catch ex As Exception |
||
191 | |||
192 | End Try |
||
193 | |||
194 | 'End If |
||
195 | |||
196 | Next |
||
197 | |||
198 | Return drawingInfo |
||
199 | |||
200 | End Function |
||
201 | |||
202 | Private Sub TestPID() |
||
203 | Try |
||
204 | 6a6d8ab4 | Gyusu | Const CONST_SPID_OPC As String = "426E89964A7F49208AD79E1F320DA251" |
205 | e282643f | Gyusu | Dim datasource As LMADataSource |
206 | Dim objPIDAutoApp As Object |
||
207 | Dim objPIDADrawing As Object |
||
208 | Dim objDrawing As LMDrawing |
||
209 | Dim objDrawings As LMDrawings |
||
210 | datasource = New LMADataSource |
||
211 | 6a6d8ab4 | Gyusu | Dim objOPC As LMOPC |
212 | Dim objpairOPC As LMOPC |
||
213 | objOPC = datasource.GetOPC(CONST_SPID_OPC) |
||
214 | objpairOPC = objOPC.pairedWithOPCObject |
||
215 | e282643f | Gyusu | Dim oObj As Object = Nothing |
216 | objDrawing = datasource.GetDrawing(oObj) |
||
217 | objDrawings = New LMDrawings |
||
218 | objDrawings.Collect(datasource) |
||
219 | objPIDAutoApp = GetObject(, "SmartPlantPID.Application") '// CreateObject("PIDAutomation.Application") |
||
220 | For Each objDrawing In objDrawings |
||
221 | If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
||
222 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
||
223 | If Not objPIDADrawing Is Nothing Then |
||
224 | MessageBox.Show("Drawing " & objDrawing.Attributes("Name").Value & " is opened!") |
||
225 | objPIDADrawing.CloseDrawing |
||
226 | End If |
||
227 | End If |
||
228 | Next |
||
229 | objPIDAutoApp.Quit |
||
230 | objPIDAutoApp = Nothing |
||
231 | objPIDADrawing = Nothing |
||
232 | objDrawing = Nothing |
||
233 | objDrawings = Nothing |
||
234 | Catch ex As Exception |
||
235 | End Try |
||
236 | 962b2464 | Gyusu | End Sub |
237 | e282643f | Gyusu | |
238 | b6996671 | Gyusu | Public Function SetActiveSiteFromConfigInfo(ByVal strActiveSite As String) As Boolean |
239 | e282643f | Gyusu | On Error GoTo errHandler |
240 | Dim objConfigInfo As Object 'interopigrConfigInfo412.igrConfigInfo |
||
241 | objConfigInfo = CreateObject("interopigrConfigInfo412.igrConfigInfo", "") |
||
242 | If Not objConfigInfo Is Nothing Then |
||
243 | objConfigInfo.ApplicationName = "SmartPlantManager" |
||
244 | objConfigInfo.SetConfigString(3, "SmartPlant Manager", "SiteServer", strActiveSite) |
||
245 | SetActiveSiteFromConfigInfo = True |
||
246 | End If |
||
247 | objConfigInfo = Nothing |
||
248 | Exit Function |
||
249 | errHandler: |
||
250 | ' LogAndRaiseError ModuleName & "::GetConfigInfo " |
||
251 | End Function |
||
252 | 4f359afa | Gyusu | |
253 | 1229ad76 | Gyusu | Private Function CreateDwg(ByVal oDwgName As String) As Boolean |
254 | Dim objPIDADrawing As Object = Nothing |
||
255 | Dim objPIDAutoApp As Object = Nothing |
||
256 | Dim datasource As LMADataSource = Nothing |
||
257 | 4f359afa | Gyusu | Try |
258 | Dim DrawingNumber As String |
||
259 | Dim DrawingName As String |
||
260 | 1229ad76 | Gyusu | Dim sPlantGroupName As String = "Test" |
261 | Dim sTemplateName As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\P&ID Reference Data\Template Files\Gazprom Project.pid" |
||
262 | Dim objDrawing As LMDrawing |
||
263 | Dim objDrawings As LMDrawings |
||
264 | objDrawings = New LMDrawings |
||
265 | datasource = New LMADataSource |
||
266 | Debug.Print(datasource.ProjectNumber) |
||
267 | Debug.Print(datasource.SiteNode) |
||
268 | Debug.Print(datasource.IsSatellite) |
||
269 | Debug.Print(datasource.GetSystemEditingToolbarSetting) |
||
270 | objDrawings.Collect(datasource) |
||
271 | Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid" |
||
272 | objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
273 | 54b98e09 | Gyusu | |
274 | 1229ad76 | Gyusu | For Each objDrawing In objDrawings |
275 | If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
||
276 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(sPath) |
||
277 | If Not objPIDADrawing Is Nothing Then |
||
278 | objPIDADrawing.CloseDrawing |
||
279 | End If |
||
280 | End If |
||
281 | Next |
||
282 | 4f359afa | Gyusu | |
283 | Dim extension As String = Path.GetExtension(oDwgName) |
||
284 | oDwgName = oDwgName.Replace(extension, "") |
||
285 | 1229ad76 | Gyusu | |
286 | 4f359afa | Gyusu | objPIDAutoApp = CreateObject("PIDAutomation.Application") |
287 | 1229ad76 | Gyusu | |
288 | 'For Each objDrawing In objPIDAutoApp.Drawings |
||
289 | ' objDrawing.CloseDrawing(True) |
||
290 | 'Next |
||
291 | |||
292 | objPIDAutoApp.Drawings.OpenDrawing(oDwgName + ".pid") |
||
293 | |||
294 | objPIDAutoApp.ActiveWindow.Fit() |
||
295 | |||
296 | Return True |
||
297 | Catch ex As Exception |
||
298 | If objPIDADrawing IsNot Nothing Then |
||
299 | 4f359afa | Gyusu | objPIDADrawing.CloseDrawing |
300 | End If |
||
301 | 1229ad76 | Gyusu | If objPIDAutoApp IsNot Nothing Then |
302 | objPIDAutoApp.Quit |
||
303 | End If |
||
304 | datasource = Nothing |
||
305 | 4f359afa | Gyusu | objPIDAutoApp = Nothing |
306 | objPIDADrawing = Nothing |
||
307 | Return False |
||
308 | End Try |
||
309 | 1229ad76 | Gyusu | If objPIDADrawing IsNot Nothing Then |
310 | objPIDADrawing.CloseDrawing |
||
311 | End If |
||
312 | 4f359afa | Gyusu | |
313 | End Function |
||
314 | |||
315 | 1229ad76 | Gyusu | |
316 | 171ac39d | Gyusu | Private Function GetDataFromMappingDB(ByVal sSymbolName As String, ByVal sColumn As String) As String |
317 | Dim sValue As String = "" |
||
318 | 54b98e09 | Gyusu | For Each oDt As DataTable In _Mapping_DB.Tables |
319 | If oDt.Rows.Count > 0 Then |
||
320 | Dim oSelectRow() As DataRow = oDt.Select("[img_symbolname] = '" + sSymbolName + "'") |
||
321 | If oSelectRow.Length = 1 Then |
||
322 | If sColumn = _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME Then |
||
323 | sValue = oSelectRow(0).Item("SYM FILE NAME").ToString() |
||
324 | ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH Then |
||
325 | sValue = "\" & oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString() |
||
326 | ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_COMPTPYE Then |
||
327 | sValue = oSelectRow(0).Item("ITEM TYPE").ToString() |
||
328 | ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_CLASS Then |
||
329 | sValue = oSelectRow(0).Item("CLASS").ToString() |
||
330 | Else |
||
331 | sValue = oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString() |
||
332 | End If |
||
333 | |||
334 | End If |
||
335 | e282643f | Gyusu | End If |
336 | 54b98e09 | Gyusu | Next |
337 | |||
338 | 171ac39d | Gyusu | Return sValue |
339 | 4f359afa | Gyusu | End Function |
340 | |||
341 | 171ac39d | Gyusu | Private Function GetAttributeMapping(ByVal sAttributeName As String, ByVal sColumn As String) As String |
342 | Dim sSPPIDAttribute As String = "" |
||
343 | If _Attribute_DB.Rows.Count > 0 Then |
||
344 | Dim oSelectRow() As DataRow = _Attribute_DB.Select("[pid_attribute] = '" + sAttributeName + "'") |
||
345 | If oSelectRow.Length = 1 Then |
||
346 | sSPPIDAttribute = oSelectRow(0).Item(sColumn).ToString() |
||
347 | End If |
||
348 | End If |
||
349 | Return sSPPIDAttribute |
||
350 | End Function |
||
351 | e282643f | Gyusu | |
352 | d039e347 | Gyusu | ' Dim _TempSymbolDt As DataTable = Symbol_Dt() |
353 | 6a6d8ab4 | Gyusu | |
354 | |||
355 | 171ac39d | Gyusu | Private Function LoadSymbolInXml(ByVal sXmlPath As String) As Drawing |
356 | 54b98e09 | Gyusu | Try |
357 | '' _TempSymbolDt = Symbol_Dt() |
||
358 | Dim CDrawing As Drawing = New Drawing() |
||
359 | Dim oDt As DataTable = LoadSymbol_DT() |
||
360 | Dim oElement As XElement = XElement.Load(sXmlPath) |
||
361 | 6a6d8ab4 | Gyusu | |
362 | 54b98e09 | Gyusu | If oElement IsNot Nothing Then |
363 | CDrawing.DwgName = oElement.Element(_XML_DWGNAME).Value |
||
364 | CDrawing.Size = oElement.Element(_XML_DWGSIZE).Value |
||
365 | SplitLocation(CDrawing.Size, _IMG_X, _IMG_Y) |
||
366 | CDrawing.Unit = oElement.Element(_XML_UNIT).Value |
||
367 | 171ac39d | Gyusu | |
368 | 54b98e09 | Gyusu | Dim oLineno_list As New List(Of Line_no) |
369 | Dim oEqp_list As New List(Of Eqp_no) |
||
370 | |||
371 | For Each oLineNo As Object In oElement.Elements(_XML_CATEGORY_LINENO) |
||
372 | |||
373 | Dim CLineNo As Line_no = New Line_no() |
||
374 | Try |
||
375 | CLineNo.Uid = oLineNo.Element(_XML_LINENO_UID).Value |
||
376 | CLineNo.Text = oLineNo.Element(_XML_LINENO_TEXT).Value |
||
377 | CLineNo.Location = oLineNo.Element(_XML_LINENO_LOCATION).Value |
||
378 | CLineNo.Angle = oLineNo.Element(_XML_LINENO_ANGLE).Value |
||
379 | CLineNo.SystemPath = "\Piping\Labels - Piping Segments\Kemya Line Number.sym" 'GetDataFromMappingDB(_XML_CATEGORY_LINENO, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
380 | Catch ex As Exception |
||
381 | 'CLineNo.Text = "PipeLineNo" |
||
382 | 'CLineNo.Uid = "PipeLineNo" |
||
383 | End Try |
||
384 | |||
385 | |||
386 | Dim oLine_Dt As DataTable = Line_Dt() |
||
387 | Dim oSymbol_Dt As DataTable = Symbol_Dt() |
||
388 | Dim oAttribute_Dt As DataTable = Attribute_Dt() |
||
389 | |||
390 | For Each oRun As Object In oLineNo.Elements(_XML_CATEGORY_RUN) |
||
391 | For Each oLine As Object In oRun.Elements(_XML_CATEGORY_LINE) |
||
392 | Try |
||
393 | Dim oAddrow As DataRow = oLine_Dt.NewRow() |
||
394 | Dim oEleObj As XElement |
||
395 | Dim sUid As String |
||
396 | Dim sStartpoint As String |
||
397 | Dim sEndpoint As String |
||
398 | oEleObj = oLine.Element(_XML_LINE_UID) |
||
399 | sUid = oEleObj.Value |
||
400 | oEleObj = oLine.Element(_XML_LINE_STARTPOINT) |
||
401 | sStartpoint = oEleObj.Value |
||
402 | oEleObj = oLine.Element(_XML_LINE_ENDPOINT) |
||
403 | sEndpoint = oEleObj.Value |
||
404 | |||
405 | oAddrow(_XML_LINE_UID) = sUid |
||
406 | oAddrow(_XML_LINE_STARTPOINT) = sStartpoint |
||
407 | oAddrow(_XML_LINE_ENDPOINT) = sEndpoint |
||
408 | oAddrow(_XML_LINE_SYSTEMPATH) = GetDataFromMappingDB(_XML_CATEGORY_LINE, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
409 | oAddrow(_XML_LINE_DRAWING) = "FALSE" |
||
410 | oLine_Dt.Rows.Add(oAddrow) |
||
411 | Catch ex As Exception |
||
412 | |||
413 | End Try |
||
414 | |||
415 | Next |
||
416 | |||
417 | For Each oSymbol As Object In oRun.Elements(_XML_CATEGORY_SYMBOL) |
||
418 | Try |
||
419 | Dim oAddrow As DataRow = oSymbol_Dt.NewRow() |
||
420 | Dim oEleObj As XElement |
||
421 | Dim sUid As String |
||
422 | Dim sName As String |
||
423 | Dim sLocation As String |
||
424 | Dim sSize As String |
||
425 | Dim sAngle As String |
||
426 | Dim sOriginalPoint As String = "" |
||
427 | oEleObj = oSymbol.Element(_XML_SYMBOL_UID) |
||
428 | sUid = oEleObj.Value |
||
429 | oEleObj = oSymbol.Element(_XML_SYMBOL_PARENT) |
||
430 | sName = oEleObj.Value |
||
431 | oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
||
432 | sLocation = oEleObj.Value |
||
433 | oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE) |
||
434 | sSize = oEleObj.Value |
||
435 | oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
||
436 | sAngle = oEleObj.Value |
||
437 | Try |
||
438 | oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT) |
||
439 | sOriginalPoint = oEleObj.Value |
||
440 | Catch ex As Exception |
||
441 | |||
442 | End Try |
||
443 | |||
444 | oAddrow(_XML_SYMBOL_UID) = sUid |
||
445 | oAddrow(_XML_SYMBOL_NAME) = IO.Path.GetFileNameWithoutExtension(GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME)) |
||
446 | oAddrow(_XML_SYMBOL_LOCATION) = sLocation |
||
447 | oAddrow(_XML_SYMBOL_SIZE) = sSize |
||
448 | oAddrow(_XML_SYMBOL_ANGLE) = sAngle |
||
449 | oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
450 | oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE) |
||
451 | oAddrow(_XML_SYMBOL_CLASS) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_CLASS) |
||
452 | oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint |
||
453 | |||
454 | oSymbol_Dt.Rows.Add(oAddrow) |
||
455 | Catch ex As Exception |
||
456 | |||
457 | End Try |
||
458 | |||
459 | Next |
||
460 | |||
461 | For Each oAtrribute As Object In oRun.Elements(_XML_CATEGORY_ATTRIBUTE) |
||
462 | Try |
||
463 | Dim oAddrow As DataRow = oAttribute_Dt.NewRow() |
||
464 | Dim oEleObj As XElement |
||
465 | Dim sUid As String |
||
466 | Dim sName As String |
||
467 | Dim sValue As String |
||
468 | |||
469 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID) |
||
470 | sUid = oEleObj.Value |
||
471 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME) |
||
472 | sName = oEleObj.Value |
||
473 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE) |
||
474 | sValue = oEleObj.Value |
||
475 | |||
476 | oAddrow(_XML_ATTRIBUTE_UID) = sUid |
||
477 | oAddrow(_XML_ATTRIBUTE_NAME) = sName |
||
478 | oAddrow(_XML_ATTRIBUTE_VALUE) = sValue |
||
479 | oAttribute_Dt.Rows.Add(oAddrow) |
||
480 | Catch ex As Exception |
||
481 | |||
482 | End Try |
||
483 | d039e347 | Gyusu | |
484 | 54b98e09 | Gyusu | Next |
485 | |||
486 | Next |
||
487 | 'Line No Attribute |
||
488 | For Each oAtrribute As Object In oLineNo.Elements(_XML_CATEGORY_ATTRIBUTE) |
||
489 | d039e347 | Gyusu | Try |
490 | 54b98e09 | Gyusu | Dim oAddrow As DataRow = oAttribute_Dt.NewRow() |
491 | Dim oEleObj As XElement |
||
492 | Dim sUid As String |
||
493 | Dim sName As String |
||
494 | Dim sValue As String |
||
495 | |||
496 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID) |
||
497 | sUid = oEleObj.Value |
||
498 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME) |
||
499 | sName = oEleObj.Value |
||
500 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE) |
||
501 | sValue = oEleObj.Value |
||
502 | oAddrow(_XML_ATTRIBUTE_UID) = sUid |
||
503 | oAddrow(_XML_ATTRIBUTE_NAME) = sName |
||
504 | oAddrow(_XML_ATTRIBUTE_VALUE) = sValue |
||
505 | oAttribute_Dt.Rows.Add(oAddrow) |
||
506 | d039e347 | Gyusu | Catch ex As Exception |
507 | 171ac39d | Gyusu | |
508 | d039e347 | Gyusu | End Try |
509 | 171ac39d | Gyusu | |
510 | d039e347 | Gyusu | Next |
511 | 54b98e09 | Gyusu | CLineNo.Dt_Line = oLine_Dt |
512 | CLineNo.Dt_Symbol = oSymbol_Dt |
||
513 | CLineNo.Dt_Attribute = oAttribute_Dt |
||
514 | oLineno_list.Add(CLineNo) |
||
515 | 'For Each oSymbol As Object In oElement.Elements(_XML_CATEGORY_SYMBOL) |
||
516 | ' Dim oAddrow As DataRow = _TempSymbolDt.NewRow() |
||
517 | ' Dim oEleObj As XElement |
||
518 | ' Dim sUid As String |
||
519 | ' Dim sName As String |
||
520 | ' Dim sLocation As String |
||
521 | ' Dim sSize As String |
||
522 | ' Dim sAngle As String |
||
523 | ' Dim sOriginalPoint As String = "" |
||
524 | ' oEleObj = oSymbol.Element(_XML_SYMBOL_UID) |
||
525 | ' sUid = oEleObj.Value |
||
526 | ' oEleObj = oSymbol.Element(_XML_SYMBOL_NAME) |
||
527 | ' sName = oEleObj.Value |
||
528 | ' oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
||
529 | ' sLocation = oEleObj.Value |
||
530 | ' oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE) |
||
531 | ' sSize = oEleObj.Value |
||
532 | ' oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
||
533 | ' sAngle = oEleObj.Value |
||
534 | ' Try |
||
535 | ' oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT) |
||
536 | ' sOriginalPoint = oEleObj.Value |
||
537 | ' Catch ex As Exception |
||
538 | |||
539 | ' End Try |
||
540 | ' oAddrow(_XML_SYMBOL_UID) = sUid |
||
541 | ' oAddrow(_XML_SYMBOL_NAME) = sName |
||
542 | ' oAddrow(_XML_SYMBOL_LOCATION) = sLocation |
||
543 | ' oAddrow(_XML_SYMBOL_SIZE) = sSize |
||
544 | ' oAddrow(_XML_SYMBOL_ANGLE) = sAngle |
||
545 | ' oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
546 | ' oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE) |
||
547 | ' oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint |
||
548 | ' _TempSymbolDt.Rows.Add(oAddrow) |
||
549 | 'Next |
||
550 | Next |
||
551 | For Each oEqpNo As Object In oElement.Elements(_XML_CATEGORY_EQUIPMENT) |
||
552 | Dim CEqp_no As Eqp_no = New Eqp_no() |
||
553 | 'CEqp_no.Uid = oEqpNo.Element(_XML_EQP_UID).Value |
||
554 | 'CEqp_no.Text = oEqpNo.Element(_XML_EQP_TEXT).Value |
||
555 | 'CEqp_no.Location = oEqpNo.Element(_XML_EQP_LOCATION).Value |
||
556 | 'CEqp_no.Angle = oEqpNo.Element(_XML_EQP_ANGLE).Value |
||
557 | 'CEqp_no.SystemPath = GetDataFromMappingDB(_XML_CATEGORY_EQUIPMENT, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
558 | Dim oSymbol_Dt As DataTable = Symbol_Dt() |
||
559 | Dim oAttribute_Dt As DataTable = Attribute_Dt() |
||
560 | |||
561 | For Each oSymbol As Object In oEqpNo.Elements(_XML_CATEGORY_SYMBOL) |
||
562 | Try |
||
563 | Dim oAddrow As DataRow = oSymbol_Dt.NewRow() |
||
564 | Dim oEleObj As XElement |
||
565 | Dim sUid As String |
||
566 | Dim sName As String |
||
567 | Dim sLocation As String |
||
568 | Dim sSize As String |
||
569 | Dim sAngle As String |
||
570 | Dim sOriginalPoint As String = "" |
||
571 | oEleObj = oSymbol.Element(_XML_SYMBOL_UID) |
||
572 | sUid = oEleObj.Value |
||
573 | oEleObj = oSymbol.Element(_XML_SYMBOL_NAME) |
||
574 | sName = oEleObj.Value |
||
575 | oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION) |
||
576 | sLocation = oEleObj.Value |
||
577 | oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE) |
||
578 | sSize = oEleObj.Value |
||
579 | oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE) |
||
580 | sAngle = oEleObj.Value |
||
581 | Try |
||
582 | oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT) |
||
583 | sOriginalPoint = oEleObj.Value |
||
584 | Catch ex As Exception |
||
585 | End Try |
||
586 | oAddrow(_XML_SYMBOL_UID) = sUid |
||
587 | oAddrow(_XML_SYMBOL_NAME) = sName |
||
588 | oAddrow(_XML_SYMBOL_LOCATION) = sLocation |
||
589 | oAddrow(_XML_SYMBOL_SIZE) = sSize |
||
590 | oAddrow(_XML_SYMBOL_ANGLE) = sAngle |
||
591 | oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
592 | oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE) |
||
593 | oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint |
||
594 | oSymbol_Dt.Rows.Add(oAddrow) |
||
595 | Catch ex As Exception |
||
596 | |||
597 | End Try |
||
598 | d039e347 | Gyusu | |
599 | Next |
||
600 | 54b98e09 | Gyusu | For Each oAtrribute As Object In oEqpNo.Elements(_XML_CATEGORY_ATTRIBUTE) |
601 | Try |
||
602 | Dim oAddrow As DataRow = oAttribute_Dt.NewRow() |
||
603 | Dim oEleObj As XElement |
||
604 | Dim sUid As String |
||
605 | Dim sName As String |
||
606 | Dim sValue As String |
||
607 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID) |
||
608 | sUid = oEleObj.Value |
||
609 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME) |
||
610 | sName = oEleObj.Value |
||
611 | oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE) |
||
612 | sValue = oEleObj.Value |
||
613 | oAddrow(_XML_ATTRIBUTE_UID) = sUid |
||
614 | oAddrow(_XML_ATTRIBUTE_NAME) = sName |
||
615 | oAddrow(_XML_ATTRIBUTE_VALUE) = sValue |
||
616 | oAttribute_Dt.Rows.Add(oAddrow) |
||
617 | Catch ex As Exception |
||
618 | 171ac39d | Gyusu | |
619 | 54b98e09 | Gyusu | End Try |
620 | |||
621 | Next |
||
622 | CEqp_no.Dt_Equipment = oSymbol_Dt |
||
623 | CEqp_no.Dt_Attribute = oAttribute_Dt |
||
624 | oEqp_list.Add(CEqp_no) |
||
625 | 4f359afa | Gyusu | Next |
626 | 54b98e09 | Gyusu | CDrawing.Line_nos = oLineno_list |
627 | CDrawing.Eqp_nos = oEqp_list |
||
628 | End If |
||
629 | Return CDrawing |
||
630 | Catch ex As Exception |
||
631 | Return Nothing |
||
632 | End Try |
||
633 | |||
634 | 4f359afa | Gyusu | End Function |
635 | |||
636 | |||
637 | |||
638 | 171ac39d | Gyusu | 'Private Function LoadPipeInXml(ByVal sXmlPath As String) As DataTable |
639 | ' Try |
||
640 | ' Dim oDt As DataTable = LoadPipe_DT() |
||
641 | ' Dim oElement As XElement = XElement.Load(sXmlPath) |
||
642 | ' If oElement IsNot Nothing Then |
||
643 | ' Dim DWGElement As XElement = oElement.Element("DWGNAME") |
||
644 | ' Dim DWGNAME = DWGElement.Value |
||
645 | ' Dim sXY As XElement = oElement.Element("SIZE") |
||
646 | ' Dim sSize = sXY.Value |
||
647 | ' Dim oSplitDWGPos As String() = sSize.Split(", ") |
||
648 | 4f359afa | Gyusu | |
649 | 171ac39d | Gyusu | ' If IsNumeric(oSplitDWGPos(0)) Then |
650 | ' _IMG_X = Double.Parse(oSplitDWGPos(0)) |
||
651 | ' End If |
||
652 | ' If IsNumeric(oSplitDWGPos(1)) Then |
||
653 | ' _IMG_Y = Double.Parse(oSplitDWGPos(1)) |
||
654 | ' End If |
||
655 | 4f359afa | Gyusu | |
656 | 171ac39d | Gyusu | ' For Each pipes As Object In oElement.Elements("IMGLINES") |
657 | ' For Each pipe As Object In pipes.Elements("IMGLINE") |
||
658 | ' Dim oAddrow As DataRow = oDt.NewRow() |
||
659 | ' Dim oObj As XElement = pipe.Element("ITEM") |
||
660 | ' Dim oItem = oObj.Value |
||
661 | ' ' Dim oSymbolPath As String = "\" + oSymbol + "\" + oClass + "\" + oType + "\" + oItem + ".sym" |
||
662 | ' Dim oSymbolPath As String = GetSystemPathFromMappingDB(oItem) |
||
663 | ' oObj = pipe.Element("START") |
||
664 | ' Dim oStartPoint = oObj.Value |
||
665 | ' Dim oSplitPos As String() = oStartPoint.Split(", ") |
||
666 | ' Dim oStartpos_X As Double = 0.0 |
||
667 | ' Dim oStartpos_Y As Double = 0.0 |
||
668 | ' If IsNumeric(oSplitPos(0)) Then |
||
669 | ' oStartpos_X = Double.Parse(oSplitPos(0)) |
||
670 | ' End If |
||
671 | ' If IsNumeric(oSplitPos(1)) Then |
||
672 | ' oStartpos_Y = Double.Parse(oSplitPos(1)) |
||
673 | ' End If |
||
674 | 4f359afa | Gyusu | |
675 | 171ac39d | Gyusu | ' ConvertPoint(oStartpos_X, oStartpos_Y, _DWG_X, _DWG_Y) |
676 | ' oObj = pipe.Element("End") |
||
677 | ' Dim oEndPoint = oObj.Value |
||
678 | ' oSplitPos = oEndPoint.Split(", ") |
||
679 | ' Dim oEndpos_X As Double = 0.0 |
||
680 | ' Dim oEndpos_Y As Double = 0.0 |
||
681 | ' If IsNumeric(oSplitPos(0)) Then |
||
682 | ' oEndpos_X = Double.Parse(oSplitPos(0)) |
||
683 | ' End If |
||
684 | ' If IsNumeric(oSplitPos(1)) Then |
||
685 | ' oEndpos_Y = Double.Parse(oSplitPos(1)) |
||
686 | ' End If |
||
687 | ' ConvertPoint(oEndpos_X, oEndpos_Y, _DWG_X, _DWG_Y) |
||
688 | 4f359afa | Gyusu | |
689 | 171ac39d | Gyusu | ' oAddrow("start_x") = oStartpos_X '+ 0.05 |
690 | ' oAddrow("start_y") = oStartpos_Y |
||
691 | ' oAddrow("end_x") = oEndpos_X |
||
692 | ' oAddrow("end_y") = oEndpos_Y |
||
693 | ' oAddrow("SystemPath") = oSymbolPath |
||
694 | ' oDt.Rows.Add(oAddrow) |
||
695 | ' Next |
||
696 | ' Next |
||
697 | |||
698 | ' End If |
||
699 | 4f359afa | Gyusu | |
700 | 171ac39d | Gyusu | |
701 | ' Return oDt |
||
702 | ' Catch ex As Exception |
||
703 | ' Return Nothing |
||
704 | ' End Try |
||
705 | 'End Function |
||
706 | 4f359afa | Gyusu | |
707 | |||
708 | 9e1e7135 | Gyusu | Private Sub ConvertPointByImage(ByRef dX As Double, ByRef dY As Double, ByVal dDwgX As Double, ByVal dDwgY As Double) |
709 | 4f359afa | Gyusu | |
710 | Dim calcx As Double = 0 |
||
711 | Dim calcy As Double = 0 |
||
712 | calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2) |
||
713 | 171ac39d | Gyusu | calcy = _DWG_Y - ((dY * _DWG_Y) / dDwgY) '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2) |
714 | 4f359afa | Gyusu | dX = calcx |
715 | dY = calcy |
||
716 | End Sub |
||
717 | |||
718 | e1cde8f2 | Gyusu | |
719 | '@brief Convert To SPPID |
||
720 | '@author : Gyusu Park |
||
721 | '@date : 2018-04-10 |
||
722 | '@history: |
||
723 | |||
724 | 171ac39d | Gyusu | Private Sub SplitLocation(ByVal sLocation As String, ByRef dX As Double, ByRef dY As Double) |
725 | |||
726 | Dim opointstr As String() = Split(sLocation, ",") |
||
727 | If (opointstr.Length > 1) Then |
||
728 | If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
||
729 | dX = opointstr(0) |
||
730 | dY = opointstr(1) |
||
731 | End If |
||
732 | End If |
||
733 | |||
734 | End Sub |
||
735 | |||
736 | |||
737 | |||
738 | |||
739 | |||
740 | |||
741 | e1cde8f2 | Gyusu | Private Function AutoConverting(ByVal oPipe_Dt As DataTable, ByVal oSymbol_Dt As DataTable, ByVal oTreeNode As TreeNode) As Boolean |
742 | e282643f | Gyusu | Dim iTotalCount As Double = oPipe_Dt.Rows.Count + oSymbol_Dt.Rows.Count |
743 | Dim iSymbolcount As Double = 0 |
||
744 | |||
745 | e1cde8f2 | Gyusu | Dim lobjDatasource As Object = _Placement.PIDDataSource |
746 | e282643f | Gyusu | |
747 | e1cde8f2 | Gyusu | ' lobjDatasource.BeginTransaction() |
748 | e282643f | Gyusu | ' datasource = objPlacement.PIDDataSource |
749 | 'Dim iPipecnt As Integer = 0 |
||
750 | e1cde8f2 | Gyusu | SetListBoxItems(ListBox_Result, " Auto converting 시작....") |
751 | e282643f | Gyusu | |
752 | e1cde8f2 | Gyusu | Dim iPipeCnt As Integer = 0 |
753 | e282643f | Gyusu | If oPipe_Dt IsNot Nothing Then |
754 | For Each oRow As DataRow In oPipe_Dt.Rows |
||
755 | Dim oposition As String = oRow("position").ToString() |
||
756 | 20c84e05 | Gyusu | Dim oSymbol As String = oRow("SystemPath").ToString() |
757 | 171ac39d | Gyusu | |
758 | e282643f | Gyusu | Dim objConnector As LMConnector |
759 | Dim objInputs As PlaceRunInputs |
||
760 | objInputs = New PlaceRunInputs |
||
761 | 171ac39d | Gyusu | Dim oSplitStr As String() = Split(oposition, " ") |
762 | e282643f | Gyusu | For Each sposition As String In oSplitStr |
763 | 20c84e05 | Gyusu | Dim opointstr As String() = Split(sposition, ", ") |
764 | e282643f | Gyusu | |
765 | If (opointstr.Length > 1) Then |
||
766 | If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
||
767 | Dim ox As Double = opointstr(0) |
||
768 | Dim oy As Double = opointstr(1) |
||
769 | 9e1e7135 | Gyusu | ConvertPointByImage(ox, oy, _IMG_X, _IMG_Y) |
770 | e282643f | Gyusu | objInputs.AddPoint(ox, oy) |
771 | End If |
||
772 | 4f359afa | Gyusu | End If |
773 | e282643f | Gyusu | Next |
774 | Dim objItem As LMAItem |
||
775 | e1cde8f2 | Gyusu | objItem = _Placement.PIDCreateItem(oSymbol) |
776 | objConnector = _Placement.PIDPlaceRun(objItem, objInputs) |
||
777 | SetListBoxItems(ListBox_Result, " Place PipeLine...." & "(" & (iPipeCnt + 1) & "/" & oPipe_Dt.Rows.Count) |
||
778 | e282643f | Gyusu | 'Dim objPipeRun As LMPipeRun = datasource.GetPipeRun(objConnector.ModelItemID) |
779 | 'objPipeRun.Attributes("OperFluidCode").Value = "AFS" |
||
780 | 'objPipeRun.Commit() |
||
781 | iSymbolcount = iSymbolcount + 1 |
||
782 | e1cde8f2 | Gyusu | iPipeCnt = iPipeCnt + 1 |
783 | e282643f | Gyusu | Next |
784 | End If |
||
785 | 4f359afa | Gyusu | |
786 | e1cde8f2 | Gyusu | SetListBoxItems(ListBox_Result, " Place PipeLine....완료") |
787 | |||
788 | Dim iAllInstrumentCnt As Integer = oSymbol_Dt.Select("Name = 'INSTRUMENTATION'").Length |
||
789 | 20c84e05 | Gyusu | Dim iValveCnt As Integer = oSymbol_Dt.Select("Class = 'VALVES'").Length |
790 | e1cde8f2 | Gyusu | Dim iInstrumentCnt As Integer = 1 |
791 | Dim iFittingsCnt As Integer = 1 |
||
792 | |||
793 | Dim oInsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Instruments", True)(0) |
||
794 | Dim oValveNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Valves", True)(0) |
||
795 | Dim oFittingsNode As TreeNode = oTreeNode.Nodes.Find(oTreeNode.Name & "\Fittings", True)(0) |
||
796 | e282643f | Gyusu | For Each oRow As DataRow In oSymbol_Dt.Rows |
797 | 4f359afa | Gyusu | |
798 | e282643f | Gyusu | Try |
799 | e1cde8f2 | Gyusu | |
800 | 20c84e05 | Gyusu | Dim sSystemPath As String = oRow("SystemPath").ToString() |
801 | Dim sName As String = oRow("Name").ToString() |
||
802 | Dim sType As String = oRow("Type").ToString() |
||
803 | Dim sText As String = oRow("Text").ToString() |
||
804 | Dim sClass As String = oRow("Class").ToString() |
||
805 | Dim sItem As String = oRow("Item").ToString() |
||
806 | e1cde8f2 | Gyusu | |
807 | e282643f | Gyusu | Dim oX As Double = 0.0 |
808 | Dim oY As Double = 0.0 |
||
809 | 20c84e05 | Gyusu | If IsNumeric(oRow("x").ToString()) Then |
810 | oX = Double.Parse(oRow("x").ToString()) |
||
811 | e282643f | Gyusu | End If |
812 | 20c84e05 | Gyusu | If IsNumeric(oRow("y").ToString()) Then |
813 | oY = Double.Parse(oRow("y").ToString()) |
||
814 | e282643f | Gyusu | End If |
815 | Dim oAngle As Double = 0.0 |
||
816 | 20c84e05 | Gyusu | If IsNumeric(oRow("Angle").ToString()) Then |
817 | oAngle = Double.Parse(oRow("Angle").ToString()) |
||
818 | e282643f | Gyusu | End If |
819 | ' oSymbol = "\INSTRUMENTation\SYSTEM FUNCTIONS\D C S\DCS FUNC ACCESS IN PRIME LOC.sym" |
||
820 | e1cde8f2 | Gyusu | If sSystemPath <> "" Then |
821 | If sName = _TYPE_Instumentation Then |
||
822 | |||
823 | e282643f | Gyusu | Dim sTagsuffix As String = "" |
824 | Dim sTagSequenceNo As String = "" |
||
825 | Dim sMeasuredVariableCode As String = "" |
||
826 | Dim sInstrumentTypeModifier As String = "" |
||
827 | e1cde8f2 | Gyusu | |
828 | If sText <> "" Then |
||
829 | If sText.Contains(",") Then |
||
830 | Dim splitstr() As String = sText.Split(",") |
||
831 | e282643f | Gyusu | For i = 0 To splitstr.Count - 1 |
832 | If i = 0 Then |
||
833 | sMeasuredVariableCode = Mid(splitstr(i), 1, 1) |
||
834 | sTagSequenceNo = Mid(splitstr(i), 2, Len(splitstr(i))) |
||
835 | Else |
||
836 | If Len(splitstr(i)) = 1 Then |
||
837 | sInstrumentTypeModifier = splitstr(i) |
||
838 | ElseIf Len(splitstr(i)) = 0 Then |
||
839 | |||
840 | ElseIf Len(splitstr(i)) > 1 Then |
||
841 | sInstrumentTypeModifier = Mid(splitstr(i), 1, 1) |
||
842 | sTagsuffix = Mid(splitstr(i), 2, Len(splitstr(i))) |
||
843 | End If |
||
844 | End If |
||
845 | Next |
||
846 | Else |
||
847 | e1cde8f2 | Gyusu | sMeasuredVariableCode = Mid(sText, 1, 1) |
848 | sTagSequenceNo = Mid(sText, 2, Len(sText)) |
||
849 | e282643f | Gyusu | End If |
850 | 4f359afa | Gyusu | |
851 | e282643f | Gyusu | End If |
852 | 4f359afa | Gyusu | |
853 | e282643f | Gyusu | Dim objInstrSym As LMSymbol |
854 | e1cde8f2 | Gyusu | objInstrSym = _Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
855 | SetListBoxItems(ListBox_Result, " Place Instrument...." & "(" & (iInstrumentCnt + 1) & "/" & iAllInstrumentCnt & ")") |
||
856 | |||
857 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sTagSequenceNo) |
||
858 | Dim action As Action = Sub() |
||
859 | oInsNode.Nodes.Add(sClass & "-" & iInstrumentCnt) |
||
860 | oInsNode.ExpandAll() |
||
861 | End Sub |
||
862 | oInsNode.TreeView.Invoke(action) |
||
863 | |||
864 | |||
865 | e282643f | Gyusu | Dim objInstr As LMInstrument |
866 | objInstr = lobjDatasource.GetInstrument(objInstrSym.ModelItemID) |
||
867 | 4f359afa | Gyusu | |
868 | e282643f | Gyusu | Dim objItem As LMAItem |
869 | e1cde8f2 | Gyusu | objItem = _Placement.PIDCreateItem(sSystemPath) |
870 | |||
871 | 4f359afa | Gyusu | |
872 | e282643f | Gyusu | objInstr.Attributes("MeasuredVariableCode").Value = sMeasuredVariableCode |
873 | objInstr.Attributes("InstrumentTypeModifier").Value = sInstrumentTypeModifier |
||
874 | objInstr.Attributes("TagSuffix").Value = sTagsuffix |
||
875 | objInstr.Attributes("TagSequenceNo").Value = sTagSequenceNo |
||
876 | objInstr.Commit() |
||
877 | e1cde8f2 | Gyusu | iInstrumentCnt = iInstrumentCnt + 1 |
878 | ElseIf sName = "GATE VALVE WITH PLUG" Then |
||
879 | 4f359afa | Gyusu | |
880 | e1cde8f2 | Gyusu | ElseIf sName = "MEDIUM 1D 1TO1" Then |
881 | 4f359afa | Gyusu | |
882 | e1cde8f2 | Gyusu | ElseIf sClass = "VALVES" Then |
883 | Dim action As Action = Sub() |
||
884 | oValveNode.ExpandAll() |
||
885 | oValveNode.Nodes.Add(sClass & "-" & iValveCnt) |
||
886 | End Sub |
||
887 | oValveNode.TreeView.Invoke(action) |
||
888 | |||
889 | _Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
||
890 | |||
891 | iValveCnt = iValveCnt + 1 |
||
892 | e282643f | Gyusu | Else |
893 | e1cde8f2 | Gyusu | Dim action As Action = Sub() |
894 | oFittingsNode.ExpandAll() |
||
895 | oFittingsNode.Nodes.Add(sClass & "-" & iFittingsCnt) |
||
896 | End Sub |
||
897 | oFittingsNode.TreeView.Invoke(action) |
||
898 | _Placement.PIDPlaceSymbol(sSystemPath, oX, oY, , oAngle) |
||
899 | |||
900 | iFittingsCnt = iFittingsCnt + 1 |
||
901 | 4f359afa | Gyusu | |
902 | e282643f | Gyusu | End If |
903 | iSymbolcount = iSymbolcount + 1 |
||
904 | Else |
||
905 | 4f359afa | Gyusu | End If |
906 | e282643f | Gyusu | Catch ex As Exception |
907 | 4f359afa | Gyusu | |
908 | e282643f | Gyusu | End Try |
909 | Dim dCalcProgressValue As Double = (iSymbolcount / iTotalCount) * 100 |
||
910 | SetProgressbar(ProgressBar_Status, dCalcProgressValue) |
||
911 | ' ProgressBar_Status.Value = (iSymbolcount / iTotalCount) * 100 |
||
912 | e1cde8f2 | Gyusu | |
913 | 4f359afa | Gyusu | Next |
914 | |||
915 | e1cde8f2 | Gyusu | MsgBox("Complete AutoConverting") |
916 | SetListBoxItems(ListBox_Result, "Place Instrument....변환완료") |
||
917 | SetListBoxItems(ListBox_Result, "총 symbol: " & iSymbolcount & "개 변환완료") |
||
918 | SetProgressbar(ProgressBar_Status, 100) |
||
919 | e282643f | Gyusu | ' MsgBox("symbol: " & iSymbolcount & "개, pipe : " & iPipecnt & "개 변환완료") |
920 | 4f359afa | Gyusu | End Function |
921 | |||
922 | |||
923 | 272662f9 | Gyusu | Private Sub Tree_XMLFiles_AfterCheck(sender As Object, e As TreeViewEventArgs) |
924 | 4f359afa | Gyusu | If e.Node.Checked = True Then |
925 | For Each oNode As TreeNode In e.Node.Nodes |
||
926 | oNode.Checked = True |
||
927 | Next |
||
928 | Else |
||
929 | For Each oNode As TreeNode In e.Node.Nodes |
||
930 | oNode.Checked = False |
||
931 | Next |
||
932 | End If |
||
933 | End Sub |
||
934 | |||
935 | 171ac39d | Gyusu | Private Function Load_DB(ByVal sDBPath As String, ByVal sTableName As String) As DataTable |
936 | 4f359afa | Gyusu | |
937 | Try |
||
938 | 171ac39d | Gyusu | Dim oDt As New DataTable |
939 | 4f359afa | Gyusu | Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;" |
940 | Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring) |
||
941 | conn.Open() |
||
942 | 171ac39d | Gyusu | Dim sQuery As String = "Select * from " & sTableName |
943 | 4f359afa | Gyusu | Dim cmd As SQLiteCommand = conn.CreateCommand() |
944 | Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn) |
||
945 | Dim oDataSet As DataSet = New DataSet() |
||
946 | adapter.Fill(oDataSet) |
||
947 | 171ac39d | Gyusu | oDt = oDataSet.Tables(0) |
948 | Return oDt |
||
949 | 4f359afa | Gyusu | Catch ex As Exception |
950 | 171ac39d | Gyusu | Return Nothing |
951 | 4f359afa | Gyusu | End Try |
952 | |||
953 | |||
954 | 171ac39d | Gyusu | End Function |
955 | 4f359afa | Gyusu | |
956 | 171ac39d | Gyusu | Private Sub Load_AttributeDB(ByVal sDBPath As String) |
957 | |||
958 | Try |
||
959 | Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;" |
||
960 | Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring) |
||
961 | conn.Open() |
||
962 | Dim sQuery As String = "Select * from Attribute" |
||
963 | Dim cmd As SQLiteCommand = conn.CreateCommand() |
||
964 | Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn) |
||
965 | Dim oDataSet As DataSet = New DataSet() |
||
966 | adapter.Fill(oDataSet) |
||
967 | _Attribute_DB = oDataSet.Tables(0) |
||
968 | Catch ex As Exception |
||
969 | |||
970 | End Try |
||
971 | 962b2464 | Gyusu | |
972 | |||
973 | 171ac39d | Gyusu | End Sub |
974 | |||
975 | 272662f9 | Gyusu | 'Private Sub Tree_XMLFiles_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterSelect |
976 | ' If first_start = False Then Exit Sub |
||
977 | ' Dim pa = e.Node.FullPath.ToString |
||
978 | 962b2464 | Gyusu | |
979 | 272662f9 | Gyusu | ' printfilesfolders_here(pa, e.Node) |
980 | 962b2464 | Gyusu | |
981 | 272662f9 | Gyusu | ' displayfiles(pa) |
982 | |||
983 | ' Dim coco As String = "" |
||
984 | ' coco = pa.ToString |
||
985 | ' coco = coco.Replace("\\", "\") |
||
986 | ' Me.Text = coco |
||
987 | ' folders_path = coco |
||
988 | 'End Sub |
||
989 | 962b2464 | Gyusu | |
990 | Sub printfilesfolders_here(ByVal path As String, ByRef itree As TreeNode) |
||
991 | |||
992 | Dim foldername As String |
||
993 | Dim filename As String |
||
994 | itree.Nodes.Clear() |
||
995 | On Error GoTo eee |
||
996 | For Each foldername In Directory.GetDirectories(path) |
||
997 | On Error GoTo eee |
||
998 | Dim jj = foldername.LastIndexOf("\") |
||
999 | Dim jj1 = foldername.Length - jj |
||
1000 | Dim foldr = foldername.Substring((jj + 1), (jj1 - 1)) |
||
1001 | itree.Nodes.Add(foldr, foldr) |
||
1002 | Next ' if you put this next at the end of procedure recursive will be done on first folder only |
||
1003 | Exit Sub |
||
1004 | eee: |
||
1005 | End Sub |
||
1006 | |||
1007 | e282643f | Gyusu | |
1008 | 962b2464 | Gyusu | |
1009 | 272662f9 | Gyusu | ' Private Sub Tree_XMLFiles_MouseMove(sender As Object, e As MouseEventArgs) Handles Tree_XMLFiles.MouseMove |
1010 | ' first_start = True |
||
1011 | ' End Sub |
||
1012 | |||
1013 | ' Private Sub ListView_File_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView_File.SelectedIndexChanged |
||
1014 | ' Dim indexes As ListView.SelectedIndexCollection = |
||
1015 | ' Me.ListView_File.SelectedIndices |
||
1016 | ' Dim index As Integer |
||
1017 | |||
1018 | ' For Each index In indexes |
||
1019 | ' 'On Error Resume Next |
||
1020 | ' If folders_path.EndsWith("\") = True Then |
||
1021 | ' Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text) |
||
1022 | ' 'On Error Resume Next |
||
1023 | ' Else |
||
1024 | ' Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text) |
||
1025 | ' End If |
||
1026 | |||
1027 | ' Dim infoReader As System.IO.FileInfo |
||
1028 | ' infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text) |
||
1029 | ' Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString |
||
1030 | ' Next |
||
1031 | ' End Sub |
||
1032 | |||
1033 | ' Private Sub Procees() |
||
1034 | ' Dim indexes As ListView.SelectedIndexCollection = |
||
1035 | ' Me.ListView_File.SelectedIndices |
||
1036 | ' Dim index As Integer |
||
1037 | |||
1038 | ' For Each index In indexes |
||
1039 | ' 'On Error Resume Next |
||
1040 | ' If folders_path.EndsWith("\") = True Then |
||
1041 | ' On Error GoTo out |
||
1042 | ' Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text) |
||
1043 | ' On Error GoTo out |
||
1044 | ' 'On Error Resume Next |
||
1045 | ' Else |
||
1046 | ' Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text) |
||
1047 | ' On Error GoTo out |
||
1048 | ' End If |
||
1049 | |||
1050 | ' Dim infoReader As System.IO.FileInfo |
||
1051 | ' infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text) |
||
1052 | ' Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString |
||
1053 | ' On Error GoTo out |
||
1054 | ' MsgBox(Me.Status_Main.Items(0).Text + " is processed") |
||
1055 | ' On Error GoTo out |
||
1056 | ' Next |
||
1057 | ' Exit Sub |
||
1058 | 'out: |
||
1059 | ' MsgBox(Err.Description) |
||
1060 | 'End Sub |
||
1061 | 962b2464 | Gyusu | |
1062 | 31d47a80 | Gyusu | Private Function LoadAllDrawing() As DataTable |
1063 | e282643f | Gyusu | |
1064 | |||
1065 | e1cde8f2 | Gyusu | SetListBoxItems(ListBox_Result, "도면정보 로드중....") |
1066 | e282643f | Gyusu | |
1067 | 31d47a80 | Gyusu | Dim oDt As DataTable = Drawing_Dt() |
1068 | e282643f | Gyusu | Dim sHierarchy As String = My.Settings.Plant_Hierarchy |
1069 | |||
1070 | |||
1071 | Dim files() As String |
||
1072 | files = Directory.GetFiles(sHierarchy, "*.pid", SearchOption.AllDirectories) |
||
1073 | For Each FileName As String In files |
||
1074 | Dim sName As String = FileName |
||
1075 | 31d47a80 | Gyusu | Dim oAddRow As DataRow = oDt.NewRow() |
1076 | e282643f | Gyusu | oAddRow("Name") = Path.GetFileNameWithoutExtension(sName) |
1077 | oAddRow("Path") = FileName |
||
1078 | 31d47a80 | Gyusu | oDt.Rows.Add(oAddRow) |
1079 | Next |
||
1080 | Return oDt |
||
1081 | End Function |
||
1082 | |||
1083 | e282643f | Gyusu | Private Function LoadAllDrawing2() As DataTable |
1084 | 31d47a80 | Gyusu | Dim datasource As LMADataSource |
1085 | Dim objPIDAutoApp As Object |
||
1086 | Dim objPIDADrawing As Object |
||
1087 | Dim objDrawing As Object 'Drawing |
||
1088 | 'Dim objDrawing As LMDrawing |
||
1089 | 'Dim objDrawings As LMDrawings |
||
1090 | |||
1091 | datasource = New LMADataSource |
||
1092 | |||
1093 | ' objDrawings = New LMDrawings |
||
1094 | 'objDrawings.Collect(datasource) |
||
1095 | objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
1096 | |||
1097 | For Each objDrawing In objPIDAutoApp.Drawings |
||
1098 | objDrawing.CloseDrawing(True) |
||
1099 | Next |
||
1100 | Try |
||
1101 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("UY1-K-2000_P1_300dpi_0321_TEST_1") |
||
1102 | Catch ex As Exception |
||
1103 | Process.Start("\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid") |
||
1104 | End Try |
||
1105 | |||
1106 | |||
1107 | |||
1108 | Dim sType As Type = objPIDAutoApp.GetType() |
||
1109 | Dim iCount As Integer = 0 |
||
1110 | ' Dim sPath As String = "\\desktop-9vlq0dp\Test02Site\P188943_SPPID_Plant\Plant_Hierarchy\8121\8121-1\188943-8121-PR-DW-011001.pid" |
||
1111 | |||
1112 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("1") |
||
1113 | |||
1114 | For Each objDrawing In objPIDAutoApp.Drawings |
||
1115 | If objDrawing.Attributes("ItemStatus").Index = 1 Then '1 stands for Active |
||
1116 | Try |
||
1117 | |||
1118 | Dim sName As String = objDrawing.Attributes("Name").Value |
||
1119 | |||
1120 | iCount = iCount + 1 |
||
1121 | If sName = "UY1-K-2000_P1_300dpi_0321_TEST_1" Then |
||
1122 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing(objDrawing.Attributes("Name")) |
||
1123 | objPIDADrawing = objPIDAutoApp.Drawings.OpenDrawing("\8121\8121-1\UY1-K-2000_P1_300dpi_0321_TEST_1.pid") |
||
1124 | If Not objPIDADrawing Is Nothing Then |
||
1125 | objPIDADrawing.CloseDrawing() |
||
1126 | End If |
||
1127 | End If |
||
1128 | |||
1129 | |||
1130 | Catch ex As Exception |
||
1131 | |||
1132 | End Try |
||
1133 | |||
1134 | End If |
||
1135 | Next |
||
1136 | objPIDAutoApp.Quit |
||
1137 | objPIDAutoApp = Nothing |
||
1138 | objPIDADrawing = Nothing |
||
1139 | objDrawing = Nothing |
||
1140 | ' objDrawings = Nothing |
||
1141 | e282643f | Gyusu | End Function |
1142 | |||
1143 | 272662f9 | Gyusu | Dim _XMLList As ListView = New ListView() |
1144 | e282643f | Gyusu | |
1145 | 272662f9 | Gyusu | |
1146 | |||
1147 | e1cde8f2 | Gyusu | |
1148 | 171ac39d | Gyusu | |
1149 | |||
1150 | Private Function CheckOpenDrawing() As Boolean |
||
1151 | Try |
||
1152 | |||
1153 | Dim lobjDatasource As Object |
||
1154 | _Placement = CreateObject("Plaice.Placement", "") |
||
1155 | lobjDatasource = _Placement.PIDDataSource |
||
1156 | Return True |
||
1157 | Catch ex As Exception |
||
1158 | Return False |
||
1159 | End Try |
||
1160 | |||
1161 | End Function |
||
1162 | |||
1163 | |||
1164 | Private Sub Btn_Convert_Click(sender As Object, e As EventArgs) Handles Btn_Convert.Click |
||
1165 | |||
1166 | Main_Tab.SelectedIndex = 1 |
||
1167 | ListBox_Result.Items.Clear() |
||
1168 | 9e1e7135 | Gyusu | ' DataGrid_Result.DataSource = New DataTable() |
1169 | 171ac39d | Gyusu | Me.ProgressBar_Status.Visible = True |
1170 | ProgressBar_Status.Maximum = 100 |
||
1171 | ProgressBar_Status.Value = 0 |
||
1172 | ' _selectFolderPath = Tree_XMLFiles.SelectedNode.FullPath.Replace("\\", "\") |
||
1173 | 54b98e09 | Gyusu | _Main_trd = New Thread(AddressOf ThreadConvert) |
1174 | 171ac39d | Gyusu | _Main_trd.IsBackground = True |
1175 | _Main_trd.Start() |
||
1176 | 54b98e09 | Gyusu | FineOPCForm() |
1177 | End Sub |
||
1178 | 171ac39d | Gyusu | |
1179 | 54b98e09 | Gyusu | Private Sub FineOPCForm() |
1180 | _Opc_trd = New Thread(AddressOf ThreadOPCRemove) |
||
1181 | _Opc_trd.IsBackground = True |
||
1182 | _Opc_trd.Start() |
||
1183 | 171ac39d | Gyusu | End Sub |
1184 | 54b98e09 | Gyusu | |
1185 | 7824381a | Gyusu | 'Private Sub ThreadTask() |
1186 | e1cde8f2 | Gyusu | |
1187 | e282643f | Gyusu | |
1188 | 7824381a | Gyusu | ' If _XMLList.Items.Count > 0 Then |
1189 | 31d47a80 | Gyusu | |
1190 | 7824381a | Gyusu | ' Dim oDwg_Dt As DataTable = LoadAllDrawing() |
1191 | ' Dim iDwgCnt As Integer = 0 |
||
1192 | ' Dim objPIDAutoApp As Object |
||
1193 | ' objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
1194 | e282643f | Gyusu | |
1195 | e1cde8f2 | Gyusu | |
1196 | 7824381a | Gyusu | ' Dim myList = DirectCast(Invoke(New GetListViewDelegate(AddressOf GetListViewItems), _XMLList), List(Of String)) |
1197 | ' For i = 0 To myList.Count - 1 |
||
1198 | e1cde8f2 | Gyusu | |
1199 | 7824381a | Gyusu | ' Dim sDwgName As String = Path.GetFileNameWithoutExtension(myList(i)) |
1200 | ' Txt_Status.Text = sDwgName & "..(" & i + 1 & "/" & myList.Count & ")" |
||
1201 | ' SetListBoxItems(ListBox_Result, Txt_Status.Text & " 처리중....") |
||
1202 | ' Dim sDwgNo As String = myList(i) |
||
1203 | ' Dim oDwgPath As String = "" |
||
1204 | ' oDwgPath = _selectFolderPath + "\" + sDwgNo |
||
1205 | e1cde8f2 | Gyusu | |
1206 | 7824381a | Gyusu | ' Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName) |
1207 | ' If sPath <> "" Then |
||
1208 | e1cde8f2 | Gyusu | |
1209 | 7824381a | Gyusu | ' Process.Start(sPath) |
1210 | e1cde8f2 | Gyusu | |
1211 | 7824381a | Gyusu | ' Dim bCheckOpenDrawing As Boolean = False |
1212 | ' While (True) |
||
1213 | ' bCheckOpenDrawing = CheckOpenDrawing() |
||
1214 | ' If bCheckOpenDrawing = True Then |
||
1215 | ' Exit While |
||
1216 | ' Else |
||
1217 | ' Thread.Sleep(2000) |
||
1218 | ' End If |
||
1219 | ' End While |
||
1220 | e1cde8f2 | Gyusu | |
1221 | 7824381a | Gyusu | ' If bCheckOpenDrawing Then |
1222 | ' SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....") |
||
1223 | ' Dim oPipe_Dt As DataTable = New DataTable() 'LoadPipeInXml(oDwgPath) |
||
1224 | e282643f | Gyusu | |
1225 | 7824381a | Gyusu | ' Dim oSymbol_Dt As DataTable = LoadSymbolInXml(oDwgPath) |
1226 | ' Dim oTreeNode As New TreeNode 'SetTreeViewItems(Tree_Result, Tree_Result.Nodes, sDwgName, sDwgName) |
||
1227 | ' 'oTreeNode = Tree_Result.Nodes.Find(sDwgName, True)(0) |
||
1228 | ' Dim action As Action = Sub() |
||
1229 | ' oTreeNode = Tree_Result.Nodes.Add(sDwgName, sDwgName) |
||
1230 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Instruments", "Instuments") |
||
1231 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Pipes", "Pipes") |
||
1232 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Valves", "Valves") |
||
1233 | ' SetTreeViewItems(Tree_Result, oTreeNode.Nodes, sDwgName & "\Fittings", "Fittings") |
||
1234 | ' oTreeNode.ExpandAll() |
||
1235 | ' End Sub |
||
1236 | ' Tree_Result.Invoke(action) |
||
1237 | e1cde8f2 | Gyusu | |
1238 | e282643f | Gyusu | |
1239 | 7824381a | Gyusu | ' ' oTreeNode.Expand() |
1240 | ' SetListBoxItems(ListBox_Result, sDwgName & " Auto converting 대기....") |
||
1241 | ' AutoConverting(oPipe_Dt, oSymbol_Dt, oTreeNode) |
||
1242 | 4f359afa | Gyusu | |
1243 | 7824381a | Gyusu | ' End If |
1244 | |||
1245 | ' End If |
||
1246 | ' ''도면 생성 |
||
1247 | ' 'If CreateDwg(sDwgName) Then |
||
1248 | ' ' 'AutoConverting |
||
1249 | |||
1250 | ' 'End If |
||
1251 | |||
1252 | ' Next |
||
1253 | ' End If |
||
1254 | 'End Sub |
||
1255 | e282643f | Gyusu | |
1256 | 171ac39d | Gyusu | Dim _objPIDAutoApp As Object |
1257 | e282643f | Gyusu | |
1258 | 171ac39d | Gyusu | Private Function OpenSPPID(ByVal oDwg_Dt As DataTable, ByVal sDwgName As String) As Boolean |
1259 | Dim bCheckOpen As Boolean = False |
||
1260 | ' Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgPath) |
||
1261 | SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....") |
||
1262 | _objPIDAutoApp = CreateObject("PIDAutomation.Application") |
||
1263 | e1cde8f2 | Gyusu | |
1264 | 171ac39d | Gyusu | Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName) |
1265 | If sPath <> "" Then |
||
1266 | Process.Start(sPath) |
||
1267 | Else |
||
1268 | Return bCheckOpen |
||
1269 | End If |
||
1270 | |||
1271 | Dim bCheckOpenDrawing As Boolean = False |
||
1272 | While (True) |
||
1273 | bCheckOpenDrawing = CheckOpenDrawing() |
||
1274 | If bCheckOpenDrawing = True Then |
||
1275 | bCheckOpen = True |
||
1276 | Exit While |
||
1277 | Else |
||
1278 | Thread.Sleep(2000) |
||
1279 | End If |
||
1280 | End While |
||
1281 | |||
1282 | |||
1283 | Return bCheckOpen |
||
1284 | End Function |
||
1285 | |||
1286 | Private Function GetDrawing(ByVal sDwgName As String) As Drawing |
||
1287 | For Each CDrawing In _DrawingsList |
||
1288 | 559daf6d | Gyusu | If CDrawing.DwgName.ToUpper() = sDwgName.ToUpper() Then |
1289 | 171ac39d | Gyusu | Return CDrawing |
1290 | End If |
||
1291 | Next |
||
1292 | Return Nothing |
||
1293 | End Function |
||
1294 | |||
1295 | Private Function GetLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no |
||
1296 | For Each CLineNo In CDrawing.Line_nos |
||
1297 | If CLineNo.Uid = sLineNoUid Then |
||
1298 | Return CLineNo |
||
1299 | End If |
||
1300 | Next |
||
1301 | Return Nothing |
||
1302 | End Function |
||
1303 | |||
1304 | 6a6d8ab4 | Gyusu | Private Function GetOnlyPipeLineNo(ByVal CDrawing As Drawing, ByVal sPipeUid As String) As Line_no |
1305 | For Each CLineNo In CDrawing.Line_nos |
||
1306 | Dim odt As DataTable = CLineNo.Dt_Line |
||
1307 | If odt.Rows.Count > 0 Then |
||
1308 | If odt.Rows(0)(_XML_LINE_UID).ToString = sPipeUid Then |
||
1309 | Return CLineNo |
||
1310 | End If |
||
1311 | End If |
||
1312 | Next |
||
1313 | Return Nothing |
||
1314 | End Function |
||
1315 | |||
1316 | |||
1317 | Private Function GetEqpNo(ByVal CDrawing As Drawing, ByVal sEqpUid As String) As Eqp_no |
||
1318 | For Each CEqpNo In CDrawing.Eqp_nos |
||
1319 | If CEqpNo.Uid = sEqpUid Then |
||
1320 | Return CEqpNo |
||
1321 | End If |
||
1322 | Next |
||
1323 | Return Nothing |
||
1324 | End Function |
||
1325 | 9e1e7135 | Gyusu | Private Function ConvertPointBystring(ByVal sPoint As String, ByRef dX As Double, ByRef dY As Double) As Boolean |
1326 | 171ac39d | Gyusu | Try |
1327 | Dim opointstr As String() = Split(sPoint, ",") |
||
1328 | If (opointstr.Length > 1) Then |
||
1329 | If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then |
||
1330 | dX = opointstr(0) |
||
1331 | dY = opointstr(1) |
||
1332 | 9e1e7135 | Gyusu | |
1333 | 171ac39d | Gyusu | Else |
1334 | dX = 0 |
||
1335 | dY = 0 |
||
1336 | Return False |
||
1337 | End If |
||
1338 | End If |
||
1339 | e1cde8f2 | Gyusu | Return True |
1340 | Catch ex As Exception |
||
1341 | Return False |
||
1342 | End Try |
||
1343 | 171ac39d | Gyusu | End Function |
1344 | |||
1345 | 54b98e09 | Gyusu | |
1346 | Dim _DrawLine_Dt As DataTable = DrawLind_Dt() |
||
1347 | |||
1348 | 9e1e7135 | Gyusu | Private Function DrawLine(ByVal sUid As String, ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable) As LMPipeRun |
1349 | 171ac39d | Gyusu | Try |
1350 | Dim oPipeRun As LMPipeRun |
||
1351 | Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" + sUid + "'") |
||
1352 | Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'") |
||
1353 | |||
1354 | If oPipeRow.Length > 0 Then |
||
1355 | Dim oDatasource As Object = _Placement.PIDDataSource |
||
1356 | Dim objItem As LMAItem |
||
1357 | Dim objConnector As LMConnector |
||
1358 | Dim objInputs As PlaceRunInputs |
||
1359 | objInputs = New PlaceRunInputs |
||
1360 | 9e1e7135 | Gyusu | Dim dOriginalStart_x As Double = 0.0 |
1361 | Dim dOriginalStart_y As Double = 0.0 |
||
1362 | Dim dOriginalEnd_x As Double = 0.0 |
||
1363 | Dim dOriginalEnd_y As Double = 0.0 |
||
1364 | 171ac39d | Gyusu | Dim dStart_x As Double = 0.0 |
1365 | Dim dStart_y As Double = 0.0 |
||
1366 | Dim dEnd_x As Double = 0.0 |
||
1367 | Dim dEnd_y As Double = 0.0 |
||
1368 | 54b98e09 | Gyusu | Dim sSystempath As String = "\Piping\Routing\Process Lines\Primary Piping.sym" ' oPipeRow(0)(_XML_LINE_SYSTEMPATH).ToString() |
1369 | 171ac39d | Gyusu | Dim sStartpoint As String = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString() |
1370 | Dim sEndpoint As String = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString() |
||
1371 | 460d6abd | Gyusu | Dim sPipeUid As String = oPipeRow(0)(_XML_LINE_UID).ToString() |
1372 | |||
1373 | 9e1e7135 | Gyusu | ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y) |
1374 | dStart_x = dOriginalStart_x |
||
1375 | dStart_y = dOriginalStart_y |
||
1376 | 460d6abd | Gyusu | |
1377 | 9e1e7135 | Gyusu | If ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y) Then |
1378 | dEnd_x = dOriginalEnd_x |
||
1379 | dEnd_y = dOriginalEnd_y |
||
1380 | 54b98e09 | Gyusu | |
1381 | ' 라인보정(oLine_Dt, sPipeUid, dStart_x, dStart_y, dEnd_x, dEnd_y) |
||
1382 | 460d6abd | Gyusu | '//Overlap 보정 |
1383 | 54b98e09 | Gyusu | 'If FindOverlapLine(oLine_Dt, sPipeUid, dStart_x, dStart_y, dEnd_x, dEnd_y) = False Then |
1384 | ' '//떨어진 라인 보정 |
||
1385 | ' Dim dSeperate_start_x As Double = dStart_x |
||
1386 | ' Dim dSeperate_start_y As Double = dStart_y |
||
1387 | ' Dim dSeperate_end_x As Double = dEnd_x |
||
1388 | ' Dim dSeperate_end_y As Double = dEnd_y |
||
1389 | ' CalcSperateLine(dSeperate_start_x, dSeperate_start_y, dSeperate_end_x, dSeperate_end_y) |
||
1390 | ' If (FindOverlapLine(oLine_Dt, sPipeUid, dSeperate_start_x, dSeperate_start_y, dSeperate_end_x, dSeperate_end_y)) Then |
||
1391 | ' dStart_x = dSeperate_start_x |
||
1392 | ' dStart_y = dSeperate_start_y |
||
1393 | ' dEnd_x = dSeperate_end_x |
||
1394 | ' dEnd_y = dSeperate_end_y |
||
1395 | ' End If |
||
1396 | 'End If |
||
1397 | 460d6abd | Gyusu | |
1398 | ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y) |
||
1399 | 9e1e7135 | Gyusu | ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y) |
1400 | 171ac39d | Gyusu | If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then |
1401 | 460d6abd | Gyusu | |
1402 | 54b98e09 | Gyusu | 'Dim iConnType As Integer = ModelingLine(dStart_x, dStart_y, dEnd_x, dEnd_y) |
1403 | 'If iConnType = 1 Then |
||
1404 | ' objInputs.AddLocatedTarget(dStart_x, dStart_y) |
||
1405 | ' objInputs.AddPoint(dEnd_x, dEnd_y) |
||
1406 | 'ElseIf iConnType = 2 Then |
||
1407 | ' objInputs.AddLocatedTarget(dEnd_x, dEnd_y) |
||
1408 | ' objInputs.AddPoint(dStart_x, dStart_y) |
||
1409 | 'ElseIf iConnType = 3 Then |
||
1410 | ' objInputs.AddLocatedTarget(dEnd_x, dEnd_y) |
||
1411 | ' objInputs.AddPoint(dStart_x, dStart_y) |
||
1412 | 'ElseIf iConnType = 4 Then |
||
1413 | ' objInputs.AddLocatedTarget(dStart_x, dStart_y) |
||
1414 | ' objInputs.AddPoint(dEnd_x, dEnd_y) |
||
1415 | 'Else |
||
1416 | ' objInputs.AddPoint(dStart_x, dStart_y) |
||
1417 | ' objInputs.AddPoint(dEnd_x, dEnd_y) |
||
1418 | 'End If |
||
1419 | 171ac39d | Gyusu | objInputs.AddPoint(dStart_x, dStart_y) |
1420 | objInputs.AddPoint(dEnd_x, dEnd_y) |
||
1421 | 54b98e09 | Gyusu | AddModelingLine(dStart_x, dStart_y, dEnd_x, dEnd_y) |
1422 | 171ac39d | Gyusu | objItem = _Placement.PIDCreateItem(sSystempath) |
1423 | 9e1e7135 | Gyusu | _iPipecnt = _iPipecnt + 1 |
1424 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place PipeLine..(" & dOriginalStart_x & "," & dOriginalStart_y & ") - (" & dOriginalEnd_x & "," & dOriginalEnd_y & ").." & _iPipecnt & " count ") |
1425 | 171ac39d | Gyusu | objConnector = _Placement.PIDPlaceRun(objItem, objInputs) |
1426 | oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID) |
||
1427 | 559daf6d | Gyusu | oPipeRun.Attributes("FlowDirection").Value = "End 1 is upstream (Inlet)" |
1428 | 171ac39d | Gyusu | If oAttributeRow.Length > 0 Then |
1429 | For Each oAttribute In oAttributeRow |
||
1430 | 54b98e09 | Gyusu | Try |
1431 | Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString() |
||
1432 | Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString() |
||
1433 | Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE) |
||
1434 | oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue |
||
1435 | Catch ex As Exception |
||
1436 | |||
1437 | End Try |
||
1438 | |||
1439 | 559daf6d | Gyusu | |
1440 | 171ac39d | Gyusu | Next |
1441 | oPipeRun.Commit() |
||
1442 | End If |
||
1443 | 6a6d8ab4 | Gyusu | 'Flow Direction |
1444 | 'Dim sFlowDirectionPath As String = GetDataFromMappingDB(_XML_CATEGORY_FLOWDIRECITON, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH) |
||
1445 | 'Dim dFlowDirectionAngle As Double = 0.0 |
||
1446 | 'If dStart_y <> dEnd_y Then |
||
1447 | ' If dStart_y > dEnd_y Then |
||
1448 | ' dFlowDirectionAngle = -1.57 |
||
1449 | ' Else |
||
1450 | ' dFlowDirectionAngle = 1.57 |
||
1451 | ' End If |
||
1452 | 'End If |
||
1453 | 'If dStart_x <> dEnd_x Then |
||
1454 | ' If dStart_x > dEnd_x Then |
||
1455 | ' dFlowDirectionAngle = 3.14 |
||
1456 | ' Else |
||
1457 | ' dFlowDirectionAngle = 0 |
||
1458 | ' End If |
||
1459 | 'End If |
||
1460 | |||
1461 | '_Placement.PIDPlaceSymbol(sFlowDirectionPath, dEnd_x, dEnd_y, , dFlowDirectionAngle) |
||
1462 | 171ac39d | Gyusu | End If |
1463 | End If |
||
1464 | e1cde8f2 | Gyusu | |
1465 | 171ac39d | Gyusu | |
1466 | End If |
||
1467 | Return oPipeRun |
||
1468 | Catch ex As Exception |
||
1469 | Return Nothing |
||
1470 | End Try |
||
1471 | e1cde8f2 | Gyusu | End Function |
1472 | |||
1473 | 54b98e09 | Gyusu | Private Sub AddModelingLine(ByVal dStart_x As Double, ByVal dStart_y As Double, ByVal dEnd_x As Double, ByVal dEnd_y As Double) |
1474 | Dim oAddRow = _DrawLine_Dt.NewRow() |
||
1475 | oAddRow(_XML_LINE_STARTPOINT_X) = dStart_x |
||
1476 | oAddRow(_XML_LINE_STARTPOINT_Y) = dStart_y |
||
1477 | oAddRow(_XML_LINE_ENDPOINT_X) = dEnd_x |
||
1478 | oAddRow(_XML_LINE_ENDPOINT_Y) = dEnd_y |
||
1479 | _DrawLine_Dt.Rows.Add(oAddRow) |
||
1480 | End Sub |
||
1481 | |||
1482 | |||
1483 | Private Function ModelingLine(ByVal dStart_x As Double, ByVal dStart_y As Double, ByVal dEnd_x As Double, ByVal dEnd_y As Double) As Integer |
||
1484 | Dim oFindRows_1 As DataRow() = _DrawLine_Dt.Select("start_x = '" & dStart_x & "' and start_y = '" & dStart_y & "'") |
||
1485 | |||
1486 | Dim oFindRows_2 As DataRow() = _DrawLine_Dt.Select("end_x = '" & dEnd_x & "' and end_y = '" & dEnd_y & "'") |
||
1487 | |||
1488 | Dim oFindRows_3 As DataRow() = _DrawLine_Dt.Select("start_x = '" & dEnd_x & "' and start_y = '" & dEnd_y & "'") |
||
1489 | |||
1490 | Dim oFindRows_4 As DataRow() = _DrawLine_Dt.Select("end_x = '" & dStart_x & "' and end_y = '" & dStart_y & "'") |
||
1491 | |||
1492 | If oFindRows_1.Length > 0 Then |
||
1493 | Return 1 |
||
1494 | ElseIf oFindRows_2.Length > 0 Then |
||
1495 | Return 2 |
||
1496 | ElseIf oFindRows_3.Length > 0 Then |
||
1497 | Return 3 |
||
1498 | ElseIf oFindRows_4.Length > 0 Then |
||
1499 | Return 4 |
||
1500 | Else |
||
1501 | Return 0 |
||
1502 | End If |
||
1503 | End Function |
||
1504 | |||
1505 | Private Function FindConnectionPoint(ByVal dX As Double, ByVal dY As Double) |
||
1506 | |||
1507 | |||
1508 | End Function |
||
1509 | |||
1510 | |||
1511 | Private Function DrawSymbol(ByVal sUid As String, ByVal sLineNoUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oLine_Dt As DataTable) As Boolean |
||
1512 | 171ac39d | Gyusu | Try |
1513 | e282643f | Gyusu | |
1514 | 171ac39d | Gyusu | Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'") |
1515 | 6a6d8ab4 | Gyusu | Dim oAttributeRow() As DataRow |
1516 | If oAttribute_Dt.Rows.Count > 0 Then |
||
1517 | 460d6abd | Gyusu | oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'") |
1518 | 6a6d8ab4 | Gyusu | End If |
1519 | |||
1520 | 171ac39d | Gyusu | If oSymbolRow.Length > 0 Then |
1521 | Dim oDatasource As Object = _Placement.PIDDataSource |
||
1522 | Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString() |
||
1523 | Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString() |
||
1524 | 54b98e09 | Gyusu | Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString() |
1525 | 171ac39d | Gyusu | Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString() |
1526 | 9e1e7135 | Gyusu | Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString() |
1527 | 171ac39d | Gyusu | Dim dAngle As Double = 0.0 |
1528 | If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then |
||
1529 | dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) |
||
1530 | End If |
||
1531 | |||
1532 | Dim objSymbol As LMSymbol |
||
1533 | 9e1e7135 | Gyusu | Dim dLocationX As Double = 0.0 |
1534 | Dim dLocationY As Double = 0.0 |
||
1535 | 171ac39d | Gyusu | Dim dX As Double = 0.0 |
1536 | Dim dY As Double = 0.0 |
||
1537 | |||
1538 | 9e1e7135 | Gyusu | If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then |
1539 | dX = dLocationX |
||
1540 | dY = dLocationY |
||
1541 | 54b98e09 | Gyusu | If sSymbolCompType = "" Or sSymbolCompType = "Piping OPC's" Then |
1542 | FindConnectionLine(oLine_Dt, dX, dY) |
||
1543 | End If |
||
1544 | |||
1545 | 9e1e7135 | Gyusu | ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
1546 | 54b98e09 | Gyusu | Dim oInstrument As LMInstrument |
1547 | If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then |
||
1548 | 9e1e7135 | Gyusu | _iInstrumentcnt = _iInstrumentcnt + 1 |
1549 | 171ac39d | Gyusu | objSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1550 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place Instrument..(" & dLocationX & "," & dLocationY & ")..." & _iInstrumentcnt & " count ") |
1551 | 171ac39d | Gyusu | oInstrument = oDatasource.GetInstrument(objSymbol.ModelItemID) |
1552 | 6a6d8ab4 | Gyusu | Try |
1553 | If oAttributeRow.Length > 0 Then |
||
1554 | For Each oAttribute In oAttributeRow |
||
1555 | 54b98e09 | Gyusu | Try |
1556 | Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString() |
||
1557 | Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString() |
||
1558 | Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE) |
||
1559 | oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue |
||
1560 | Catch ex As Exception |
||
1561 | |||
1562 | End Try |
||
1563 | |||
1564 | 6a6d8ab4 | Gyusu | Next |
1565 | oInstrument.Commit() |
||
1566 | End If |
||
1567 | Catch ex As Exception |
||
1568 | End Try |
||
1569 | 54b98e09 | Gyusu | ElseIf sSymbolCompType.ToUpper() = _DB_FITTINGS.ToUpper() Then |
1570 | 9e1e7135 | Gyusu | _iValvecnt = _iValvecnt + 1 |
1571 | 171ac39d | Gyusu | _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1572 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place Valve..(" & dLocationX & "," & dLocationY & ")..." & _iValvecnt & " count ") |
1573 | 171ac39d | Gyusu | |
1574 | 54b98e09 | Gyusu | ElseIf sSymbolCompType.ToUpper() = _SYMBOL_FITTINGS.ToUpper() Then |
1575 | 9e1e7135 | Gyusu | _iFittingcnt = _iFittingcnt + 1 |
1576 | d039e347 | Gyusu | If sSystemPath.Contains(",") Then |
1577 | |||
1578 | Dim sDuplicatePath As String() = sSystemPath.Split(",") |
||
1579 | Dim sMainSymbol As String = "" |
||
1580 | Dim sSubSymbol As String = "" |
||
1581 | For Each sPath In sDuplicatePath |
||
1582 | If sMainSymbol = "" Then |
||
1583 | sMainSymbol = sPath.Replace(vbLf, "") |
||
1584 | Else |
||
1585 | sSubSymbol = sPath.Replace(vbLf, "") |
||
1586 | End If |
||
1587 | Next |
||
1588 | Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle) |
||
1589 | Dim dConnpos_x As Double = 0.0 |
||
1590 | Dim dConnpos_y As Double = 0.0 |
||
1591 | _Placement.PIDConnectPointLocation(oSymbolObj, 2, dConnpos_x, dConnpos_y) |
||
1592 | ' _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y, dAngle, TargetItem:=oSymbolObj.AsLMRepresentation) |
||
1593 | _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y,, dAngle) |
||
1594 | |||
1595 | Else |
||
1596 | _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
||
1597 | End If |
||
1598 | |||
1599 | |||
1600 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ") |
1601 | 54b98e09 | Gyusu | ElseIf sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() And sClass.ToUpper() = _SYMBOL_ACTUATORS.ToUpper() Then |
1602 | d039e347 | Gyusu | _iFittingcnt = _iFittingcnt + 1 |
1603 | Dim sDuplicatePath As String() = sSystemPath.Split(",") |
||
1604 | Dim sMainSymbol As String = "" |
||
1605 | Dim sSubSymbol As String = "" |
||
1606 | For Each sPath In sDuplicatePath |
||
1607 | If sMainSymbol = "" Then |
||
1608 | sMainSymbol = sPath.Replace(vbLf, "") |
||
1609 | Else |
||
1610 | sSubSymbol = sPath.Replace(vbLf, "") |
||
1611 | End If |
||
1612 | Next |
||
1613 | Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle) |
||
1614 | Dim dSymbolpos_x As Double = oSymbolObj.XCoordinate |
||
1615 | Dim dSymbolpos_y As Double = oSymbolObj.YCoordinate |
||
1616 | _Placement.PIDPlaceSymbol(sSubSymbol, dSymbolpos_x, dSymbolpos_y, , dAngle, TargetItem:=oSymbolObj.AsLMAItem) |
||
1617 | |||
1618 | 171ac39d | Gyusu | Else |
1619 | 9e1e7135 | Gyusu | _iFittingcnt = _iFittingcnt + 1 |
1620 | 171ac39d | Gyusu | _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle) |
1621 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ") |
1622 | 54b98e09 | Gyusu | End If |
1623 | |||
1624 | 171ac39d | Gyusu | End If |
1625 | |||
1626 | End If |
||
1627 | |||
1628 | 54b98e09 | Gyusu | Catch ex As Exception |
1629 | Return False |
||
1630 | End Try |
||
1631 | End Function |
||
1632 | |||
1633 | |||
1634 | Private Sub FindConnectionLine(ByVal oLine_Dt As DataTable, ByRef dx As Double, ByRef dy As Double) |
||
1635 | |||
1636 | Try |
||
1637 | For Each oRow In oLine_Dt.Rows |
||
1638 | Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString() |
||
1639 | Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString() |
||
1640 | Dim d기준s_x As Double = 0 |
||
1641 | Dim d기준s_y As Double = 0 |
||
1642 | Dim d기준e_x As Double = 0 |
||
1643 | Dim d기준e_y As Double = 0 |
||
1644 | ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y) |
||
1645 | ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y) |
||
1646 | If dx + 300 > d기준s_x And dx - 300 < d기준s_x And dy + 300 > d기준s_y And dy - 300 < d기준s_y Then |
||
1647 | dx = d기준s_x |
||
1648 | dy = d기준s_y |
||
1649 | ElseIf dx + 300 > d기준e_x And dx - 300 < d기준e_x And dy + 300 > d기준e_y And dy - 300 < d기준e_y Then |
||
1650 | dx = d기준e_x |
||
1651 | dy = d기준e_y |
||
1652 | End If |
||
1653 | Next |
||
1654 | Catch ex As Exception |
||
1655 | End Try |
||
1656 | End Sub |
||
1657 | |||
1658 | |||
1659 | Dim _라인보정기준값 As Integer = 10 |
||
1660 | |||
1661 | Private Function 라인보정(ByRef oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double, |
||
1662 | ByRef dex As Double, ByRef dey As Double) |
||
1663 | Try |
||
1664 | Dim bCheck라인 As Boolean = False |
||
1665 | '일치하는 Line 찾기 |
||
1666 | For Each oRow In oLine_Dt.Rows |
||
1667 | Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString() |
||
1668 | Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString() |
||
1669 | Dim sBUid As String = oRow(_XML_LINE_UID).ToString() |
||
1670 | If sBUid <> sUid Then |
||
1671 | Dim d기준s_x As Double = 0 |
||
1672 | Dim d기준s_y As Double = 0 |
||
1673 | Dim d기준e_x As Double = 0 |
||
1674 | Dim d기준e_y As Double = 0 |
||
1675 | ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y) |
||
1676 | ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y) |
||
1677 | |||
1678 | If (dsx = d기준s_x And dsy = d기준s_y) Or (dsx = d기준e_x And dsy = d기준e_y) Or |
||
1679 | (dex = d기준s_x And dey = d기준s_y) Or (dex = d기준e_x And dey = d기준e_y) Then |
||
1680 | bCheck라인 = True |
||
1681 | End If |
||
1682 | End If |
||
1683 | Next |
||
1684 | |||
1685 | If bCheck라인 = False Then |
||
1686 | For Each oRow In oLine_Dt.Rows |
||
1687 | Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString() |
||
1688 | Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString() |
||
1689 | Dim sBUid As String = oRow(_XML_LINE_UID).ToString() |
||
1690 | If sBUid <> sUid Then |
||
1691 | Dim d기준s_x As Double = 0 |
||
1692 | Dim d기준s_y As Double = 0 |
||
1693 | Dim d기준e_x As Double = 0 |
||
1694 | Dim d기준e_y As Double = 0 |
||
1695 | ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y) |
||
1696 | ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y) |
||
1697 | If ((dsx - _라인보정기준값 <= d기준s_x And dsx + _라인보정기준값 >= d기준s_x) And (dsy - _라인보정기준값 <= d기준s_y And dsy + _라인보정기준값 >= d기준s_y)) Then |
||
1698 | oRow(_XML_LINE_STARTPOINT) = dsx & "," & dsy |
||
1699 | bCheck라인 = True |
||
1700 | Exit For |
||
1701 | ElseIf ((dsx - _라인보정기준값 <= d기준e_x And dsx + _라인보정기준값 >= d기준e_x) And (dsy - _라인보정기준값 <= d기준e_y And dsy + _라인보정기준값 >= d기준e_y)) Then |
||
1702 | oRow(_XML_LINE_ENDPOINT) = dsx & "," & dsy |
||
1703 | bCheck라인 = True |
||
1704 | Exit For |
||
1705 | ElseIf ((dex - _라인보정기준값 <= d기준s_x And dex + _라인보정기준값 >= d기준s_x) And (dey - _라인보정기준값 <= d기준s_y And dey + _라인보정기준값 >= d기준s_y)) Then |
||
1706 | oRow(_XML_LINE_STARTPOINT) = dex & "," & dey |
||
1707 | bCheck라인 = True |
||
1708 | Exit For |
||
1709 | ElseIf ((dex - _라인보정기준값 <= d기준e_x And dex + _라인보정기준값 >= d기준e_x) And (dey - _라인보정기준값 <= d기준e_y And dey + _라인보정기준값 >= d기준e_y)) Then |
||
1710 | oRow(_XML_LINE_ENDPOINT) = dex & "," & dey |
||
1711 | bCheck라인 = True |
||
1712 | Exit For |
||
1713 | End If |
||
1714 | |||
1715 | End If |
||
1716 | Next |
||
1717 | 171ac39d | Gyusu | End If |
1718 | |||
1719 | 54b98e09 | Gyusu | Return bCheck라인 |
1720 | 171ac39d | Gyusu | Catch ex As Exception |
1721 | Return False |
||
1722 | End Try |
||
1723 | 54b98e09 | Gyusu | |
1724 | |||
1725 | 171ac39d | Gyusu | End Function |
1726 | |||
1727 | 460d6abd | Gyusu | Private Function FindOverlapLine(ByVal oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double, |
1728 | ByRef dex As Double, ByRef dey As Double) |
||
1729 | Try |
||
1730 | Dim bCheckOverlap As Boolean = False |
||
1731 | For Each oRow In oLine_Dt.Rows |
||
1732 | Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString() |
||
1733 | Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString() |
||
1734 | Dim sBUid As String = oRow(_XML_LINE_UID).ToString() |
||
1735 | If sBUid <> sUid Then |
||
1736 | Dim d기준s_x As Double = 0 |
||
1737 | Dim d기준s_y As Double = 0 |
||
1738 | Dim d기준e_x As Double = 0 |
||
1739 | Dim d기준e_y As Double = 0 |
||
1740 | ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y) |
||
1741 | ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y) |
||
1742 | 54b98e09 | Gyusu | If (d기준s_x <= dsx And d기준e_x >= dex And |
1743 | d기준s_y <= dsy And d기준e_y >= dey) Then |
||
1744 | 460d6abd | Gyusu | '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정 |
1745 | If dsy - d기준s_y > d기준e_y - dey Then |
||
1746 | Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100 |
||
1747 | If dResultCalc < 10 Then |
||
1748 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1749 | Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y) |
||
1750 | Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x) |
||
1751 | Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX |
||
1752 | If dCalcStartY = 0 Then |
||
1753 | dey = d기준e_y |
||
1754 | Else |
||
1755 | dey = dCalcStartY |
||
1756 | End If |
||
1757 | End If |
||
1758 | Else |
||
1759 | abb01e6c | Gyusu | ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100 |
1760 | Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100 |
||
1761 | 460d6abd | Gyusu | If dResultCalc < 10 Then |
1762 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1763 | Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y) |
||
1764 | Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x) |
||
1765 | Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX |
||
1766 | If dCalcStartY = 0 Then |
||
1767 | dsy = d기준s_y |
||
1768 | Else |
||
1769 | dsy = dCalcStartY |
||
1770 | End If |
||
1771 | End If |
||
1772 | End If |
||
1773 | bCheckOverlap = True |
||
1774 | ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And |
||
1775 | d기준s_y <= dey And d기준e_y >= dsy Then |
||
1776 | '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정 |
||
1777 | If dey - d기준s_y > d기준e_y - dsy Then |
||
1778 | Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100 |
||
1779 | If dResultCalc < 10 Then |
||
1780 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1781 | Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y) |
||
1782 | Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x) |
||
1783 | Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX |
||
1784 | If dCalcStartY = 0 Then |
||
1785 | abb01e6c | Gyusu | dsy = d기준e_y |
1786 | 460d6abd | Gyusu | Else |
1787 | abb01e6c | Gyusu | dsy = dCalcStartY |
1788 | 460d6abd | Gyusu | End If |
1789 | |||
1790 | End If |
||
1791 | '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정 |
||
1792 | Else |
||
1793 | abb01e6c | Gyusu | ' Dim dResultCalc As Double = (Math.Abs((dsy - d기준s_y)) / Math.Abs((d기준e_y - dey))) * 100 |
1794 | Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100 |
||
1795 | 460d6abd | Gyusu | If dResultCalc < 10 Then |
1796 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1797 | Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y) |
||
1798 | Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x) |
||
1799 | Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX |
||
1800 | If dCalcStartY = 0 Then |
||
1801 | abb01e6c | Gyusu | dey = d기준e_y |
1802 | 460d6abd | Gyusu | Else |
1803 | abb01e6c | Gyusu | dey = dCalcStartY |
1804 | 460d6abd | Gyusu | End If |
1805 | End If |
||
1806 | End If |
||
1807 | bCheckOverlap = True |
||
1808 | ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And |
||
1809 | d기준s_y <= dey And d기준e_y >= dsy Then |
||
1810 | |||
1811 | If dsx - d기준s_x > d기준e_x - dex Then |
||
1812 | Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100 |
||
1813 | If dResultCalc < 10 Then |
||
1814 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1815 | Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y) |
||
1816 | Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y) |
||
1817 | Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY |
||
1818 | If dCalcStartX = 0 Then |
||
1819 | dex = d기준e_x |
||
1820 | Else |
||
1821 | dex = dCalcStartX |
||
1822 | End If |
||
1823 | End If |
||
1824 | Else |
||
1825 | abb01e6c | Gyusu | ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100 |
1826 | Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100 |
||
1827 | 460d6abd | Gyusu | If dResultCalc < 10 Then |
1828 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1829 | Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y) |
||
1830 | Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y) |
||
1831 | Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY |
||
1832 | If dCalcStartX = 0 Then |
||
1833 | dsx = d기준s_x |
||
1834 | Else |
||
1835 | dsx = dCalcStartX |
||
1836 | End If |
||
1837 | End If |
||
1838 | End If |
||
1839 | bCheckOverlap = True |
||
1840 | ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And |
||
1841 | d기준s_y <= dey And d기준e_y >= dsy Then |
||
1842 | |||
1843 | If dex - d기준s_x > d기준e_x - dsx Then |
||
1844 | Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100 |
||
1845 | If dResultCalc < 10 Then |
||
1846 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1847 | Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y) |
||
1848 | Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y) |
||
1849 | Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY |
||
1850 | If dCalcStartX = 0 Then |
||
1851 | abb01e6c | Gyusu | dsx = d기준e_x |
1852 | 460d6abd | Gyusu | Else |
1853 | abb01e6c | Gyusu | dsx = dCalcStartX |
1854 | 460d6abd | Gyusu | End If |
1855 | End If |
||
1856 | Else |
||
1857 | abb01e6c | Gyusu | ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100 |
1858 | Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100 |
||
1859 | 460d6abd | Gyusu | If dResultCalc < 10 Then |
1860 | Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x) |
||
1861 | Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y) |
||
1862 | Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y) |
||
1863 | Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY |
||
1864 | If dCalcStartX = 0 Then |
||
1865 | abb01e6c | Gyusu | dex = d기준s_x |
1866 | 460d6abd | Gyusu | Else |
1867 | abb01e6c | Gyusu | dex = dCalcStartX |
1868 | 460d6abd | Gyusu | End If |
1869 | End If |
||
1870 | |||
1871 | End If |
||
1872 | bCheckOverlap = True |
||
1873 | End If |
||
1874 | End If |
||
1875 | Next |
||
1876 | Return bCheckOverlap |
||
1877 | Catch ex As Exception |
||
1878 | Return False |
||
1879 | End Try |
||
1880 | End Function |
||
1881 | |||
1882 | Private Sub CalcSperateLine(ByRef dStartX As Double, ByRef dStartY As Double, |
||
1883 | ByRef dEndX As Double, ByRef dEndY As Double) |
||
1884 | Try |
||
1885 | 54b98e09 | Gyusu | Dim dRange As Double = 1 'Line 전체 길이의 10%씩 늘이기 |
1886 | 460d6abd | Gyusu | If Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then |
1887 | 54b98e09 | Gyusu | Dim dCalc_x As Double = Math.Abs(dStartX - dEndX) * 0.1 |
1888 | 460d6abd | Gyusu | If dStartX > dEndX Then |
1889 | dStartX = dStartX + dCalc_x |
||
1890 | dEndX = dEndX - dCalc_x |
||
1891 | Else |
||
1892 | dEndX = dEndX + dCalc_x |
||
1893 | dStartX = dStartX - dCalc_x |
||
1894 | End If |
||
1895 | Else |
||
1896 | 54b98e09 | Gyusu | Dim dCalc_y As Double = Math.Abs(dStartY - dEndY) * 0.1 |
1897 | 460d6abd | Gyusu | If dStartY > dEndY Then |
1898 | dStartY = dStartY + dCalc_y |
||
1899 | dEndY = dEndY - dCalc_y |
||
1900 | Else |
||
1901 | dEndY = dEndY + dCalc_y |
||
1902 | dStartY = dStartY - dCalc_y |
||
1903 | End If |
||
1904 | End If |
||
1905 | |||
1906 | |||
1907 | |||
1908 | Catch ex As Exception |
||
1909 | |||
1910 | End Try |
||
1911 | |||
1912 | |||
1913 | End Sub |
||
1914 | |||
1915 | 171ac39d | Gyusu | Private Function DrawLineNo(ByVal oPiperun As LMPipeRun, ByVal CLine_No As Line_no) As Boolean |
1916 | Try |
||
1917 | Dim oDatasource As Object = _Placement.PIDDataSource |
||
1918 | Dim sLocation = CLine_No.Location |
||
1919 | 9e1e7135 | Gyusu | Dim dLocationx As Double = 0.0 |
1920 | Dim dLocationy As Double = 0.0 |
||
1921 | |||
1922 | 171ac39d | Gyusu | Dim dX As Double = 0.0 |
1923 | Dim dY As Double = 0.0 |
||
1924 | 9e1e7135 | Gyusu | If ConvertPointBystring(sLocation, dLocationx, dLocationy) Then |
1925 | dX = dLocationx |
||
1926 | dY = dLocationy |
||
1927 | ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y) |
||
1928 | 171ac39d | Gyusu | Dim dLineNoLocation(2) As Double |
1929 | dLineNoLocation(1) = dX |
||
1930 | dLineNoLocation(2) = dY |
||
1931 | 'Label |
||
1932 | Dim sSystemPath As String = CLine_No.SystemPath |
||
1933 | 9e1e7135 | Gyusu | Dim dAngle As Double = CLine_No.Angle |
1934 | 171ac39d | Gyusu | Dim labelpersist As LMLabelPersist |
1935 | |||
1936 | For Each representation In oPiperun.Representations |
||
1937 | If representation.RepresentationType = "Connector" Then |
||
1938 | labelpersist = _Placement.PIDPlaceLabel(sSystemPath, |
||
1939 | 9e1e7135 | Gyusu | dLineNoLocation,, dAngle, LabeledItem:=representation) |
1940 | _iPipeLineNocnt = _iPipeLineNocnt + 1 |
||
1941 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place PipeLineNo Label..(" & dLocationx & "," & dLocationy & ")..." & _iPipeLineNocnt & " count ") |
1942 | 171ac39d | Gyusu | End If |
1943 | Next |
||
1944 | Return True |
||
1945 | Else |
||
1946 | Return False |
||
1947 | End If |
||
1948 | |||
1949 | Catch ex As Exception |
||
1950 | Return False |
||
1951 | End Try |
||
1952 | End Function |
||
1953 | |||
1954 | 9e1e7135 | Gyusu | |
1955 | Private Sub InitItemCount() |
||
1956 | _iPipeLineNocnt = 0 |
||
1957 | _iPipecnt = 0 |
||
1958 | _iFittingcnt = 0 |
||
1959 | _iValvecnt = 0 |
||
1960 | _iInstrumentcnt = 0 |
||
1961 | _iEquipmentcnt = 0 |
||
1962 | _iNozzlecnt = 0 |
||
1963 | End Sub |
||
1964 | 171ac39d | Gyusu | |
1965 | 54b98e09 | Gyusu | |
1966 | |||
1967 | 171ac39d | Gyusu | Private Function AutoModeling() As Boolean |
1968 | Try |
||
1969 | 54b98e09 | Gyusu | _CompleteConvert = False |
1970 | 171ac39d | Gyusu | SetListBoxItems(ListBox_Result, " Auto converting 시작....") |
1971 | Dim oDwg_Dt As DataTable = LoadAllDrawing() |
||
1972 | For Each oDrwing As TreeNode In Tree_Result.Nodes |
||
1973 | For Each oDwgNode As TreeNode In oDrwing.Nodes |
||
1974 | Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text) |
||
1975 | 54b98e09 | Gyusu | Dim CDrawing As Drawing = GetDrawing(sDwgName) |
1976 | If CDrawing IsNot Nothing Then |
||
1977 | 9e1e7135 | Gyusu | If OpenSPPID(oDwg_Dt, oDwgNode.Text) Then |
1978 | InitItemCount() |
||
1979 | Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode) |
||
1980 | Dim iLineNoCount As Integer = 0 ' GetCheckNodeCount(oLinenoNode) |
||
1981 | 6a6d8ab4 | Gyusu | SetListBoxItems(ListBox_Result, "Place " & CDrawing.DwgName & "....") |
1982 | For Each oNode As TreeNode In oDwgNode.Nodes |
||
1983 | 54b98e09 | Gyusu | Dim iItemcnt As Integer = 0 |
1984 | 6a6d8ab4 | Gyusu | Dim sNodeUid As String = oNode.Name |
1985 | If sNodeUid <> "PipeLineNo" Then |
||
1986 | Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid) |
||
1987 | If CLineNo IsNot Nothing Then |
||
1988 | 54b98e09 | Gyusu | Dim oPipeRun As LMPipeRun = Nothing |
1989 | 6a6d8ab4 | Gyusu | Dim oLine_Dt As DataTable = CLineNo.Dt_Line |
1990 | Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol |
||
1991 | Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute |
||
1992 | Dim oDrawLinenoLabel As Boolean = False |
||
1993 | For Each oLineNode As TreeNode In oNode.Nodes |
||
1994 | 54b98e09 | Gyusu | iItemcnt = iItemcnt + 1 |
1995 | 6a6d8ab4 | Gyusu | Dim sLineUid As String = oLineNode.Name |
1996 | If oLineNode.Checked Then |
||
1997 | Dim sUid As String = oLineNode.Name |
||
1998 | If oLine_Dt.Select("[" & _XML_LINE_UID & "]= '" & sUid & "'").Length = 1 Then |
||
1999 | oPipeRun = DrawLine(sUid, sNodeUid, oLine_Dt, oAttribute_Dt) |
||
2000 | End If |
||
2001 | 54b98e09 | Gyusu | If oDrawLinenoLabel = False Then |
2002 | DrawLineNo(oPipeRun, CLineNo) |
||
2003 | End If |
||
2004 | oDrawLinenoLabel = True |
||
2005 | 6a6d8ab4 | Gyusu | End If |
2006 | 54b98e09 | Gyusu | 'If oNode.Nodes.Count - 1 = iItemcnt And oDrawLinenoLabel Then |
2007 | ' DrawLineNo(oPipeRun, CLineNo) |
||
2008 | 'End If |
||
2009 | 6a6d8ab4 | Gyusu | Next |
2010 | For Each oSymbolNode As TreeNode In oNode.Nodes |
||
2011 | If oSymbolNode.Checked Then |
||
2012 | Dim sUid As String = oSymbolNode.Name |
||
2013 | If oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sUid & "'").Length = 1 Then |
||
2014 | 54b98e09 | Gyusu | DrawSymbol(sUid, sNodeUid, oSymbol_Dt, oAttribute_Dt, CLineNo.Dt_Line) |
2015 | 6a6d8ab4 | Gyusu | End If |
2016 | End If |
||
2017 | Next |
||
2018 | iLineNoCount = iLineNoCount + 1 |
||
2019 | End If |
||
2020 | Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid) |
||
2021 | If CEqpNo IsNot Nothing Then |
||
2022 | Dim oSymbol_Dt As DataTable = CEqpNo.Dt_Equipment |
||
2023 | Dim oAttribute_Dt As DataTable = CEqpNo.Dt_Attribute |
||
2024 | For Each oSymbolNode As TreeNode In oNode.Nodes |
||
2025 | If oSymbolNode.Checked Then |
||
2026 | Dim sUid As String = oSymbolNode.Name |
||
2027 | 54b98e09 | Gyusu | DrawSymbol(sUid, sNodeUid, oSymbol_Dt, oAttribute_Dt, CLineNo.Dt_Line) |
2028 | 6a6d8ab4 | Gyusu | End If |
2029 | Next |
||
2030 | End If |
||
2031 | Else |
||
2032 | 171ac39d | Gyusu | Dim oDrawLinenoLabel As Boolean = False |
2033 | 6a6d8ab4 | Gyusu | For Each oLineNode As TreeNode In oNode.Nodes |
2034 | Dim CLineNo As Line_no = GetOnlyPipeLineNo(CDrawing, oLineNode.Name) |
||
2035 | Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute |
||
2036 | Dim oLine_Dt As DataTable = CLineNo.Dt_Line |
||
2037 | 9e1e7135 | Gyusu | Dim sLineUid As String = oLineNode.Name |
2038 | If oLineNode.Checked Then |
||
2039 | Dim sUid As String = oLineNode.Name |
||
2040 | 6a6d8ab4 | Gyusu | DrawLine(sUid, sNodeUid, oLine_Dt, oAttribute_Dt) |
2041 | 171ac39d | Gyusu | End If |
2042 | 9e1e7135 | Gyusu | Next |
2043 | End If |
||
2044 | Next |
||
2045 | 171ac39d | Gyusu | End If |
2046 | 9e1e7135 | Gyusu | End If |
2047 | 171ac39d | Gyusu | Next |
2048 | Next |
||
2049 | SetProgressbar(ProgressBar_Status, 100) |
||
2050 | SetListBoxItems(ListBox_Result, " Auto converting 완료") |
||
2051 | 54b98e09 | Gyusu | _CompleteConvert = True |
2052 | 171ac39d | Gyusu | Return True |
2053 | Catch ex As Exception |
||
2054 | Return False |
||
2055 | End Try |
||
2056 | End Function |
||
2057 | |||
2058 | |||
2059 | |||
2060 | 54b98e09 | Gyusu | Private Sub ThreadConvert() |
2061 | 559daf6d | Gyusu | If _DrawingsList IsNot Nothing Then |
2062 | If _DrawingsList.Count > 0 Then |
||
2063 | AutoModeling() |
||
2064 | End If |
||
2065 | 171ac39d | Gyusu | End If |
2066 | e282643f | Gyusu | End Sub |
2067 | |||
2068 | 54b98e09 | Gyusu | Private Sub ThreadOPCRemove() |
2069 | While _CompleteConvert = False |
||
2070 | Dim oFindOPC As New FindOpc |
||
2071 | oFindOPC.RemoveOPCDlg() |
||
2072 | End While |
||
2073 | e282643f | Gyusu | |
2074 | 54b98e09 | Gyusu | End Sub |
2075 | 171ac39d | Gyusu | |
2076 | e282643f | Gyusu | |
2077 | Private Function OpenDrawing(ByVal oDt As DataTable, ByVal sDwgName As String) As String |
||
2078 | Dim oRows As DataRow() = oDt.Select("[Name] = '" & sDwgName & "'") |
||
2079 | Dim oPath As String = "" |
||
2080 | If oRows.Length > 0 Then |
||
2081 | oPath = oRows(0).Item("Path").ToString() |
||
2082 | End If |
||
2083 | Return oPath |
||
2084 | End Function |
||
2085 | |||
2086 | 272662f9 | Gyusu | Private Sub LoadXmlToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadXmlToolStripMenuItem.Click |
2087 | 171ac39d | Gyusu | If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then |
2088 | 54b98e09 | Gyusu | LoadDB() |
2089 | 171ac39d | Gyusu | LoadXmlItem(FolderBrowserDialog1.SelectedPath) |
2090 | End If |
||
2091 | End Sub |
||
2092 | Private Sub LoadXmlItem(ByVal sFolderPath As String) |
||
2093 | _DrawingsList = New List(Of Drawing) |
||
2094 | Dim sfileEntries As String() = Directory.GetFiles(sFolderPath) |
||
2095 | If Tree_Result.Nodes.Count > 0 Then |
||
2096 | Tree_Result.Nodes(0).Nodes.Clear() |
||
2097 | For Each sfileName In sfileEntries |
||
2098 | Dim sExtension As String = Path.GetExtension(sfileName) |
||
2099 | If sExtension = ".xml" Then |
||
2100 | Dim sDwgName As String = Path.GetFileNameWithoutExtension(sfileName) |
||
2101 | Dim sDwgPath As String = sfileName |
||
2102 | Dim oNode As TreeNode = Tree_Result.Nodes(0).Nodes.Add(sDwgPath, sDwgName, 15) |
||
2103 | Dim oDwg As Drawing = AddSymbolItem(sDwgPath, oNode) |
||
2104 | _DrawingsList.Add(oDwg) |
||
2105 | End If |
||
2106 | Next |
||
2107 | Tree_Result.Nodes(0).Expand() |
||
2108 | End If |
||
2109 | End Sub |
||
2110 | 272662f9 | Gyusu | |
2111 | |||
2112 | 20c84e05 | Gyusu | ''' <summary> |
2113 | ''' XML Tree 구조 생성 |
||
2114 | ''' </summary> |
||
2115 | ''' <param name="sDwgPath"></param> |
||
2116 | 171ac39d | Gyusu | Private Function AddSymbolItem(ByVal sDwgPath As String, ByVal oParentNode As TreeNode) As Drawing |
2117 | Dim oDwg_Ds As Drawing = LoadSymbolInXml(sDwgPath) |
||
2118 | 54b98e09 | Gyusu | If oDwg_Ds IsNot Nothing Then |
2119 | Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos |
||
2120 | |||
2121 | Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos |
||
2122 | Dim oPipe As Boolean = False |
||
2123 | Dim oFitting As Boolean = False |
||
2124 | Dim oOnlyPipesNode As TreeNode |
||
2125 | Dim oOnlyFittingsNode As TreeNode |
||
2126 | 'PipeLine 구분 |
||
2127 | |||
2128 | For Each oLinelist In oLineLists |
||
2129 | Dim sLineNoUid As String = oLinelist.Uid |
||
2130 | Dim sLineNo As String = oLinelist.Text |
||
2131 | Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo) |
||
2132 | For Each oLineRow In oLinelist.Dt_Line.Rows |
||
2133 | Dim sLineUid As String = oLineRow(_XML_LINE_UID) |
||
2134 | Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe") |
||
2135 | oPipeNode.Tag = sLineNoUid |
||
2136 | Next |
||
2137 | For Each oSymbolRow In oLinelist.Dt_Symbol.Rows |
||
2138 | Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
||
2139 | Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
||
2140 | Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName) |
||
2141 | oSymbolNode.Tag = sLineNoUid |
||
2142 | Next |
||
2143 | 'If sLineNo <> "PipeLineNo" Then |
||
2144 | 20c84e05 | Gyusu | |
2145 | 54b98e09 | Gyusu | 'Else |
2146 | ' 'If oPipe = False Then |
||
2147 | ' ' oOnlyPipesNode = oParentNode.Nodes.Add("PipeLineNo", "PipeLineNo") |
||
2148 | ' ' oPipe = True |
||
2149 | ' 'End If |
||
2150 | ' 'For Each oLineRow In oLinelist.Dt_Line.Rows |
||
2151 | ' ' Dim sLineUid As String = oLineRow(_XML_SYMBOL_UID) |
||
2152 | ' ' Dim oPipeNode As TreeNode = oOnlyPipesNode.Nodes.Add(sLineUid, "Pipe") |
||
2153 | ' ' oPipeNode.Tag = sLineNoUid |
||
2154 | ' 'Next |
||
2155 | 6a6d8ab4 | Gyusu | |
2156 | 272662f9 | Gyusu | |
2157 | 6a6d8ab4 | Gyusu | |
2158 | |||
2159 | 54b98e09 | Gyusu | 'End If |
2160 | Next |
||
2161 | 'For Each oSymbolRow In _TempSymbolDt.Rows |
||
2162 | ' If oFitting = False Then |
||
2163 | ' oOnlyFittingsNode = oParentNode.Nodes.Add("Symbols", "Symbols") |
||
2164 | ' oFitting = True |
||
2165 | ' End If |
||
2166 | ' Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
||
2167 | ' Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
||
2168 | ' Dim oSymbolNode As TreeNode = oOnlyFittingsNode.Nodes.Add(sSymbolUid, sSymbolName) |
||
2169 | ' oSymbolNode.Tag = sSymbolUid |
||
2170 | 'Next |
||
2171 | For Each oEqplist In oEqpLists |
||
2172 | Dim sEqpUid As String = oEqplist.Uid |
||
2173 | Dim sEqpNo As String = "EQUIPMENT" |
||
2174 | Dim oEqpNode As TreeNode = oParentNode.Nodes.Add(sEqpUid, sEqpNo) |
||
2175 | d039e347 | Gyusu | |
2176 | 54b98e09 | Gyusu | |
2177 | For Each oSymbolRow In oEqplist.Dt_Equipment.Rows |
||
2178 | Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID) |
||
2179 | Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME) |
||
2180 | Dim oSymbolNode As TreeNode = oEqpNode.Nodes.Add(sSymbolUid, sSymbolName) |
||
2181 | oSymbolNode.Tag = sEqpUid |
||
2182 | Next |
||
2183 | 171ac39d | Gyusu | Next |
2184 | 54b98e09 | Gyusu | End If |
2185 | |||
2186 | 171ac39d | Gyusu | Return oDwg_Ds |
2187 | End Function |
||
2188 | 272662f9 | Gyusu | Private Sub Tree_Result_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_Result.AfterCheck |
2189 | If e.Node.Checked = True Then |
||
2190 | For Each oNode As TreeNode In e.Node.Nodes |
||
2191 | oNode.Checked = True |
||
2192 | Next |
||
2193 | Else |
||
2194 | For Each oNode As TreeNode In e.Node.Nodes |
||
2195 | oNode.Checked = False |
||
2196 | Next |
||
2197 | End If |
||
2198 | End Sub |
||
2199 | 171ac39d | Gyusu | |
2200 | 559daf6d | Gyusu | Private Sub Btn_Setting_Click(sender As Object, e As EventArgs) Handles Btn_Setting.Click |
2201 | Dim oSettings As Settings = New Settings() |
||
2202 | oSettings.ShowDialog() |
||
2203 | End Sub |
||
2204 | 42c0013c | Gyusu | |
2205 | Private Sub Btn_TestNozzle_Click(sender As Object, e As EventArgs) Handles Btn_TestNozzle.Click |
||
2206 | |||
2207 | Dim sVessel_ID As String = "841D5E640AE5421B9A017DDC2E87FF11" |
||
2208 | Dim objVessel As LMVessel |
||
2209 | objVessel = _Placement.PIDDataSource.GetVessel(sVessel_ID) |
||
2210 | Dim oVesselLocation As LMLocations = objVessel.Locations |
||
2211 | Dim symVessel As LMSymbol = _Placement.PIDDataSource.GetSymbol(objVessel.Representations.Nth(1).Id) |
||
2212 | Dim XCoordinate As String = symVessel.Attributes("XCoordinate").Value |
||
2213 | Dim YCoordinate As String = symVessel.Attributes("YCoordinate").Value |
||
2214 | symVessel.Attributes("XCoordinate").Value = XCoordinate + 0.01 |
||
2215 | symVessel.Attributes("YCoordinate").Value = YCoordinate + 0.01 |
||
2216 | symVessel.Commit() |
||
2217 | Dim sValve_ID As String = "DB7B0CA8A2664A6BA7A9615764BA62B0" |
||
2218 | Dim objValve As LMSymbol |
||
2219 | Dim objValves As LMPipingComp = _Placement.PIDDataSource.GetPipingComp(sValve_ID) |
||
2220 | |||
2221 | objValve = _Placement.PIDDataSource.GetSymbol(objValves.Representations.Nth(1).Id) |
||
2222 | objValve.Commit() |
||
2223 | Dim dVesselX As Double = XCoordinate |
||
2224 | Dim dVesselY As Double = YCoordinate |
||
2225 | Dim X1 As Double, Y1 As Double, X2 As Double, Y2 As Double |
||
2226 | |||
2227 | _Placement.PIDConnectPointLocation(objValve, 1, X1, Y1) |
||
2228 | |||
2229 | _Placement.PIDConnectPointLocation(objValve, 2, X2, Y2) |
||
2230 | |||
2231 | Dim nozzlename As String = "\Equipment Components\Nozzles\Flanged Nozzle.sym" |
||
2232 | Dim dCalc_x As Double = 0 |
||
2233 | Dim dCalc_y As Double = 0 |
||
2234 | |||
2235 | If dVesselX - X2 > 0 Then |
||
2236 | dCalc_x = dVesselX - (dVesselX - X2) |
||
2237 | Else |
||
2238 | dCalc_x = dVesselX + (X2 - dVesselX) |
||
2239 | End If |
||
2240 | If dVesselY - Y2 > 0 Then |
||
2241 | dCalc_y = dVesselY - (dVesselY - Y2) |
||
2242 | Else |
||
2243 | dCalc_y = dVesselY + (Y2 - dVesselY) |
||
2244 | End If |
||
2245 | |||
2246 | Dim objNozzle As LMSymbol = _Placement.PIDPlaceSymbol(nozzlename, dCalc_x, dCalc_y, |
||
2247 | TargetItem:=symVessel.AsLMRepresentation) |
||
2248 | |||
2249 | Dim blnSuccess As Boolean = _Placement.PIDConnectPointLocation(objNozzle, 1, X1, Y1) |
||
2250 | blnSuccess = _Placement.PIDConnectPointLocation(objNozzle, 2, X1, Y1) |
||
2251 | |||
2252 | objValve = _Placement.PIDPlaceSymbol(objValve.FileName, X1, Y1, ExistingItem:=objValve.AsLMAItem, |
||
2253 | TargetItem:=objNozzle.AsLMRepresentation) |
||
2254 | |||
2255 | |||
2256 | |||
2257 | End Sub |
||
2258 | 39d43554 | Gyusu | |
2259 | Private Sub Btn_SymbolLibrary_Click(sender As Object, e As EventArgs) Handles Btn_SymbolLibrary.Click |
||
2260 | Dim oMapping As New Mapping(_PIDSymbol_DB) |
||
2261 | oMapping.Show() |
||
2262 | End Sub |
||
2263 | e282643f | Gyusu | End Class |
2264 | |||
2265 | |||
2266 | Public Class DrawingInfo |
||
2267 | Public mDrawingName As String |
||
2268 | Public mSpID As String |
||
2269 | Public mPath As String |
||
2270 | 4f359afa | Gyusu | End Class |
2271 | e282643f | Gyusu | |
2272 | |||
2273 | |||
2274 |