프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Main.vb @ 3e63328a

이력 | 보기 | 이력해설 | 다운로드 (310 KB)

1 4f359afa Gyusu
Imports System.IO
2
Imports System.Data.SqlClient
3
Imports System.Data.SQLite
4
Imports Plaice
5
Imports Llama
6 b08338e3 Gyusu
Imports ComUtil.MessageLog.CEventLog
7 e282643f Gyusu
8
Imports System.Threading
9
10 4f359afa Gyusu
Public Class Main
11
12 54b98e09 Gyusu
    'Dim _Mapping_DB As DataTable = New DataTable()
13
    Dim _Mapping_DB As DataSet = New DataSet()
14 171ac39d Gyusu
    Dim _Attribute_DB As DataTable = New DataTable()
15 39d43554 Gyusu
    Dim _PIDSymbol_DB As DataTable = New DataTable()
16 e4000111 Gyusu
    Dim _ResultModeling_DT As DataTable = New DataTable()
17
18 76f465d0 Gyusu
    Dim _AllLine_DT As New DataTable()
19
    Dim _AllSymbol_DT As New DataTable()
20 e4000111 Gyusu
21 79326880 Gyusu
    Dim _ModelingLine_Dt As New DataTable()
22
23 4f359afa Gyusu
    Dim _Placement As New Placement
24 e4000111 Gyusu
    Dim _DWG_X = 0.875 '0.695 '1 '
25
    Dim _DWG_Y = 0.617 '0.585 '0.8 '
26 c2c36314 Gyusu
    'Dim _DWG_X = 0.842 '0.695 '1 '
27
    'Dim _DWG_Y = 0.614 '0.585 '0.8 '
28 171ac39d Gyusu
    Dim _IMG_X = 0
29
    Dim _IMG_Y = 0
30
31
    Dim _Unit As String
32 4f359afa Gyusu
33 31d47a80 Gyusu
    'Drawing 전역변수
34
    Dim _objPIDADrawing As Object
35 e282643f Gyusu
    '현재선택한 폴더경로
36
    Dim _selectFolderPath As String
37
38
    Private _Main_trd As Thread
39 54b98e09 Gyusu
    Private _Opc_trd As Thread
40
41
    Private _CompleteConvert As Boolean = False
42 e282643f Gyusu
43 171ac39d Gyusu
    Private _DrawingsList As List(Of Drawing)
44 272662f9 Gyusu
45
46 9e1e7135 Gyusu
    Private _iPipeLineNocnt As Integer
47
    Private _iPipecnt As Integer
48
    Private _iFittingcnt As Integer
49
    Private _iValvecnt As Integer
50
    Private _iInstrumentcnt As Integer
51
    Private _iEquipmentcnt As Integer
52
    Private _iNozzlecnt As Integer
53 e4000111 Gyusu
    Private _iPipintOpccnt As Integer
54 9e1e7135 Gyusu
55 41e4023e Gyusu
    Private _allItem As Integer
56
    Private _Itemcnt As Integer
57 b08338e3 Gyusu
58
    Dim _Gembox As New CGembox()
59 4f359afa Gyusu
    Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
60 54b98e09 Gyusu
        LoadDB()
61
    End Sub
62 272662f9 Gyusu
63 54b98e09 Gyusu
    Private Sub LoadDB()
64 e282643f Gyusu
        If My.Settings.DBPath <> "" And My.Settings.Plant_Hierarchy <> "" Then
65
            Dim sDBPath As String = My.Settings.DBPath
66 54b98e09 Gyusu
67
            _Gembox.isLoadFile(My.Settings.SymbolLibrary)
68
            _Mapping_DB = _Gembox.LoadFileFunc()
69 171ac39d Gyusu
            _Attribute_DB = Load_DB(sDBPath, _DB_TABLE_ATTRIBUTE)
70 39d43554 Gyusu
            _PIDSymbol_DB = Load_DB(sDBPath, _DB_TABLE_SYMBOLNAME)
71 e4000111 Gyusu
            _ResultModeling_DT = ModelingResult_Dt()
72 e282643f Gyusu
        Else
73
            MessageBox.Show("설정값을 먼저 확인해주세요")
74
        End If
75
    End Sub
76 41e4023e Gyusu
77 1229ad76 Gyusu
78 171ac39d Gyusu
    Private Function GetDataFromMappingDB(ByVal sSymbolName As String, ByVal sColumn As String) As String
79
        Dim sValue As String = ""
80 54b98e09 Gyusu
        For Each oDt As DataTable In _Mapping_DB.Tables
81
            If oDt.Rows.Count > 0 Then
82
                Dim oSelectRow() As DataRow = oDt.Select("[img_symbolname] = '" + sSymbolName + "'")
83
                If oSelectRow.Length = 1 Then
84
                    If sColumn = _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME Then
85
                        sValue = oSelectRow(0).Item("SYM FILE NAME").ToString()
86
                    ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH Then
87
                        sValue = "\" & oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString()
88
                    ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_COMPTPYE Then
89
                        sValue = oSelectRow(0).Item("ITEM TYPE").ToString()
90
                    ElseIf sColumn = _DB_COLUMN_MAPPING_SPPID_CLASS Then
91
                        sValue = oSelectRow(0).Item("CLASS").ToString()
92
                    Else
93
                        sValue = oSelectRow(0).Item("SYMBOL PATH").ToString() & "\" & oSelectRow(0).Item("SYM FILE NAME").ToString()
94
                    End If
95
                End If
96 e282643f Gyusu
            End If
97 54b98e09 Gyusu
        Next
98 171ac39d Gyusu
        Return sValue
99 4f359afa Gyusu
    End Function
100
101 171ac39d Gyusu
    Private Function GetAttributeMapping(ByVal sAttributeName As String, ByVal sColumn As String) As String
102
        Dim sSPPIDAttribute As String = ""
103
        If _Attribute_DB.Rows.Count > 0 Then
104
            Dim oSelectRow() As DataRow = _Attribute_DB.Select("[pid_attribute] = '" + sAttributeName + "'")
105
            If oSelectRow.Length = 1 Then
106
                sSPPIDAttribute = oSelectRow(0).Item(sColumn).ToString()
107
            End If
108
        End If
109
        Return sSPPIDAttribute
110
    End Function
111 e282643f Gyusu
112 6a6d8ab4 Gyusu
113
114 171ac39d Gyusu
    Private Function LoadSymbolInXml(ByVal sXmlPath As String) As Drawing
115 54b98e09 Gyusu
        Try
116
            ''  _TempSymbolDt = Symbol_Dt()
117
            Dim CDrawing As Drawing = New Drawing()
118
            Dim oDt As DataTable = LoadSymbol_DT()
119
            Dim oElement As XElement = XElement.Load(sXmlPath)
120 6a6d8ab4 Gyusu
121 54b98e09 Gyusu
            If oElement IsNot Nothing Then
122
                CDrawing.DwgName = oElement.Element(_XML_DWGNAME).Value
123
                CDrawing.Size = oElement.Element(_XML_DWGSIZE).Value
124
                SplitLocation(CDrawing.Size, _IMG_X, _IMG_Y)
125
                CDrawing.Unit = oElement.Element(_XML_UNIT).Value
126 171ac39d Gyusu
127 54b98e09 Gyusu
                Dim oLineno_list As New List(Of Line_no)
128
                Dim oEqp_list As New List(Of Eqp_no)
129 3acffcee Gyusu
                Dim oTrim_Lineno_list As New List(Of Line_no)
130
                oLineno_list = LoadLineNo(oElement, _XML_CATEGORY_LINENO)
131 54b98e09 Gyusu
                For Each oEqpNo As Object In oElement.Elements(_XML_CATEGORY_EQUIPMENT)
132
                    Dim CEqp_no As Eqp_no = New Eqp_no()
133
                    Dim oSymbol_Dt As DataTable = Symbol_Dt()
134
                    Dim oAttribute_Dt As DataTable = Attribute_Dt()
135 b08338e3 Gyusu
                    Dim sUid As String = ""
136 54b98e09 Gyusu
                    For Each oSymbol As Object In oEqpNo.Elements(_XML_CATEGORY_SYMBOL)
137
                        Try
138 b08338e3 Gyusu
                            Dim oAddrow As DataRow = oSymbol_Dt.NewRow()
139 54b98e09 Gyusu
                            Dim oEleObj As XElement
140
                            Dim sName As String
141
                            Dim sLocation As String
142
                            Dim sSize As String
143
                            Dim sAngle As String
144 b08338e3 Gyusu
                            Dim sOriginalPoint As String = ""
145 e4000111 Gyusu
                            Dim sConnectionPoint As String = ""
146 b08338e3 Gyusu
                            Dim sConnectionUids As String = ""
147
                            Dim sConnArray As String()
148
                            Dim sConnPointArray As String()
149
150 54b98e09 Gyusu
                            oEleObj = oSymbol.Element(_XML_SYMBOL_UID)
151
                            sUid = oEleObj.Value
152
                            oEleObj = oSymbol.Element(_XML_SYMBOL_NAME)
153
                            sName = oEleObj.Value
154
                            oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION)
155
                            sLocation = oEleObj.Value
156
                            oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE)
157
                            sSize = oEleObj.Value
158
                            oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE)
159
                            sAngle = oEleObj.Value
160 e4000111 Gyusu
                            oEleObj = oSymbol.Element(_XML_SYMBOL_CONNECTIONPOINT)
161
                            sConnectionPoint = oEleObj.Value
162 b08338e3 Gyusu
                            sConnPointArray = sConnectionPoint.Split("/")
163
164 f9b63682 Gyusu
                            If sConnPointArray.Length > 4 Then
165
                                MessageBox.Show(sConnPointArray.Length)
166
                            End If
167
                            For i = 0 To sConnPointArray.Length - 1
168
                                If i = 0 Then
169
                                    oAddrow(_XML_SYMBOL_Conn1_Point) = sConnPointArray(i)
170
                                ElseIf i = 1 Then
171
                                    oAddrow(_XML_SYMBOL_Conn2_Point) = sConnPointArray(i)
172
                                ElseIf i = 2 Then
173
                                    oAddrow(_XML_SYMBOL_Conn3_Point) = sConnPointArray(i)
174
                                ElseIf i = 3 Then
175
                                    oAddrow(_XML_SYMBOL_Conn4_Point) = sConnPointArray(i)
176
                                End If
177
                            Next
178 b08338e3 Gyusu
179
                            oEleObj = oSymbol.Element(_XML_SYMBOL_CONNS)
180
                            sConnectionUids = oEleObj.Value
181
                            sConnArray = sConnectionUids.Split(",")
182 54b98e09 Gyusu
                            Try
183
                                oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT)
184
                                sOriginalPoint = oEleObj.Value
185
                            Catch ex As Exception
186
                            End Try
187 b08338e3 Gyusu
188
189
190 54b98e09 Gyusu
                            oAddrow(_XML_SYMBOL_UID) = sUid
191 b08338e3 Gyusu
                            oAddrow(_XML_SYMBOL_LINENOUID) = sUid
192 54b98e09 Gyusu
                            oAddrow(_XML_SYMBOL_NAME) = sName
193
                            oAddrow(_XML_SYMBOL_LOCATION) = sLocation
194
                            oAddrow(_XML_SYMBOL_SIZE) = sSize
195
                            oAddrow(_XML_SYMBOL_ANGLE) = sAngle
196
                            oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
197
                            oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE)
198
                            oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint
199 e4000111 Gyusu
                            oAddrow(_XML_SYMBOL_CONNECTIONPOINT) = sConnectionPoint
200 f9b63682 Gyusu
201 b08338e3 Gyusu
                            If sConnArray.Length > 4 Then
202
                                MessageBox.Show(sConnArray.Length)
203
                            End If
204
                            For i = 0 To sConnArray.Length - 1
205
                                If i = 0 Then
206
                                    oAddrow(_XML_SYMBOL_Conn1_Uid) = sConnArray(i)
207
                                ElseIf i = 1 Then
208
                                    oAddrow(_XML_SYMBOL_Conn2_Uid) = sConnArray(i)
209
                                ElseIf i = 2 Then
210
                                    oAddrow(_XML_SYMBOL_Conn3_Uid) = sConnArray(i)
211
                                ElseIf i = 3 Then
212
                                    oAddrow(_XML_SYMBOL_Conn4_Uid) = sConnArray(i)
213
                                End If
214
                            Next
215
216 e4000111 Gyusu
                            oAddrow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
217 54b98e09 Gyusu
                            oSymbol_Dt.Rows.Add(oAddrow)
218
                        Catch ex As Exception
219
220
                        End Try
221 d039e347 Gyusu
                    Next
222 54b98e09 Gyusu
                    For Each oAtrribute As Object In oEqpNo.Elements(_XML_CATEGORY_ATTRIBUTE)
223
                        Try
224
                            Dim oAddrow As DataRow = oAttribute_Dt.NewRow()
225
                            Dim oEleObj As XElement
226 41e4023e Gyusu
                            Dim sAttUid As String
227 54b98e09 Gyusu
                            Dim sName As String
228
                            Dim sValue As String
229
                            oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID)
230 41e4023e Gyusu
                            sAttUid = oEleObj.Value
231 54b98e09 Gyusu
                            oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME)
232
                            sName = oEleObj.Value
233
                            oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE)
234
                            sValue = oEleObj.Value
235 41e4023e Gyusu
                            oAddrow(_XML_ATTRIBUTE_UID) = sAttUid
236 54b98e09 Gyusu
                            oAddrow(_XML_ATTRIBUTE_NAME) = sName
237
                            oAddrow(_XML_ATTRIBUTE_VALUE) = sValue
238
                            oAttribute_Dt.Rows.Add(oAddrow)
239
                        Catch ex As Exception
240
                        End Try
241
                    Next
242 41e4023e Gyusu
                    CEqp_no.Uid = sUid
243 54b98e09 Gyusu
                    CEqp_no.Dt_Equipment = oSymbol_Dt
244
                    CEqp_no.Dt_Attribute = oAttribute_Dt
245
                    oEqp_list.Add(CEqp_no)
246 4f359afa Gyusu
                Next
247 3acffcee Gyusu
                oTrim_Lineno_list = LoadLineNo(oElement, _XML_CATEGORY_TRIM_LINENO)
248 54b98e09 Gyusu
                CDrawing.Line_nos = oLineno_list
249
                CDrawing.Eqp_nos = oEqp_list
250 3acffcee Gyusu
                CDrawing.TrimLine_nos = oTrim_Lineno_list
251
252 54b98e09 Gyusu
            End If
253
            Return CDrawing
254
        Catch ex As Exception
255
            Return Nothing
256
        End Try
257
258 4f359afa Gyusu
    End Function
259
260 76f465d0 Gyusu
    Private Function FindConnection(ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable, ByVal sUid As String, ByVal dPos_x As Double, ByVal dPos_y As Double) As String
261
262
        Dim sReturnUid As String = ""
263
        Try
264
            Dim oFindLineRow As DataRow() = oLine_Dt.Select(
265
            "[" & _XML_LINE_DWG_STARTPOINT_X & "] >= '" & dPos_x - 0.001 & "' And " &
266
            "[" & _XML_LINE_DWG_STARTPOINT_X & "] <= '" & dPos_x + 0.001 & "' And " &
267
            "[" & _XML_LINE_DWG_STARTPOINT_Y & "] >= '" & dPos_y - 0.001 & "' And " &
268
            "[" & _XML_LINE_DWG_STARTPOINT_Y & "] <= '" & dPos_y + 0.001 & "' And " &
269
            "[" & _XML_LINE_UID & "] <> '" & sUid & "' And " &
270
            "[" & _XML_LINE_Conn1_Uid & "] = ''")
271
            If oFindLineRow.Length = 0 Then
272
                oFindLineRow = oLine_Dt.Select(
273
                "[" & _XML_LINE_DWG_ENDPOINT_X & "] >= '" & dPos_x - 0.001 & "' And " &
274
                "[" & _XML_LINE_DWG_ENDPOINT_X & "] <= '" & dPos_x + 0.001 & "' And " &
275
                "[" & _XML_LINE_DWG_ENDPOINT_Y & "] >= '" & dPos_y - 0.001 & "' And " &
276
                "[" & _XML_LINE_DWG_ENDPOINT_Y & "] <= '" & dPos_y + 0.001 & "' And " &
277
                "[" & _XML_LINE_UID & "] <> '" & sUid & "' And " &
278
                "[" & _XML_LINE_Conn2_Uid & "] = ''")
279
                If oFindLineRow.Length = 0 Then
280
                    oFindLineRow = oSymbol_Dt.Select(
281
              "[" & _XML_SYMBOL_DWG_CONN1_POINT_X & "] >= '" & dPos_x - 0.001 & "' And " &
282
              "[" & _XML_SYMBOL_DWG_CONN1_POINT_X & "] <= '" & dPos_x + 0.001 & "' And " &
283
              "[" & _XML_SYMBOL_DWG_CONN1_POINT_Y & "] >= '" & dPos_y - 0.001 & "' And " &
284
              "[" & _XML_SYMBOL_DWG_CONN1_POINT_Y & "] <= '" & dPos_y + 0.001 & "' And " &
285
              "[" & _XML_SYMBOL_UID & "] <> '" & sUid & "' And " &
286
              "[" & _XML_SYMBOL_Conn1_Uid & "] = ''")
287
                    If oFindLineRow.Length = 0 Then
288
                        oFindLineRow = oSymbol_Dt.Select(
289
                   "[" & _XML_SYMBOL_DWG_CONN2_POINT_X & "] >= '" & dPos_x - 0.001 & "' And " &
290
                   "[" & _XML_SYMBOL_DWG_CONN2_POINT_X & "] <= '" & dPos_x + 0.001 & "' And " &
291
                   "[" & _XML_SYMBOL_DWG_CONN2_POINT_Y & "] >= '" & dPos_y - 0.001 & "' And " &
292
                   "[" & _XML_SYMBOL_DWG_CONN2_POINT_Y & "] <= '" & dPos_y + 0.001 & "' And " &
293
                   "[" & _XML_SYMBOL_UID & "] <> '" & sUid & "' And " &
294
                   "[" & _XML_SYMBOL_Conn2_Uid & "] = ''")
295
                        If oFindLineRow.Length = 0 Then
296
                        Else
297
                            oFindLineRow(0)(_XML_SYMBOL_Conn2_Uid) = sUid
298
                            sReturnUid = oFindLineRow(0)(_XML_SYMBOL_UID).ToString()
299
                        End If
300
                    Else
301
                        oFindLineRow(0)(_XML_SYMBOL_Conn1_Uid) = sUid
302
                        sReturnUid = oFindLineRow(0)(_XML_SYMBOL_UID).ToString()
303
                    End If
304
                Else
305
                    oFindLineRow(0)(_XML_LINE_Conn2_Uid) = sUid
306
                    sReturnUid = oFindLineRow(0)(_XML_LINE_UID).ToString()
307
                End If
308
            Else
309
                oFindLineRow(0)(_XML_LINE_Conn1_Uid) = sUid
310
                sReturnUid = oFindLineRow(0)(_XML_LINE_UID).ToString()
311
            End If
312
        Catch ex As Exception
313
314
        End Try
315
316
        Return sReturnUid
317
    End Function
318
319
320
    Private Function SetConnectionInfo(ByRef oLine_Dt As DataTable, ByRef oSymbol_Dt As DataTable)
321
        Try
322
            For Each oLineInfo In oLine_Dt.Rows
323
                Dim sLineUid As String = oLineInfo(_XML_LINE_UID).ToString()
324
                Dim dStartPos_x As Double = oLineInfo(_XML_LINE_DWG_STARTPOINT_X)
325
                Dim dStartPos_y As Double = oLineInfo(_XML_LINE_DWG_STARTPOINT_Y)
326
                Dim dEndPos_x As Double = oLineInfo(_XML_LINE_DWG_ENDPOINT_X)
327
                Dim dEndPos_y As Double = oLineInfo(_XML_LINE_DWG_ENDPOINT_Y)
328
                Dim sConn1Uid As String = ""
329
                Dim sConn2Uid As String = ""
330
                sConn1Uid = FindConnection(oLine_Dt, oSymbol_Dt, sLineUid, dStartPos_x, dStartPos_y)
331
                If sConn1Uid <> "" Then
332
                    oLineInfo(_XML_LINE_Conn1_Uid) = sConn1Uid
333
                End If
334
                sConn2Uid = FindConnection(oLine_Dt, oSymbol_Dt, sLineUid, dEndPos_x, dEndPos_y)
335
                If sConn2Uid <> "" Then
336
                    oLineInfo(_XML_LINE_Conn2_Uid) = sConn2Uid
337
                End If
338
            Next
339
            For Each oSymbolInfo In oSymbol_Dt.Rows
340
                Dim sSymbolUid As String = oSymbolInfo(_XML_SYMBOL_UID).ToString()
341
                Dim dConn1Pos_x As Double = oSymbolInfo(_XML_SYMBOL_DWG_CONN1_POINT_X)
342
                Dim dConn1Pos_y As Double = oSymbolInfo(_XML_SYMBOL_DWG_CONN1_POINT_Y)
343
344
                Dim sConn1Uid As String = ""
345
                Dim sConn2Uid As String = ""
346
347
                sConn1Uid = FindConnection(oLine_Dt, oSymbol_Dt, sSymbolUid, dConn1Pos_x, dConn1Pos_y)
348
                If sConn1Uid <> "" Then
349
                    oSymbolInfo(_XML_SYMBOL_Conn1_Uid) = sConn1Uid
350
                End If
351
                Try
352
                    Dim dConn2Pos_x As Double = oSymbolInfo(_XML_SYMBOL_DWG_CONN2_POINT_X)
353
                    Dim dConn2Pos_y As Double = oSymbolInfo(_XML_SYMBOL_DWG_CONN2_POINT_Y)
354
                    sConn2Uid = FindConnection(oLine_Dt, oSymbol_Dt, sSymbolUid, dConn2Pos_x, dConn2Pos_y)
355
                    If sConn2Uid <> "" Then
356
                        oSymbolInfo(_XML_SYMBOL_Conn2_Uid) = sConn2Uid
357
                    End If
358
                Catch ex As Exception
359
                End Try
360
            Next
361
        Catch ex As Exception
362
        End Try
363
    End Function
364
365 76f5e1a8 Gyusu
    Private Function GetFlowDirection(ByRef dStart_x As Double, ByRef dStart_y As Double, ByRef dEnd_x As Double, ByRef dEnd_y As Double, ByRef sDirection As String, ByRef sFlowdirection As String) As Boolean
366
        Dim bValidLine As Boolean = True
367 76f465d0 Gyusu
        If Math.Abs(dStart_x - dEnd_x) > Math.Abs(dStart_y - dEnd_y) Then
368
            If dStart_x > dEnd_x Then
369
                sDirection = "X"
370
                sFlowdirection = "Left_x"
371
                If Math.Abs(dStart_y - dEnd_y) < 5 Then
372
                    dEnd_y = dStart_y
373
                End If
374
            Else
375
                sDirection = "X"
376
                sFlowdirection = "Right_x"
377
                If Math.Abs(dStart_y - dEnd_y) < 5 Then
378
                    dEnd_y = dStart_y
379
                End If
380
            End If
381 79326880 Gyusu
            If Math.Abs(dStart_x - dEnd_x) <= 15 Then
382 76f5e1a8 Gyusu
                bValidLine = False
383
            End If
384 76f465d0 Gyusu
        Else
385
            If dStart_y > dEnd_y Then
386
                sDirection = "Y"
387
                sFlowdirection = "Down_y"
388
                If Math.Abs(dStart_x - dEnd_x) < 5 Then
389
                    dEnd_x = dStart_x
390
                End If
391
392
            Else
393
                sDirection = "Y"
394
                sFlowdirection = "Up_y"
395
                If Math.Abs(dStart_x - dEnd_x) < 5 Then
396
                    dEnd_x = dStart_x
397
                End If
398
            End If
399 79326880 Gyusu
            If Math.Abs(dStart_y - dEnd_y) <= 20 Then
400 76f5e1a8 Gyusu
                bValidLine = False
401
            End If
402 76f465d0 Gyusu
        End If
403 76f5e1a8 Gyusu
        Return bValidLine
404 76f465d0 Gyusu
    End Function
405 4f359afa Gyusu
406 3acffcee Gyusu
    Private Function LoadLineNo(ByVal oElement As XElement, ByVal sLineType As String) As List(Of Line_no)
407
408
        Dim oLineno_list As New List(Of Line_no)
409
410
        For Each oLineNo As Object In oElement.Elements(sLineType)
411
412
            Dim CLineNo As Line_no = New Line_no()
413
            Try
414
                CLineNo.Uid = oLineNo.Element(_XML_LINENO_UID).Value
415
                CLineNo.Text = oLineNo.Element(_XML_LINENO_TEXT).Value
416
                CLineNo.Location = oLineNo.Element(_XML_LINENO_LOCATION).Value
417
                CLineNo.Angle = oLineNo.Element(_XML_LINENO_ANGLE).Value
418
                CLineNo.SystemPath = "\Piping\Labels - Piping Segments\Kemya Line Number.sym" 'GetDataFromMappingDB(_XML_CATEGORY_LINENO, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
419
            Catch ex As Exception
420
            End Try
421
            Dim oLine_Dt As DataTable = Line_Dt()
422
            Dim oSymbol_Dt As DataTable = Symbol_Dt()
423
            Dim oAttribute_Dt As DataTable = Attribute_Dt()
424 76f465d0 Gyusu
            Dim iRunCnt As Integer = 0
425 3acffcee Gyusu
            For Each oRun As Object In oLineNo.Elements(_XML_CATEGORY_RUN)
426 76f465d0 Gyusu
                iRunCnt = iRunCnt + 1
427
                Dim sRunName As String = CLineNo.Text & "_" & iRunCnt
428
                For Each oMERGEDLine As Object In oRun.Elements(_XML_CATEGORY_MERGEDLINE)
429
                    For Each oLine As Object In oMERGEDLine.Elements(_XML_CATEGORY_LINE)
430
                        Try
431
                            Dim oAddrow As DataRow = oLine_Dt.NewRow()
432
                            Dim oEleObj As XElement
433
                            Dim sUid As String
434
                            Dim sStartpoint As String
435
                            Dim sEndpoint As String
436
                            Dim sType As String
437
                            Dim sConnectionUids As String = ""
438
                            Dim dStartPos_x As Double = 0.0
439
                            Dim dStartPos_y As Double = 0.0
440
                            Dim dEndPos_x As Double = 0.0
441
                            Dim dEndPos_y As Double = 0.0
442
                            Dim dDWG_StartPos_x As Double = 0.0
443
                            Dim dDWG_StartPos_y As Double = 0.0
444
                            Dim dDWG_EndPos_x As Double = 0.0
445
                            Dim dDWG_EndPos_y As Double = 0.0
446
                            oEleObj = oLine.Element(_XML_LINE_UID)
447
                            sUid = oEleObj.Value
448 b08338e3 Gyusu
449 76f465d0 Gyusu
                            If oLine_Dt.Select(_XML_LINE_UID & "='" & sUid & "'").Length = 0 Then
450
                                oEleObj = oLine.Element(_XML_LINE_STARTPOINT)
451
                                sStartpoint = oEleObj.Value
452
                                oEleObj = oLine.Element(_XML_LINE_ENDPOINT)
453
                                sEndpoint = oEleObj.Value
454
                                oEleObj = oLine.Element(_XML_LINE_TYPE)
455
                                sType = oEleObj.Value
456
                                'oEleObj = oLine.Element(_XML_LINE_CONNS)
457
                                'sConnectionUids = oEleObj.Value
458
                                'sConnArray = sConnectionUids.Split(",")
459
                                'For i = 0 To sConnArray.Length - 1
460
                                '    If i = 0 Then
461
                                '        oAddrow(_XML_LINE_Conn1_Uid) = sConnArray(i)
462
                                '    ElseIf i = 1 Then
463
                                '        oAddrow(_XML_LINE_Conn2_Uid) = sConnArray(i)
464
                                '    End If
465
                                'Next
466
                                'If sConnArray.Length > 2 Then
467
                                '    MessageBox.Show(sConnArray.Length)
468
                                'End If
469
                                oAddrow(_XML_LINE_Conn1_Uid) = ""
470
                                oAddrow(_XML_LINE_Conn2_Uid) = ""
471
                                oAddrow(_XML_LINE_UID) = sUid
472
                                oAddrow(_XML_LINE_RUNNAME) = sRunName
473
                                oAddrow(_XML_LINE_LINENOUID) = CLineNo.Uid
474
                                oAddrow(_XML_LINENO_TEXT) = CLineNo.Text
475
                                oAddrow(_XML_LINE_STARTPOINT) = sStartpoint
476
                                oAddrow(_XML_LINE_ENDPOINT) = sEndpoint
477
478
                                ConvertPointBystring(sStartpoint, dStartPos_x, dStartPos_y)
479
                                ConvertPointBystring(sEndpoint, dEndPos_x, dEndPos_y)
480
                                Dim sDirection As String = ""
481 76f5e1a8 Gyusu
                                Dim sFlowDirection As String = ""
482
                                Dim bValidLine As Boolean = GetFlowDirection(dStartPos_x, dStartPos_y, dEndPos_x, dEndPos_y, sDirection, sFlowDirection)
483
                                oAddrow(_XML_LINE_FlowDirection) = sFlowDirection
484 76f465d0 Gyusu
                                oAddrow(_XML_LINE_Direction) = sDirection
485 76f5e1a8 Gyusu
                                oAddrow(_XML_LINE_ValieLine) = bValidLine
486 76f465d0 Gyusu
                                dDWG_StartPos_x = dStartPos_x
487
                                dDWG_StartPos_y = dStartPos_y
488
                                ConvertPointByImage(dDWG_StartPos_x, dDWG_StartPos_y, _IMG_X, _IMG_Y)
489
                                dDWG_EndPos_x = dEndPos_x
490
                                dDWG_EndPos_y = dEndPos_y
491
                                ConvertPointByImage(dDWG_EndPos_x, dDWG_EndPos_y, _IMG_X, _IMG_Y)
492
493
                                oAddrow(_XML_LINE_STARTPOINT_X) = dStartPos_x
494
                                oAddrow(_XML_LINE_STARTPOINT_Y) = dStartPos_y
495
                                oAddrow(_XML_LINE_ENDPOINT_X) = dEndPos_x
496
                                oAddrow(_XML_LINE_ENDPOINT_Y) = dEndPos_y
497
498
                                oAddrow(_XML_LINE_DWG_STARTPOINT_X) = dDWG_StartPos_x
499
                                oAddrow(_XML_LINE_DWG_STARTPOINT_Y) = dDWG_StartPos_y
500
                                oAddrow(_XML_LINE_DWG_ENDPOINT_X) = dDWG_EndPos_x
501
                                oAddrow(_XML_LINE_DWG_ENDPOINT_Y) = dDWG_EndPos_y
502
503
                                oAddrow(_XML_LINE_SYSTEMPATH) = GetDataFromMappingDB(_XML_CATEGORY_LINE, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
504
                                If oAddrow(_XML_LINE_SYSTEMPATH) = "" Then
505
                                    MessageBox.Show("")
506 b08338e3 Gyusu
                                End If
507 76f465d0 Gyusu
                                oAddrow(_XML_LINE_DRAWING_TF) = "FALSE"
508
                                oAddrow(_XML_LINE_TYPE) = sType
509
                                '  _AllLine_DT.Rows.Add(oAddrow)
510
                                oLine_Dt.Rows.Add(oAddrow)
511
                            Else
512 b08338e3 Gyusu
                            End If
513 76f465d0 Gyusu
                        Catch ex As Exception
514
                        End Try
515
                    Next
516 3acffcee Gyusu
                Next
517
518
                For Each oSymbol As Object In oRun.Elements(_XML_CATEGORY_SYMBOL)
519
                    Try
520 76f465d0 Gyusu
521 3acffcee Gyusu
                        Dim oAddrow As DataRow = oSymbol_Dt.NewRow()
522
                        Dim oEleObj As XElement
523
                        Dim sUid As String
524
                        Dim sName As String
525
                        Dim sLocation As String
526
                        Dim sSize As String
527
                        Dim sAngle As String
528
                        Dim sOriginalPoint As String = ""
529 bb2a0c79 Gyusu
                        Dim sConnectionPoint As String = ""
530 b08338e3 Gyusu
                        Dim sConnectionUids As String = ""
531
                        Dim sConnArray As String()
532 9c86a823 Gyusu
                        Dim sChild As String = ""
533 76f465d0 Gyusu
                        Dim dCenterPos_x As Double = 0.0
534
                        Dim dCenterPos_y As Double = 0.0
535
                        Dim dDwgCenterPos_x As Double = 0.0
536
                        Dim dDwgCenterPos_y As Double = 0.0
537
538
539
                        Dim dConn1Pos_x As Double = 0.0
540
                        Dim dConn1Pos_y As Double = 0.0
541
                        Dim dConn2Pos_x As Double = 0.0
542
                        Dim dConn2Pos_y As Double = 0.0
543
                        Dim dConn3Pos_x As Double = 0.0
544
                        Dim dConn3Pos_y As Double = 0.0
545
                        Dim dConn4Pos_x As Double = 0.0
546
                        Dim dConn4Pos_y As Double = 0.0
547
548
                        Dim dDwg_Conn1Pos_x As Double = 0.0
549
                        Dim dDwg_Conn1Pos_y As Double = 0.0
550
                        Dim dDwg_Conn2Pos_x As Double = 0.0
551
                        Dim dDwg_Conn2Pos_y As Double = 0.0
552
                        Dim dDwg_Conn3Pos_x As Double = 0.0
553
                        Dim dDwg_Conn3Pos_y As Double = 0.0
554
                        Dim dDwg_Conn4Pos_x As Double = 0.0
555
                        Dim dDwg_Conn4Pos_y As Double = 0.0
556
557 3acffcee Gyusu
                        oEleObj = oSymbol.Element(_XML_SYMBOL_UID)
558
                        sUid = oEleObj.Value
559
                        oEleObj = oSymbol.Element(_XML_SYMBOL_PARENT)
560
                        sName = oEleObj.Value
561
                        oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION)
562
                        sLocation = oEleObj.Value
563
                        oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE)
564
                        sSize = oEleObj.Value
565
                        oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE)
566
                        sAngle = oEleObj.Value
567 bb2a0c79 Gyusu
                        oEleObj = oSymbol.Element(_XML_SYMBOL_CONNECTIONPOINT)
568
                        sConnectionPoint = oEleObj.Value
569 9c86a823 Gyusu
                        oEleObj = oSymbol.Element(_XML_SYMBOL_CHILD)
570
                        sChild = oEleObj.Value
571 3acffcee Gyusu
                        Try
572
                            oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT)
573
                            sOriginalPoint = oEleObj.Value
574
                        Catch ex As Exception
575
576
                        End Try
577 76f465d0 Gyusu
                        'oEleObj = oSymbol.Element(_XML_LINE_CONNS)
578
                        'sConnectionUids = oEleObj.Value
579
                        'sConnArray = sConnectionUids.Split(",")
580
                        'If sConnArray.Length > 4 Then
581
                        '    MessageBox.Show(sConnArray.Length)
582
                        'End If
583
                        'For i = 0 To sConnArray.Length - 1
584
                        '    If i = 0 Then
585
                        '        oAddrow(_XML_SYMBOL_Conn1_Uid) = sConnArray(i)
586
                        '    ElseIf i = 1 Then
587
                        '        oAddrow(_XML_SYMBOL_Conn2_Uid) = sConnArray(i)
588
                        '    ElseIf i = 2 Then
589
                        '        oAddrow(_XML_SYMBOL_Conn3_Uid) = sConnArray(i)
590
                        '    ElseIf i = 3 Then
591
                        '        oAddrow(_XML_SYMBOL_Conn4_Uid) = sConnArray(i)
592
                        '    End If
593
                        'Next
594
                        oAddrow(_XML_SYMBOL_Conn1_Uid) = ""
595
                        oAddrow(_XML_SYMBOL_Conn2_Uid) = ""
596
                        oAddrow(_XML_SYMBOL_Conn3_Uid) = ""
597
                        oAddrow(_XML_SYMBOL_Conn4_Uid) = ""
598
                        ConvertPointBystring(sOriginalPoint, dCenterPos_x, dCenterPos_y)
599
                        dDwgCenterPos_x = dCenterPos_x
600
                        dDwgCenterPos_y = dCenterPos_y
601
                        ConvertPointByImage(dDwgCenterPos_x, dDwgCenterPos_y, _IMG_X, _IMG_Y)
602
603
                        oAddrow(_XML_SYMBOL_CENTERPOINT_X) = dCenterPos_x
604
                        oAddrow(_XML_SYMBOL_CENTERPOINT_Y) = dCenterPos_y
605
                        oAddrow(_XML_SYMBOL_DWG_CENTERPOINT_X) = dDwgCenterPos_x
606
                        oAddrow(_XML_SYMBOL_DWG_CENTERPOINT_Y) = dDwgCenterPos_y
607
                        sConnArray = sConnectionPoint.Split("/")
608 b08338e3 Gyusu
                        If sConnArray.Length > 4 Then
609
                            MessageBox.Show(sConnArray.Length)
610
                        End If
611
                        For i = 0 To sConnArray.Length - 1
612
                            If i = 0 Then
613 76f465d0 Gyusu
                                oAddrow(_XML_SYMBOL_Conn1_Point) = sConnArray(i)
614
                                ConvertPointBystring(sConnArray(i), dConn1Pos_x, dConn1Pos_y)
615
                                dDwg_Conn1Pos_x = dConn1Pos_x
616
                                dDwg_Conn1Pos_y = dConn1Pos_y
617
                                ConvertPointByImage(dDwg_Conn1Pos_x, dDwg_Conn1Pos_y, _IMG_X, _IMG_Y)
618
619
                                oAddrow(_XML_SYMBOL_CONN1_POINT_X) = dConn1Pos_x
620
                                oAddrow(_XML_SYMBOL_CONN1_POINT_Y) = dConn1Pos_y
621
                                oAddrow(_XML_SYMBOL_DWG_CONN1_POINT_X) = dDwg_Conn1Pos_x
622
                                oAddrow(_XML_SYMBOL_DWG_CONN1_POINT_Y) = dDwg_Conn1Pos_y
623 b08338e3 Gyusu
                            ElseIf i = 1 Then
624 76f465d0 Gyusu
                                oAddrow(_XML_SYMBOL_Conn2_Point) = sConnArray(i)
625
                                ConvertPointBystring(sConnArray(i), dConn2Pos_x, dConn2Pos_y)
626
                                dDwg_Conn2Pos_x = dConn2Pos_x
627
                                dDwg_Conn2Pos_y = dConn2Pos_y
628
                                ConvertPointByImage(dDwg_Conn2Pos_x, dDwg_Conn2Pos_y, _IMG_X, _IMG_Y)
629
                                oAddrow(_XML_SYMBOL_CONN2_POINT_X) = dConn2Pos_x
630
                                oAddrow(_XML_SYMBOL_CONN2_POINT_Y) = dConn2Pos_y
631
                                oAddrow(_XML_SYMBOL_DWG_CONN2_POINT_X) = dDwg_Conn2Pos_x
632
                                oAddrow(_XML_SYMBOL_DWG_CONN2_POINT_Y) = dDwg_Conn2Pos_y
633 b08338e3 Gyusu
                            ElseIf i = 2 Then
634 76f465d0 Gyusu
                                oAddrow(_XML_SYMBOL_Conn3_Point) = sConnArray(i)
635
                                ConvertPointBystring(sConnArray(i), dConn3Pos_x, dConn3Pos_y)
636
                                dDwg_Conn3Pos_x = dConn3Pos_x
637
                                dDwg_Conn3Pos_y = dConn3Pos_y
638
                                ConvertPointByImage(dDwg_Conn3Pos_x, dDwg_Conn3Pos_y, _IMG_X, _IMG_Y)
639
                                oAddrow(_XML_SYMBOL_CONN3_POINT_X) = dConn3Pos_x
640
                                oAddrow(_XML_SYMBOL_CONN3_POINT_Y) = dConn3Pos_y
641
                                oAddrow(_XML_SYMBOL_DWG_CONN3_POINT_X) = dDwg_Conn3Pos_x
642
                                oAddrow(_XML_SYMBOL_DWG_CONN3_POINT_Y) = dDwg_Conn3Pos_y
643 b08338e3 Gyusu
                            ElseIf i = 3 Then
644 76f465d0 Gyusu
                                oAddrow(_XML_SYMBOL_Conn4_Point) = sConnArray(i)
645
                                ConvertPointBystring(sConnArray(i), dConn4Pos_x, dConn4Pos_y)
646
                                dDwg_Conn4Pos_x = dConn4Pos_x
647
                                dDwg_Conn4Pos_y = dConn4Pos_y
648
                                ConvertPointByImage(dDwg_Conn4Pos_x, dDwg_Conn4Pos_y, _IMG_X, _IMG_Y)
649
                                oAddrow(_XML_SYMBOL_CONN4_POINT_X) = dConn4Pos_x
650
                                oAddrow(_XML_SYMBOL_CONN4_POINT_Y) = dConn4Pos_y
651
                                oAddrow(_XML_SYMBOL_DWG_CONN4_POINT_X) = dDwg_Conn4Pos_x
652
                                oAddrow(_XML_SYMBOL_DWG_CONN4_POINT_Y) = dDwg_Conn4Pos_y
653 b08338e3 Gyusu
                            End If
654
                        Next
655
656 3acffcee Gyusu
                        oAddrow(_XML_SYMBOL_UID) = sUid
657 b08338e3 Gyusu
                        oAddrow(_XML_LINE_LINENOUID) = CLineNo.Uid
658 76f465d0 Gyusu
                        oAddrow(_XML_SYMBOL_RUNNAME) = sRunName
659 b08338e3 Gyusu
                        oAddrow(_XML_LINENO_TEXT) = CLineNo.Text
660 3acffcee Gyusu
                        oAddrow(_XML_SYMBOL_NAME) = IO.Path.GetFileNameWithoutExtension(GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME))
661
                        oAddrow(_XML_SYMBOL_LOCATION) = sLocation
662
                        oAddrow(_XML_SYMBOL_SIZE) = sSize
663
                        oAddrow(_XML_SYMBOL_ANGLE) = sAngle
664
                        oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
665
                        oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE)
666
                        oAddrow(_XML_SYMBOL_CLASS) = GetDataFromMappingDB(sName, _DB_COLUMN_MAPPING_SPPID_CLASS)
667
                        oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint
668 76f465d0 Gyusu
669 bb2a0c79 Gyusu
                        oAddrow(_XML_SYMBOL_CONNECTIONPOINT) = sConnectionPoint
670 e4000111 Gyusu
                        oAddrow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
671 9c86a823 Gyusu
                        oAddrow(_XML_SYMBOL_CHILD) = sChild
672 76f465d0 Gyusu
                        '   _AllSymbol_DT.Rows.Add(oAddrow)
673 3acffcee Gyusu
                        oSymbol_Dt.Rows.Add(oAddrow)
674
                    Catch ex As Exception
675
                    End Try
676
                Next
677
678
                For Each oAtrribute As Object In oRun.Elements(_XML_CATEGORY_ATTRIBUTE)
679
                    Try
680
                        Dim oAddrow As DataRow = oAttribute_Dt.NewRow()
681
                        Dim oEleObj As XElement
682
                        Dim sUid As String
683
                        Dim sName As String
684
                        Dim sValue As String
685
                        oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID)
686
                        sUid = oEleObj.Value
687
                        oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME)
688
                        sName = oEleObj.Value
689
                        oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE)
690
                        sValue = oEleObj.Value
691
                        oAddrow(_XML_ATTRIBUTE_UID) = sUid
692
                        oAddrow(_XML_ATTRIBUTE_NAME) = sName
693
                        oAddrow(_XML_ATTRIBUTE_VALUE) = sValue
694
                        oAttribute_Dt.Rows.Add(oAddrow)
695
                    Catch ex As Exception
696
                    End Try
697
                Next
698
            Next
699
            'Line No Attribute
700
            For Each oAtrribute As Object In oLineNo.Elements(_XML_CATEGORY_ATTRIBUTE)
701
                Try
702
                    Dim oAddrow As DataRow = oAttribute_Dt.NewRow()
703
                    Dim oEleObj As XElement
704
                    Dim sUid As String = ""
705
                    Dim sName As String
706
                    Dim sValue As String
707
708
                    oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_UID)
709
                    sUid = oEleObj.Value
710
                    oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_NAME)
711
                    sName = oEleObj.Value
712
                    oEleObj = oAtrribute.Element(_XML_ATTRIBUTE_VALUE)
713
                    sValue = oEleObj.Value
714
                    oAddrow(_XML_ATTRIBUTE_UID) = sUid
715
                    oAddrow(_XML_ATTRIBUTE_NAME) = sName
716
                    oAddrow(_XML_ATTRIBUTE_VALUE) = sValue
717
                    oAttribute_Dt.Rows.Add(oAddrow)
718
                Catch ex As Exception
719
                End Try
720
            Next
721 76f465d0 Gyusu
722
            SetConnectionInfo(oLine_Dt, oSymbol_Dt)
723
            _AllLine_DT.Merge(oLine_Dt)
724
            _AllSymbol_DT.Merge(oSymbol_Dt)
725 3acffcee Gyusu
            CLineNo.Dt_Line = oLine_Dt
726
            CLineNo.Dt_Symbol = oSymbol_Dt
727
            CLineNo.Dt_Attribute = oAttribute_Dt
728
            oLineno_list.Add(CLineNo)
729
        Next
730
        Return oLineno_list
731
    End Function
732
733 4f359afa Gyusu
734 9e1e7135 Gyusu
    Private Sub ConvertPointByImage(ByRef dX As Double, ByRef dY As Double, ByVal dDwgX As Double, ByVal dDwgY As Double)
735 4f359afa Gyusu
736
        Dim calcx As Double = 0
737
        Dim calcy As Double = 0
738
        calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2)
739 76f465d0 Gyusu
        'calcx = Math.Round(calcx, 4, MidpointRounding.)
740
        calcx = Math.Truncate(calcx * 1000) / 1000
741 171ac39d Gyusu
        calcy = _DWG_Y - ((dY * _DWG_Y) / dDwgY) '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2)
742 76f465d0 Gyusu
        '   calcy = Math.Round(calcy, 4)
743
        calcy = Math.Truncate(calcy * 1000) / 1000
744 4f359afa Gyusu
        dX = calcx
745
        dY = calcy
746
    End Sub
747
748 e1cde8f2 Gyusu
749
    '@brief Convert To SPPID
750
    '@author : Gyusu Park
751
    '@date : 2018-04-10
752
    '@history:
753
754 171ac39d Gyusu
    Private Sub SplitLocation(ByVal sLocation As String, ByRef dX As Double, ByRef dY As Double)
755
756
        Dim opointstr As String() = Split(sLocation, ",")
757
        If (opointstr.Length > 1) Then
758
            If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then
759
                dX = opointstr(0)
760
                dY = opointstr(1)
761
            End If
762
        End If
763
764
    End Sub
765
766
    Private Function Load_DB(ByVal sDBPath As String, ByVal sTableName As String) As DataTable
767 4f359afa Gyusu
768
        Try
769 171ac39d Gyusu
            Dim oDt As New DataTable
770 4f359afa Gyusu
            Dim sConnectionstring As String = "Data Source=" & sDBPath & ";Version=3;Synchronous=Off;UTF8Encoding=True;"
771
            Dim conn As SQLiteConnection = New SQLiteConnection(sConnectionstring)
772
            conn.Open()
773 171ac39d Gyusu
            Dim sQuery As String = "Select * from " & sTableName
774 4f359afa Gyusu
            Dim cmd As SQLiteCommand = conn.CreateCommand()
775
            Dim adapter As SQLiteDataAdapter = New SQLiteDataAdapter(sQuery, conn)
776
            Dim oDataSet As DataSet = New DataSet()
777
            adapter.Fill(oDataSet)
778 171ac39d Gyusu
            oDt = oDataSet.Tables(0)
779
            Return oDt
780 4f359afa Gyusu
        Catch ex As Exception
781 171ac39d Gyusu
            Return Nothing
782 4f359afa Gyusu
        End Try
783
784
785 171ac39d Gyusu
    End Function
786 4f359afa Gyusu
787 31d47a80 Gyusu
    Private Function LoadAllDrawing() As DataTable
788 e282643f Gyusu
789
790 e1cde8f2 Gyusu
        SetListBoxItems(ListBox_Result, "도면정보 로드중....")
791 b08338e3 Gyusu
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "도면정보 로드중....")
792 31d47a80 Gyusu
        Dim oDt As DataTable = Drawing_Dt()
793 e282643f Gyusu
        Dim sHierarchy As String = My.Settings.Plant_Hierarchy
794
795
796
        Dim files() As String
797
        files = Directory.GetFiles(sHierarchy, "*.pid", SearchOption.AllDirectories)
798
        For Each FileName As String In files
799
            Dim sName As String = FileName
800 31d47a80 Gyusu
            Dim oAddRow As DataRow = oDt.NewRow()
801 e282643f Gyusu
            oAddRow("Name") = Path.GetFileNameWithoutExtension(sName)
802
            oAddRow("Path") = FileName
803 31d47a80 Gyusu
            oDt.Rows.Add(oAddRow)
804
        Next
805
        Return oDt
806
    End Function
807
808 e282643f Gyusu
809 272662f9 Gyusu
    Dim _XMLList As ListView = New ListView()
810 e282643f Gyusu
811 272662f9 Gyusu
812
813 e1cde8f2 Gyusu
814 171ac39d Gyusu
815
816
    Private Function CheckOpenDrawing() As Boolean
817
        Try
818
819
            Dim lobjDatasource As Object
820
            _Placement = CreateObject("Plaice.Placement", "")
821
            lobjDatasource = _Placement.PIDDataSource
822
            Return True
823
        Catch ex As Exception
824
            Return False
825
        End Try
826
827
    End Function
828
829
830
    Private Sub Btn_Convert_Click(sender As Object, e As EventArgs) Handles Btn_Convert.Click
831
832
        Main_Tab.SelectedIndex = 1
833
        ListBox_Result.Items.Clear()
834 9e1e7135 Gyusu
        ' DataGrid_Result.DataSource = New DataTable()
835 171ac39d Gyusu
        Me.ProgressBar_Status.Visible = True
836
        ProgressBar_Status.Maximum = 100
837
        ProgressBar_Status.Value = 0
838 b08338e3 Gyusu
        InitItemCount()
839 171ac39d Gyusu
        ' _selectFolderPath = Tree_XMLFiles.SelectedNode.FullPath.Replace("\\", "\")
840 54b98e09 Gyusu
        _Main_trd = New Thread(AddressOf ThreadConvert)
841 171ac39d Gyusu
        _Main_trd.IsBackground = True
842
        _Main_trd.Start()
843 54b98e09 Gyusu
        FineOPCForm()
844
    End Sub
845 171ac39d Gyusu
846 54b98e09 Gyusu
    Private Sub FineOPCForm()
847
        _Opc_trd = New Thread(AddressOf ThreadOPCRemove)
848
        _Opc_trd.IsBackground = True
849
        _Opc_trd.Start()
850 171ac39d Gyusu
    End Sub
851 54b98e09 Gyusu
852 31d47a80 Gyusu
853 b08338e3 Gyusu
    Dim _objPIDAutoApp As Object
854 e282643f Gyusu
855 b08338e3 Gyusu
    Private Function OpenSPPID(ByVal oDwg_Dt As DataTable, ByVal sDwgName As String) As Boolean
856
        Dim bCheckOpen As Boolean = False
857
        '   Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgPath)
858
        SetListBoxItems(ListBox_Result, sDwgName & " 도면 Open....")
859
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, sDwgName & " 도면 Open....")
860
        _objPIDAutoApp = CreateObject("PIDAutomation.Application")
861 e1cde8f2 Gyusu
862 b08338e3 Gyusu
        Dim sPath As String = OpenDrawing(oDwg_Dt, sDwgName)
863
        If sPath <> "" Then
864
            Process.Start(sPath)
865
        Else
866
            Return bCheckOpen
867
        End If
868 171ac39d Gyusu
869
            Dim bCheckOpenDrawing As Boolean = False
870
            While (True)
871
                bCheckOpenDrawing = CheckOpenDrawing()
872
                If bCheckOpenDrawing = True Then
873
                    bCheckOpen = True
874
                    Exit While
875
                Else
876
                    Thread.Sleep(2000)
877
                End If
878
            End While
879
880
881
            Return bCheckOpen
882
    End Function
883
884
    Private Function GetDrawing(ByVal sDwgName As String) As Drawing
885
        For Each CDrawing In _DrawingsList
886 559daf6d Gyusu
            If CDrawing.DwgName.ToUpper() = sDwgName.ToUpper() Then
887 171ac39d Gyusu
                Return CDrawing
888
            End If
889
        Next
890
        Return Nothing
891
    End Function
892
893
    Private Function GetLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no
894
        For Each CLineNo In CDrawing.Line_nos
895
            If CLineNo.Uid = sLineNoUid Then
896
                Return CLineNo
897
            End If
898
        Next
899
        Return Nothing
900
    End Function
901
902 3acffcee Gyusu
    Private Function GetTrimLineNo(ByVal CDrawing As Drawing, ByVal sLineNoUid As String) As Line_no
903
        For Each CLineNo In CDrawing.TrimLine_nos
904
            If CLineNo.Uid = sLineNoUid Then
905
                Return CLineNo
906
            End If
907
        Next
908
        Return Nothing
909
    End Function
910
911
912 bb2a0c79 Gyusu
913
    Private Function GetPipeFromConnection(ByVal CDrawing As Drawing, ByVal sSymbolUid As String, ByRef sConnTypeNo As String) As DataTable
914 6a6d8ab4 Gyusu
        For Each CLineNo In CDrawing.Line_nos
915
            Dim odt As DataTable = CLineNo.Dt_Line
916
            If odt.Rows.Count > 0 Then
917 bb2a0c79 Gyusu
                If odt.Rows(0)(_XML_LINE_Conn1_Uid).ToString = sSymbolUid Then
918
                    sConnTypeNo = "1"
919
                    Return odt
920
                ElseIf odt.Rows(0)(_XML_LINE_Conn2_Uid).ToString() = sSymbolUid Then
921
                    sConnTypeNo = "2"
922
                    Return odt
923 6a6d8ab4 Gyusu
                End If
924
            End If
925
        Next
926 bb2a0c79 Gyusu
        Return New DataTable
927 6a6d8ab4 Gyusu
    End Function
928
929 bb2a0c79 Gyusu
    Private Function GetSymbolFromConnection(ByVal CDrawing As Drawing, ByVal sSymbolUid As String, ByRef sConnTypeNo As String) As DataTable
930
        For Each CLineNo In CDrawing.Line_nos
931
            Dim odt As DataTable = CLineNo.Dt_Symbol
932
            If odt.Rows.Count > 0 Then
933
                If odt.Rows(0)(_XML_SYMBOL_Conn1_Uid).ToString = sSymbolUid Then
934
                    sConnTypeNo = "1"
935
                    Return odt
936
                ElseIf odt.Rows(0)(_XML_SYMBOL_Conn2_Uid).ToString() = sSymbolUid Then
937
                    sConnTypeNo = "2"
938
                    Return odt
939
                ElseIf odt.Rows(0)(_XML_SYMBOL_Conn3_Uid).ToString() = sSymbolUid Then
940
                    sConnTypeNo = "3"
941
                    Return odt
942
                ElseIf odt.Rows(0)(_XML_SYMBOL_Conn4_Uid).ToString() = sSymbolUid Then
943
                    sConnTypeNo = "4"
944
                    Return odt
945
                End If
946
            End If
947
        Next
948
        Return New DataTable
949
    End Function
950 6a6d8ab4 Gyusu
951
    Private Function GetEqpNo(ByVal CDrawing As Drawing, ByVal sEqpUid As String) As Eqp_no
952
        For Each CEqpNo In CDrawing.Eqp_nos
953
            If CEqpNo.Uid = sEqpUid Then
954
                Return CEqpNo
955
            End If
956
        Next
957
        Return Nothing
958
    End Function
959 9e1e7135 Gyusu
    Private Function ConvertPointBystring(ByVal sPoint As String, ByRef dX As Double, ByRef dY As Double) As Boolean
960 171ac39d Gyusu
        Try
961
            Dim opointstr As String() = Split(sPoint, ",")
962
            If (opointstr.Length > 1) Then
963
                If IsNumeric(opointstr(0)) And IsNumeric(opointstr(1)) Then
964
                    dX = opointstr(0)
965
                    dY = opointstr(1)
966 9e1e7135 Gyusu
967 171ac39d Gyusu
                Else
968
                    dX = 0
969
                    dY = 0
970
                    Return False
971
                End If
972
            End If
973 e1cde8f2 Gyusu
            Return True
974
        Catch ex As Exception
975
            Return False
976
        End Try
977 171ac39d Gyusu
    End Function
978
979 54b98e09 Gyusu
980
    Dim _DrawLine_Dt As DataTable = DrawLind_Dt()
981
982 e1cde8f2 Gyusu
983 41e4023e Gyusu
    Private Sub AddModelingLine(ByVal dStart_x As Double, ByVal dStart_y As Double, ByVal dEnd_x As Double, ByVal dEnd_y As Double, ByVal sUid As String)
984 54b98e09 Gyusu
        Dim oAddRow = _DrawLine_Dt.NewRow()
985 41e4023e Gyusu
        oAddRow(_XML_LINE_UID) = sUid
986 54b98e09 Gyusu
        oAddRow(_XML_LINE_STARTPOINT_X) = dStart_x
987
        oAddRow(_XML_LINE_STARTPOINT_Y) = dStart_y
988
        oAddRow(_XML_LINE_ENDPOINT_X) = dEnd_x
989
        oAddRow(_XML_LINE_ENDPOINT_Y) = dEnd_y
990
        _DrawLine_Dt.Rows.Add(oAddRow)
991
    End Sub
992
993
994
995 b08338e3 Gyusu
    Private Sub PlaceEquipment(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sEqpName As String)
996 41e4023e Gyusu
        Try
997
            Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'")
998
            Dim oAttributeRow() As DataRow
999
            If oAttribute_Dt.Rows.Count > 0 Then
1000
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
1001
            End If
1002
            If oSymbolRow.Length > 0 Then
1003
                Dim oDatasource As Object = _Placement.PIDDataSource
1004
                Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString()
1005
                Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString()
1006
                Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString()
1007
                Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString()
1008
                Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
1009
                Dim dAngle As Double = 0.0
1010
                If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then
1011
                    dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString())
1012
                End If
1013
                Dim dLocationX As Double = 0.0
1014
                Dim dLocationY As Double = 0.0
1015
                Dim dX As Double = 0.0
1016
                Dim dY As Double = 0.0
1017
1018
                If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
1019
                    dX = dLocationX
1020
                    dY = dLocationY
1021
                    ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1022
                    _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1023 b08338e3 Gyusu
                    SetListBoxItems(ListBox_Result, "Place Equipment.." & sUid & " (" & dLocationX & "," & dLocationY & ")..." & _iEquipmentcnt & " count ")
1024
1025
                    _iEquipmentcnt = _iEquipmentcnt + 1
1026
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Equipment : " & sUid)
1027
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Equipment Name : " & sEqpName)
1028
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1029
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
1030
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Equipment Count : " & _iEquipmentcnt)
1031
1032
1033 41e4023e Gyusu
                End If
1034
            End If
1035
        Catch ex As Exception
1036
1037
        End Try
1038
1039
1040
    End Sub
1041 54b98e09 Gyusu
1042 b08338e3 Gyusu
    Private Function PlacePipingOPC(ByVal sUid As String, ByVal oOPCRow As DataRow, ByVal oAttribute_Dt As DataTable, ByVal sLineNoText As String) As LMSymbol
1043 e4000111 Gyusu
        Try
1044
            Dim oAttributeRow() As DataRow
1045
            If oAttribute_Dt.Rows.Count > 0 Then
1046
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
1047
            End If
1048
            Dim oDatasource As Object = _Placement.PIDDataSource
1049
            Dim sSymbolCompType As String = oOPCRow(_XML_SYMBOL_TYPE).ToString()
1050
            Dim sSystemPath As String = oOPCRow(_XML_SYMBOL_SYSTEMPATH).ToString()
1051
            Dim sClass As String = oOPCRow(_XML_SYMBOL_CLASS).ToString()
1052
            Dim sLocation As String = oOPCRow(_XML_SYMBOL_LOCATION).ToString()
1053
            Dim sOriginalPoint As String = oOPCRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
1054
            Dim dAngle As Double = 0.0
1055
            If IsNumeric(oOPCRow(_XML_SYMBOL_ANGLE).ToString()) Then
1056
                dAngle = Double.Parse(oOPCRow(_XML_SYMBOL_ANGLE).ToString())
1057
            End If
1058
1059
            Dim dLocationX As Double = 0.0
1060
            Dim dLocationY As Double = 0.0
1061
            Dim dX As Double = 0.0
1062
            Dim dY As Double = 0.0
1063 bb2a0c79 Gyusu
            Dim oLMSymbol As LMSymbol = Nothing
1064 e4000111 Gyusu
            If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
1065
                dX = dLocationX
1066
                dY = dLocationY
1067
                ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1068
                _iPipintOpccnt = _iPipintOpccnt + 1
1069 bb2a0c79 Gyusu
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1070 e4000111 Gyusu
                '모델링된 형상은 Drawing True 로 처리
1071 bb2a0c79 Gyusu
                oOPCRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
1072 b08338e3 Gyusu
                SetListBoxItems(ListBox_Result, "Place Piping OPC.." & sUid & " (" & dLocationX & "," & dLocationY & ")..." & _iPipintOpccnt & " count ")
1073
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Piping OPC : " & sUid & "")
1074
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
1075
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oOPCRow(_XML_SYMBOL_Conn1_Uid).ToString())
1076
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oOPCRow(_XML_SYMBOL_Conn2_Uid).ToString())
1077
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1078
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
1079
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OPC Count : " & _iPipintOpccnt)
1080 e4000111 Gyusu
1081
                Dim dConn_X1 As Double, dConn_Y1 As Double, dConn_X2 As Double, dConn_Y2 As Double
1082
                _Placement.PIDConnectPointLocation(oLMSymbol, 1, dConn_X1, dConn_Y1)
1083
                _Placement.PIDConnectPointLocation(oLMSymbol, 2, dConn_X2, dConn_Y2)
1084
1085 bb2a0c79 Gyusu
                'Dim oAddrow As DataRow = _ResultModeling_DT.NewRow()
1086
                'oAddrow(_Modeling_Uid) = sUid
1087
                'oAddrow(_Modeling_Location_X) = dLocationX
1088
                'oAddrow(_Modeling_Location_Y) = dLocationY
1089
                'oAddrow(_Modeling_LineNoUid) = sLineUid
1090
                'oAddrow(_Modeling_Type) = sSymbolCompType
1091
                'oAddrow(_Modeling_Connection1_X) = dConn_X1
1092
                'oAddrow(_Modeling_Connection1_Y) = dConn_Y1
1093
                'oAddrow(_Modeling_Connection2_X) = dConn_X2
1094
                'oAddrow(_Modeling_Connection2_X) = dConn_Y2
1095
                'oAddrow(_Modeling_LMSymbol) = oLMSymbol
1096
1097
                '_ResultModeling_DT.Rows.Add(oAddrow)
1098 e4000111 Gyusu
            End If
1099
            _Itemcnt = _Itemcnt + 1
1100
            Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
1101
            SetProgressbar(ProgressBar_Status, dCalcProgressValue)
1102
            Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
1103 bb2a0c79 Gyusu
            Return oLMSymbol
1104 e4000111 Gyusu
        Catch ex As Exception
1105
1106
        End Try
1107 bb2a0c79 Gyusu
        Return Nothing
1108 e4000111 Gyusu
1109 bb2a0c79 Gyusu
    End Function
1110 e4000111 Gyusu
1111 76f465d0 Gyusu
    Private Sub AddProgress()
1112
        _Itemcnt = _Itemcnt + 1
1113
        Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
1114
        SetProgressbar(ProgressBar_Status, dCalcProgressValue)
1115
        Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
1116
    End Sub
1117 e4000111 Gyusu
    Private Function DrawSymbol(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oLine_Dt As DataTable) As Boolean
1118 171ac39d Gyusu
        Try
1119 e282643f Gyusu
1120 171ac39d Gyusu
            Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'")
1121 b08338e3 Gyusu
                Dim oAttributeRow() As DataRow
1122 6a6d8ab4 Gyusu
            If oAttribute_Dt.Rows.Count > 0 Then
1123 460d6abd Gyusu
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
1124 6a6d8ab4 Gyusu
            End If
1125
1126 171ac39d Gyusu
            If oSymbolRow.Length > 0 Then
1127
                Dim oDatasource As Object = _Placement.PIDDataSource
1128
                Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString()
1129
                Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString()
1130 54b98e09 Gyusu
                Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString()
1131 171ac39d Gyusu
                Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString()
1132 9e1e7135 Gyusu
                Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
1133 171ac39d Gyusu
                Dim dAngle As Double = 0.0
1134
                If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then
1135
                    dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString())
1136
                End If
1137
1138
                Dim objSymbol As LMSymbol
1139 9e1e7135 Gyusu
                Dim dLocationX As Double = 0.0
1140
                Dim dLocationY As Double = 0.0
1141 171ac39d Gyusu
                Dim dX As Double = 0.0
1142
                Dim dY As Double = 0.0
1143
1144 9e1e7135 Gyusu
                If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
1145
                    dX = dLocationX
1146
                    dY = dLocationY
1147 54b98e09 Gyusu
                    If sSymbolCompType = "" Or sSymbolCompType = "Piping OPC's" Then
1148
                        FindConnectionLine(oLine_Dt, dX, dY)
1149
                    End If
1150
1151 9e1e7135 Gyusu
                    ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1152 e4000111 Gyusu
                    Dim oInstrument As LMInstrument
1153 54b98e09 Gyusu
                    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
1154 9e1e7135 Gyusu
                        _iInstrumentcnt = _iInstrumentcnt + 1
1155 171ac39d Gyusu
                        objSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1156 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Instrument..(" & dLocationX & "," & dLocationY & ")..." & _iInstrumentcnt & " count ")
1157 171ac39d Gyusu
                        oInstrument = oDatasource.GetInstrument(objSymbol.ModelItemID)
1158 6a6d8ab4 Gyusu
                        Try
1159
                            If oAttributeRow.Length > 0 Then
1160
                                For Each oAttribute In oAttributeRow
1161 54b98e09 Gyusu
                                    Try
1162
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
1163
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
1164
                                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
1165
                                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
1166
                                    Catch ex As Exception
1167
1168
                                    End Try
1169
1170 6a6d8ab4 Gyusu
                                Next
1171
                                oInstrument.Commit()
1172
                            End If
1173
                        Catch ex As Exception
1174
                        End Try
1175 54b98e09 Gyusu
                    ElseIf sSymbolCompType.ToUpper() = _DB_FITTINGS.ToUpper() Then
1176 9e1e7135 Gyusu
                        _iValvecnt = _iValvecnt + 1
1177 171ac39d Gyusu
                        _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1178 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Valve..(" & dLocationX & "," & dLocationY & ")..." & _iValvecnt & " count ")
1179 171ac39d Gyusu
1180 54b98e09 Gyusu
                    ElseIf sSymbolCompType.ToUpper() = _SYMBOL_FITTINGS.ToUpper() Then
1181 9e1e7135 Gyusu
                        _iFittingcnt = _iFittingcnt + 1
1182 d039e347 Gyusu
                        If sSystemPath.Contains(",") Then
1183
1184
                            Dim sDuplicatePath As String() = sSystemPath.Split(",")
1185
                            Dim sMainSymbol As String = ""
1186
                            Dim sSubSymbol As String = ""
1187
                            For Each sPath In sDuplicatePath
1188
                                If sMainSymbol = "" Then
1189
                                    sMainSymbol = sPath.Replace(vbLf, "")
1190
                                Else
1191
                                    sSubSymbol = sPath.Replace(vbLf, "")
1192
                                End If
1193
                            Next
1194
                            Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle)
1195
                            Dim dConnpos_x As Double = 0.0
1196
                            Dim dConnpos_y As Double = 0.0
1197
                            _Placement.PIDConnectPointLocation(oSymbolObj, 2, dConnpos_x, dConnpos_y)
1198
                            '   _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y, dAngle, TargetItem:=oSymbolObj.AsLMRepresentation)
1199
                            _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y,, dAngle)
1200
1201
                        Else
1202
                            _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1203
                        End If
1204
1205
1206 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
1207 54b98e09 Gyusu
                    ElseIf sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() And sClass.ToUpper() = _SYMBOL_ACTUATORS.ToUpper() Then
1208 d039e347 Gyusu
                        _iFittingcnt = _iFittingcnt + 1
1209
                        Dim sDuplicatePath As String() = sSystemPath.Split(",")
1210
                        Dim sMainSymbol As String = ""
1211
                        Dim sSubSymbol As String = ""
1212
                        For Each sPath In sDuplicatePath
1213
                            If sMainSymbol = "" Then
1214
                                sMainSymbol = sPath.Replace(vbLf, "")
1215
                            Else
1216
                                sSubSymbol = sPath.Replace(vbLf, "")
1217
                            End If
1218
                        Next
1219
                        Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle)
1220
                        Dim dSymbolpos_x As Double = oSymbolObj.XCoordinate
1221
                        Dim dSymbolpos_y As Double = oSymbolObj.YCoordinate
1222
                        _Placement.PIDPlaceSymbol(sSubSymbol, dSymbolpos_x, dSymbolpos_y, , dAngle, TargetItem:=oSymbolObj.AsLMAItem)
1223
1224 171ac39d Gyusu
                    Else
1225 9e1e7135 Gyusu
                        _iFittingcnt = _iFittingcnt + 1
1226 171ac39d Gyusu
                        _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1227 6a6d8ab4 Gyusu
                        SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
1228 171ac39d Gyusu
                    End If
1229 e4000111 Gyusu
1230
                End If
1231 41e4023e Gyusu
                _Itemcnt = _Itemcnt + 1
1232
                Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
1233
                SetProgressbar(ProgressBar_Status, dCalcProgressValue)
1234
                Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
1235
            End If
1236 171ac39d Gyusu
1237 54b98e09 Gyusu
        Catch ex As Exception
1238
            Return False
1239
        End Try
1240
    End Function
1241
1242
1243
    Private Sub FindConnectionLine(ByVal oLine_Dt As DataTable, ByRef dx As Double, ByRef dy As Double)
1244
1245
        Try
1246
            For Each oRow In oLine_Dt.Rows
1247
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1248
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1249
                Dim d기준s_x As Double = 0
1250
                Dim d기준s_y As Double = 0
1251
                Dim d기준e_x As Double = 0
1252
                Dim d기준e_y As Double = 0
1253
                ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1254
                ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1255
                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
1256
                    dx = d기준s_x
1257
                    dy = d기준s_y
1258
                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
1259
                    dx = d기준e_x
1260
                    dy = d기준e_y
1261
                End If
1262
            Next
1263
        Catch ex As Exception
1264
        End Try
1265
    End Sub
1266
1267
1268
    Dim _라인보정기준값 As Integer = 10
1269
1270
    Private Function 라인보정(ByRef oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double,
1271
                                      ByRef dex As Double, ByRef dey As Double)
1272
        Try
1273
            Dim bCheck라인 As Boolean = False
1274
            '일치하는 Line 찾기
1275
            For Each oRow In oLine_Dt.Rows
1276
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1277
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1278
                Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1279
                If sBUid <> sUid Then
1280
                    Dim d기준s_x As Double = 0
1281
                    Dim d기준s_y As Double = 0
1282
                    Dim d기준e_x As Double = 0
1283
                    Dim d기준e_y As Double = 0
1284
                    ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1285
                    ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1286
1287
                    If (dsx = d기준s_x And dsy = d기준s_y) Or (dsx = d기준e_x And dsy = d기준e_y) Or
1288
                       (dex = d기준s_x And dey = d기준s_y) Or (dex = d기준e_x And dey = d기준e_y) Then
1289
                        bCheck라인 = True
1290
                    End If
1291
                End If
1292
            Next
1293
1294
            If bCheck라인 = False Then
1295
                For Each oRow In oLine_Dt.Rows
1296
                    Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1297
                    Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1298
                    Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1299
                    If sBUid <> sUid Then
1300
                        Dim d기준s_x As Double = 0
1301
                        Dim d기준s_y As Double = 0
1302
                        Dim d기준e_x As Double = 0
1303
                        Dim d기준e_y As Double = 0
1304
                        ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1305
                        ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1306
                        If ((dsx - _라인보정기준값 <= d기준s_x And dsx + _라인보정기준값 >= d기준s_x) And (dsy - _라인보정기준값 <= d기준s_y And dsy + _라인보정기준값 >= d기준s_y)) Then
1307
                            oRow(_XML_LINE_STARTPOINT) = dsx & "," & dsy
1308
                            bCheck라인 = True
1309
                            Exit For
1310
                        ElseIf ((dsx - _라인보정기준값 <= d기준e_x And dsx + _라인보정기준값 >= d기준e_x) And (dsy - _라인보정기준값 <= d기준e_y And dsy + _라인보정기준값 >= d기준e_y)) Then
1311
                            oRow(_XML_LINE_ENDPOINT) = dsx & "," & dsy
1312
                            bCheck라인 = True
1313
                            Exit For
1314
                        ElseIf ((dex - _라인보정기준값 <= d기준s_x And dex + _라인보정기준값 >= d기준s_x) And (dey - _라인보정기준값 <= d기준s_y And dey + _라인보정기준값 >= d기준s_y)) Then
1315
                            oRow(_XML_LINE_STARTPOINT) = dex & "," & dey
1316
                            bCheck라인 = True
1317
                            Exit For
1318
                        ElseIf ((dex - _라인보정기준값 <= d기준e_x And dex + _라인보정기준값 >= d기준e_x) And (dey - _라인보정기준값 <= d기준e_y And dey + _라인보정기준값 >= d기준e_y)) Then
1319
                            oRow(_XML_LINE_ENDPOINT) = dex & "," & dey
1320
                            bCheck라인 = True
1321
                            Exit For
1322
                        End If
1323
1324
                    End If
1325
                Next
1326 171ac39d Gyusu
            End If
1327
1328 54b98e09 Gyusu
            Return bCheck라인
1329 171ac39d Gyusu
        Catch ex As Exception
1330
            Return False
1331
        End Try
1332 54b98e09 Gyusu
1333
1334 171ac39d Gyusu
    End Function
1335
1336 460d6abd Gyusu
    Private Function FindOverlapLine(ByVal oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double,
1337
                                      ByRef dex As Double, ByRef dey As Double)
1338
        Try
1339
            Dim bCheckOverlap As Boolean = False
1340
            For Each oRow In oLine_Dt.Rows
1341
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1342
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1343
                Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1344
                If sBUid <> sUid Then
1345
                    Dim d기준s_x As Double = 0
1346
                    Dim d기준s_y As Double = 0
1347
                    Dim d기준e_x As Double = 0
1348
                    Dim d기준e_y As Double = 0
1349
                    ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1350
                    ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1351 54b98e09 Gyusu
                    If (d기준s_x <= dsx And d기준e_x >= dex And
1352
                        d기준s_y <= dsy And d기준e_y >= dey) Then
1353 460d6abd Gyusu
                        '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1354
                        If dsy - d기준s_y > d기준e_y - dey Then
1355
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1356
                            If dResultCalc < 10 Then
1357
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1358
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1359
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1360
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1361
                                If dCalcStartY = 0 Then
1362
                                    dey = d기준e_y
1363
                                Else
1364
                                    dey = dCalcStartY
1365
                                End If
1366
                            End If
1367
                        Else
1368 abb01e6c Gyusu
                            '  Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1369
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1370 460d6abd Gyusu
                            If dResultCalc < 10 Then
1371
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1372
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1373
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1374
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1375
                                If dCalcStartY = 0 Then
1376
                                    dsy = d기준s_y
1377
                                Else
1378
                                    dsy = dCalcStartY
1379
                                End If
1380
                            End If
1381
                        End If
1382
                        bCheckOverlap = True
1383
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1384
                            d기준s_y <= dey And d기준e_y >= dsy Then
1385
                        '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1386
                        If dey - d기준s_y > d기준e_y - dsy Then
1387
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1388
                            If dResultCalc < 10 Then
1389
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1390
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1391
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1392
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1393
                                If dCalcStartY = 0 Then
1394 abb01e6c Gyusu
                                    dsy = d기준e_y
1395 460d6abd Gyusu
                                Else
1396 abb01e6c Gyusu
                                    dsy = dCalcStartY
1397 460d6abd Gyusu
                                End If
1398
1399
                            End If
1400
                            '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1401
                        Else
1402 abb01e6c Gyusu
                            '  Dim dResultCalc As Double = (Math.Abs((dsy - d기준s_y)) / Math.Abs((d기준e_y - dey))) * 100
1403
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1404 460d6abd Gyusu
                            If dResultCalc < 10 Then
1405
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1406
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1407
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1408
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1409
                                If dCalcStartY = 0 Then
1410 abb01e6c Gyusu
                                    dey = d기준e_y
1411 460d6abd Gyusu
                                Else
1412 abb01e6c Gyusu
                                    dey = dCalcStartY
1413 460d6abd Gyusu
                                End If
1414
                            End If
1415
                        End If
1416
                        bCheckOverlap = True
1417
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1418
                            d기준s_y <= dey And d기준e_y >= dsy Then
1419
1420
                        If dsx - d기준s_x > d기준e_x - dex Then
1421
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1422
                            If dResultCalc < 10 Then
1423
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1424
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1425
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1426
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1427
                                If dCalcStartX = 0 Then
1428
                                    dex = d기준e_x
1429
                                Else
1430
                                    dex = dCalcStartX
1431
                                End If
1432
                            End If
1433
                        Else
1434 abb01e6c Gyusu
                            '  Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1435
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1436 460d6abd Gyusu
                            If dResultCalc < 10 Then
1437
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1438
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1439
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1440
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1441
                                If dCalcStartX = 0 Then
1442
                                    dsx = d기준s_x
1443
                                Else
1444
                                    dsx = dCalcStartX
1445
                                End If
1446
                            End If
1447
                        End If
1448
                        bCheckOverlap = True
1449
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1450
                            d기준s_y <= dey And d기준e_y >= dsy Then
1451
1452
                        If dex - d기준s_x > d기준e_x - dsx Then
1453
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1454
                            If dResultCalc < 10 Then
1455
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1456
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1457
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1458
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1459
                                If dCalcStartX = 0 Then
1460 abb01e6c Gyusu
                                    dsx = d기준e_x
1461 460d6abd Gyusu
                                Else
1462 abb01e6c Gyusu
                                    dsx = dCalcStartX
1463 460d6abd Gyusu
                                End If
1464
                            End If
1465
                        Else
1466 abb01e6c Gyusu
                            ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1467
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1468 460d6abd Gyusu
                            If dResultCalc < 10 Then
1469
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1470
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1471
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1472
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1473
                                If dCalcStartX = 0 Then
1474 abb01e6c Gyusu
                                    dex = d기준s_x
1475 460d6abd Gyusu
                                Else
1476 abb01e6c Gyusu
                                    dex = dCalcStartX
1477 460d6abd Gyusu
                                End If
1478
                            End If
1479
1480
                        End If
1481
                        bCheckOverlap = True
1482
                    End If
1483
                End If
1484
            Next
1485 3acffcee Gyusu
1486 460d6abd Gyusu
            Return bCheckOverlap
1487
        Catch ex As Exception
1488
            Return False
1489
        End Try
1490
    End Function
1491
1492
    Private Sub CalcSperateLine(ByRef dStartX As Double, ByRef dStartY As Double,
1493
                                      ByRef dEndX As Double, ByRef dEndY As Double)
1494
        Try
1495 54b98e09 Gyusu
            Dim dRange As Double = 1 'Line 전체 길이의 10%씩 늘이기
1496 460d6abd Gyusu
            If Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then
1497 54b98e09 Gyusu
                Dim dCalc_x As Double = Math.Abs(dStartX - dEndX) * 0.1
1498 460d6abd Gyusu
                If dStartX > dEndX Then
1499
                    dStartX = dStartX + dCalc_x
1500
                    dEndX = dEndX - dCalc_x
1501
                Else
1502
                    dEndX = dEndX + dCalc_x
1503
                    dStartX = dStartX - dCalc_x
1504
                End If
1505
            Else
1506 54b98e09 Gyusu
                Dim dCalc_y As Double = Math.Abs(dStartY - dEndY) * 0.1
1507 460d6abd Gyusu
                If dStartY > dEndY Then
1508
                    dStartY = dStartY + dCalc_y
1509
                    dEndY = dEndY - dCalc_y
1510
                Else
1511
                    dEndY = dEndY + dCalc_y
1512
                    dStartY = dStartY - dCalc_y
1513
                End If
1514
            End If
1515
1516
        Catch ex As Exception
1517
1518
        End Try
1519
1520
1521
    End Sub
1522
1523 3acffcee Gyusu
    Private Function DrawLineNo(ByVal oPipeRun_Dt As DataTable, ByVal CLine_No As Line_no) As Boolean
1524 171ac39d Gyusu
        Try
1525
            Dim oDatasource As Object = _Placement.PIDDataSource
1526
            Dim sLocation = CLine_No.Location
1527 9e1e7135 Gyusu
            Dim dLocationx As Double = 0.0
1528
            Dim dLocationy As Double = 0.0
1529
1530 171ac39d Gyusu
            Dim dX As Double = 0.0
1531
            Dim dY As Double = 0.0
1532 9e1e7135 Gyusu
            If ConvertPointBystring(sLocation, dLocationx, dLocationy) Then
1533
                dX = dLocationx
1534
                dY = dLocationy
1535 3acffcee Gyusu
1536
                For Each oRow In oPipeRun_Dt.Rows
1537
                    Dim dStartx As Double = Double.Parse(oRow("startx").ToString())
1538
                    Dim dStarty As Double = Double.Parse(oRow("starty").ToString())
1539
                    Dim dEndx As Double = Double.Parse(oRow("endx").ToString())
1540
                    Dim dEndy As Double = Double.Parse(oRow("endy").ToString())
1541
1542
                    Dim dStartSum As Double = Math.Abs(dStartx - dLocationx) + Math.Abs(dStarty - dLocationy)
1543
                    Dim dEndSum As Double = Math.Abs(dEndx - dLocationx) + Math.Abs(dEndy - dLocationy)
1544
                    If dStartSum > dEndSum Then
1545
                        oRow("value") = dEndSum
1546
                    Else
1547
                        oRow("value") = dStartSum
1548 171ac39d Gyusu
                    End If
1549 3acffcee Gyusu
1550 171ac39d Gyusu
                Next
1551 3acffcee Gyusu
                Dim dataView As New DataView(oPipeRun_Dt)
1552
                dataView.Sort = " value asc"
1553
                Dim oDt As DataTable = dataView.ToTable()
1554
                If oDt.Rows.Count > 0 Then
1555
                    Try
1556
                        Dim oPiperun As LMPipeRun = CType(oDt.Rows(0)("Piperun"), LMPipeRun)
1557
                        ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1558
                        Dim dLineNoLocation(2) As Double
1559
                        dLineNoLocation(1) = dX
1560
                        dLineNoLocation(2) = dY
1561
                        'Label
1562
                        Dim sSystemPath As String = CLine_No.SystemPath
1563
                        Dim dAngle As Double = CLine_No.Angle
1564
                        Dim labelpersist As LMLabelPersist
1565
1566
                        For Each representation In oPiperun.Representations
1567
                            If representation.RepresentationType = "Connector" Then
1568
                                labelpersist = _Placement.PIDPlaceLabel(sSystemPath,
1569
                                dLineNoLocation,, dAngle, LabeledItem:=representation)
1570
                                _iPipeLineNocnt = _iPipeLineNocnt + 1
1571 b08338e3 Gyusu
                                SetListBoxItems(ListBox_Result, "Place PipeLineNo Label.." & CLine_No.Uid & " (" & dLocationx & "," & dLocationy & ")..." & _iPipeLineNocnt & " count ")
1572
1573
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & CLine_No.Uid & "")
1574
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & CLine_No.Text)
1575
                                'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1576
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Origina lPoint : " & dLocationx & "," & dLocationy)
1577
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "PipeLineNo Count : " & _iPipeLineNocnt)
1578 3acffcee Gyusu
                            End If
1579
                        Next
1580
                    Catch ex As Exception
1581
1582
                    End Try
1583
1584
1585
                End If
1586
1587
1588
1589 171ac39d Gyusu
                Return True
1590
            Else
1591
                Return False
1592
            End If
1593
1594
        Catch ex As Exception
1595
            Return False
1596
        End Try
1597
    End Function
1598
1599 9e1e7135 Gyusu
1600
    Private Sub InitItemCount()
1601
        _iPipeLineNocnt = 0
1602 b08338e3 Gyusu
        _iPipecnt = 1
1603
        _iFittingcnt = 1
1604 9e1e7135 Gyusu
        _iValvecnt = 0
1605
        _iInstrumentcnt = 0
1606
        _iEquipmentcnt = 0
1607 3acffcee Gyusu
        _iNozzlecnt = 1
1608 e4000111 Gyusu
        _iPipintOpccnt = 0
1609 3acffcee Gyusu
1610 9e1e7135 Gyusu
    End Sub
1611 171ac39d Gyusu
1612 41e4023e Gyusu
    Private Function GetAllCheckNodeCount() As Integer
1613
        _allItem = 0
1614
        For i = 0 To Tree_Result.Nodes.Count - 1
1615
            For j = 0 To Tree_Result.Nodes(i).Nodes.Count - 1
1616
                For k = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes.Count - 1
1617
                    For l = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes.Count - 1
1618
                        If Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes(l).Checked = True Then
1619
                            _allItem = _allItem + 1
1620
                        End If
1621
                    Next
1622
                Next
1623
            Next
1624
        Next
1625
        Return _allItem
1626
    End Function
1627 54b98e09 Gyusu
1628
1629 e4000111 Gyusu
    ''' <summary>
1630
    ''' Equipment 모델링
1631
    ''' </summary>
1632
    Private Sub EquipmentModeling(ByVal oDwg_Dt As DataTable)
1633
        For Each oDrwing As TreeNode In Tree_Result.Nodes
1634
            For Each oDwgNode As TreeNode In oDrwing.Nodes
1635
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
1636
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
1637
                If CDrawing IsNot Nothing Then
1638
                    If OpenSPPID(oDwg_Dt, oDwgNode.Text) Then
1639 b08338e3 Gyusu
1640 e4000111 Gyusu
                        For Each oNode As TreeNode In oDwgNode.Nodes
1641
                            Dim iItemcnt As Integer = 0
1642
                            Dim sNodeUid As String = oNode.Name
1643
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
1644
                            '1.Equipment
1645
                            '2.Piping OPC
1646
                            '3.OPC 시작되는 Line
1647
                            'Equipment 생성
1648
                            Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid)
1649
                            If CEqpNo IsNot Nothing Then
1650
                                Dim oSymbol_Dt As DataTable = CEqpNo.Dt_Equipment
1651
                                Dim oAttribute_Dt As DataTable = CEqpNo.Dt_Attribute
1652
                                For Each oSymbolNode As TreeNode In oNode.Nodes
1653
                                    If oSymbolNode.Checked Then
1654
                                        Dim sUid As String = oSymbolNode.Name
1655 b08338e3 Gyusu
                                        PlaceEquipment(sUid, oSymbol_Dt, oAttribute_Dt, CEqpNo.Text)
1656 e4000111 Gyusu
                                    End If
1657
                                Next
1658
                            End If
1659
                        Next
1660
                    End If
1661
                End If
1662
            Next
1663
        Next
1664
    End Sub
1665
1666 bb2a0c79 Gyusu
    Private Sub ManualCheckNode(ByRef oDt As DataTable)
1667
        For Each oDrwing As TreeNode In Tree_Result.Nodes
1668
            For Each oDwgNode As TreeNode In oDrwing.Nodes
1669
                For Each oNode As TreeNode In oDwgNode.Nodes
1670
                    For Each oSymbolNode As TreeNode In oNode.Nodes
1671
                        Dim sUid As String = oSymbolNode.Name
1672 76f465d0 Gyusu
                        'Dim oSelectRows() As DataRow = oDt.Select("[" & _XML_SYMBOL_UID & "] = '" & sUid &
1673 3b7a4470 Gyusu
                        '                                      "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False'")
1674
                        If oSymbolNode.Checked Then
1675
                            Dim oSelectRows() As DataRow = oDt.Select("[" & _XML_SYMBOL_UID & "] = '" & sUid & "'")
1676
                            If oSelectRows.Length = 1 Then
1677
                                oSelectRows(0)(_XML_SYMBOL_DRAWING_TF) = "FALSE"
1678 76f465d0 Gyusu
1679 3b7a4470 Gyusu
                                If oSymbolNode.Checked Then
1680
1681
                                    oSelectRows(0)(_XML_SYMBOL_Check) = "TRUE"
1682
                                Else
1683
                                    oSelectRows(0)(_XML_SYMBOL_Check) = "FALSE"
1684
                                End If
1685 bb2a0c79 Gyusu
                            End If
1686 3b7a4470 Gyusu
1687 bb2a0c79 Gyusu
                        End If
1688
1689
                    Next
1690
                Next
1691
            Next
1692
        Next
1693
1694
    End Sub
1695 b08338e3 Gyusu
1696 f9b63682 Gyusu
    Private Function FinalSymbolModeling(ByVal oCurrentSymbolRow As DataRow, ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable,
1697
                                  ByVal oAttribute_Dt As DataTable) As String
1698
        Dim sReturnUid As String = ""
1699
        Dim sOriginalPoint As String = ""
1700
        Dim dOriginal_x As Double = 0.0
1701
        Dim dOriginal_y As Double = 0.0
1702
1703
        Dim dConn1_x As Double = 0.0
1704
        Dim dConn1_y As Double = 0.0
1705
        Dim dConn2_x As Double = 0.0
1706
        Dim dConn2_y As Double = 0.0
1707
        Dim dConn3_x As Double = 0.0
1708
        Dim dConn3_y As Double = 0.0
1709
        Dim dConn4_x As Double = 0.0
1710
        Dim dConn4_y As Double = 0.0
1711
1712
        Dim sUid As String = oCurrentSymbolRow(_XML_SYMBOL_UID)
1713
        Dim sSystemPath As String = oCurrentSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
1714
        Dim dAngle As Double = oCurrentSymbolRow(_XML_SYMBOL_ANGLE)
1715
        Dim sLineNoText As String = oCurrentSymbolRow(_XML_LINENO_TEXT)
1716
        Dim sLineNoUid As String = oCurrentSymbolRow(_XML_LINE_LINENOUID).ToString()
1717
        sOriginalPoint = oCurrentSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
1718 76f465d0 Gyusu
        Dim sSymbolCompType As String = oCurrentSymbolRow(_XML_SYMBOL_TYPE).ToString()
1719 f9b63682 Gyusu
        ConvertPointBystring(sOriginalPoint, dOriginal_x, dOriginal_y)
1720
        ConvertPointByImage(dOriginal_x, dOriginal_y, _IMG_X, _IMG_Y)
1721
1722 9c86a823 Gyusu
        Dim sChildItem As String = oCurrentSymbolRow(_XML_SYMBOL_CHILD)
1723
1724 f9b63682 Gyusu
        'Connection 정보 체크, 모델링 되어 있는지 유무
1725
        '양 커넥션의 모델링 유무를 체크한다.
1726
        Dim sConn1Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString()
1727
        Dim sConn2Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString()
1728
        Dim sConn3Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString()
1729
        Dim sConn4Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString()
1730
1731
        Dim sConn1Type As String = ""
1732
        Dim sConn2Type As String = ""
1733
        Dim sConn3Type As String = ""
1734
        Dim sConn4Type As String = ""
1735
1736
        Dim oConn1Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn1Uid & "'")
1737
        If oConn1Rows.Length = 0 Then
1738
            oConn1Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn1Uid & "'")
1739
            If oConn1Rows.Length = 1 Then
1740
                sConn1Type = "Line"
1741 b08338e3 Gyusu
            End If
1742 f9b63682 Gyusu
        Else
1743
            sConn1Type = "Symbol"
1744
        End If
1745 b08338e3 Gyusu
1746 f9b63682 Gyusu
        Dim oConn2Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn2Uid & "'")
1747
        If oConn2Rows.Length = 0 Then
1748
            oConn2Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn2Uid & "'")
1749
            If oConn2Rows.Length = 1 Then
1750
                sConn2Type = "Line"
1751 b08338e3 Gyusu
            End If
1752 f9b63682 Gyusu
        Else
1753
            sConn2Type = "Symbol"
1754
        End If
1755 b08338e3 Gyusu
1756 f9b63682 Gyusu
        Dim oConn3Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn3Uid & "'")
1757
        If oConn3Rows.Length = 0 Then
1758
            oConn3Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn3Uid & "'")
1759
            If oConn3Rows.Length = 1 Then
1760
                sConn3Type = "Line"
1761 b08338e3 Gyusu
            End If
1762 f9b63682 Gyusu
        Else
1763
            sConn3Type = "Symbol"
1764
        End If
1765 b08338e3 Gyusu
1766 f9b63682 Gyusu
        Dim oConn4Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn4Uid & "'")
1767
        If oConn4Rows.Length = 0 Then
1768
            oConn4Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn4Uid & "'")
1769
            If oConn4Rows.Length = 1 Then
1770
                sConn4Type = "Line"
1771 b08338e3 Gyusu
            End If
1772 f9b63682 Gyusu
        Else
1773
            sConn4Type = "Symbol"
1774
        End If
1775 b08338e3 Gyusu
1776 f9b63682 Gyusu
        Dim oStartLMConnector As LMConnector = Nothing
1777
        Dim oEndLMConnector As LMConnector = Nothing
1778
        Dim objInputs As PlaceRunInputs
1779
        objInputs = New PlaceRunInputs
1780
        Dim iModelingType As Integer = 0
1781 76f465d0 Gyusu
        If sConn1Type <> "" Then
1782
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1783 f9b63682 Gyusu
        End If
1784 76f465d0 Gyusu
        If sConn2Type <> "" Then
1785
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1786 f9b63682 Gyusu
        End If
1787 76f465d0 Gyusu
        If sConn3Type <> "" Then
1788
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1789 f9b63682 Gyusu
        End If
1790 76f465d0 Gyusu
        If sConn4Type <> "" Then
1791
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1792 f9b63682 Gyusu
        End If
1793 b08338e3 Gyusu
1794 9c86a823 Gyusu
1795
1796
1797
1798 76f465d0 Gyusu
        'If sConn1Type = "Line" Then
1799
        '    Dim sStartpoint As String = oCurrentSymbolRow(0)(_XML_SYMBOL_Conn1_Point).ToString()
1800
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1801
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1802
        'ElseIf sConn1Type = "Symbol" Then
1803
        '    ConvertPoint(oCurrentSymbolRow(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1804
        'End If
1805
1806
        'If sConn2Type = "Line" Then
1807
        '    Dim sEndpoint As String = oCurrentSymbolRow(0)(_XML_SYMBOL_Conn2_Point).ToString()
1808
        '    ConvertPointBystring(sEndpoint, dConn2_x, dConn2_y)
1809
        '    ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
1810
        'ElseIf sConn2Type = "Symbol" Then
1811
        '    ConvertPoint(oCurrentSymbolRow(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1812
        'End If
1813
1814
        'If sConn3Type = "Line" Then
1815
        '    Dim sStartpoint As String = oCurrentSymbolRow(0)(_XML_SYMBOL_Conn3_Point).ToString()
1816
        '    ConvertPointBystring(sStartpoint, dConn3_x, dConn3_y)
1817
        '    ConvertPointByImage(dConn3_x, dConn3_y, _IMG_X, _IMG_Y)
1818
        'ElseIf sConn3Type = "Symbol" Then
1819
        '    ConvertPoint(oCurrentSymbolRow(0)(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1820
        'End If
1821
1822
        'If sConn4Type = "Line" Then
1823
        '    Dim sEndpoint As String = oCurrentSymbolRow(0)(_XML_SYMBOL_Conn4_Point).ToString()
1824
        '    ConvertPointBystring(sEndpoint, dConn4_x, dConn4_y)
1825
        '    ConvertPointByImage(dConn4_x, dConn4_y, _IMG_X, _IMG_Y)
1826
        'ElseIf sConn4Type = "Symbol" Then
1827
        '    ConvertPoint(oCurrentSymbolRow(0)(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1828
        'End If
1829
1830 b08338e3 Gyusu
1831
1832 f9b63682 Gyusu
        'If sConn1Type = "Line" And sConn2Type = "Line" Then
1833
        '    Dim sStartpoint As String = oConn1Rows(_XML_LINE_STARTPOINT).ToString()
1834
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1835
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1836
        '    Dim sEndpoint As String = oConn1Rows(_XML_LINE_ENDPOINT).ToString()
1837
        '    ConvertPointBystring(sEndpoint, dConn2_x, dConn2_y)
1838
        '    ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
1839
1840
        'ElseIf sConn1Type = "Line" And sConn2Type = "Symbol" Then
1841
        '    Dim sStartpoint As String = oConn1Rows(_XML_LINE_STARTPOINT).ToString()
1842
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1843
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1844
1845
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1846
        'ElseIf sConn1Type = "Symbol" And sConn2Type = "Line" Then
1847
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1848
1849
        '    Dim sEndpoint As String = oConn1Rows(_XML_LINE_ENDPOINT).ToString()
1850
        '    ConvertPointBystring(sEndpoint, dConn2_x, dConn2_y)
1851
        '    ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
1852
1853
        'ElseIf sConn1Type = "Symbol" And sConn2Type = "Symbol" Then
1854
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1855
        '    ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1856
        'ElseIf sConn1Type = "Line" And sConn2Type = "" Then
1857
        '    Dim sStartpoint As String = oConn1Rows(_XML_LINE_STARTPOINT).ToString()
1858
        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
1859
        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
1860
1861
        'ElseIf sConn1Type = "Symbol" And sConn2Type = "" Then
1862
        '    iModelingType = 6
1863
        'ElseIf sConn1Type = "" And sConn2Type = "Line" Then
1864
        '    iModelingType = 7
1865
        'ElseIf sConn1Type = "" And sConn2Type = "Symbol" Then
1866
        '    iModelingType = 8
1867
        'ElseIf sConn3Type = "Line" And sConn4Type = "Line" Then
1868
        '        iModelingType = 4
1869
        '    ElseIf sConn3Type = "Line" And sConn4Type = "Symbol" Then
1870
        '        iModelingType = 4
1871
        '    ElseIf sConn3Type = "Symbol" And sConn4Type = "Line" Then
1872
        '        iModelingType = 4
1873
        '    ElseIf sConn3Type = "Symbol" And sConn4Type = "Symbol" Then
1874
        '        iModelingType = 4
1875
        '    ElseIf sConn3Type = "Line" And sConn4Type = "" Then
1876
        '        iModelingType = 5
1877
        '    ElseIf sConn3Type = "Symbol" And sConn4Type = "" Then
1878
        '        iModelingType = 5
1879
        '    ElseIf sConn3Type = "" And sConn4Type = "Line" Then
1880
        '        iModelingType = 6
1881
        '    ElseIf sConn3Type = "" And sConn4Type = "Symbol" Then
1882
        '        iModelingType = 6
1883
        '    Else
1884
        '        iModelingType = 7
1885
        '    End If
1886
1887
        'If iModelingType = 1 Then
1888
        '        ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1889
        '        ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1890
        '    ElseIf iModelingType = 2 Then
1891
        '        ConvertPoint(oConn1Rows(0)(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1892
        '    ElseIf iModelingType = 3 Then
1893
        '        ConvertPoint(oConn2Rows(0)(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1894
        '    ElseIf iModelingType = 4 Then
1895
        '        ConvertPoint(oConn3Rows(0)(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1896
        '        ConvertPoint(oConn4Rows(0)(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1897
        '    ElseIf iModelingType = 5 Then
1898
        '        ConvertPoint(oConn3Rows(0)(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1899
        '    ElseIf iModelingType = 6 Then
1900
        '        ConvertPoint(oConn4Rows(0)(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
1901
        '    End If
1902
        Dim sFirstUid As String = ""
1903
        Dim sSecondUid As String = ""
1904
        Dim oLMSymbol As LMSymbol = Nothing
1905 76f465d0 Gyusu
        Dim dPreConn_x As Double = 0
1906
        Dim dPreConn_y As Double = 0
1907 f9b63682 Gyusu
        If sConn1Type <> "" And sConn2Type <> "" Then
1908 76f465d0 Gyusu
            If sConn1Type = "Line" Then
1909 79326880 Gyusu
                CheckConnectionLine(dConn1_x, dConn1_y, oStartLMConnector)
1910 76f465d0 Gyusu
            Else
1911
                CheckConnectionSymbolToSymbol(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector)
1912
            End If
1913
1914
            If sConn2Type = "Line" Then
1915 79326880 Gyusu
                CheckConnectionLine(dConn2_x, dConn2_y, oEndLMConnector)
1916 76f465d0 Gyusu
            Else
1917
                CheckConnectionSymbolToSymbol(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector)
1918
            End If
1919
1920 f9b63682 Gyusu
            sFirstUid = CheckExistModeling(oConn1Rows(0))
1921
            sSecondUid = CheckExistModeling(oConn2Rows(0))
1922 79326880 Gyusu
            Dim oCurrentLMConnector As LMConnector = Nothing
1923
            'If oStartLMConnector IsNot Nothing And oEndLMConnector IsNot Nothing Then
1924
1925
            '    '라인을 센터점에 먼저그리기
1926
            '    'If dConn1_x <> dConn2_x And dConn1_y <> dConn2_y Then
1927
            '    '    'Angle Valve
1928
            '    '    '라인두개 긋기
1929
            '    '    objInputs.Clear()
1930
            '    '    '   objInputs.AddPoint(dConn1_x, dConn1_y)
1931
            '    '    objInputs.AddConnectorTarget(oStartLMConnector, dConn1_x, dConn1_y)
1932
            '    '    objInputs.AddPoint(dOriginal_x, dOriginal_y)
1933
1934
1935
            '    '    Dim objItem As LMAItem
1936
            '    '    Dim sLineType As String = oConn1Rows(0)(_XML_LINE_TYPE).ToString()
1937
            '    '    Dim sLine1Path As String = GetPipeType(sLineType)
1938
            '    '    sLineType = oConn2Rows(0)(_XML_LINE_TYPE).ToString()
1939
            '    '    Dim sLine2Path As String = GetPipeType(sLineType)
1940
            '    '    If sLine1Path = sLine2Path Then
1941
            '    '        objItem = _Placement.PIDCreateItem(sLine1Path)
1942
            '    '        oCurrentLMConnector = _Placement.PIDPlaceRun(objItem, objInputs)
1943
            '    '    Else
1944
            '    '        '//서로다른선일경우 먼저 Symbol을 그리고 커넥션으로 부터 각 선까지 선을 잇는다.
1945
            '    '    End If
1946
            '    '    Dim sID_1 As String = ""
1947
            '    '    Dim sID_2 As String = ""
1948
            '    '    Dim sID_3 As String = ""
1949
            '    '    sID_1 = oStartLMConnector.ModelItemID
1950
            '    '    sID_2 = oCurrentLMConnector.ModelItemID
1951
            '    '    sID_3 = oEndLMConnector.ModelItemID
1952
            '    '    Try
1953
1954
            '    '        If sID_1 <> "" And sID_2 <> "" Then
1955
            '    '            Dim objSurvivorItem As LMAItem = Nothing
1956
            '    '            Dim oPipeRun1 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_1)
1957
            '    '            Dim oPipeRun2 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_2)
1958
            '    '            _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
1959
            '    '        End If
1960
            '    '    Catch ex As Exception
1961
1962
            '    '    End Try
1963
            '    '    objInputs.Clear()
1964
            '    '    '     objInputs.AddPoint(dOriginal_x, dOriginal_y)
1965
            '    '    objInputs.AddConnectorTarget(oStartLMConnector, dOriginal_x, dOriginal_y)
1966
            '    '    'objInputs.AddPoint(dConn2_x, dConn2_y)
1967
            '    '    objInputs.AddConnectorTarget(oEndLMConnector, dOriginal_x, dOriginal_y)
1968
            '    '    If sLine1Path = sLine2Path Then
1969
            '    '        objItem = _Placement.PIDCreateItem(sLine1Path)
1970
            '    '        oCurrentLMConnector = _Placement.PIDPlaceRun(objItem, objInputs)
1971
            '    '    Else
1972
            '    '        '//서로다른선일경우 먼저 Symbol을 그리고 커넥션으로 부터 각 선까지 선을 잇는다.
1973
            '    '    End If
1974
1975
            '    '    Try
1976
            '    '        sID_1 = oEndLMConnector.ModelItemID
1977
            '    '        sID_2 = oCurrentLMConnector.ModelItemID
1978
            '    '        If sID_1 <> "" And sID_2 <> "" Then
1979
            '    '            Dim objSurvivorItem As LMAItem = Nothing
1980
            '    '            Dim oPipeRun1 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_1)
1981
            '    '            Dim oPipeRun2 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_2)
1982
            '    '            _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
1983
            '    '        End If
1984
            '    '    Catch ex As Exception
1985
            '    '    End Try
1986
            '    'End If
1987
            'Else
1988
            '    If oStartLMConnector IsNot Nothing Then
1989
            '        dOriginal_x = dConn1_x
1990
            '        dOriginal_y = dConn1_y
1991
            '    Else
1992
            '        dOriginal_x = dConn2_x
1993
            '        dOriginal_y = dConn2_y
1994
            '    End If
1995
            'End If
1996 f9b63682 Gyusu
        ElseIf sConn1Type <> "" And sConn2Type = "" Then
1997 76f465d0 Gyusu
            If sConn1Type = "Line" Then
1998 79326880 Gyusu
                CheckConnectionLine(dConn1_x, dConn1_y, oStartLMConnector)
1999 76f465d0 Gyusu
            Else
2000
                CheckConnectionSymbolToSymbol(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector)
2001 79326880 Gyusu
                dOriginal_x = dConn1_x
2002
                dOriginal_y = dConn1_y
2003 76f465d0 Gyusu
            End If
2004
2005 f9b63682 Gyusu
            sFirstUid = CheckExistModeling(oConn1Rows(0))
2006 79326880 Gyusu
2007 f9b63682 Gyusu
        ElseIf sConn1Type = "" And sConn2Type <> "" Then
2008 76f465d0 Gyusu
2009
            If sConn1Type = "Line" Then
2010 79326880 Gyusu
                CheckConnectionLine(dConn2_x, dConn2_y, oEndLMConnector)
2011 76f465d0 Gyusu
            Else
2012
                CheckConnectionSymbolToSymbol(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector)
2013 79326880 Gyusu
                dOriginal_x = dConn2_x
2014
                dOriginal_y = dConn2_y
2015 76f465d0 Gyusu
            End If
2016 f9b63682 Gyusu
            sSecondUid = CheckExistModeling(oConn2Rows(0))
2017 79326880 Gyusu
2018 f9b63682 Gyusu
        ElseIf sConn3Type <> "" And sConn4Type <> "" Then
2019 76f465d0 Gyusu
            If sConn1Type = "Line" Then
2020 79326880 Gyusu
                CheckConnectionLine(dConn3_x, dConn3_y, oStartLMConnector)
2021 76f465d0 Gyusu
            Else
2022
                CheckConnectionSymbolToSymbol(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector)
2023
            End If
2024
2025
            If sConn2Type = "Line" Then
2026 79326880 Gyusu
                CheckConnectionLine(dConn4_x, dConn4_y, oEndLMConnector)
2027 76f465d0 Gyusu
            Else
2028
                CheckConnectionSymbolToSymbol(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector)
2029
            End If
2030
2031 f9b63682 Gyusu
            sFirstUid = CheckExistModeling(oConn3Rows(0))
2032
            sSecondUid = CheckExistModeling(oConn4Rows(0))
2033 79326880 Gyusu
            'If oStartLMConnector IsNot Nothing Then
2034
            '    dOriginal_x = dConn3_x
2035
            '    dOriginal_y = dConn3_y
2036
            'Else
2037
            '    dOriginal_x = dConn4_x
2038
            '    dOriginal_y = dConn4_y
2039
            'End If
2040 76f465d0 Gyusu
2041 f9b63682 Gyusu
        ElseIf sConn3Type <> "" And sConn4Type = "" Then
2042 76f465d0 Gyusu
            If sConn1Type = "Line" Then
2043 79326880 Gyusu
                CheckConnectionLine(dConn3_x, dConn3_y, oStartLMConnector)
2044 76f465d0 Gyusu
            Else
2045
                CheckConnectionSymbolToSymbol(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector)
2046 79326880 Gyusu
                dOriginal_x = dConn3_x
2047
                dOriginal_y = dConn3_y
2048 76f465d0 Gyusu
            End If
2049
2050 f9b63682 Gyusu
            sFirstUid = CheckExistModeling(oConn3Rows(0))
2051 79326880 Gyusu
2052 f9b63682 Gyusu
        ElseIf sConn3Type = "" And sConn4Type <> "" Then
2053 76f465d0 Gyusu
            If sConn2Type = "Line" Then
2054 79326880 Gyusu
                CheckConnectionLine(dConn4_x, dConn4_y, oEndLMConnector)
2055 76f465d0 Gyusu
            Else
2056
                CheckConnectionSymbolToSymbol(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector)
2057 79326880 Gyusu
                dOriginal_x = dConn4_x
2058
                dOriginal_y = dConn4_y
2059 76f465d0 Gyusu
            End If
2060
2061 f9b63682 Gyusu
            sSecondUid = CheckExistModeling(oConn4Rows(0))
2062 79326880 Gyusu
2063 f9b63682 Gyusu
        Else
2064 76f465d0 Gyusu
            '      oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2065 f9b63682 Gyusu
        End If
2066 b08338e3 Gyusu
2067 f9b63682 Gyusu
        If sFirstUid <> "" And sSecondUid <> "" Then
2068
            sReturnUid = sSecondUid
2069
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
2070
            sReturnUid = sFirstUid
2071
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
2072
            sReturnUid = sFirstUid
2073 76f465d0 Gyusu
        ElseIf sSecondUid <> "" And sFirstUid = "" Then
2074
            sReturnUid = sSecondUid
2075
        ElseIf sSecondUid <> "" And sFirstUid = "" Then
2076
            sReturnUid = sSecondUid
2077 f9b63682 Gyusu
        Else
2078
            sReturnUid = ""
2079
        End If
2080 b08338e3 Gyusu
2081 76f465d0 Gyusu
        If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
2082 f9b63682 Gyusu
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2083 76f465d0 Gyusu
            oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2084
        Else
2085
            If oStartLMConnector IsNot Nothing And oEndLMConnector IsNot Nothing Then
2086
                'oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle, ExistingItem:=oStartLMConnector.AsLMAItem,
2087
                '            TargetItem:=oEndLMConnector.AsLMAItem)
2088
                'oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2089
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2090
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2091
            ElseIf oStartLMConnector IsNot Nothing And oEndLMConnector Is Nothing Then
2092
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle,,
2093
                            TargetItem:=oStartLMConnector.AsLMAItem)
2094
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2095
            ElseIf oStartLMConnector Is Nothing And oEndLMConnector IsNot Nothing Then
2096
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle,,
2097
                TargetItem:=oEndLMConnector.AsLMAItem)
2098
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2099
            Else
2100
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2101
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2102
            End If
2103 9c86a823 Gyusu
        End If
2104
2105
        If sChildItem <> "" Then
2106
            Dim sConn1_Systempath As String = ""
2107
            Dim sConn2_Systempath As String = ""
2108
            Dim sConn1_Angle As Double = 0
2109
            Dim sConn2_Angle As Double = 0
2110
2111
            For Each sDirection In sChildItem.Split("/")
2112
                Dim iType As Integer = 0
2113
                For Each sType In sDirection.Split(",")
2114
                    If sConn1_Systempath = "" Then
2115 79326880 Gyusu
2116 9c86a823 Gyusu
                        If iType = 0 Then
2117
                            sConn1_Angle = GetChildSymbolDirection(sType)
2118
                            iType = iType + 1
2119
                        Else
2120
                            Dim sStartpoint As String = oCurrentSymbolRow(_XML_SYMBOL_Conn1_Point).ToString()
2121
                            ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
2122
                            ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
2123
                            sConn1_Systempath = GetDataFromMappingDB(sType, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
2124 79326880 Gyusu
                            Dim dChildConn1_x As Double = 0
2125
                            Dim dChildConn1_y As Double = 0
2126 9c86a823 Gyusu
2127 79326880 Gyusu
                            If oLMSymbol IsNot Nothing Then
2128
                                _Placement.PIDConnectPointLocation(oLMSymbol, 1, dChildConn1_x, dChildConn1_y)
2129
                                _Placement.PIDPlaceSymbol(sConn1_Systempath, dChildConn1_x, dChildConn1_y,, sConn1_Angle,,
2130
                                 TargetItem:=oLMSymbol.AsLMAItem)
2131 9c86a823 Gyusu
                            Else
2132 79326880 Gyusu
                                _Placement.PIDPlaceSymbol(sConn1_Systempath, dConn1_x, dConn1_y,, sConn1_Angle,,)
2133 9c86a823 Gyusu
                            End If
2134
                        End If
2135 79326880 Gyusu
2136
                        'If iType = 0 Then
2137
                        '    sConn1_Angle = GetChildSymbolDirection(sType)
2138
                        '    iType = iType + 1
2139
                        'Else
2140
                        '    Dim sStartpoint As String = oCurrentSymbolRow(_XML_SYMBOL_Conn1_Point).ToString()
2141
                        '    ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
2142
                        '    ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
2143
                        '    sConn1_Systempath = GetDataFromMappingDB(sType, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
2144
                        '    If oStartLMConnector Is Nothing Then
2145
                        '        Dim dChildConn1_x As Double = 0
2146
                        '        Dim dChildConn1_y As Double = 0
2147
                        '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dChildConn1_x, dChildConn1_y)
2148
                        '        If oLMSymbol.Connect1Connectors.Count = 0 And oLMSymbol IsNot Nothing Then
2149
                        '            _Placement.PIDPlaceSymbol(sConn1_Systempath, dChildConn1_x, dChildConn1_y,, sConn1_Angle,,
2150
                        '             TargetItem:=oLMSymbol.AsLMAItem)
2151
                        '        Else
2152
                        '            For Each oConnector In oLMSymbol.Connect1Connectors
2153
                        '                _Placement.PIDPlaceSymbol(sConn1_Systempath, dChildConn1_x, dChildConn1_y,, sConn1_Angle,,
2154
                        '                TargetItem:=oConnector.AsLMAItem)
2155
                        '            Next
2156
                        '        End If
2157
2158
                        '    Else
2159
                        '        _Placement.PIDPlaceSymbol(sConn1_Systempath, dConn1_x, dConn1_y,, sConn1_Angle,,
2160
                        '                    TargetItem:=oLMSymbol.AsLMAItem)
2161
                        '        'oLMSymbol = _Placement.PIDPlaceSymbol(sConn1_Systempath, dConn1_x, dConn1_y,, sConn1_Angle,,
2162
                        '        'TargetItem:=oStartLMConnector.AsLMAItem)
2163
                        '    End If
2164
2165
                        'End If
2166 9c86a823 Gyusu
                    Else
2167
                        If iType = 0 Then
2168
                            sConn2_Angle = GetChildSymbolDirection(sType)
2169
                            iType = iType + 1
2170
                        Else
2171
                            Dim sEndPoint As String = oCurrentSymbolRow(_XML_SYMBOL_Conn2_Point).ToString()
2172
                            ConvertPointBystring(sEndPoint, dConn2_x, dConn2_y)
2173
                            ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
2174
                            sConn2_Systempath = GetDataFromMappingDB(sType, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
2175
2176 79326880 Gyusu
                            Dim dChildConn2_x As Double = 0
2177
                            Dim dChildConn2_y As Double = 0
2178
2179
                            If oLMSymbol IsNot Nothing Then
2180
                                _Placement.PIDConnectPointLocation(oLMSymbol, 2, dChildConn2_x, dChildConn2_y)
2181
                                _Placement.PIDPlaceSymbol(sConn1_Systempath, dChildConn2_x, dChildConn2_y,, sConn2_Angle,,
2182
                                        TargetItem:=oLMSymbol.AsLMAItem)
2183 9c86a823 Gyusu
                            Else
2184 79326880 Gyusu
                                _Placement.PIDPlaceSymbol(sConn2_Systempath, dChildConn2_x, dChildConn2_y,, sConn2_Angle,,)
2185 9c86a823 Gyusu
                            End If
2186
2187
                        End If
2188 79326880 Gyusu
2189
2190
                        'If iType = 0 Then
2191
                        '    sConn2_Angle = GetChildSymbolDirection(sType)
2192
                        '    iType = iType + 1
2193
                        'Else
2194
                        '    Dim sEndPoint As String = oCurrentSymbolRow(_XML_SYMBOL_Conn2_Point).ToString()
2195
                        '    ConvertPointBystring(sEndPoint, dConn2_x, dConn2_y)
2196
                        '    ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
2197
                        '    sConn2_Systempath = GetDataFromMappingDB(sType, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
2198
                        '    If oEndLMConnector Is Nothing Then
2199
                        '        Dim dChildConn2_x As Double = 0
2200
                        '        Dim dChildConn2_y As Double = 0
2201
                        '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dChildConn2_x, dChildConn2_y)
2202
                        '        If oLMSymbol.Connect2Connectors.Count = 0 And oLMSymbol IsNot Nothing Then
2203
                        '            _Placement.PIDPlaceSymbol(sConn1_Systempath, dChildConn2_x, dChildConn2_y,, sConn2_Angle,,
2204
                        '            TargetItem:=oLMSymbol.AsLMAItem)
2205
                        '        Else
2206
                        '            For Each oConnector In oLMSymbol.Connect2Connectors
2207
                        '                oLMSymbol = _Placement.PIDPlaceSymbol(sConn2_Systempath, dChildConn2_x, dChildConn2_y,, sConn2_Angle,,
2208
                        '                TargetItem:=oConnector.AsLMAItem)
2209
                        '            Next
2210
                        '        End If
2211
2212
                        '    Else
2213
                        '        _Placement.PIDPlaceSymbol(sConn1_Systempath, dConn2_x, dConn2_y,, sConn2_Angle,,
2214
                        '            TargetItem:=oLMSymbol.AsLMAItem)
2215
                        '        '    oLMSymbol = _Placement.PIDPlaceSymbol(sConn2_Systempath, dConn2_x, dConn2_y,, sConn2_Angle,,
2216
                        '        'TargetItem:=oEndLMConnector.AsLMAItem)
2217
                        '    End If
2218
2219
                        'End If
2220 9c86a823 Gyusu
                    End If
2221
                Next
2222
            Next
2223
2224
2225
            'If sConn1_Systempath <> "" Then
2226
            '    Dim oConn1s As LMConnectors = oLMSymbol.Connect1Connectors
2227
            '    Dim dChildConn1_x As Double = 0
2228
            '    Dim dChildConn1_y As Double = 0
2229
            '    _Placement.PIDConnectPointLocation(oLMSymbol, 1, dChildConn1_x, dChildConn1_y)
2230
            '    oLMSymbol = _Placement.PIDPlaceSymbol(sConn1_Systempath, dChildConn1_x, dChildConn1_y,, sConn1_Angle)
2231
            '    'For Each oConnector In oLMSymbol.Connect1Connectors
2232
            '    '    oLMSymbol = _Placement.PIDPlaceSymbol(sConn1_Systempath, dChildConn1_x, dChildConn1_y,, sConn1_Angle,,
2233
            '    '    TargetItem:=oConnector.AsLMAItem)
2234
            '    'Next
2235
            'End If
2236
2237
            'If sConn2_Systempath <> "" Then
2238
            '    Dim oConn2s As LMConnectors = oLMSymbol.Connect2Connectors
2239
            '    Dim dChildConn2_x As Double = 0
2240
            '    Dim dChildConn2_y As Double = 0
2241
            '    _Placement.PIDConnectPointLocation(oLMSymbol, 2, dChildConn2_x, dChildConn2_y)
2242
            '    oLMSymbol = _Placement.PIDPlaceSymbol(sConn2_Systempath, dChildConn2_x, dChildConn2_y,, sConn2_Angle)
2243
            '    'For Each oConnector In oLMSymbol.Connect2Connectors
2244
            '    '    oLMSymbol = _Placement.PIDPlaceSymbol(sConn2_Systempath, dChildConn2_x, dChildConn2_y,, sConn2_Angle,,
2245
            '    '    TargetItem:=oConnector.AsLMAItem)
2246
            '    'Next
2247
            'End If
2248
            ''Child 모델링
2249
2250
2251
2252
2253
2254
2255
2256 b08338e3 Gyusu
        End If
2257 9c86a823 Gyusu
2258
2259
2260
2261
2262 76f465d0 Gyusu
        AddProgress()
2263 b08338e3 Gyusu
2264 f9b63682 Gyusu
        SetListBoxItems(ListBox_Result, "Place Fitting.." & sUid & " (" & dOriginal_x & "," & dOriginal_y & ")..." & _iFittingcnt & " count ")
2265
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Fitting : " & sUid)
2266
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
2267
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "ModelingType : " & iModelingType)
2268
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn1_Point : " & dConn1_x & "," & dConn1_y)
2269
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn2_Point : " & dConn2_x & "," & dConn2_y)
2270
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn3_Point : " & dConn3_x & "," & dConn3_y)
2271
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn4_Point : " & dConn4_x & "," & dConn4_y)
2272
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString())
2273
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString())
2274
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection3 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString())
2275
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection4 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString())
2276
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
2277
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dOriginal_x & "," & dOriginal_y)
2278
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Fitting Count : " & _iFittingcnt)
2279
        _iFittingcnt = _iFittingcnt + 1
2280
        oCurrentSymbolRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
2281 76f465d0 Gyusu
        Dim oAttributeRow() As DataRow
2282
        oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
2283
        If oAttribute_Dt.Rows.Count > 0 Then
2284 f9b63682 Gyusu
2285 76f465d0 Gyusu
            If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
2286
                Dim oInstrument As LMInstrument
2287
                oInstrument = _Placement.PIDDataSource.GetInstrument(oLMSymbol.ModelItemID)
2288
                Try
2289
                    If oAttributeRow.Length > 0 Then
2290
                        For Each oAttribute In oAttributeRow
2291
                            Try
2292
                                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2293
                                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2294
                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2295
                                oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
2296
                            Catch ex As Exception
2297
                            End Try
2298
                        Next
2299
                        oInstrument.Commit()
2300
                    End If
2301
                Catch ex As Exception
2302
                End Try
2303
            Else
2304 f9b63682 Gyusu
                Try
2305 76f465d0 Gyusu
                    If oAttributeRow.Length > 0 And oLMSymbol IsNot Nothing Then
2306
                        For Each oAttribute In oAttributeRow
2307
                            Try
2308
                                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2309
                                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2310
                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2311
                                oLMSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
2312
2313
                            Catch ex As Exception
2314
                            End Try
2315
                        Next
2316
                        oLMSymbol.Commit()
2317 f9b63682 Gyusu
                    End If
2318
                Catch ex As Exception
2319
                End Try
2320 76f465d0 Gyusu
            End If
2321 f9b63682 Gyusu
        End If
2322 76f465d0 Gyusu
        'Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
2323
        'If oAttributeRow.Length > 0 Then
2324
        '    For Each oAttribute In oAttributeRow
2325
        '        Try
2326
        '            Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2327
        '            Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2328
        '            If sPIDValue.Contains("'") Then
2329
        '                sPIDValue = sPIDValue.Replace("'", """")
2330
        '            End If
2331
        '            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2332
        '            oLMSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
2333
        '        Catch ex As Exception
2334
        '        End Try
2335
        '    Next
2336
        'End If
2337 b08338e3 Gyusu
2338 f9b63682 Gyusu
        Return sReturnUid
2339 b08338e3 Gyusu
2340
2341 f9b63682 Gyusu
        '현재 Uid 모델링
2342
    End Function
2343 b08338e3 Gyusu
2344 9c86a823 Gyusu
    Private Function GetChildSymbolDirection(ByVal sDirection As String) As Double
2345
        Dim sReturnDirection As String = ""
2346
        If sDirection.ToUpper() = "RIGHT" Then
2347
            Return 3.14
2348
        ElseIf sDirection.ToUpper() = "LEFT" Then
2349
            Return 0
2350
        ElseIf sDirection.ToUpper = "DOWN" Then
2351
            Return 1.57
2352
        ElseIf sDirection.ToUpper() = "UP" Then
2353
            Return 4.71
2354
        Else
2355
            Return 0
2356
        End If
2357
    End Function
2358
2359
2360
2361 f9b63682 Gyusu
    Private Function CheckExistModeling(ByVal oRow As DataRow) As String
2362
        If oRow(_XML_LINE_DRAWING_TF).ToString() = "FALSE" And oRow(_XML_LINE_Check).ToString() = "TRUE" Then
2363
            Return oRow(_XML_LINE_UID).ToString()
2364
        End If
2365
        Return String.Empty
2366
    End Function
2367 b08338e3 Gyusu
2368
2369 f9b63682 Gyusu
    Private Sub ConvertPoint(ByVal sOriginalPoint As String, ByRef dConn1_x As Double, ByRef dConn1_y As Double)
2370
        ConvertPointBystring(sOriginalPoint, dConn1_x, dConn1_y)
2371
        ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
2372
    End Sub
2373 b08338e3 Gyusu
2374 f9b63682 Gyusu
    Private Function FinalLineModeling(ByVal oCurrentLineRow As DataRow,
2375
                              ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable,
2376
                                  ByVal oAttribute_Dt As DataTable) As String
2377
        Dim sReturnUid As String = ""
2378 76f465d0 Gyusu
        Try
2379 f9b63682 Gyusu
2380 76f465d0 Gyusu
            '현재 Uid  모델링 여부 체크
2381
            'Dim sStartpoint As String = ""
2382
            'Dim sEndpoint As String = ""
2383
            'Dim dOriginalStart_x As Double = 0.0
2384
            'Dim dOriginalStart_y As Double = 0.0
2385
            'Dim dOriginalEnd_x As Double = 0.0
2386
            'Dim dOriginalEnd_y As Double = 0.0
2387
            Dim dCenterPos_x As Double = 0.0
2388
            Dim dCenterPos_y As Double = 0.0
2389
            Dim objItem As LMAItem
2390 f9b63682 Gyusu
2391 76f465d0 Gyusu
            Dim sUid As String = oCurrentLineRow(_XML_LINE_UID).ToString()
2392
            Dim sLineType As String = oCurrentLineRow(_XML_LINE_TYPE).ToString()
2393
            Dim sSystemPath As String = GetPipeType(sLineType)
2394
            Dim sLineNoText As String = oCurrentLineRow(_XML_LINENO_TEXT).ToString()
2395
            Dim sLineNoUid As String = oCurrentLineRow(_XML_LINE_LINENOUID).ToString()
2396
            'sStartpoint = oCurrentLineRow(_XML_LINE_STARTPOINT).ToString()
2397
            'ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
2398
            'ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
2399
            'sEndpoint = oCurrentLineRow(_XML_LINE_ENDPOINT).ToString()
2400
            'ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
2401
            'ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
2402 f9b63682 Gyusu
2403 76f465d0 Gyusu
2404
            Dim dStart_Dwg_x As Double = oCurrentLineRow(_XML_LINE_DWG_STARTPOINT_X)
2405
            Dim dStart_Dwg_y As Double = oCurrentLineRow(_XML_LINE_DWG_STARTPOINT_Y)
2406
            Dim dEnd_Dwg_x As Double = oCurrentLineRow(_XML_LINE_DWG_ENDPOINT_X)
2407
            Dim dEnd_Dwg_y As Double = oCurrentLineRow(_XML_LINE_DWG_ENDPOINT_Y)
2408
            Dim sPreFlowDirection As String = ""
2409
            Dim sFlowDirection As String = oCurrentLineRow(_XML_LINE_FlowDirection)
2410
2411
            Dim sPreConn1Direction As String = ""
2412
            Dim sPreConn2Direction As String = ""
2413
            Dim sDirection As String = oCurrentLineRow(_XML_LINE_Direction)
2414
2415
            dCenterPos_x = Math.Abs(dStart_Dwg_x + dEnd_Dwg_x) / 2
2416
            dCenterPos_y = Math.Abs(dStart_Dwg_y + dEnd_Dwg_y) / 2
2417
2418
2419
            Dim oPidDataSource As LMADataSource = Nothing
2420
2421
            Try
2422
                oPidDataSource = _Placement.PIDDataSource
2423
            Catch ex As Exception
2424
                CheckOpenDrawing()
2425
                oPidDataSource = _Placement.PIDDataSource
2426
            End Try
2427
2428
            'Connection 정보 체크, 모델링 되어 있는지 유무
2429
            '양 커넥션의 모델링 유무를 체크한다.
2430
            Dim sConn1Uid As String = oCurrentLineRow(_XML_LINE_Conn1_Uid).ToString()
2431
            Dim sConn2Uid As String = oCurrentLineRow(_XML_LINE_Conn2_Uid).ToString()
2432
            Dim sConn1Type As String = ""
2433
            Dim sConn2Type As String = ""
2434
2435
            Dim oConn1Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn1Uid & "'")
2436
            If oConn1Rows.Length = 0 Then
2437
                oConn1Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn1Uid & "'")
2438
                If oConn1Rows.Length = 1 Then
2439
                    sConn1Type = "Line"
2440
                    'sPreConn1Direction = oConn1Rows(0)(_XML_LINE_Direction).ToString()
2441
                    'If sDirection = sPreConn1Direction Then
2442
                    '    If sDirection = "X" Then
2443
                    '        dStart_Dwg_y = oConn1Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2444
                    '        dEnd_Dwg_y = oConn1Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2445
                    '    Else
2446
                    '        dStart_Dwg_x = oConn1Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2447
                    '        dEnd_Dwg_x = oConn1Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2448
                    '    End If
2449
                    'End If
2450
2451
                End If
2452
            Else
2453 79326880 Gyusu
2454
                Dim oOriginalPoint As String = oConn1Rows(0)(_XML_SYMBOL_ORIGINALPOINT)
2455
                ConvertPointBystring(oOriginalPoint, dStart_Dwg_x, dStart_Dwg_y)
2456
                ConvertPointByImage(dStart_Dwg_x, dStart_Dwg_y, _IMG_X, _IMG_Y)
2457
                oCurrentLineRow(_XML_LINE_DWG_STARTPOINT_X) = dStart_Dwg_x
2458
                oCurrentLineRow(_XML_LINE_DWG_STARTPOINT_Y) = dStart_Dwg_y
2459 76f465d0 Gyusu
                sConn1Type = "Symbol"
2460
            End If
2461
2462
            Dim oConn2Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn2Uid & "'")
2463
            If oConn2Rows.Length = 0 Then
2464
                oConn2Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn2Uid & "'")
2465
                If oConn2Rows.Length = 1 Then
2466
                    sConn2Type = "Line"
2467
                    'sPreConn2Direction = oConn1Rows(0)(_XML_LINE_Direction).ToString()
2468
                    'If sDirection = sPreConn2Direction Then
2469
                    '    If sDirection = "X" Then
2470
                    '        dStart_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2471
                    '        dEnd_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2472
                    '    Else
2473
                    '        dStart_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2474
                    '        dEnd_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2475
                    '    End If
2476
                    'End If
2477
                End If
2478
            Else
2479 79326880 Gyusu
                Dim oOriginalPoint As String = oConn2Rows(0)(_XML_SYMBOL_ORIGINALPOINT)
2480
                ConvertPointBystring(oOriginalPoint, dEnd_Dwg_x, dEnd_Dwg_y)
2481
                ConvertPointByImage(dEnd_Dwg_x, dEnd_Dwg_y, _IMG_X, _IMG_Y)
2482
                oCurrentLineRow(_XML_LINE_DWG_ENDPOINT_X) = dEnd_Dwg_x
2483
                oCurrentLineRow(_XML_LINE_DWG_ENDPOINT_Y) = dEnd_Dwg_y
2484 76f465d0 Gyusu
                sConn2Type = "Symbol"
2485
            End If
2486
2487
2488 79326880 Gyusu
            If sConn1Type = "Symbol" Then
2489
2490 76f465d0 Gyusu
2491
2492 79326880 Gyusu
            End If
2493
2494 76f465d0 Gyusu
            Dim sConn1LineNo As String = ""
2495
            Dim sConn2LineNo As String = ""
2496 3b7a4470 Gyusu
            Dim oLMConnector As LMConnector = Nothing
2497 76f465d0 Gyusu
            Dim oStartLMConnector As LMConnector = Nothing
2498
            Dim oEndLMConnector As LMConnector = Nothing
2499
            Dim oLMSymbol1 As LMSymbol = Nothing
2500
            Dim oLMSymbol2 As LMSymbol = Nothing
2501
            Dim objInputs As PlaceRunInputs
2502
            objInputs = New PlaceRunInputs
2503
            Dim iModelingType As Integer = 0
2504
            If sConn1Type = "Line" And sConn2Type = "Line" Then
2505
                iModelingType = 1
2506
            ElseIf sConn1Type = "Line" And sConn2Type = "Symbol" Then
2507
                iModelingType = 1
2508
            ElseIf sConn1Type = "Symbol" And sConn2Type = "Line" Then
2509
                iModelingType = 1
2510
            ElseIf sConn1Type = "Symbol" And sConn2Type = "Symbol" Then
2511
                iModelingType = 1
2512
            ElseIf sConn1Type = "Line" And sConn2Type = "" Then
2513
                iModelingType = 2
2514
            ElseIf sConn1Type = "Symbol" And sConn2Type = "" Then
2515
                iModelingType = 2
2516
            ElseIf sConn1Type = "" And sConn2Type = "Line" Then
2517
                iModelingType = 3
2518
            ElseIf sConn1Type = "" And sConn2Type = "Symbol" Then
2519
                iModelingType = 3
2520
            Else
2521
                iModelingType = 4
2522
            End If
2523
2524
            Dim dPreConnX As Double = 0
2525
            Dim dPreConnY As Double = 0
2526
2527 3b7a4470 Gyusu
2528 79326880 Gyusu
            '   Dim sTargetDirection As String = CheckBranchLine(dStart_Dwg_x, dStart_Dwg_y, dEnd_Dwg_x, dEnd_Dwg_y, oLMConnector)
2529 3b7a4470 Gyusu
2530 79326880 Gyusu
            ' If sTargetDirection = "" Then
2531
            CheckConnectionLine(dStart_Dwg_x, dStart_Dwg_y, oStartLMConnector)
2532 3b7a4470 Gyusu
2533 79326880 Gyusu
            If oStartLMConnector Is Nothing Then
2534
                UpdateCheckBranchLine(dStart_Dwg_x, dStart_Dwg_y, oStartLMConnector)
2535 3b7a4470 Gyusu
                If oStartLMConnector Is Nothing Then
2536
                    oLMSymbol1 = CheckConnectionSymbolToLine(oConn1Rows, dStart_Dwg_x, dStart_Dwg_y, dCenterPos_x, dCenterPos_y, oStartLMConnector)
2537
                    If oLMSymbol1 IsNot Nothing Then
2538
                        sConn1Type = "Symbol"
2539 76f465d0 Gyusu
                    Else
2540 3b7a4470 Gyusu
                        sConn1Type = ""
2541
                    End If
2542
                Else
2543
                    sConn1Type = "Line"
2544 79326880 Gyusu
                    'sPreConn1Direction = oConn1Rows(0)(_XML_LINE_Direction).ToString()
2545
                    'If sDirection = sPreConn1Direction Then
2546
                    '    If sDirection = "X" Then
2547
                    '        dStart_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2548
                    '        dEnd_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2549
                    '    Else
2550
                    '        dStart_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2551
                    '        dEnd_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2552
                    '    End If
2553
                    'End If
2554 76f465d0 Gyusu
                End If
2555 79326880 Gyusu
            Else
2556
                sConn1Type = "Line"
2557
2558
            End If
2559
                CheckConnectionLine(dEnd_Dwg_x, dEnd_Dwg_y, oEndLMConnector)
2560
            If oEndLMConnector Is Nothing Then
2561
                UpdateCheckBranchLine(dEnd_Dwg_x, dEnd_Dwg_y, oEndLMConnector)
2562 3b7a4470 Gyusu
                If oEndLMConnector Is Nothing Then
2563
                    oLMSymbol2 = CheckConnectionSymbolToLine(oConn2Rows, dEnd_Dwg_x, dEnd_Dwg_y, dCenterPos_x, dCenterPos_y, oEndLMConnector)
2564
                    If oLMSymbol2 IsNot Nothing Then
2565
                        sConn2Type = "Symbol"
2566
                    End If
2567
                Else
2568
                    sConn2Type = "Line"
2569 76f465d0 Gyusu
                End If
2570 3b7a4470 Gyusu
            Else
2571 79326880 Gyusu
                sConn2Type = "Line"
2572
                    'sPreConn2Direction = oConn2Rows(0)(_XML_LINE_Direction).ToString()
2573
                    'If sDirection = sPreConn2Direction Then
2574
                    '    If sDirection = "X" Then
2575
                    '        dStart_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2576
                    '        dEnd_Dwg_y = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_Y)
2577
                    '    Else
2578
                    '        dStart_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2579
                    '        dEnd_Dwg_x = oConn2Rows(0)(_XML_LINE_DWG_STARTPOINT_X)
2580
                    '    End If
2581
                    'End If
2582 3b7a4470 Gyusu
                End If
2583 79326880 Gyusu
                'Else
2584
                '    If sTargetDirection = "START" Then
2585
                '        oStartLMConnector = oLMConnector
2586
                '        sConn1Type = "Line"
2587
                '    ElseIf sTargetDirection = "END" Then
2588
                '        oEndLMConnector = oLMConnector
2589
                '        sConn2Type = "Line"
2590
                '    End If
2591
                'End If
2592
2593
2594 3b7a4470 Gyusu
2595 b08338e3 Gyusu
2596
2597 79326880 Gyusu
2598
2599
                'If iModelingType = 1 Then
2600
                '    If sConn1Type = "Line" Then
2601
                '        CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2602
                '    Else
2603
                '        oLMSymbol1 = CheckConnectionSymbolToLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, dCenterPos_x, dCenterPos_y, oStartLMConnector)
2604
                '    End If
2605
                '    If sConn1Type = "Line" Then
2606
                '        CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
2607
                '    Else
2608
                '        oLMSymbol2 = CheckConnectionSymbolToLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, dCenterPos_x, dCenterPos_y, oEndLMConnector)
2609
                '    End If
2610
                '    'CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2611
                '    'CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
2612
                'ElseIf iModelingType = "2" Then
2613
                '    If sConn1Type = "Line" Then
2614
                '        CheckConnectionLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2615
                '    Else
2616
                '        oLMSymbol1 = CheckConnectionSymbolToLine(oConn1Rows, dOriginalStart_x, dOriginalStart_y, dCenterPos_x, dCenterPos_y, oStartLMConnector)
2617
                '    End If
2618
                '    ' CheckConnectionLine(oConn2Rows, dOriginalStart_x, dOriginalStart_y, oStartLMConnector)
2619
                'ElseIf iModelingType = "3" Then
2620
                '    If sConn1Type = "Line" Then
2621
                '        CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oEndLMConnector)
2622
                '    Else
2623
                '        oLMSymbol2 = CheckConnectionSymbolToLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, dCenterPos_x, dCenterPos_y, oEndLMConnector)
2624
                '    End If
2625
                '    ' CheckConnectionLine(oConn2Rows, dOriginalEnd_x, dOriginalEnd_y, oStartLMConnector)
2626
2627
                'Else
2628
                '    'objInputs.AddPoint(dOriginalStart_x, dOriginalStart_y)
2629
                '    'objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
2630
                'End If
2631
2632
                Dim sFirstUid As String = ""
2633 76f465d0 Gyusu
            Dim sSecondUid As String = ""
2634
            Try
2635
                If oStartLMConnector Is Nothing And oEndLMConnector Is Nothing Then
2636
                    objInputs.AddPoint(dStart_Dwg_x, dStart_Dwg_y)
2637
                    objInputs.AddPoint(dEnd_Dwg_x, dEnd_Dwg_y)
2638
                    'sFirstUid = CheckExistModeling(oConn1Rows(0))
2639
                    'sSecondUid = CheckExistModeling(oConn2Rows(0))
2640
                ElseIf oStartLMConnector IsNot Nothing And oEndLMConnector Is Nothing Then
2641
                    If sConn1Type = "Line" Then
2642
                        objInputs.AddConnectorTarget(oStartLMConnector, dStart_Dwg_x, dStart_Dwg_y)
2643
                    Else
2644
                        objInputs.AddSymbolTarget(oLMSymbol1, dStart_Dwg_x, dStart_Dwg_y)
2645
                    End If
2646 b08338e3 Gyusu
2647 76f465d0 Gyusu
                    objInputs.AddPoint(dEnd_Dwg_x, dEnd_Dwg_y)
2648
                    '    sSecondUid = CheckExistModeling(oConn2Rows(0))
2649
                ElseIf oStartLMConnector Is Nothing And oEndLMConnector IsNot Nothing Then
2650
                    If sConn2Type = "Line" Then
2651
                        objInputs.AddConnectorTarget(oEndLMConnector, dEnd_Dwg_x, dEnd_Dwg_y)
2652
                    Else
2653
                        objInputs.AddSymbolTarget(oLMSymbol2, dEnd_Dwg_x, dEnd_Dwg_y)
2654
                    End If
2655 b08338e3 Gyusu
2656 76f465d0 Gyusu
                    objInputs.AddPoint(dStart_Dwg_x, dStart_Dwg_y)
2657 f9b63682 Gyusu
2658 76f465d0 Gyusu
                    'objInputs.AddPoint(dOriginalEnd_x, dOriginalEnd_y)
2659 b08338e3 Gyusu
2660 76f465d0 Gyusu
                    '   sFirstUid = CheckExistModeling(oConn1Rows(0))
2661
                Else
2662
                    If sConn1Type = "Line" Then
2663
                        objInputs.AddConnectorTarget(oStartLMConnector, dStart_Dwg_x, dStart_Dwg_y)
2664
                    Else
2665
                        objInputs.AddSymbolTarget(oLMSymbol1, dStart_Dwg_x, dStart_Dwg_y)
2666
                    End If
2667
                    If sConn2Type = "Line" Then
2668
                        objInputs.AddConnectorTarget(oStartLMConnector, dEnd_Dwg_x, dEnd_Dwg_y)
2669
                    Else
2670
                        objInputs.AddSymbolTarget(oLMSymbol2, dEnd_Dwg_x, dEnd_Dwg_y)
2671
                    End If
2672
                    'objInputs.AddConnectorTarget(oStartLMConnector, dOriginalStart_x, dOriginalStart_y)
2673
                    'objInputs.AddConnectorTarget(oEndLMConnector, dEnd_Dwg_x, dOriginalEnd_y)
2674
                End If
2675
                If sConn1Type <> "" And sConn2Type <> "" Then
2676 73bfb231 Gyusu
                    If oConn1Rows.Count > 0 Then
2677
                        sFirstUid = CheckExistModeling(oConn1Rows(0))
2678
                    End If
2679
                    If oConn2Rows.Count > 0 Then
2680
                        sSecondUid = CheckExistModeling(oConn2Rows(0))
2681
                    End If
2682
2683 76f465d0 Gyusu
                ElseIf sConn1Type <> "" And sConn2Type = "" Then
2684 73bfb231 Gyusu
                    If oConn1Rows.Count > 0 Then
2685
                        sFirstUid = CheckExistModeling(oConn1Rows(0))
2686
                    End If
2687
2688 76f465d0 Gyusu
                ElseIf sConn1Type = "" And sConn2Type <> "" Then
2689 73bfb231 Gyusu
                    If oConn2Rows.Count > 0 Then
2690
                        sSecondUid = CheckExistModeling(oConn2Rows(0))
2691
                    End If
2692
2693 76f465d0 Gyusu
                End If
2694 f9b63682 Gyusu
2695 76f465d0 Gyusu
                If sFirstUid <> "" And sSecondUid <> "" Then
2696
                    sReturnUid = sSecondUid
2697
                ElseIf sFirstUid = "" And sSecondUid <> "" Then
2698
                    sReturnUid = sSecondUid
2699
                ElseIf sFirstUid <> "" And sSecondUid = "" Then
2700
                    sReturnUid = sFirstUid
2701
                Else
2702
                    sReturnUid = ""
2703
                End If
2704
                _iPipecnt = _iPipecnt + 1
2705
                Dim oCurrentConnector As LMConnector = Nothing
2706 f9b63682 Gyusu
2707 76f465d0 Gyusu
                objItem = _Placement.PIDCreateItem(sSystemPath)
2708 f9b63682 Gyusu
                Try
2709 76f465d0 Gyusu
                    If Chk_OnlyPoint.Checked Then
2710
                        objInputs.Clear()
2711
                        objInputs.AddPoint(dStart_Dwg_x, dStart_Dwg_y)
2712
                        objInputs.AddPoint(dEnd_Dwg_x, dEnd_Dwg_y)
2713
                        oCurrentConnector = _Placement.PIDPlaceRun(objItem, objInputs)
2714
                    Else
2715
                        oCurrentConnector = _Placement.PIDPlaceRun(objItem, objInputs)
2716 f9b63682 Gyusu
                    End If
2717 76f465d0 Gyusu
                    AddProgress()
2718
2719 f9b63682 Gyusu
                Catch ex As Exception
2720 76f465d0 Gyusu
2721 f9b63682 Gyusu
                End Try
2722 76f465d0 Gyusu
                If oCurrentConnector IsNot Nothing Then
2723
                    oCurrentLineRow(_XML_LINE_LMCONNECTOR) = oCurrentConnector
2724
                    oCurrentLineRow(_XML_LINE_DRAWING_TF) = "TRUE"
2725
2726
                    SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dStart_Dwg_x & "," & dStart_Dwg_y & ") - (" & dEnd_Dwg_x & "," & dEnd_Dwg_y & ")..." & _iPipecnt & " count ")
2727
2728
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
2729
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
2730
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oCurrentLineRow(_XML_SYMBOL_Conn1_Uid).ToString())
2731
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oCurrentLineRow(_XML_SYMBOL_Conn2_Uid).ToString())
2732
                    'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
2733
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dStart_Dwg_x & "," & dStart_Dwg_y)
2734
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dEnd_Dwg_x & "," & dEnd_Dwg_y)
2735
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
2736
2737
                    Dim oPipeRun As LMPipeRun = oPidDataSource.GetPipeRun(oCurrentConnector.ModelItemID)
2738 79326880 Gyusu
2739
                    '모델링 된 PipeLine 데이터 테이블 저장
2740
                    Dim oAddRow As DataRow = _ModelingLine_Dt.NewRow
2741
                    oAddRow(_XML_LINE_SPID) = oCurrentConnector.ModelItemID
2742
                    oAddRow(_XML_LINE_LMCONNECTOR) = oCurrentConnector
2743
                    oAddRow(_XML_LINE_DRAWING_TF) = "TRUE"
2744
                    oAddRow(_XML_LINE_DWG_STARTPOINT_X) = dStart_Dwg_x
2745
                    oAddRow(_XML_LINE_DWG_STARTPOINT_Y) = dStart_Dwg_y
2746
                    oAddRow(_XML_LINE_DWG_ENDPOINT_X) = dEnd_Dwg_x
2747
                    oAddRow(_XML_LINE_DWG_ENDPOINT_Y) = dEnd_Dwg_y
2748
                    _ModelingLine_Dt.Rows.Add(oAddRow)
2749
2750
2751 76f465d0 Gyusu
                    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
2752 79326880 Gyusu
                        If oAttributeRow.Length > 0 Then
2753
                            For Each oAttribute In oAttributeRow
2754
                                Try
2755
                                    Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2756
                                    Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2757
                                    If sPIDValue.Contains("'") Then
2758
                                        sPIDValue = sPIDValue.Replace("'", """")
2759
                                    End If
2760
                                    Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2761
                                    oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
2762
                                Catch ex As Exception
2763
                                End Try
2764
                            Next
2765
                            oPipeRun.Commit()
2766
                        End If
2767 76f465d0 Gyusu
2768 79326880 Gyusu
                        Dim sID_1 As String = ""
2769 76f465d0 Gyusu
                    Dim sID_2 As String = ""
2770 79326880 Gyusu
                    Dim oAddConnector As LMConnector = Nothing
2771 76f465d0 Gyusu
                    If oStartLMConnector IsNot Nothing Then
2772 79326880 Gyusu
                            sID_1 = oStartLMConnector.ModelItemID
2773 76f465d0 Gyusu
                        sID_2 = oCurrentConnector.ModelItemID
2774 79326880 Gyusu
                        oAddConnector = oStartLMConnector
2775 76f465d0 Gyusu
                    ElseIf oEndLMConnector IsNot Nothing Then
2776 79326880 Gyusu
                            sID_1 = oEndLMConnector.ModelItemID
2777 76f465d0 Gyusu
                        sID_2 = oCurrentConnector.ModelItemID
2778 79326880 Gyusu
                        oAddConnector = oEndLMConnector
2779 76f465d0 Gyusu
                    End If
2780 79326880 Gyusu
                        If sID_1 <> "" And sID_2 <> "" Then
2781
                            Dim objSurvivorItem As LMAItem = Nothing
2782
                            Dim oPipeRun1 As LMPipeRun = oPidDataSource.GetPipeRun(sID_1)
2783
                            Dim oPipeRun2 As LMPipeRun = oPidDataSource.GetPipeRun(sID_2)
2784 73bfb231 Gyusu
                        _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
2785 79326880 Gyusu
2786
                        Dim oChangeRow() As DataRow = _ModelingLine_Dt.Select(_XML_LINE_SPID & " = '" & sID_2 & "'")
2787
                        If oChangeRow.Length = 1 Then
2788
                            oChangeRow(0)(_XML_LINE_SPID) = sID_1
2789
                            oChangeRow(0)(_XML_LINE_LMCONNECTOR) = oAddConnector
2790
                        End If
2791 76f465d0 Gyusu
                    End If
2792 79326880 Gyusu
                    Else
2793
                        sReturnUid = ""
2794 76f465d0 Gyusu
                End If
2795
            Catch ex As Exception
2796
2797
            End Try
2798
2799
2800
        Catch ex As Exception
2801
2802
        End Try
2803
2804 b08338e3 Gyusu
2805 f9b63682 Gyusu
        Return sReturnUid
2806 b08338e3 Gyusu
        '현재 Uid 모델링
2807 f9b63682 Gyusu
    End Function
2808 bb2a0c79 Gyusu
2809
    Private Sub PipingModeling()
2810 e4000111 Gyusu
2811 171ac39d Gyusu
        Try
2812
            For Each oDrwing As TreeNode In Tree_Result.Nodes
2813
                For Each oDwgNode As TreeNode In oDrwing.Nodes
2814
                    Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
2815 54b98e09 Gyusu
                    Dim CDrawing As Drawing = GetDrawing(sDwgName)
2816
                    If CDrawing IsNot Nothing Then
2817 e4000111 Gyusu
                        Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
2818
                        Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
2819
                        For Each oNode As TreeNode In oDwgNode.Nodes
2820
                            Dim iItemcnt As Integer = 0
2821
                            Dim sNodeUid As String = oNode.Name
2822
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2823
                            '1.Equipment
2824
                            '2.Piping OPC
2825
                            '3.OPC 시작되는 Line
2826
                            'Equipment 생성
2827
                            'If sNodeUid <> "PipeLineNo" Then
2828
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2829 b08338e3 Gyusu
2830 e4000111 Gyusu
                            If CLineNo IsNot Nothing Then
2831
                                Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2832
                                Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2833
                                Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute
2834
                                Dim oDrawLinenoLabel As Boolean = False
2835 b08338e3 Gyusu
                                Try
2836
                                    ManualCheckNode(oLine_Dt)
2837
                                    ManualCheckNode(oSymbol_Dt)
2838
                                Catch ex As Exception
2839
                                End Try
2840 e4000111 Gyusu
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2841
                                    If oSymbolNode.Checked Then
2842 b08338e3 Gyusu
                                        Try
2843
                                            Dim sUid As String = oSymbolNode.Name
2844 3b7a4470 Gyusu
                                            If sUid = "152b5931-e7ed-4fe9-bed8-6c01303567b7" Then
2845
                                                MessageBox.Show("")
2846
                                            End If
2847 b08338e3 Gyusu
                                            Dim sLineNoUid As String = CLineNo.Uid
2848 76f465d0 Gyusu
                                            Dim sReturnUid = sUid
2849
                                            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2850
                                            While True
2851
                                                Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2852
                                                                   _XML_SYMBOL_Check & "] = 'TRUE'")
2853
                                                If oLineRows.Count > 0 Then
2854
                                                    sReturnUid = FinalLineModeling(oLineRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2855
                                                Else
2856
                                                    sReturnUid = ""
2857 b08338e3 Gyusu
                                                End If
2858 76f465d0 Gyusu
                                                If sReturnUid = "" Then
2859
                                                    Exit While
2860
                                                End If
2861
                                            End While
2862 b08338e3 Gyusu
                                        Catch ex As Exception
2863
                                        End Try
2864 6a6d8ab4 Gyusu
                                    End If
2865 e4000111 Gyusu
                                Next
2866 76f465d0 Gyusu
                            End If
2867
                            Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2868
                            If CTrimLineNo IsNot Nothing Then
2869
                                Dim oLine_Dt As DataTable = CTrimLineNo.Dt_Line
2870
                                Dim oSymbol_Dt As DataTable = CTrimLineNo.Dt_Symbol
2871
                                Dim oAttribute_Dt As DataTable = CTrimLineNo.Dt_Attribute
2872
                                Dim oDrawLinenoLabel As Boolean = False
2873
                                Try
2874
                                    ManualCheckNode(oLine_Dt)
2875
                                    ManualCheckNode(oSymbol_Dt)
2876
                                Catch ex As Exception
2877
                                End Try
2878 f9b63682 Gyusu
2879 bb2a0c79 Gyusu
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2880
                                    If oSymbolNode.Checked Then
2881 b08338e3 Gyusu
                                        Try
2882
                                            Dim sUid As String = oSymbolNode.Name
2883 76f465d0 Gyusu
                                            Dim sLineNoUid As String = CTrimLineNo.Uid
2884 f9b63682 Gyusu
                                            Dim sReturnUid = sUid
2885 76f465d0 Gyusu
                                            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2886 f9b63682 Gyusu
                                            While True
2887
                                                Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2888
                                                                   _XML_SYMBOL_Check & "] = 'TRUE'")
2889
                                                If oLineRows.Count > 0 Then
2890
                                                    sReturnUid = FinalLineModeling(oLineRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2891 76f465d0 Gyusu
                                                Else
2892
                                                    sReturnUid = ""
2893 f9b63682 Gyusu
                                                End If
2894
                                                If sReturnUid = "" Then
2895
                                                    Exit While
2896
                                                End If
2897
                                            End While
2898 b08338e3 Gyusu
                                        Catch ex As Exception
2899
                                        End Try
2900 bb2a0c79 Gyusu
                                    End If
2901
                                Next
2902 f9b63682 Gyusu
                                'For Each oSymbolNode As TreeNode In oNode.Nodes
2903
                                '    If oSymbolNode.Checked Then
2904
                                '        Try
2905
                                '            Dim sUid As String = oSymbolNode.Name
2906
                                '            Dim sLineNoUid As String = CLineNo.Uid
2907 76f465d0 Gyusu
                                '            Dim sReturnUid = sUid
2908
                                '            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2909
                                '            Dim oSymbolRows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2910
                                '                                                               _XML_SYMBOL_Check & "] = 'TRUE'")
2911
                                '            If oSymbolRows.Count > 0 Then
2912
                                '                sReturnUid = FinalSymbolModeling(oSymbolRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2913
                                '            Else
2914
                                '                sReturnUid = ""
2915
                                '            End If
2916
                                '            If sReturnUid = "" Then
2917 f9b63682 Gyusu
                                '            End If
2918
                                '        Catch ex As Exception
2919
                                '        End Try
2920
                                '    End If
2921
                                'Next
2922 e4000111 Gyusu
                            End If
2923 76f465d0 Gyusu
                        Next
2924 3acffcee Gyusu
2925
2926 76f465d0 Gyusu
                        For Each oNode As TreeNode In oDwgNode.Nodes
2927
                            Dim iItemcnt As Integer = 0
2928
                            Dim sNodeUid As String = oNode.Name
2929
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2930
                            '1.Equipment
2931
                            '2.Piping OPC
2932
                            '3.OPC 시작되는 Line
2933
                            'Equipment 생성
2934
                            'If sNodeUid <> "PipeLineNo" Then
2935
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2936 bb2a0c79 Gyusu
2937 76f465d0 Gyusu
                            If CLineNo IsNot Nothing Then
2938
                                Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2939
                                Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2940
                                Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute
2941 b08338e3 Gyusu
                                Dim oDrawLinenoLabel As Boolean = False
2942
                                Try
2943
                                    ManualCheckNode(oLine_Dt)
2944
                                    ManualCheckNode(oSymbol_Dt)
2945
                                Catch ex As Exception
2946
                                End Try
2947
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2948
                                    If oSymbolNode.Checked Then
2949
                                        Try
2950
                                            Dim sUid As String = oSymbolNode.Name
2951 76f465d0 Gyusu
                                            Dim sLineNoUid As String = CLineNo.Uid
2952
                                            Dim sReturnUid = sUid
2953
                                            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2954 3b7a4470 Gyusu
                                            Dim oSymbolRows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'FALSE' And [" &
2955 76f465d0 Gyusu
                                                                                               _XML_SYMBOL_Check & "] = 'TRUE'")
2956 3b7a4470 Gyusu
2957 76f465d0 Gyusu
                                            If oSymbolRows.Count > 0 Then
2958
                                                sReturnUid = FinalSymbolModeling(oSymbolRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2959
                                            Else
2960
                                                sReturnUid = ""
2961
                                            End If
2962
                                            If sReturnUid = "" Then
2963 b08338e3 Gyusu
                                            End If
2964
                                        Catch ex As Exception
2965
                                        End Try
2966
                                    End If
2967
                                Next
2968 76f465d0 Gyusu
                            End If
2969
                            Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2970
                            If CTrimLineNo IsNot Nothing Then
2971
                                Dim oLine_Dt As DataTable = CTrimLineNo.Dt_Line
2972
                                Dim oSymbol_Dt As DataTable = CTrimLineNo.Dt_Symbol
2973
                                Dim oAttribute_Dt As DataTable = CTrimLineNo.Dt_Attribute
2974
                                Dim oDrawLinenoLabel As Boolean = False
2975
                                Try
2976
                                    ManualCheckNode(oLine_Dt)
2977
                                    ManualCheckNode(oSymbol_Dt)
2978
                                Catch ex As Exception
2979
                                End Try
2980 b08338e3 Gyusu
                                For Each oSymbolNode As TreeNode In oNode.Nodes
2981 76f465d0 Gyusu
                                    If oSymbolNode.Checked Then
2982
                                        Try
2983 b08338e3 Gyusu
                                            Dim sUid As String = oSymbolNode.Name
2984 76f465d0 Gyusu
                                            Dim sLineNoUid As String = CTrimLineNo.Uid
2985
                                            Dim sReturnUid = sUid
2986
                                            '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2987
                                            Dim oSymbolRows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2988
                                                                                               _XML_SYMBOL_Check & "] = 'TRUE'")
2989
                                            If oSymbolRows.Count > 0 Then
2990
                                                sReturnUid = FinalSymbolModeling(oSymbolRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2991
                                            Else
2992
                                                sReturnUid = ""
2993 b08338e3 Gyusu
                                            End If
2994 76f465d0 Gyusu
                                            If sReturnUid = "" Then
2995 b08338e3 Gyusu
                                            End If
2996 76f465d0 Gyusu
                                        Catch ex As Exception
2997
                                        End Try
2998
                                    End If
2999 b08338e3 Gyusu
                                Next
3000
                            End If
3001
                        Next
3002
                    End If
3003
                Next
3004
            Next
3005
        Catch ex As Exception
3006
3007
        End Try
3008
    End Sub
3009
3010
3011
    Private Sub FindNearPoint(ByVal oOPCSymbol As LMSymbol, ByRef dNear_x As Double, ByRef dNear_y As Double)
3012
        Dim oConnectionPoints_x(4) As Double
3013
        Dim oConnectionPoints_y(4) As Double
3014
3015
        Try
3016
            _Placement.PIDConnectPointLocation(oOPCSymbol, 1, oConnectionPoints_x(0), oConnectionPoints_y(0))
3017
            _Placement.PIDConnectPointLocation(oOPCSymbol, 2, oConnectionPoints_x(1), oConnectionPoints_y(1))
3018
            _Placement.PIDConnectPointLocation(oOPCSymbol, 3, oConnectionPoints_x(2), oConnectionPoints_y(2))
3019
            _Placement.PIDConnectPointLocation(oOPCSymbol, 4, oConnectionPoints_x(3), oConnectionPoints_y(3))
3020
            Dim iNearPoint As Integer = 0
3021
            Dim dGap As Double = 0
3022
            For i = 0 To 3
3023
                If dGap = 0 Then
3024
                    iNearPoint = i
3025
                    dGap = Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y)
3026
                Else
3027
                    If dGap >= Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y) Then
3028
                        iNearPoint = i
3029
                        dGap = Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y)
3030
                    End If
3031
                End If
3032
            Next
3033
            dNear_x = oConnectionPoints_x(iNearPoint)
3034
            dNear_y = oConnectionPoints_y(iNearPoint)
3035
        Catch ex As Exception
3036 e4000111 Gyusu
3037 bb2a0c79 Gyusu
        End Try
3038 e4000111 Gyusu
3039 bb2a0c79 Gyusu
    End Sub
3040
3041 9c86a823 Gyusu
    Private Function GetPipeColor(ByVal sType As String) As Color
3042
        If sType.ToUpper() = "ELECTRIC" Then
3043
            Return Color.DarkOrange
3044
        ElseIf sType.ToUpper() = "CONNECT TO PROCESS" Then
3045
            Return Color.LightGreen
3046
        ElseIf sType.ToUpper() = "SOFTWARE" Then
3047
            Return Color.Blue
3048
        ElseIf sType.ToUpper() = "PNEUMATIC" Then
3049
            Return Color.Gray
3050
        Else
3051
            Return Color.Black
3052
        End If
3053
    End Function
3054
3055 bb2a0c79 Gyusu
    Private Function GetPipeType(ByVal sType As String) As String
3056
        Dim sSystempath As String = "\Piping\Routing\Process Lines\Primary Piping.sym" ' oPipeRow(0)(_XML_LINE_SYSTEMPATH).ToString()
3057
        If sType.ToUpper() = "ELECTRIC" Then
3058
            sSystempath = "\Instrumentation\Signal Line\Electric.sym"
3059
        ElseIf sType.ToUpper() = "CONNECT TO PROCESS" Then
3060
            sSystempath = "\Instrumentation\Signal Line\Connect to Process.sym"
3061 9c86a823 Gyusu
        ElseIf sType.ToUpper() = "SOFTWARE" Then
3062
            sSystempath = "\Instrumentation\Signal Line\Software Link.sym"
3063
        ElseIf sType.ToUpper() = "PNEUMATIC" Then
3064
            sSystempath = "\Instrumentation\Signal Line\Pneumatic.sym"
3065 bb2a0c79 Gyusu
        Else
3066
        End If
3067
        Return sSystempath
3068
    End Function
3069
3070
    Private Sub InitAutoRouting()
3071
        For Each oDrwing As TreeNode In Tree_Result.Nodes
3072
            For Each oDwgNode As TreeNode In oDrwing.Nodes
3073
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
3074
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
3075
                If CDrawing IsNot Nothing Then
3076
                    Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
3077
                    Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
3078
                    SetListBoxItems(ListBox_Result, "Place " & CDrawing.DwgName & "....")
3079 b08338e3 Gyusu
3080 bb2a0c79 Gyusu
                    For Each oNode As TreeNode In oDwgNode.Nodes
3081
                        Dim iItemcnt As Integer = 0
3082
                        Dim sNodeUid As String = oNode.Name
3083
                        Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
3084
                        Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
3085
                        If CLineNo IsNot Nothing Then
3086
                            Dim oLine_Dt As DataTable = CLineNo.Dt_Line
3087
                            Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
3088
3089
                            For Each oLineRow In oLine_Dt.Rows
3090 76f465d0 Gyusu
                                ' oLineRow(_XML_LINE_UID) = ""
3091
                                oLineRow(_XML_LINE_SPID) = ""
3092
                                oLineRow(_XML_LINE_LMCONNECTOR) = Nothing
3093
                                oLineRow(_XML_LINE_LMCONNECTOR_1) = Nothing
3094
                                oLineRow(_XML_LINE_LMCONNECTOR_2) = Nothing
3095
                                oLineRow(_XML_LINE_DRAWING_TF) = "FALSE"
3096 76f5e1a8 Gyusu
                                oLineRow(_XML_LINE_Check) = "FALSE"
3097 76f465d0 Gyusu
                            Next
3098
                            For Each oSymbolRow In oSymbol_Dt.Rows
3099
                                '   oSymbolRow(_XML_SYMBOL_UID) = ""
3100
                                oSymbolRow(_XML_SYMBOL_SPID) = ""
3101
                                oSymbolRow(_XML_SYMBOL_LMSYMBOL) = Nothing
3102
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_1) = Nothing
3103
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_2) = Nothing
3104
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_3) = Nothing
3105
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_4) = Nothing
3106 76f5e1a8 Gyusu
                                oSymbolRow(_XML_SYMBOL_Check) = "FALSE"
3107 76f465d0 Gyusu
                                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
3108
3109
                            Next
3110
3111
                        End If
3112
3113
                        Dim CTRIMLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
3114
                        If CTRIMLineNo IsNot Nothing Then
3115
                            Dim oLine_Dt As DataTable = CTRIMLineNo.Dt_Line
3116
                            Dim oSymbol_Dt As DataTable = CTRIMLineNo.Dt_Symbol
3117
3118
                            For Each oLineRow In oLine_Dt.Rows
3119
                                ' oLineRow(_XML_LINE_UID) = ""
3120 bb2a0c79 Gyusu
                                oLineRow(_XML_LINE_SPID) = ""
3121 76f465d0 Gyusu
                                oLineRow(_XML_LINE_LMCONNECTOR) = Nothing
3122
                                oLineRow(_XML_LINE_LMCONNECTOR_1) = Nothing
3123
                                oLineRow(_XML_LINE_LMCONNECTOR_2) = Nothing
3124 bb2a0c79 Gyusu
                                oLineRow(_XML_LINE_DRAWING_TF) = "FALSE"
3125 76f5e1a8 Gyusu
                                oLineRow(_XML_LINE_Check) = "FALSE"
3126 bb2a0c79 Gyusu
                            Next
3127
                            For Each oSymbolRow In oSymbol_Dt.Rows
3128 76f465d0 Gyusu
                                '   oSymbolRow(_XML_SYMBOL_UID) = ""
3129 bb2a0c79 Gyusu
                                oSymbolRow(_XML_SYMBOL_SPID) = ""
3130 76f465d0 Gyusu
                                oSymbolRow(_XML_SYMBOL_LMSYMBOL) = Nothing
3131
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_1) = Nothing
3132
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_2) = Nothing
3133
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_3) = Nothing
3134
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_4) = Nothing
3135 76f5e1a8 Gyusu
                                oSymbolRow(_XML_SYMBOL_Check) = "FALSE"
3136 bb2a0c79 Gyusu
                                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
3137 76f465d0 Gyusu
3138 bb2a0c79 Gyusu
                            Next
3139
3140
                        End If
3141
                    Next
3142
                End If
3143
            Next
3144
        Next
3145
    End Sub
3146
3147
3148
3149
3150
3151
3152 79326880 Gyusu
    Private Function CheckBranchLine(ByVal dStartX As Double, ByVal dStartY As Double,
3153 bb2a0c79 Gyusu
                                ByRef dEndX As Double, ByRef dEndY As Double, ByRef sBranchType As String, ByRef oLMConnector As LMConnector) As Boolean
3154
3155
        Try
3156 79326880 Gyusu
3157
            For Each oModelrow In _ModelingLine_Dt.Rows
3158
                'Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
3159
                'Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
3160 bb2a0c79 Gyusu
                Dim dModelStartX As Double
3161
                Dim dModelStartY As Double
3162
                Dim dModelEndX As Double
3163
                Dim dModelEndY As Double
3164 79326880 Gyusu
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3165
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3166
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3167
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3168
                'ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
3169
                'ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
3170
                'ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
3171
                'ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
3172 bb2a0c79 Gyusu
                Dim dGap As Double = 0.0002
3173
                Dim d기준x As Double = (dModelStartX + dModelEndX) / 2
3174
                Dim d기준y As Double = (dModelStartY + dModelEndY) / 2
3175
                Try
3176
                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3177
                Catch ex As Exception
3178
3179
                End Try
3180
                Dim oRun As LMPipeRun = Nothing
3181
                Try
3182
3183
                    oRun = _Placement.PIDDataSource.GetPipeRun(oLMConnector.ModelItemID)
3184
                    Dim dResultCalc As Double = -1
3185
                    For Each objRep In oRun.Representations
3186
                        If objRep.Attributes("RepresentationType").Value = "Connector" And objRep.Attributes("ItemStatus").Value = "Active" Then
3187
                            Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
3188
                            For Each objConnectorVertex In objConnector.ConnectorVertices
3189
                                Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3190
                                Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3191
                                Dim dStartCalc As Double = Math.Abs(dStartX - dConn_X) + Math.Abs(dStartY - dConn_Y)
3192
3193
                                If dResultCalc > dStartCalc Or dResultCalc = -1 Then
3194
                                    dResultCalc = dStartCalc
3195
                                    oLMConnector = objConnector
3196
                                    d기준x = dConn_X
3197
                                    d기준y = dConn_Y
3198
                                End If
3199
                                Dim dEndCalc As Double = Math.Abs(dEndX - dConn_X) + Math.Abs(dEndY - dConn_Y)
3200
                                If dResultCalc > dEndCalc Then
3201
                                    dResultCalc = dEndCalc
3202
                                    oLMConnector = objConnector
3203
                                    d기준x = dConn_X
3204
                                    d기준y = dConn_Y
3205
                                End If
3206
                            Next
3207
                        End If
3208
                    Next
3209
                    '        _Placement.PIDConnectPointLocation(oRun, 1, dModelStartX, dModelEndX)
3210
                    '       _Placement.PIDConnectPointLocation(oRun, 2, dModelEndX, dModelEndY)
3211
                Catch ex As Exception
3212
                End Try
3213
3214
3215
                'Dim sSPID As String = oModelrow(_XML_LINE_SPID).ToString()
3216
                'Dim oPipeRun As LMPipeRun = _Placement.PIDDataSource.Get PipeRun(sSPID)
3217
                'If dModelStartX + dGap > dStartX And dModelStartX - dGap < dStartX And
3218
                '        dModelStartY + dGap > dStartY And dModelStartY - dGap < dStartY Then
3219
                '    dStartX = dModelStartX
3220
                '    dStartY = dModelStartY
3221
                'ElseIf dModelEndX + dGap > dStartX And dModelEndX - dGap < dStartX And
3222
                '        dModelEndY + dGap > dStartY And dModelEndY - dGap < dStartY Then
3223
                '    dStartX = dModelEndX
3224
                '    dStartY = dModelEndY
3225
                'End If
3226
3227
                'Vetical
3228
                If Math.Abs(dModelStartX - dModelEndX) <= Math.Abs(dModelStartY - dModelEndY) Then
3229
                    If Math.Abs(dStartX - dEndX) >= Math.Abs(dStartY - dEndY) Then
3230
                        'Horizontal 
3231
                        ' dGap = 0.0002 'Math.Abs(dStartX - dEndX) / 20
3232
                        '기준선의 Y범위안에 가로선이 포함되어야됨
3233
                        If (dModelStartY + dGap >= dStartY And dModelEndY - dGap <= dStartY) Or
3234
                            (dModelStartY - dGap <= dStartY And dModelEndY + dGap >= dStartY) And
3235
                            (dModelStartY + dGap >= dEndY And dModelEndY - dGap <= dEndY) Or
3236
                            (dModelStartY - dGap <= dEndY And dModelEndY + dGap >= dEndY) Then
3237
                            '기준선보다 왼쪽에 가로선이 있을때
3238
                            If d기준x >= dStartX And d기준x >= dEndX Then
3239
                                If dStartX >= dEndX Then
3240
                                    'dStartX 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3241
                                    If dStartX + dGap >= d기준x Then
3242
                                        dStartX = d기준x
3243
                                        sBranchType = "1"
3244
                                        Return True
3245
                                    End If
3246
                                Else
3247
                                    'dEndX 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3248
                                    If dEndX + dGap >= d기준x Then
3249
                                        dEndX = d기준x
3250
                                        sBranchType = "2"
3251
                                        Return True
3252
                                    End If
3253
                                End If
3254
                                '기준선보다 오른쪽에 가로선이 있을때
3255
                            ElseIf d기준x <= dStartX And d기준x <= dEndX Then
3256
                                If dStartX >= dEndX Then
3257
                                    'dEndX 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3258
                                    If dEndX - dGap <= d기준x Then
3259
                                        dEndX = d기준x
3260
                                        sBranchType = "2"
3261
                                        Return True
3262
                                    End If
3263
                                Else
3264
                                    'dStartX 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3265
                                    If dStartX - dGap <= d기준x Then
3266
                                        dStartX = d기준x
3267
                                        sBranchType = "1"
3268
                                        Return True
3269
                                    End If
3270
                                End If
3271
                            Else
3272
                                '기준선과 세로선이 겹칠때
3273
                                If (d기준x >= dStartX And d기준x <= dEndX) Or
3274
                                        (d기준x <= dStartX And d기준x >= dEndX) Then
3275
                                    If (dModelStartY <= dStartY And dModelEndY >= dEndY) Or
3276
                                        (dModelStartY >= dStartY And dModelEndY <= dEndY) Then
3277
                                        '기준선이 dStartX와 dEndX중 어느쪽에 가까운지 확인
3278
                                        '가로선의 왼쪽점과 기준선이 가까울때는 gap만큼 뺐을때 기준선보다 작은지확인
3279
                                        '가로선의 오른쪽점과 기준선이 가까울때는 gap만큼 더했을때 기준선보다 큰지확인
3280
                                        If Math.Abs(d기준x - dStartX) >= Math.Abs(d기준x - dEndX) Then
3281
                                            'EndX점이 기준선과 더 가까이 있음
3282
                                            If dStartX >= dEndX Then
3283
                                                '가로선의 왼쪽점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3284
                                                If dEndX - dGap <= d기준x Then
3285
                                                    dEndX = d기준x
3286
                                                    sBranchType = "4"
3287
                                                    Return True
3288
                                                End If
3289
                                            Else
3290
                                                '가로선의 오른쪽점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3291
                                                If dEndX + dGap >= d기준x Then
3292
                                                    dEndX = d기준x
3293
                                                    sBranchType = "4"
3294
                                                    Return True
3295
                                                End If
3296
3297
                                            End If
3298
                                        Else
3299
                                            'dStartX점이 기준선과 더 가까이 있음
3300
                                            If dStartX >= dEndX Then
3301
                                                '가로선의 오른쪽점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3302
                                                If dStartX + dGap >= d기준x Then
3303
                                                    dStartX = d기준x
3304
                                                    sBranchType = "3"
3305
                                                    Return True
3306
                                                End If
3307
3308
                                            Else
3309
                                                '가로선의 왼쪽점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3310
                                                If dStartX - dGap <= d기준x Then
3311
                                                    dStartX = d기준x
3312
                                                    sBranchType = "3"
3313
                                                    Return True
3314
                                                End If
3315
                                            End If
3316
                                        End If
3317
                                    End If
3318
3319
                                End If
3320
                            End If
3321
                        End If
3322
3323
                    End If
3324 79326880 Gyusu
                Else
3325 bb2a0c79 Gyusu
                    'Horizontal
3326
                    If Math.Abs(dModelStartX - dModelEndX) >= Math.Abs(dModelStartY - dModelEndY) Then
3327
                        'Vertical
3328
                        If Math.Abs(dStartX - dEndX) <= Math.Abs(dStartY - dEndY) Then
3329
                            '  dGap = 0.0015 'Math.Abs(dStartY - dEndY) / 80
3330
3331
                            '기준선의 X범위안에 세로선이 포함되어야됨
3332
                            If ((dModelStartX + dGap >= dStartX And dModelEndX - dGap <= dStartX) Or
3333
                            (dModelStartX - dGap <= dStartX And dModelEndX + dGap >= dStartX)) And
3334
                            ((dModelStartX + dGap >= dEndX And dModelEndX - dGap <= dEndX) Or
3335
                            (dModelStartX - dGap <= dEndX And dModelEndX + dGap >= dEndX)) Then
3336
3337
                                '가로선보다 아래에 세로선이 있을때
3338
                                If d기준y >= dStartY And d기준y >= dEndY Then
3339
                                    If dStartY >= dEndY Then
3340
                                        'dStartY 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3341
                                        If dStartY + dGap >= d기준y Then
3342
                                            dStartY = d기준y
3343
                                            sBranchType = "3"
3344
                                            Return True
3345
                                        End If
3346
                                    Else
3347
                                        'dEndY 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3348
                                        If dEndY + dGap >= d기준y Then
3349
                                            dEndY = d기준y
3350
3351
                                            If Math.Abs(dEndX - dModelStartX) > Math.Abs(dEndX - dModelEndX) Then
3352
                                                dEndX = dModelEndX
3353
                                            Else
3354
                                                dEndX = dModelStartX
3355
                                            End If
3356
3357
                                            sBranchType = "4"
3358
                                            Return True
3359
                                        End If
3360
                                    End If
3361
                                    '기준선보다 위에 세로선이 있을때
3362
                                ElseIf d기준y <= dStartY And d기준y <= dEndY Then
3363
                                    If dStartY >= dEndY Then
3364
                                        'dEndY 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3365
                                        If dEndY - dGap <= d기준y Then
3366
                                            dEndY = d기준y
3367
                                            sBranchType = "4"
3368
                                            Return True
3369
                                        End If
3370
                                    Else
3371
                                        'dStartY 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3372
                                        If dStartY - dGap <= d기준y Then
3373
                                            dStartY = d기준y
3374
                                            sBranchType = "3"
3375
                                            Return True
3376
                                        End If
3377
                                    End If
3378
                                Else
3379
                                    '기준선과 세로선이 겹칠때
3380
                                    If (d기준y >= dStartY And d기준y <= dEndY) Or
3381
                                            (d기준y <= dStartY And d기준y >= dEndY) Then
3382
                                        '기준선이 dStartY와 dEndY중 어느쪽에 가까운지 확인
3383
                                        '세로선의 윗점과 기준선이 가까울때는 gap만큼 뺐을때 기준선보다 작은지확인
3384
                                        '세로선의 아래점과 기준선이 가까울때는 gap만큼 더했을때 기준선보다 큰지확인
3385
                                        If (dModelStartX <= dStartX And dModelEndX >= dEndX) Or
3386
                                            (dModelStartX >= dStartX And dModelEndX <= dEndX) Then
3387
                                            If Math.Abs(d기준y - dStartY) >= Math.Abs(d기준y - dEndY) Then
3388
                                                'Endy점이 기준선과 더 가까이 있음
3389
                                                If dStartY >= dEndY Then
3390
                                                    '세로선의 아래점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3391
                                                    If dEndY + dGap >= d기준y Then
3392
                                                        dEndY = d기준y
3393
                                                        sBranchType = "4"
3394
                                                        Return True
3395
                                                    End If
3396
                                                Else
3397
                                                    '세로선의 윗점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3398
                                                    If dEndY - dGap <= d기준y Then
3399
                                                        dEndY = d기준y
3400
                                                        sBranchType = "4"
3401
                                                        Return True
3402
                                                    End If
3403
                                                End If
3404
                                            Else
3405
                                                'dStartY점이 기준선과 더 가까이 있음
3406
                                                If dStartY >= dEndY Then
3407
                                                    '세로선의 윗점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3408
                                                    If dStartY - dGap <= d기준y Then
3409
                                                        dStartY = d기준y
3410
                                                        sBranchType = "3"
3411
                                                        Return True
3412
                                                    End If
3413
                                                Else
3414
                                                    '세로선의 아래점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3415
                                                    If dStartY + dGap >= d기준y Then
3416
                                                        dStartY = d기준y
3417
                                                        sBranchType = "3"
3418
                                                        Return True
3419
                                                    End If
3420
                                                End If
3421
                                            End If
3422
                                        End If
3423
3424
                                    End If
3425
                                End If
3426
                            End If
3427
                        End If
3428
                    End If
3429
                End If
3430
            Next
3431
        Catch ex As Exception
3432
3433
        End Try
3434
        oLMConnector = Nothing
3435
        Return False
3436
    End Function
3437
3438 76f465d0 Gyusu
    Private Function CheckConnectionSymbolToSymbol(ByVal oModelingLineRows() As DataRow, ByRef dX As Double, ByRef dY As Double,
3439
                                  ByRef oLMConnector As LMConnector) As Boolean
3440
        Dim bConnectionFlag As Boolean = False
3441
        Try
3442
            For Each oModelrow In oModelingLineRows
3443
                Dim d기준x As Double = dX
3444
                Dim d기준y As Double = dY
3445
                Dim dGap As Double = 0.0002
3446
                Dim oRun As LMPipeRun = Nothing
3447
                Try
3448
                    Dim oLMSymbol As LMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3449
                    Dim dX1 As Double = 0.0
3450
                    Dim dY1 As Double = 0.0
3451
                    Dim dX2 As Double = 0.0
3452
                    Dim dY2 As Double = 0.0
3453
                    For Each oConnector In oLMSymbol.Connect1Connectors
3454
                        oLMConnector = oConnector
3455
                    Next
3456
                    '  oRun = _Placement.PIDDataSource.GetPipeRun(oLMSymbol.Connect1Connectors.Nth(1).ModelItemID)
3457
                    _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
3458
                    _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
3459
                    If Math.Abs(dX - dX1) < dGap And Math.Abs(dY - dY1) < dGap Then
3460
                        dX = dX1
3461
                        dY = dY1
3462
                        bConnectionFlag = True
3463
                        Exit For
3464
                    End If
3465
                    If Math.Abs(dX - dX2) < dGap And Math.Abs(dY - dY2) < dGap Then
3466
                        dX = dX2
3467
                        dY = dY2
3468
                        bConnectionFlag = True
3469
                        Exit For
3470
                    End If
3471
3472
                    'For Each oConnector In oLMSymbol.Connect1Connectors
3473
                    '    For Each objConnectorVertex In oConnector.ConnectorVertices
3474
                    '        Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3475
                    '        Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3476
                    '        If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3477
                    '            oLMConnector = oConnector
3478
                    '            dX = dConn_X
3479
                    '            dY = dConn_Y
3480
                    '            bConnectionFlag = True
3481
                    '            Exit For
3482
                    '        End If
3483
                    '    Next
3484
                    'Next
3485
3486
                    'For Each oConnector In oLMSymbol.Connect2Connectors
3487
                    '    For Each objConnectorVertex In oConnector.ConnectorVertices
3488
                    '        Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3489
                    '        Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3490
                    '        If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3491
                    '            oLMConnector = oConnector
3492
                    '            dX = dConn_X
3493
                    '            dY = dConn_Y
3494
                    '            bConnectionFlag = True
3495
                    '            Exit For
3496
                    '        End If
3497
                    '    Next
3498
                    'Next
3499
3500
3501
                    'If oRun IsNot Nothing Then
3502
                    '    Dim dResultCalc As Double = -1
3503
                    '    For Each objRep In oRun.Representations
3504
                    '        Dim sRepresentationType As String = objRep.Attributes("RepresentationType").Value
3505
                    '        If objRep.Attributes("RepresentationType").Value = "Connector" Or
3506
                    '            objRep.Attributes("RepresentationType").Value = "Symbol" And
3507
                    '             objRep.Attributes("ItemStatus").Value = "Active" Then
3508
                    '            Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
3509
                    '            For Each objConnectorVertex In objConnector.ConnectorVertices
3510
                    '                Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3511
                    '                Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3512
                    '                If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3513
                    '                    oLMConnector = objConnector
3514
                    '                    d기준x = dConn_X
3515
                    '                    d기준y = dConn_Y
3516
                    '                    bConnectionFlag = True
3517
                    '                    Exit For
3518
                    '                End If
3519
                    '            Next
3520
                    '        End If
3521
                    '    Next
3522
                    'End If
3523
3524
                Catch ex As Exception
3525
                End Try
3526
            Next
3527
3528
        Catch ex As Exception
3529
3530
        End Try
3531
        Return bConnectionFlag
3532
    End Function
3533
3534
    Private Function CheckConnectionSymbolToLine(ByVal oModelingLineRows() As DataRow, ByRef dX As Double, ByRef dY As Double,
3535
ByVal dCenterX As Double, ByVal dCenterY As Double, ByRef oLMConnector As LMConnector) As LMSymbol
3536
        Dim bConnectionFlag As Boolean = False
3537
        Dim oLMSymbol As LMSymbol = Nothing
3538
        Try
3539
3540
            For Each oModelrow In oModelingLineRows
3541
                Dim d기준x As Double = dCenterX
3542
                Dim d기준y As Double = dCenterY
3543
                Dim dGap As Double = 0.001
3544
                Dim oRun As LMPipeRun = Nothing
3545
                Dim dCheckGap As Double = 0
3546
                Try
3547
3548
                    Dim dX1 As Double = 0.0
3549
                    Dim dY1 As Double = 0.0
3550
                    Dim dX2 As Double = 0.0
3551
                    Dim dY2 As Double = 0.0
3552
                    '  oRun = _Placement.PIDDataSource.GetPipeRun(oLMSymbol.Connect1Connectors.Nth(1).ModelItemID)
3553
                    oLMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3554
                    For Each oConnector In oLMSymbol.Connect1Connectors
3555
                        oLMConnector = oConnector
3556
                    Next
3557
                    _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
3558
                    _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
3559
                    '  If Math.Abs(dX - dX1) < dGap And Math.Abs(dY - dY1) < dGap And
3560
                    If Math.Abs(d기준x - dX1) < dCheckGap And Math.Abs(d기준y - dY1) < dCheckGap Or dCheckGap = 0 Then
3561
                        dX = dX1
3562
                        dY = dY1
3563
                        bConnectionFlag = True
3564
                        dCheckGap = Math.Abs(d기준x - dX1) + Math.Abs(d기준y - dY1)
3565
                    End If
3566
                    'If Math.Abs(dX - dX2) < dGap And Math.Abs(dY - dY2) < dGap And
3567
                    '  Math.Abs(d기준x - dX2) < dCheckGap And Math.Abs(d기준y - dY2 < dCheckGap) Or dCheckGap = 0 Then
3568
                    If Math.Abs(d기준x - dX2) < dCheckGap And Math.Abs(d기준y - dY2) < dCheckGap Or dCheckGap = 0 Then
3569
                        dX = dX2
3570
                        dY = dY2
3571
                        bConnectionFlag = True
3572
                    End If
3573
3574
                Catch ex As Exception
3575
                End Try
3576
                If bConnectionFlag Then
3577
                    oLMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3578
                Else
3579
                    oLMSymbol = Nothing
3580
                End If
3581
            Next
3582 b08338e3 Gyusu
3583 76f465d0 Gyusu
        Catch ex As Exception
3584 b08338e3 Gyusu
3585 76f465d0 Gyusu
        End Try
3586 b08338e3 Gyusu
3587 76f465d0 Gyusu
        Return oLMSymbol
3588
    End Function
3589 b08338e3 Gyusu
3590 3b7a4470 Gyusu
    ''' <summary>
3591
    ''' 라인과 라인이 만나는점이 브런치점인지 확인, 오차범위내 라인보정
3592
    ''' </summary>
3593
    ''' <param name="oModelingLineRows"></param>
3594
    ''' <param name="dStartX"></param>
3595
    ''' <param name="dStartY"></param>
3596
    ''' <param name="dEndX"></param>
3597
    ''' <param name="dEndY"></param>
3598
    ''' <param name="oLMConnector"></param>
3599
    ''' <returns></returns>
3600
    Private Function CheckBranchLine(ByVal oModelingLineRows As DataRowCollection, ByRef dStartX As Double, ByRef dStartY As Double,
3601
                                     ByRef dEndX As Double, ByRef dEndY As Double, ByRef oLMConnector As LMConnector) As String
3602
        Dim bConnectionFlag As Boolean = False
3603
        Dim sBranchDirection As String = ""
3604
        Try
3605
            For Each oModelrow In oModelingLineRows
3606
                Dim dModelStartX As Double
3607
                Dim dModelStartY As Double
3608
                Dim dModelEndX As Double
3609
                Dim dModelEndY As Double
3610 73bfb231 Gyusu
                Dim dGap As Double = 0.002
3611 3b7a4470 Gyusu
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3612
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3613
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3614
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3615
3616
                '기존라인이 X축방향이라면 현재선은 Y축방향이 되어야됨
3617
                If Math.Abs(dModelStartX - dModelEndX) > Math.Abs(dModelStartY - dModelEndY) And
3618
                    Math.Abs(dStartX - dEndX) < Math.Abs(dStartY - dEndY) Then
3619
3620
                    '기본라인의 X축영역안에 현재선이 있어야됨
3621
                    '      If dModelEndY > dModelStartY Then
3622
                    If (dStartX < dModelEndX And dStartX > dModelStartX) Or
3623
                            (dStartX > dModelEndX And dStartX < dModelStartX) Then
3624
                        '[오차범위 수정]
3625
                        '현재선의 Y축방향이 기존라인의 X축방향을 통과하는지 확인
3626
                        If dStartY < dEndY Then
3627
                            If dEndY > dModelStartY And dModelStartY > dStartY Then
3628
                                If dEndY - dModelStartY > dModelStartY - dStartY Then
3629
                                    '위쪽으로 라인이 나와있을때
3630
                                    '현재선 중 작은 Y좌표를 오차범위만큼 더했을때 기존라인의 Y축보다 큰지확인 
3631
                                    'Y축보다 클경우 작은 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 큰 Y좌표에 더한다.
3632 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3633 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartY - dStartY
3634
                                        dEndY = dEndY + dAddPoint
3635
                                        dStartY = dModelStartY
3636
                                        sBranchDirection = "START"
3637 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3638
                                        Exit For
3639 3b7a4470 Gyusu
                                    End If
3640
                                Else
3641
                                    '아래쪽으로 라인이 나와있을때
3642
                                    '현재선 중 큰 Y좌표를 오차범위만큼 뺐을때 기존라인의 Y축보다 작은지확인 
3643
                                    'Y축보다 작을경우 큰 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 작은 Y좌표에 뺀다.
3644 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3645 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dEndY - dModelStartY
3646
                                        dStartY = dStartY - dAddPoint
3647
                                        dEndY = dModelStartY
3648
                                        sBranchDirection = "END"
3649 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3650
                                        Exit For
3651 3b7a4470 Gyusu
                                    End If
3652
                                End If
3653
                            Else
3654
                                '현재선의 Y축방향이 기존라인의 X축방향에 못미치는지 확인
3655
                                If dStartY > dModelStartY Then
3656
                                    '기존라인보다 위쪽에 현재선이 있을때
3657 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3658 3b7a4470 Gyusu
                                        '오차범위만큼 작은 y좌표를 뺐을때 기존라인보다 아래쪽에 있을경우 오차보정
3659
                                        Dim dAddPoint As Double = dStartY - dModelStartY
3660
                                        dEndY = dEndY - dAddPoint
3661
                                        dStartY = dModelStartY
3662
                                        sBranchDirection = "START"
3663 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3664
                                        Exit For
3665 3b7a4470 Gyusu
                                    End If
3666
                                Else
3667
                                    '기존라인보다 아래쪽에 현재선이 있을때
3668 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3669 3b7a4470 Gyusu
                                        '오차범위만큼 큰 y좌표를 더했을때 기존라인보다 위쪽에 있을경우 오차보정
3670
                                        Dim dAddPoint As Double = dModelStartY - dEndY
3671
                                        dEndY = dModelStartY
3672
                                        dStartY = dStartY + dAddPoint
3673
                                        sBranchDirection = "END"
3674 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3675
                                        Exit For
3676 3b7a4470 Gyusu
                                    End If
3677
                                End If
3678
                            End If
3679
                        Else
3680
                            If dEndY < dModelStartY And dModelStartY < dStartY Then
3681
                                If dModelStartY - dEndY < dStartY - dModelStartY Then
3682
                                    '위쪽으로 라인이 나와있을때
3683
                                    '현재선 중 작은 Y좌표를 오차범위만큼 더했을때 기존라인의 Y축보다 큰지확인 
3684
                                    'Y축보다 클경우 작은 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 큰 Y좌표에 더한다.
3685 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3686 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartY - dEndY
3687
                                        dStartY = dStartY + dAddPoint
3688
                                        dEndY = dModelStartY
3689
                                        sBranchDirection = "END"
3690 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3691
                                        Exit For
3692 3b7a4470 Gyusu
                                    End If
3693
                                Else
3694
                                    '아래쪽으로 라인이 나와있을때
3695
                                    '현재선 중 큰 Y좌표를 오차범위만큼 뺐을때 기존라인의 Y축보다 작은지확인 
3696
                                    'Y축보다 작을경우 큰 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 작은 Y좌표에 뺀다.
3697 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3698 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dStartY - dModelStartY
3699
                                        dEndY = dEndY - dAddPoint
3700
                                        dStartY = dModelStartY
3701
                                        sBranchDirection = "START"
3702 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3703
                                        Exit For
3704 3b7a4470 Gyusu
                                    End If
3705
                                End If
3706
                            Else
3707
                                If dEndY > dModelStartY Then
3708
                                    '기존라인보다 우측에 현재선이 있을때
3709 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3710 3b7a4470 Gyusu
                                        '오차범위만큼 작은 x좌표를 뺐을때 기존라인보다 좌측에 있을경우 오차보정
3711
                                        Dim dAddPoint As Double = dEndY - dModelStartY
3712
                                        dStartY = dStartY - dAddPoint
3713
                                        dEndY = dModelStartY
3714
                                        sBranchDirection = "END"
3715 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3716
                                        Exit For
3717 3b7a4470 Gyusu
                                    End If
3718
                                Else
3719
                                    '기존라인보다 좌측에 현재선이 있을때
3720 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3721 3b7a4470 Gyusu
                                        '오차범위만큼 큰 x좌표를 더했을때 기존라인보다 우측에 있을경우 오차보정
3722
                                        Dim dAddPoint As Double = dModelStartY - dStartY
3723
                                        dStartY = dModelStartY
3724
                                        dEndY = dEndY + dAddPoint
3725
                                        sBranchDirection = "START"
3726 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3727
                                        Exit For
3728 3b7a4470 Gyusu
                                    End If
3729
                                End If
3730
                            End If
3731
                        End If
3732
                    End If
3733
                    '기존라인이 Y축방향이라면 현재선은 X축방향이 되어야됨
3734
                ElseIf Math.Abs(dModelStartX - dModelEndX) < Math.Abs(dModelStartY - dModelEndY) And
3735
                Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then
3736
3737
                    '기본라인의 Y축영역안에 현재선이 있어야됨
3738
                    '      If dModelEndY > dModelStartY Then
3739
                    If (dStartY < dModelEndY And dStartY > dModelStartY) Or
3740
                            (dStartY > dModelEndY And dStartY < dModelStartY) Then
3741
                        '[오차범위 수정]
3742
                        '현재선의 X축방향이 기존라인의 Y축방향을 통과하는지 확인
3743
                        If dStartX < dEndX Then
3744
                            If dEndX > dModelStartX And dModelStartX > dStartX Then
3745
                                If dEndX - dModelStartX > dModelStartX - dStartX Then
3746
                                    '우측으로 라인이 나와있을때
3747
                                    '현재선 중 작은 X좌표를 오차범위만큼 더했을때 기존라인의 X축보다 큰지확인 
3748
                                    'X축보다 클경우 작은 X좌표를 기존라인의 X축에 맞추고 더한 길이만큼 큰 X좌표에 더한다.
3749 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3750 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartX - dStartX
3751
                                        dEndX = dEndX + dAddPoint
3752
                                        dStartX = dModelStartX
3753
                                        sBranchDirection = "START"
3754 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3755
                                        Exit For
3756 3b7a4470 Gyusu
                                    End If
3757
                                Else
3758
                                    '좌측으로 라인이 나와있을때
3759
                                    '현재선 중 큰 X좌표를 오차범위만큼 뺐을때 기존라인의 X축보다 작은지확인 
3760
                                    'X축보다 작을경우 큰 X좌표를 기존라인의 X축에 맞추고 뺀 길이만큼 작은 X좌표에 뺀다.
3761 73bfb231 Gyusu
                                    If Math.Abs(dEndX - dModelStartX) <= dGap Then
3762 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dEndX - dModelStartX
3763
                                        dStartX = dStartX - dAddPoint
3764
                                        dEndX = dModelStartX
3765
                                        sBranchDirection = "END"
3766 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3767
                                        Exit For
3768 3b7a4470 Gyusu
                                    End If
3769
                                End If
3770
                            Else
3771
                                '현재선의 X축방향이 기존라인의 Y축방향에 못미치는지 확인
3772
                                If dStartX > dModelStartX Then
3773
                                    '기존라인보다 우측에 현재선이 있을때
3774 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3775 3b7a4470 Gyusu
                                        '오차범위만큼 작은 x좌표를 뺐을때 기존라인보다 좌측에 있을경우 오차보정
3776
                                        Dim dAddPoint As Double = dStartX - dModelStartX
3777
                                        dEndX = dEndX - dAddPoint
3778
                                        dStartX = dModelStartX
3779
                                        sBranchDirection = "START"
3780 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3781
                                        Exit For
3782 3b7a4470 Gyusu
                                    End If
3783
                                Else
3784
                                    '기존라인보다 좌측에 현재선이 있을때
3785 73bfb231 Gyusu
                                    If Math.Abs(dEndX - dModelStartX) <= dGap Then
3786 3b7a4470 Gyusu
                                        '오차범위만큼 큰 x좌표를 더했을때 기존라인보다 우측에 있을경우 오차보정
3787
                                        Dim dAddPoint As Double = dModelStartX - dEndX
3788
                                        dEndX = dModelStartX
3789
                                        dStartX = dStartX + dAddPoint
3790
                                        sBranchDirection = "END"
3791 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3792
                                        Exit For
3793 3b7a4470 Gyusu
                                    End If
3794
                                End If
3795
                            End If
3796
                        Else
3797
                            If dEndX < dModelStartX And dModelStartX < dStartX Then
3798
                                If dModelStartX - dEndX < dStartX - dModelStartX Then
3799
                                    '우측으로 라인이 나와있을때
3800
                                    '현재선 중 작은 X좌표를 오차범위만큼 더했을때 기존라인의 X축보다 큰지확인 
3801
                                    'X축보다 클경우 작은 X좌표를 기존라인의 X축에 맞추고 더한 길이만큼 큰 X좌에 더한다.
3802 73bfb231 Gyusu
                                    If Math.Abs(dModelStartX - dEndX) <= dGap Then
3803 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartX - dEndX
3804
                                        dStartX = dStartX + dAddPoint
3805
                                        dEndX = dModelStartX
3806
                                        sBranchDirection = "END"
3807 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3808
                                        Exit For
3809 3b7a4470 Gyusu
                                    End If
3810
                                Else
3811
                                    '좌측으로 라인이 나와있을때
3812
                                    '현재선 중 큰 X좌표를 오차범위만큼 뺐을때 기존라인의 X축보다 작은지확인 
3813
                                    'X축보다 작을경우 큰 X좌표를 기존라인의 X축에 맞추고 뺀 길이만큼 작은 X좌표에 뺀다.
3814 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3815 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dStartX - dModelStartX
3816
                                        dEndX = dEndX - dAddPoint
3817
                                        dStartX = dModelStartX
3818
                                        sBranchDirection = "START"
3819 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3820
                                        Exit For
3821 3b7a4470 Gyusu
                                    End If
3822
3823
                                End If
3824
                            Else
3825
                                If dEndX > dModelStartX Then
3826
                                    '기존라인보다 우측에 현재선이 있을때
3827 73bfb231 Gyusu
                                    If Math.Abs(dEndX - dModelStartX) <= dGap Then
3828 3b7a4470 Gyusu
                                        '오차범위만큼 작은 x좌표를 뺐을때 기존라인보다 좌측에 있을경우 오차보정
3829
                                        Dim dAddPoint As Double = dEndX - dModelStartX
3830
                                        dStartX = dStartX - dAddPoint
3831
                                        dEndX = dModelStartX
3832
                                        sBranchDirection = "END"
3833 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3834
                                        Exit For
3835 3b7a4470 Gyusu
                                    End If
3836
                                Else
3837
                                    '기존라인보다 좌측에 현재선이 있을때
3838 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3839 3b7a4470 Gyusu
                                        '오차범위만큼 큰 x좌표를 더했을때 기존라인보다 우측에 있을경우 오차보정
3840
                                        Dim dAddPoint As Double = dModelStartX - dStartX
3841
                                        dStartX = dModelStartX
3842
                                        dEndX = dEndX + dAddPoint
3843
                                        sBranchDirection = "START"
3844 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3845
                                        Exit For
3846 3b7a4470 Gyusu
                                    End If
3847
                                End If
3848
                            End If
3849
                        End If
3850
                    End If
3851
                End If
3852
            Next
3853
        Catch ex As Exception
3854
            bConnectionFlag = False
3855
            oLMConnector = Nothing
3856
        End Try
3857
        Return sBranchDirection
3858
3859
    End Function
3860
3861 79326880 Gyusu
    Private Function UpdateCheckBranchLine(ByRef dX As Double, ByRef dY As Double,
3862
                                  ByRef oLMConnector As LMConnector) As Boolean
3863
        Dim bConnectionFlag As Boolean = False
3864
        Dim iGapCheck As Integer = 0
3865
        Try
3866
            For Each oModelrow In _ModelingLine_Dt.Rows
3867
                Dim d기준x As Double = dX
3868
                Dim d기준y As Double = dY
3869
                Dim dGap As Double = 0.001
3870
                Dim oRun As LMPipeRun = Nothing
3871
                Dim dModelStartX As Double
3872
                Dim dModelStartY As Double
3873
                Dim dModelEndX As Double
3874
                Dim dModelEndY As Double
3875
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3876
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3877
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3878
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3879
                d기준x = (dModelStartX + dModelEndX) / 2
3880
                d기준y = (dModelStartY + dModelEndY) / 2
3881
3882
3883
                Dim dMax_X As Double = 0.0
3884
                Dim dMax_Y As Double = 0.0
3885
                Dim dMin_X As Double = 0.0
3886
                Dim dMin_Y As Double = 0.0
3887
3888
3889
                If dModelEndX > dModelStartX Then
3890
                    dMax_X = dModelEndX
3891
                    dMin_X = dModelStartX
3892
                Else
3893
                    dMax_X = dModelStartX
3894
                    dMin_X = dModelEndX
3895
                End If
3896
3897
                If dModelEndY > dModelStartY Then
3898
                    dMax_Y = dModelEndY
3899
                    dMin_Y = dModelStartY
3900
                Else
3901
                    dMax_Y = dModelStartY
3902
                    dMin_Y = dModelEndY
3903
                End If
3904
3905
                If dX <= dMax_X + dGap And dX >= dMin_X - dGap And
3906
                  dY <= dMax_Y + dGap And dY >= dMin_Y - dGap Then
3907
                    If Math.Abs(dMax_X - dMin_X) > Math.Abs(dMax_Y - dMin_Y) Then
3908
                        dY = dMax_Y
3909
                    Else
3910
                        dX = dMax_X
3911
                    End If
3912
3913
                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3914
                End If
3915
3916
3917
            Next
3918
        Catch ex As Exception
3919
            bConnectionFlag = False
3920
            oLMConnector = Nothing
3921
        End Try
3922
        Return bConnectionFlag
3923
    End Function
3924
3925
3926 3b7a4470 Gyusu
    ''' <summary>
3927
    ''' 라인과 특정 포인트에 커넥션을 확인하는 메서드
3928
    ''' </summary>
3929
    ''' <param name="oModelingLineRows"></param>
3930
    ''' <param name="dX"></param>
3931
    ''' <param name="dY"></param>
3932
    ''' <param name="oLMConnector"></param>
3933
    ''' <param name="dPreConnX"></param>
3934
    ''' <param name="dPreConnY"></param>
3935
    ''' <returns></returns>
3936
3937
3938 79326880 Gyusu
3939
    Private Function CheckConnectionLine(ByRef dX As Double, ByRef dY As Double,
3940
                                  ByRef oLMConnector As LMConnector) As Boolean
3941 b08338e3 Gyusu
        Dim bConnectionFlag As Boolean = False
3942 76f465d0 Gyusu
        Dim iGapCheck As Integer = 0
3943 b08338e3 Gyusu
        Try
3944 79326880 Gyusu
            For Each oModelrow In _ModelingLine_Dt.Rows
3945 76f465d0 Gyusu
                Dim d기준x As Double = dX
3946
                Dim d기준y As Double = dY
3947
                Dim dGap As Double = 0.0002
3948
                Dim oRun As LMPipeRun = Nothing
3949
                'Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
3950 3b7a4470 Gyusu
                'Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
3951 b08338e3 Gyusu
                Dim dModelStartX As Double
3952
                Dim dModelStartY As Double
3953
                Dim dModelEndX As Double
3954
                Dim dModelEndY As Double
3955 3b7a4470 Gyusu
                'ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
3956
                'ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
3957
                'ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
3958 76f465d0 Gyusu
                'ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
3959
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3960
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3961
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3962
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3963
                d기준x = (dModelStartX + dModelEndX) / 2
3964
                d기준y = (dModelStartY + dModelEndY) / 2
3965 79326880 Gyusu
3966
3967
                Dim bCheckEqual As Boolean = False
3968
                If dX <= dModelStartX + dGap And dX >= dModelStartX - dGap And
3969
                        dY <= dModelStartY + dGap And dY >= dModelStartY - dGap Then
3970
                    bCheckEqual = True
3971
                ElseIf dX <= dModelEndX + dGap And dX >= dModelEndX - dGap And
3972
                        dY <= dModelEndY + dGap And dY >= dModelEndY - dGap Then
3973
                    bCheckEqual = True
3974
3975
                End If
3976
3977
                If bCheckEqual Then
3978
                    Try
3979
                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3980
                        oRun = _Placement.PIDDataSource.GetPipeRun(oLMConnector.ModelItemID)
3981
                    Catch ex As Exception
3982
                    End Try
3983
                    Try
3984
                        If oRun IsNot Nothing Then
3985
                            Dim dResultCalc As Double = -1
3986
                            For Each objRep In oRun.Representations
3987
                                If objRep.Attributes("RepresentationType").Value = "Connector" And objRep.Attributes("ItemStatus").Value = "Active" Then
3988
                                    Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
3989
                                    For Each objConnectorVertex In objConnector.ConnectorVertices
3990
                                        Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3991
                                        Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3992
                                        If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3993
                                            oLMConnector = objConnector
3994
                                            dX = dConn_X
3995
                                            dY = dConn_Y
3996
                                            bConnectionFlag = True
3997
                                        End If
3998
                                    Next
3999
                                End If
4000
                            Next
4001
                        End If
4002
                    Catch ex As Exception
4003
                    End Try
4004
                Else
4005
                    'Dim dMax_X As Double = 0.0
4006
                    'Dim dMax_Y As Double = 0.0
4007
                    'Dim dMin_X As Double = 0.0
4008
                    'Dim dMin_Y As Double = 0.0
4009
4010
4011
                    'If dModelEndX > dModelStartX Then
4012
                    '    dMax_X = dModelEndX
4013
                    '    dMin_X = dModelStartX
4014
                    'Else
4015
                    '    dMax_X = dModelStartX
4016
                    '    dMin_X = dModelEndX
4017
                    'End If
4018
4019
                    'If dModelEndY > dModelStartY Then
4020
                    '    dMax_Y = dModelEndY
4021
                    '    dMin_Y = dModelStartY
4022
                    'Else
4023
                    '    dMin_Y = dModelStartY
4024
                    '    dMin_X = dModelEndY
4025
                    'End If
4026
4027
                    'If dX <= dMax_X + dGap And dX >= dMin_X - dGap And
4028
                    '  dY <= dMax_Y + dGap And dY >= dMin_Y - dGap Then
4029
4030
                    '    If Math.Abs(dMax_X - dMin_X) > Math.Abs(dMax_Y - dMin_Y) Then
4031
                    '        dY = dMax_Y
4032
                    '    Else
4033
                    '        dX = dMax_X
4034
                    '    End If
4035
4036
                    '    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
4037
                    'End If
4038
                End If
4039
4040 b08338e3 Gyusu
            Next
4041
        Catch ex As Exception
4042 76f465d0 Gyusu
            bConnectionFlag = False
4043
            oLMConnector = Nothing
4044 b08338e3 Gyusu
        End Try
4045
        Return bConnectionFlag
4046
    End Function
4047
4048
    Private Function CheckLineBranch(ByVal oLine_Dt As DataTable, ByRef dX As Double, ByRef dY As Double,
4049
                                     ByVal sDirection As String, ByRef oLMConnector As LMConnector) As Boolean
4050
4051
        Dim oModelingLineRows() As DataRow = oLine_Dt.Select("[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And " &
4052
                                                                "[" & _XML_LINE_SPID & "] <> ''")
4053
4054
        Dim bConnectionFlag As Boolean = False
4055
        Try
4056
            For Each oModelrow In oModelingLineRows
4057
                Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
4058
                Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
4059
                Dim dModelStartX As Double
4060
                Dim dModelStartY As Double
4061
                Dim dModelEndX As Double
4062
                Dim dModelEndY As Double
4063
                ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
4064
                ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
4065
                ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
4066
                ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
4067
                Dim dGap As Double = 0.0002
4068
4069
                If Math.Abs(dModelStartX - dModelEndX) <= Math.Abs(dModelStartY - dModelEndY) Then
4070
                    'Vertical
4071
                    If sDirection = "X" Then
4072
                        'x Direction Line
4073
                        If (dModelStartY + dGap >= dY And dModelEndY - dGap <= dY) Or
4074
                        (dModelStartY - dGap <= dY And dModelEndY + dGap >= dY) Then
4075
                            If (dX > dModelStartX And dX < dModelEndX) Or (dX > dModelEndX And dX < dModelStartX) Then
4076
                                If Math.Abs(dX - dModelStartX) > Math.Abs(dX - dModelEndX) Then
4077
                                    dX = dModelEndX
4078
                                Else
4079
                                    dX = dModelStartX
4080
                                End If
4081
                                Try
4082
                                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
4083
                                Catch ex As Exception
4084
4085
                                End Try
4086
                                bConnectionFlag = True
4087
                            End If
4088
                        End If
4089
                    End If
4090
                Else
4091
                    'Horizontal 
4092
                    If sDirection = "Y" Then
4093
                        If (dModelStartX + dGap >= dX And dModelEndX - dGap <= dX) Or
4094
                       (dModelStartX - dGap <= dX And dModelEndX + dGap >= dX) Then
4095
                            If (dY > dModelStartY And dY < dModelEndY) Or (dY > dModelEndY And dY < dModelStartY) Then
4096
                                If Math.Abs(dY - dModelStartY) > Math.Abs(dY - dModelEndY) Then
4097
                                    dY = dModelEndY
4098
                                Else
4099
                                    dY = dModelStartY
4100
                                End If
4101
                                Try
4102
                                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
4103
                                Catch ex As Exception
4104
                                End Try
4105
                                bConnectionFlag = True
4106
                            End If
4107
                        End If
4108
                    End If
4109
                End If
4110
            Next
4111
        Catch ex As Exception
4112
        End Try
4113
        Return bConnectionFlag
4114
    End Function
4115
    Private Function LineModeling(ByVal oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sStartLineUid As String, ByVal sEndLineUid As String, ByVal dStart_x As Double, ByVal dStart_y As Double, ByVal dEnd_x As Double, ByVal dEnd_y As Double,
4116
                              ByVal sLineNoUid As String, ByVal sLineUid As String, ByVal sSystemPath As String, ByRef oLMConnector As LMConnector) As Boolean
4117 76f465d0 Gyusu
        'Try
4118
        '    Dim oDatasource As Object = _Placement.PIDDataSource
4119
        '    Dim oPipeRun As LMPipeRun = Nothing
4120
        '    Dim objInputs As PlaceRunInputs
4121
        '    objInputs = New PlaceRunInputs
4122
        '    Dim objItem As LMAItem
4123
        '    '       Dim objConnector As LMConnector
4124
4125
        '    Dim oStartLineRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sStartLineUid & "' And " &
4126
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4127
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4128
        '    If oStartLineRow.Length = 0 Then
4129
        '        oStartLineRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sStartLineUid & "' And " &
4130
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4131
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4132
        '    End If
4133
        '    Dim oEndLineRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sEndLineUid & "' And " &
4134
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4135
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4136
4137
        '    oEndLineRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sEndLineUid & "' And " &
4138
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4139
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4140
        '    Dim sStartConnectionType As String = ""
4141
        '    Dim sEndConnectionType As String = ""
4142
4143
        '    Dim oStartLMConnector As LMConnector = Nothing
4144
        '    Dim oEndLMConnector As LMConnector = Nothing
4145
        '    Dim oDirectionLine As String = ""
4146
4147
        '    If Math.Abs(dStart_x - dEnd_x) > Math.Abs(dStart_y - dEnd_y) Then
4148
        '        oDirectionLine = "X"
4149
        '    Else
4150
        '        oDirectionLine = "Y"
4151
        '    End If
4152 b08338e3 Gyusu
4153 76f465d0 Gyusu
        '    Dim bCheckFlag As Boolean = False
4154 b08338e3 Gyusu
4155 76f465d0 Gyusu
        '    Dim bStartCheckFlag As Boolean = CheckConnectionLine(oStartLineRow, dStart_x, dStart_y, oStartLMConnector)
4156
        '    If bStartCheckFlag = False Then
4157
        '        bStartCheckFlag = CheckConnectionLine(oStartLineRow, dEnd_x, dEnd_y, oStartLMConnector)
4158
        '        bCheckFlag = True
4159
        '    End If
4160
        '    Dim bEndCheckFlag As Boolean = CheckConnectionLine(oEndLineRow, dEnd_x, dEnd_y, oEndLMConnector)
4161 b08338e3 Gyusu
4162 76f465d0 Gyusu
        '    If bEndCheckFlag = False Then
4163 b08338e3 Gyusu
4164 76f465d0 Gyusu
        '        bEndCheckFlag = CheckConnectionLine(oEndLineRow, dStart_x, dStart_y, oEndLMConnector)
4165
        '        bCheckFlag = True
4166
        '    End If
4167 b08338e3 Gyusu
4168 76f465d0 Gyusu
        '    If bStartCheckFlag = True And bEndCheckFlag = False Then
4169
        '        If bCheckFlag Then
4170
        '            objInputs.AddConnectorTarget(oStartLMConnector, dEnd_x, dEnd_y)
4171
        '            objInputs.AddPoint(dStart_x, dStart_y)
4172
        '        Else
4173
        '            objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
4174
        '            objInputs.AddPoint(dEnd_x, dEnd_y)
4175
        '        End If
4176
4177
        '    ElseIf bStartCheckFlag = False And bEndCheckFlag = True Then
4178
        '        If bCheckFlag Then
4179
4180
        '            objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
4181
        '            objInputs.AddPoint(dEnd_x, dEnd_y)
4182
        '        Else
4183
        '            objInputs.AddPoint(dStart_x, dStart_y)
4184
        '            objInputs.AddConnectorTarget(oStartLMConnector, dEnd_x, dEnd_y)
4185
        '        End If
4186
4187
        '    ElseIf bStartCheckFlag = True And bEndCheckFlag = True Then
4188
        '        objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
4189
        '        objInputs.AddConnectorTarget(oEndLMConnector, dEnd_x, dEnd_y)
4190
        '    Else
4191
        '        objInputs.AddPoint(dStart_x, dStart_y)
4192
        '        objInputs.AddPoint(dEnd_x, dEnd_y)
4193
        '    End If
4194
        '    SetListBoxItems(ListBox_Result, "Place Pipe..(" & dStart_x & "," & dStart_y & ") - (" & dEnd_x & "," & dEnd_y & ")..." & _iPipecnt & " count ")
4195
        '    _iPipecnt = _iPipecnt + 1
4196
        '    objItem = _Placement.PIDCreateItem(sSystemPath)
4197
        '    oLMConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4198 b08338e3 Gyusu
4199 76f465d0 Gyusu
        '    Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + sLineUid + "'")
4200
        '    If oUpdateRow.Length = 1 Then
4201
        '        oUpdateRow(0)(_XML_LINE_SPID) = oLMConnector.ModelItemID
4202
        '        oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = oLMConnector
4203 b08338e3 Gyusu
4204 76f465d0 Gyusu
        '        oUpdateRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4205
        '    End If
4206 b08338e3 Gyusu
4207 76f465d0 Gyusu
        '    oPipeRun = oDatasource.GetPipeRun(oLMConnector.ModelItemID)
4208
4209
        '    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4210
        '    If oAttributeRow.Length > 0 Then
4211
        '        For Each oAttribute In oAttributeRow
4212
        '            Try
4213
        '                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4214
        '                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4215
        '                If sPIDValue.Contains("'") Then
4216
        '                    sPIDValue = sPIDValue.Replace("'", """")
4217
        '                End If
4218
        '                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4219
        '                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4220
        '            Catch ex As Exception
4221
        '            End Try
4222
        '        Next
4223
        '        oPipeRun.Commit()
4224
        '    End If
4225
        '    Dim sID_1 As String = ""
4226
        '    Dim sID_2 As String = ""
4227
        '    If oStartLMConnector IsNot Nothing Then
4228
        '        sID_1 = oStartLMConnector.ModelItemID
4229
        '        sID_2 = oLMConnector.ModelItemID
4230
        '    ElseIf oEndLMConnector IsNot Nothing Then
4231
        '        sID_1 = oEndLMConnector.ModelItemID
4232
        '        sID_2 = oLMConnector.ModelItemID
4233
        '    End If
4234
        '    If sID_1 <> "" And sID_2 <> "" Then
4235
        '        Dim objSurvivorItem As LMAItem = Nothing
4236
        '        Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(sID_1)
4237
        '        Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(sID_2)
4238
        '        _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
4239
        '    End If
4240
        '    Return True
4241
        'Catch ex As Exception
4242
        '    Return False
4243
        'End Try
4244 b08338e3 Gyusu
4245
    End Function
4246
4247
    Private Function LineToLineModeling(ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable,
4248
                                        ByVal oAttribute_Dt As DataTable, ByVal sConnLineUid As String, ByVal sType As String,
4249
                                        ByRef oLMConnector As LMConnector) As String
4250
        Dim sReturnUid As String = ""
4251
        Try
4252
            Dim sLineUid As String = ""
4253
4254
            Dim iConnType As Integer = 0
4255
4256
            Dim sStartpoint As String = ""
4257
            Dim sEndpoint As String = ""
4258 bb2a0c79 Gyusu
            Dim dOriginalStart_x As Double = 0.0
4259
            Dim dOriginalStart_y As Double = 0.0
4260
            Dim dOriginalEnd_x As Double = 0.0
4261
            Dim dOriginalEnd_y As Double = 0.0
4262
4263 b08338e3 Gyusu
            Dim dStart_x As Double = 0
4264
            Dim dStart_y As Double = 0
4265
            Dim dEnd_x As Double = 0
4266
            Dim dEnd_y As Double = 0
4267
            Dim sStartLineUid As String = sConnLineUid
4268
            Dim sEndLineUid As String = ""
4269
            Dim sDirection As String = ""
4270
            Dim sSystemPath As String = GetPipeType(sType)
4271
4272
            Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" & sConnLineUid & "' And " &
4273
                                                                    "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4274
                                                                     "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4275
                                                                     "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4276
            If oPipeRow.Length > 0 Then
4277 bb2a0c79 Gyusu
                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4278
                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4279 e4000111 Gyusu
                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4280
                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4281 b08338e3 Gyusu
                ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4282
                ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4283
                If dStart_x = 0 And dStart_y = 0 Then
4284
                    dStart_x = dOriginalStart_x
4285
                    dStart_y = dOriginalStart_y
4286
                    dEnd_x = dOriginalEnd_x
4287
                    dEnd_y = dOriginalEnd_y
4288
                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4289
                        sDirection = "X"
4290
                    Else
4291
                        sDirection = "Y"
4292
                    End If
4293
                    oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4294
                    sLineUid = sConnLineUid
4295
                End If
4296
            End If
4297 bb2a0c79 Gyusu
4298 b08338e3 Gyusu
            While True
4299
                sLineUid = ""
4300
                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sConnLineUid + "' And " &
4301 f9b63682 Gyusu
                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4302
                                            "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4303
                                            "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4304 b08338e3 Gyusu
4305
                If oPipeRow.Length = 0 Then
4306
                    oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sConnLineUid + "' And " &
4307 f9b63682 Gyusu
                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4308
                                            "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4309
                                            "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4310 bb2a0c79 Gyusu
                Else
4311 b08338e3 Gyusu
                    'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4312
                    'sConnLineUid = sLineUid
4313
                    sLineUid = sConnLineUid
4314
                    sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4315
                    iConnType = 1
4316
                End If
4317
4318
                If oPipeRow.Length > 0 Then
4319
                    If sLineUid = "" Then
4320
                        'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4321
                        'sConnLineUid = sLineUid
4322
                        sLineUid = sConnLineUid
4323
                        sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4324
                        iConnType = 2
4325
                    End If
4326
                    If iConnType = 1 Then
4327
4328
                    ElseIf iConnType = 2 Then
4329
4330
                    End If
4331
                    sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4332
                    sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4333
                    ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4334
                    ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4335
                    ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4336
                    ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4337
4338
4339
4340
                    If dStart_x = 0 And dStart_y = 0 Then
4341
                        dStart_x = dOriginalStart_x
4342
                        dStart_y = dOriginalStart_y
4343
                        dEnd_x = dOriginalEnd_x
4344
                        dEnd_y = dOriginalEnd_y
4345
                        If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4346
                            sDirection = "X"
4347
                        Else
4348
                            sDirection = "Y"
4349
                        End If
4350
                        sType = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4351
                        sSystemPath = GetPipeType(sType)
4352
                    Else
4353
                        If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4354
                            If sDirection = "Y" Then
4355
                                '방향이 바꼈음 Y - > X
4356
4357
                                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4358
                                sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4359
                                dStart_x = dOriginalStart_x
4360
                                dStart_y = dOriginalStart_y
4361
                                dEnd_x = dOriginalEnd_x
4362
                                dEnd_y = dOriginalEnd_y
4363
                                sStartLineUid = sConnLineUid
4364
                            Else
4365
                                dEnd_x = dOriginalEnd_x
4366
                                dEnd_y = dOriginalEnd_y
4367
                            End If
4368
                            sDirection = "X"
4369
                        Else
4370
                            If sDirection = "X" Then
4371
                                '방향이 바꼈음 X - > Y
4372
                                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4373
                                sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4374
                                dStart_x = dOriginalStart_x
4375
                                dStart_y = dOriginalStart_y
4376
                                dEnd_x = dOriginalEnd_x
4377
                                dEnd_y = dOriginalEnd_y
4378
                                sStartLineUid = sConnLineUid
4379
                            Else
4380
4381
                                dEnd_x = dOriginalEnd_x
4382
                                dEnd_y = dOriginalEnd_y
4383
                            End If
4384
                            sDirection = "Y"
4385
                        End If
4386
                    End If
4387
                    '            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4388
                Else
4389
                    If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then
4390
                        LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4391
                         sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4392
                    End If
4393
                    sReturnUid = sConnLineUid
4394
                    Exit While
4395
                End If
4396
            End While
4397
4398
            If sStartLineUid <> "" And sEndLineUid <> "" Then
4399
                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4400
                             sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4401
                dStart_x = 0
4402
                dStart_y = 0
4403
                dEnd_x = 0
4404
                dEnd_y = 0
4405
            End If
4406
        Catch ex As Exception
4407
4408
        End Try
4409
4410
        Return sReturnUid
4411
    End Function
4412
4413
4414
    'Private Function LineToLineModeling(ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable,
4415
    '                                    ByVal oAttribute_Dt As DataTable, ByVal sConnLineUid As String, ByVal sType As String) As String
4416
    '    Dim sReturnUid As String = ""
4417
    '    Try
4418
    '        Dim sLineUid As String = ""
4419
4420
    '        Dim iConnType As Integer = 0
4421
4422
    '        Dim sStartpoint As String = ""
4423
    '        Dim sEndpoint As String = ""
4424
    '        Dim dOriginalStart_x As Double = 0.0
4425
    '        Dim dOriginalStart_y As Double = 0.0
4426
    '        Dim dOriginalEnd_x As Double = 0.0
4427
    '        Dim dOriginalEnd_y As Double = 0.0
4428
4429
    '        Dim dStart_x As Double = 0
4430
    '        Dim dStart_y As Double = 0
4431
    '        Dim dEnd_x As Double = 0
4432
    '        Dim dEnd_y As Double = 0
4433
    '        Dim sStartLineUid As String = sConnLineUid
4434
    '        Dim sEndLineUid As String = ""
4435
    '        Dim sDirection As String = ""
4436
    '        Dim sSystemPath As String = GetPipeType(sType)
4437
4438
    '        Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" & sConnLineUid & "' And " &
4439
    '                                                                "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4440
    '                                                                 "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4441
    '                                                                 "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4442
    '        If oPipeRow.Length > 0 Then
4443
    '            sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4444
    '            sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4445
    '            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4446
    '            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4447
    '            ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4448
    '            ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4449
    '            If dStart_x = 0 And dStart_y = 0 Then
4450
    '                dStart_x = dOriginalStart_x
4451
    '                dStart_y = dOriginalStart_y
4452
    '                dEnd_x = dOriginalEnd_x
4453
    '                dEnd_y = dOriginalEnd_y
4454
    '                If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4455
    '                    sDirection = "X"
4456
    '                Else
4457
    '                    sDirection = "Y"
4458
    '                End If
4459
    '                oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4460
    '                sLineUid = sConnLineUid
4461
    '            End If
4462
    '        End If
4463
4464
    '        While True
4465
    '            sLineUid = ""
4466
    '            oPipeRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sConnLineUid + "' And " &
4467
    '                                                                "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4468
    '                                                                         "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4469
    '                                                                         "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4470
4471
    '            If oPipeRow.Length = 0 Then
4472
    '                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sConnLineUid + "' And " &
4473
    '                                         "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4474
    '                                       "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4475
    '                                      "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4476
    '            Else
4477
    '                'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4478
    '                'sConnLineUid = sLineUid
4479
    '                sLineUid = sConnLineUid
4480
    '                sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4481
    '                iConnType = 1
4482
    '            End If
4483
4484
    '            If oPipeRow.Length > 0 Then
4485
    '                If sLineUid = "" Then
4486
    '                    'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4487
    '                    'sConnLineUid = sLineUid
4488
    '                    sLineUid = sConnLineUid
4489
    '                    sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4490
    '                    iConnType = 2
4491
    '                End If
4492
    '                If iConnType = 1 Then
4493
4494
    '                ElseIf iConnType = 2 Then
4495
4496
    '                End If
4497
    '                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4498
    '                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4499
    '                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4500
    '                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4501
    '                ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4502
    '                ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4503
4504
4505
4506
    '                If dStart_x = 0 And dStart_y = 0 Then
4507
    '                    dStart_x = dOriginalStart_x
4508
    '                    dStart_y = dOriginalStart_y
4509
    '                    dEnd_x = dOriginalEnd_x
4510
    '                    dEnd_y = dOriginalEnd_y
4511
    '                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4512
    '                        sDirection = "X"
4513
    '                    Else
4514
    '                        sDirection = "Y"
4515
    '                    End If
4516
    '                    sType = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4517
    '                    sSystemPath = GetPipeType(sType)
4518
    '                Else
4519
    '                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4520
    '                        If sDirection = "Y" Then
4521
    '                            '방향이 바꼈음 Y - > X
4522
    '                            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4523
    '                            sLineNoUid, sLineUid, sSystemPath)
4524
    '                            dStart_x = dOriginalStart_x
4525
    '                            dStart_y = dOriginalStart_y
4526
    '                            dEnd_x = dOriginalEnd_x
4527
    '                            dEnd_y = dOriginalEnd_y
4528
    '                            sStartLineUid = sConnLineUid
4529
    '                        Else
4530
    '                            dEnd_x = dOriginalEnd_x
4531
    '                            dEnd_y = dOriginalEnd_y
4532
    '                        End If
4533
    '                        sDirection = "X"
4534
    '                    Else
4535
    '                        If sDirection = "X" Then
4536
    '                            '방향이 바꼈음 X - > Y
4537
    '                            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4538
    '                            sLineNoUid, sLineUid, sSystemPath)
4539
    '                            dStart_x = dOriginalStart_x
4540
    '                            dStart_y = dOriginalStart_y
4541
    '                            dEnd_x = dOriginalEnd_x
4542
    '                            dEnd_y = dOriginalEnd_y
4543
    '                            sStartLineUid = sConnLineUid
4544
    '                        Else
4545
4546
    '                            dEnd_x = dOriginalEnd_x
4547
    '                            dEnd_y = dOriginalEnd_y
4548
    '                        End If
4549
    '                        sDirection = "Y"
4550
    '                    End If
4551
    '                End If
4552
    '                '            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4553
    '            Else
4554
    '                If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then
4555
    '                    LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4556
    '                     sLineNoUid, sLineUid, sSystemPath)
4557
    '                End If
4558
4559
4560
    '                sReturnUid = sConnLineUid
4561
    '                Exit While
4562
    '            End If
4563
    '        End While
4564
4565
    '        If sStartLineUid <> "" And sEndLineUid <> "" Then
4566
    '            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4567
    '                         sLineNoUid, sLineUid, sSystemPath)
4568
    '            dStart_x = 0
4569
    '            dStart_y = 0
4570
    '            dEnd_x = 0
4571
    '            dEnd_y = 0
4572
    '        End If
4573
    '    Catch ex As Exception
4574
4575
    '    End Try
4576
4577
    '    Return sReturnUid
4578
    'End Function
4579
4580
4581
    Private Function SymbolToLine_Modeling(ByVal oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String,
4582
                                       ByVal sSymbolUid As String, ByVal oLMSymbol As LMSymbol) As String
4583
4584
4585
        Dim oDatasource As Object = _Placement.PIDDataSource
4586
        Dim oPipeRun As LMPipeRun = Nothing
4587
        Dim objItem As LMAItem
4588
        Dim objConnector As LMConnector
4589
        Dim objInputs As PlaceRunInputs
4590
        objInputs = New PlaceRunInputs
4591
4592
4593
        Dim sPipeUid As String = ""
4594
        Dim iConnType As Integer = 0
4595
        Dim sStartpoint As String = ""
4596
        Dim sEndpoint As String = ""
4597
        Dim dOriginalStart_x As Double = 0.0
4598
        Dim dOriginalStart_y As Double = 0.0
4599
        Dim dOriginalEnd_x As Double = 0.0
4600
        Dim dOriginalEnd_y As Double = 0.0
4601
        Dim dStart_x As Double = 0.0
4602
        Dim dStart_y As Double = 0.0
4603
        Dim dEnd_x As Double = 0.0
4604
        Dim dEnd_y As Double = 0.0
4605
4606
        Dim sReturnUid As String = ""
4607
        Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sSymbolUid + "' And " &
4608
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4609
                                                                                  _XML_SYMBOL_Check & "] = 'TRUE'")
4610
        If oPipeRow.Length = 0 Then
4611
            oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sSymbolUid + "' And " &
4612
                                     "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4613
                                    _XML_SYMBOL_Check & "] = 'TRUE'")
4614
        Else
4615
            sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4616
            iConnType = 1
4617
        End If
4618
4619
        If oPipeRow.Length = 1 Then
4620
            If sPipeUid = "" Then
4621
                sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4622
                iConnType = 2
4623
            End If
4624
            sReturnUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4625
            sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4626
            sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4627
            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4628
            dStart_x = dOriginalStart_x
4629
            dStart_y = dOriginalStart_y
4630
            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4631
            dEnd_x = dOriginalEnd_x
4632
            dEnd_y = dOriginalEnd_y
4633
            ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4634
            ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4635
            'OPC Connection Point가져와서 연결(2018-07-12)
4636
            If iConnType = 1 Then
4637
                FindNearPoint(oLMSymbol, dStart_x, dStart_y)
4638
                objInputs.AddSymbolTarget(oLMSymbol, dStart_x, dStart_y)
4639
                objInputs.AddPoint(dEnd_x, dEnd_y)
4640
            Else
4641
                FindNearPoint(oLMSymbol, dEnd_x, dEnd_y)
4642
                objInputs.AddSymbolTarget(oLMSymbol, dEnd_x, dEnd_y)
4643
                objInputs.AddPoint(dStart_x, dStart_y)
4644
            End If
4645
            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4646
4647
            Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4648
            Dim sSystemPath As String = GetPipeType(sType)
4649
4650
4651
4652
4653
            objItem = _Placement.PIDCreateItem(sSystemPath)
4654
            objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4655
            oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
4656
            Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4657
            If oAttributeRow.Length > 0 Then
4658
                For Each oAttribute In oAttributeRow
4659
                    Try
4660
                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4661
                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4662
                        If sPIDValue.Contains("'") Then
4663
                            sPIDValue = sPIDValue.Replace("'", """")
4664
                        End If
4665
                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4666
                        oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4667
                    Catch ex As Exception
4668
                    End Try
4669
                Next
4670
                oPipeRun.Commit()
4671
            End If
4672
        End If
4673
        Return sReturnUid
4674
    End Function
4675
4676
    Private Function LineToSymbol_Modeling(ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String,
4677
                                       ByVal sLineUid As String, ByVal oLMConnector As LMConnector, ByRef oLMSymbol As LMSymbol) As String
4678
4679
4680
        Dim oDatasource As Object = _Placement.PIDDataSource
4681
        Dim objItem As LMAItem
4682
        Dim objConnector As LMConnector
4683
        Dim objInputs As PlaceRunInputs
4684
        objInputs = New PlaceRunInputs
4685
4686
4687
        Dim sSymbolUid As String = ""
4688
        Dim iConnType As Integer = 0
4689
        Dim dOriginalPoint_x As Double = 0.0
4690
        Dim dORiginalPoint_y As Double = 0.0
4691
        Dim dX As Double = 0.0
4692
        Dim dY As Double = 0.0
4693
        Dim sReturnUid As String = ""
4694
        Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn1_Uid & " = '" + sLineUid + "' And " &
4695
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4696
                                                                                  _XML_SYMBOL_Check & "] = 'TRUE'")
4697
        If oSymbolRow.Length = 0 Then
4698
            oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
4699
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4700
                                                                                 _XML_SYMBOL_Check & "] = 'TRUE'")
4701
            If oSymbolRow.Length = 0 Then
4702
                oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
4703
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4704
                                                                          _XML_SYMBOL_Check & "] = 'TRUE'")
4705
                If oSymbolRow.Length = 0 Then
4706
                    oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
4707
                                                   "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4708
                                                            _XML_SYMBOL_Check & "] = 'TRUE'")
4709
                    If oSymbolRow.Length = 0 Then
4710
4711
                    Else
4712
                        sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4713
                        iConnType = 4
4714
                    End If
4715
                Else
4716
                    sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4717
                    iConnType = 3
4718
                End If
4719
            Else
4720
                sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4721
                iConnType = 2
4722
            End If
4723
4724
        Else
4725
            sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4726
            iConnType = 1
4727
        End If
4728
4729
        If oSymbolRow.Length = 1 Then
4730
            If sSymbolUid = "" Then
4731
                sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4732
                iConnType = 2
4733
            End If
4734
            sReturnUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4735
            Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
4736
            ConvertPointBystring(sOriginalPoint, dOriginalPoint_x, dORiginalPoint_y)
4737
            dX = dOriginalPoint_x
4738
            dY = dORiginalPoint_y
4739
            ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
4740
            'OPC Connection Point가져와서 연결(2018-07-12)
4741
4742
            oSymbolRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4743
4744
            Dim sType As String = oSymbolRow(0)(_XML_LINE_TYPE).ToString()
4745
            Dim sSystemPath As String = GetPipeType(sType)
4746
4747
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, ExistingItem:=oLMConnector.AsLMAItem,
4748
          TargetItem:=oLMSymbol.AsLMAItem)
4749
4750
            Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4751
            If oAttributeRow.Length > 0 Then
4752
                For Each oAttribute In oAttributeRow
4753
                    Try
4754
                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4755
                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4756
                        If sPIDValue.Contains("'") Then
4757
                            sPIDValue = sPIDValue.Replace("'", """")
4758
                        End If
4759
                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4760
                        oLMSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
4761
                    Catch ex As Exception
4762
                    End Try
4763
                Next
4764
            End If
4765
        End If
4766
        Return sReturnUid
4767
    End Function
4768
4769
4770
    Private Sub OPCTOLineRouting(ByRef oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oOPCSymbol As LMSymbol,
4771
                            ByVal sOPCUid As String, ByVal sLineNoUid As String)
4772
        Try
4773
            Dim oDatasource As Object = _Placement.PIDDataSource
4774
            Dim objItem As LMAItem
4775
            Dim objConnector As LMConnector
4776
            Dim objInputs As PlaceRunInputs
4777
            objInputs = New PlaceRunInputs
4778
            Dim dOriginalStart_x As Double = 0.0
4779
            Dim dOriginalStart_y As Double = 0.0
4780
            Dim dOriginalEnd_x As Double = 0.0
4781
            Dim dOriginalEnd_y As Double = 0.0
4782
            Dim dStart_x As Double = 0.0
4783
            Dim dStart_y As Double = 0.0
4784
            Dim dEnd_x As Double = 0.0
4785
            Dim dEnd_y As Double = 0.0
4786
4787
            Dim oPipeRun As LMPipeRun = Nothing
4788
            Dim sStartpoint As String = ""
4789
            Dim sEndpoint As String = ""
4790
            Dim iConnType As Integer = 0
4791
            Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sOPCUid + "' And [" &
4792
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
4793
            Dim sPipeUid As String = ""
4794
            If oPipeRow.Length = 0 Then
4795
                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sOPCUid + "' And [" &
4796
                        _XML_SYMBOL_Check & "] = 'TRUE'")
4797
            Else
4798
                sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4799
                iConnType = 1
4800
            End If
4801
            Dim oAddUid_List As New List(Of String)
4802
            If oPipeRow.Length = 1 Then
4803
                If sPipeUid = "" Then
4804
                    sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4805
                    iConnType = 2
4806
                End If
4807
                oAddUid_List.Add(sPipeUid)
4808
                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4809
                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4810
                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4811
                dStart_x = dOriginalStart_x
4812
                dStart_y = dOriginalStart_y
4813
                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4814
                dEnd_x = dOriginalEnd_x
4815
                dEnd_y = dOriginalEnd_y
4816
                ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4817
                ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4818
4819
                'OPC Connection Point가져와서 연결(2018-07-12)
4820
                If iConnType = 1 Then
4821
                    FindNearPoint(oOPCSymbol, dStart_x, dStart_y)
4822
                    objInputs.AddSymbolTarget(oOPCSymbol, dStart_x, dStart_y)
4823
                    objInputs.AddPoint(dEnd_x, dEnd_y)
4824
                Else
4825
                    FindNearPoint(oOPCSymbol, dEnd_x, dEnd_y)
4826
                    objInputs.AddSymbolTarget(oOPCSymbol, dEnd_x, dEnd_y)
4827 bb2a0c79 Gyusu
                    objInputs.AddPoint(dStart_x, dStart_y)
4828
                End If
4829
                oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4830
4831
                While True
4832
                    '    objInputs.Clear()
4833
                    Dim oAddPipeRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" + sPipeUid + "' and " &
4834
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4835
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
4836
                    If oAddPipeRow.Length = 0 Then
4837
                        oAddPipeRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" + sPipeUid + "' and " &
4838
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4839
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
4840
                        sPipeUid = ""
4841
                    Else
4842
                        iConnType = 1
4843
                        sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4844
                    End If
4845
                    If oAddPipeRow.Length = 1 Then
4846
                        If sPipeUid = "" Then
4847
                            sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4848
                            iConnType = 2
4849
                        End If
4850
                        oAddUid_List.Add(sPipeUid)
4851
                        sStartpoint = oAddPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4852
                        sEndpoint = oAddPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4853
                        ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4854
                        dStart_x = dOriginalStart_x
4855
                        dStart_y = dOriginalStart_y
4856
                        ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4857
                        dEnd_x = dOriginalEnd_x
4858
                        dEnd_y = dOriginalEnd_y
4859
                        ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4860
                        ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4861
                        If iConnType = 1 Then
4862
                            objInputs.AddPoint(dEnd_x, dEnd_y)
4863
                            ' objInputs.AddPoint(dStart_x, dStart_y)
4864
                        Else
4865
                            'objInputs.AddConnectorTarget(objConnector, dStart_x, dStart_y)
4866
                            '  objInputs.AddPoint(dStart_x, dStart_y)
4867
                            '  objInputs.AddPoint(dEnd_x, dEnd_y)
4868
                            objInputs.AddPoint(dStart_x, dStart_y)
4869
                        End If
4870 e4000111 Gyusu
4871 bb2a0c79 Gyusu
                        oAddPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4872
                    Else
4873
                        Exit While
4874
                    End If
4875 e4000111 Gyusu
4876 bb2a0c79 Gyusu
                End While
4877
                Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4878
                Dim sSystemPath As String = GetPipeType(sType)
4879 e4000111 Gyusu
4880 bb2a0c79 Gyusu
                objItem = _Placement.PIDCreateItem(sSystemPath)
4881
                objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4882
                For i = 0 To oAddUid_List.Count - 1
4883
                    Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + oAddUid_List(i) + "'")
4884
                    If oUpdateRow.Length = 1 Then
4885
                        oUpdateRow(0)(_XML_LINE_SPID) = objConnector.ModelItemID
4886
                        oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = objConnector
4887
                    End If
4888
                Next
4889
4890
4891
                oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
4892
                Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4893
                If oAttributeRow.Length > 0 Then
4894
                    For Each oAttribute In oAttributeRow
4895
                        Try
4896
                            Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4897
                            Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4898
                            If sPIDValue.Contains("'") Then
4899
                                sPIDValue = sPIDValue.Replace("'", """")
4900
                            End If
4901
                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4902
                            oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4903
                        Catch ex As Exception
4904
                        End Try
4905
                    Next
4906
                    oPipeRun.Commit()
4907
                End If
4908
4909
            End If
4910
4911
        Catch ex As Exception
4912
        End Try
4913
    End Sub
4914
4915
    Private Function AddUidList중복체크(ByVal sUidList As List(Of String), ByVal sAddUid As String) As Boolean
4916 e4000111 Gyusu
4917 bb2a0c79 Gyusu
        For Each sUid In sUidList
4918
            If sUid = sAddUid Then
4919
                Return False
4920
            End If
4921
        Next
4922
        Return True
4923
    End Function
4924
4925 b08338e3 Gyusu
    Private Sub LineRouting(ByRef oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String, ByVal sLineNoText As String)
4926 bb2a0c79 Gyusu
        Try
4927
            Dim oDatasource As Object = _Placement.PIDDataSource
4928
            Dim objItem As LMAItem
4929
            Dim objConnector As LMConnector
4930
            Dim objInputs As PlaceRunInputs
4931
            objInputs = New PlaceRunInputs
4932
            Dim dOriginalStart_x As Double = 0.0
4933
            Dim dOriginalStart_y As Double = 0.0
4934
            Dim dOriginalEnd_x As Double = 0.0
4935
            Dim dOriginalEnd_y As Double = 0.0
4936
            Dim dStart_x As Double = 0.0
4937
            Dim dStart_y As Double = 0.0
4938
            Dim dEnd_x As Double = 0.0
4939
            Dim dEnd_y As Double = 0.0
4940
            Dim oPipeRun As LMPipeRun = Nothing
4941
            Dim sStartpoint As String = ""
4942
            Dim sEndpoint As String = ""
4943
            Dim iConnType As Integer = 0
4944
            Dim pLMConnector As LMConnector = Nothing
4945
            For Each oLinerow In oLine_Dt.Rows
4946
                objInputs.Clear()
4947 b08338e3 Gyusu
                Dim sCheck As String = oLinerow(_XML_LINE_DRAWING_TF).ToString()
4948
                If sCheck = "FALSE" Then
4949
                    Dim sUid As String = oLinerow(_XML_LINE_UID).ToString()
4950
                    sStartpoint = oLinerow(_XML_LINE_STARTPOINT).ToString()
4951
                    sEndpoint = oLinerow(_XML_LINE_ENDPOINT).ToString()
4952
                    ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4953
                    dStart_x = dOriginalStart_x
4954
                    dStart_y = dOriginalStart_y
4955
                    ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4956
                    dEnd_x = dOriginalEnd_x
4957
                    dEnd_y = dOriginalEnd_y
4958
                    ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4959
                    ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4960 bb2a0c79 Gyusu
4961 b08338e3 Gyusu
                    objInputs.AddPoint(dStart_x, dStart_y)
4962
                    objInputs.AddPoint(dEnd_x, dEnd_y)
4963 bb2a0c79 Gyusu
                    Dim sType As String = oLinerow(_XML_LINE_TYPE).ToString()
4964
                    Dim sSystemPath As String = GetPipeType(sType)
4965
                    objItem = _Placement.PIDCreateItem(sSystemPath)
4966
                    objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4967 b08338e3 Gyusu
                    SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dOriginalStart_x & "," & dOriginalStart_y & ") - (" & dOriginalEnd_x & "," & dOriginalEnd_y & ")..." & _iPipecnt & " count ")
4968
4969
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
4970
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
4971
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oLinerow(_XML_SYMBOL_Conn1_Uid).ToString())
4972
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oLinerow(_XML_SYMBOL_Conn2_Uid).ToString())
4973
                    'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
4974
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dOriginalStart_x & "," & dOriginalStart_y)
4975
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dOriginalEnd_x & "," & dOriginalEnd_y)
4976
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
4977
4978
                    _iPipecnt = _iPipecnt + 1
4979
                    oLinerow(_XML_LINE_SPID) = objConnector.ModelItemID
4980
                    oLinerow(_XML_LINE_LMCONNECTOR) = objConnector
4981
4982
                    oLinerow(_XML_LINE_DRAWING_TF) = "TRUE"
4983 bb2a0c79 Gyusu
                    oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
4984
4985
                    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4986
                    If oAttributeRow.Length > 0 Then
4987
                        For Each oAttribute In oAttributeRow
4988
                            Try
4989
                                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4990
                                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4991
                                If sPIDValue.Contains("'") Then
4992
                                    sPIDValue = sPIDValue.Replace("'", """")
4993
                                End If
4994
                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4995
                                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4996
                            Catch ex As Exception
4997
                            End Try
4998
                        Next
4999
                        oPipeRun.Commit()
5000
                    End If
5001
                End If
5002
5003
5004
5005
5006
5007 b08338e3 Gyusu
                'Dim sPipeUid As String = oLinerow(_XML_LINE_UID).ToString()
5008
                'Dim sCheckModeling As Boolean = False
5009
                'objInputs.Clear()
5010
                'Dim oAddUid_List As New List(Of String)
5011
                'Try
5012
                '    Dim oAddPipeRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" + sPipeUid + "' and " &
5013
                '                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
5014
                '                                            _XML_SYMBOL_Check & "] = 'TRUE'")
5015
                '    If oAddPipeRow.Length = 0 Then
5016
                '        oAddPipeRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" + sPipeUid + "' and " &
5017
                '                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
5018
                '                                        _XML_SYMBOL_Check & "] = 'TRUE'")
5019
                '        sPipeUid = ""
5020
                '    Else
5021
                '        iConnType = 1
5022
                '        sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
5023
                '    End If
5024
                '    If oAddPipeRow.Length = 1 Then
5025
                '        sCheckModeling = True
5026
                '        If sPipeUid = "" Then
5027
                '            sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
5028
                '            iConnType = 2
5029
                '        End If
5030
                '        If AddUidList중복체크(oAddUid_List, sPipeUid) Then
5031
                '            oAddUid_List.Add(sPipeUid)
5032
                '        End If
5033
                '        sStartpoint = oAddPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
5034
                '        sEndpoint = oAddPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
5035
                '        ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
5036
                '        dStart_x = dOriginalStart_x
5037
                '        dStart_y = dOriginalStart_y
5038
                '        ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
5039
                '        dEnd_x = dOriginalEnd_x
5040
                '        dEnd_y = dOriginalEnd_y
5041
                '        ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
5042
                '        ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
5043
                '        Dim sBranchType As String = ""
5044
                '        If (CheckBranchLine(oLine_Dt, dStart_x, dStart_y, dEnd_x, dEnd_y, sBranchType, pLMConnector)) Then
5045
                '            Try
5046
                '                If pLMConnector Is Nothing Then
5047
                '                    objInputs.AddPoint(dStart_x, dStart_y)
5048
                '                    objInputs.AddPoint(dEnd_x, dEnd_y)
5049
                '                Else
5050
                '                    If sBranchType = "1" Then
5051
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
5052
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
5053
                '                    ElseIf sBranchType = "2" Then
5054
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
5055
                '                        objInputs.AddPoint(dStart_x, dStart_y)
5056
                '                    ElseIf sBranchType = "3" Then
5057
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
5058
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
5059
                '                    ElseIf sBranchType = "4" Then
5060
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
5061
                '                        objInputs.AddPoint(dStart_x, dStart_y)
5062
                '                    End If
5063
                '                End If
5064
                '            Catch ex As Exception
5065
                '            End Try
5066
                '        Else
5067
                '            objInputs.AddPoint(dStart_x, dStart_y)
5068
                '            objInputs.AddPoint(dEnd_x, dEnd_y)
5069
                '        End If
5070
                '        oAddPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
5071
                '    Else
5072
                '        Dim CheckTF As String = oLinerow(_XML_LINE_DRAWING_TF).ToString()
5073
                '        Dim CheckSelect As String = oLinerow(_XML_LINE_Check).ToString()
5074
                '        If CheckTF = "FALSE" And CheckSelect = "TRUE" Then
5075
                '            sPipeUid = oLinerow(_XML_LINE_UID).ToString()
5076
                '            oAddUid_List.Clear()
5077
                '            oAddUid_List.Add(sPipeUid)
5078
                '            sCheckModeling = True
5079
                '            sStartpoint = oLinerow(_XML_LINE_STARTPOINT).ToString()
5080
                '            sEndpoint = oLinerow(_XML_LINE_ENDPOINT).ToString()
5081
                '            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
5082
                '            dStart_x = dOriginalStart_x
5083
                '            dStart_y = dOriginalStart_y
5084
                '            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
5085
                '            dEnd_x = dOriginalEnd_x
5086
                '            dEnd_y = dOriginalEnd_y
5087
                '            ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
5088
                '            ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
5089
                '            Dim sBranchType As String = ""
5090
                '            If (CheckBranchLine(oLine_Dt, dStart_x, dStart_y, dEnd_x, dEnd_y, sBranchType, pLMConnector)) Then
5091
                '                Try
5092
                '                    If sBranchType = "1" Then
5093
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
5094
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
5095
                '                    ElseIf sBranchType = "2" Then
5096
                '                        objInputs.AddPoint(dStart_x, dStart_y)
5097
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
5098
                '                    ElseIf sBranchType = "3" Then
5099
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
5100
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
5101
                '                    ElseIf sBranchType = "4" Then
5102
                '                        objInputs.AddPoint(dStart_x, dStart_y)
5103
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
5104
                '                    End If
5105
                '                Catch ex As Exception
5106
5107
                '                End Try
5108
                '            Else
5109
                '                objInputs.AddPoint(dStart_x, dStart_y)
5110
                '                objInputs.AddPoint(dEnd_x, dEnd_y)
5111
                '            End If
5112
                '            oLinerow(_XML_LINE_DRAWING_TF) = "TRUE"
5113
                '        End If
5114
                '    End If
5115
                'Catch ex As Exception
5116
                'End Try
5117
                'If sCheckModeling Then
5118
                '    Dim sType As String = oLinerow(_XML_LINE_TYPE).ToString()
5119
                '    Dim sSystemPath As String = GetPipeType(sType)
5120
                '    objItem = _Placement.PIDCreateItem(sSystemPath)
5121
                '    objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
5122
                '    For i = 0 To oAddUid_List.Count - 1
5123
                '        Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + oAddUid_List(i) + "'")
5124
                '        If oUpdateRow.Length = 1 Then
5125
                '            oUpdateRow(0)(_XML_LINE_SPID) = objConnector.ModelItemID
5126
                '            oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = objConnector
5127
                '        End If
5128
                '    Next
5129
5130
                '    oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
5131
                '    oAddUid_List.Clear()
5132
5133
                '    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
5134
                '    If oAttributeRow.Length > 0 Then
5135
                '        For Each oAttribute In oAttributeRow
5136
                '            Try
5137
                '                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5138
                '                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5139
                '                If sPIDValue.Contains("'") Then
5140
                '                    sPIDValue = sPIDValue.Replace("'", """")
5141
                '                End If
5142
                '                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5143
                '                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
5144
                '            Catch ex As Exception
5145
                '            End Try
5146
                '        Next
5147
                '        oPipeRun.Commit()
5148
                '    End If
5149
5150
                '    If pLMConnector IsNot Nothing Then
5151
                '        Dim sID_1 As String = pLMConnector.ModelItemID
5152
                '        Dim sID_2 As String = objConnector.ModelItemID
5153
                '        Dim objSurvivorItem As LMAItem = Nothing
5154
                '        Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(sID_1)
5155
                '        Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(sID_2)
5156
                '        _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
5157
                '        '     oDatasource.CommitTransaction()
5158
                '        '_Placement.PIDAutoJoin(oPipeRun1.AsLMAItem, AutoJoinEndConstants.autoJoin_End, objSurvivorItem)
5159
                '        'oPipeRun1.Commit()
5160
                '        'oDatasource.CommitTransaction()
5161
                '        'objSurvivorItem = Nothing
5162
                '        '_Placement.PIDAutoJoin(oPipeRun2.AsLMAItem, AutoJoinEndConstants.autoJoin_Start, objSurvivorItem)
5163
                '        'oPipeRun2.Commit()
5164
                '        'oDatasource.CommitTransaction()
5165
                '    End If
5166
                '    sCheckModeling = False
5167
                '  End If
5168
            Next
5169 bb2a0c79 Gyusu
        Catch ex As Exception
5170
        End Try
5171
    End Sub
5172 e4000111 Gyusu
5173 b08338e3 Gyusu
5174
    Private Sub SymbolModeling(ByVal CDrawing As Drawing, ByVal oLine_DT As DataTable, ByVal oSymbolRow As DataRow, ByVal oAttribute_Dt As DataTable,
5175
                               ByVal sLineNoText As String)
5176 bb2a0c79 Gyusu
        Try
5177 b08338e3 Gyusu
5178
            Dim sCheckModeling As String = oSymbolRow(_XML_SYMBOL_DRAWING_TF).ToString()
5179
            If sCheckModeling = "FALSE" Then
5180
                Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5181
                Dim oSymbol As LMSymbol = Nothing
5182
                Dim sSPID As String = oSymbolRow(_XML_SYMBOL_SPID).ToString()
5183
                Dim sSystemPath As String = oSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
5184 bb2a0c79 Gyusu
                Dim oDatasource As Object = _Placement.PIDDataSource
5185
                Dim sSymbolCompType As String = oSymbolRow(_XML_SYMBOL_TYPE).ToString()
5186
                Dim dLocationX As Double = 0.0
5187
                Dim dLocationY As Double = 0.0
5188
                Dim dX As Double = 0.0
5189
                Dim dY As Double = 0.0
5190 b08338e3 Gyusu
                Dim sOriginalPoint As String = oSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
5191
                ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5192
                dX = dLocationX
5193
                dY = dLocationY
5194
                ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
5195
5196
                Dim dAngle As Double = oSymbolRow(_XML_SYMBOL_ANGLE)
5197
5198
5199
                'Dim oDatarow() As DataRow = oLine_DT.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sSymbolUid & "'")
5200
                'If oDatarow.Length = 0 Then
5201
                '    oDatarow = oLine_DT.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sSymbolUid & "'")
5202
                'End If
5203
                'Dim dFix_X As Double = 0.0
5204
                'Dim dFix_Y As Double = 0.0
5205
                'If oDatarow.Length > 0 Then
5206
                '    If dAngle <> 0 Then
5207
                '        sOriginalPoint = oDatarow(0)(_XML_LINE_STARTPOINT).ToString()
5208
                '        ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5209
5210
                '        ConvertPointByImage(dLocationX, dLocationY, _IMG_X, _IMG_Y)
5211
                '        dX = dLocationX
5212
                '    Else
5213
                '        sOriginalPoint = oDatarow(0)(_XML_LINE_STARTPOINT).ToString()
5214
                '        ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5215
                '        ConvertPointByImage(dLocationX, dLocationY, _IMG_X, _IMG_Y)
5216
                '        dY = dLocationY
5217
                '    End If
5218
5219
                'End If
5220
5221
5222
5223
                oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY,, dAngle)
5224
                SetListBoxItems(ListBox_Result, "Place Fitting.." & sSymbolUid & " (" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
5225
5226
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Fitting : " & sSymbolUid)
5227
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
5228
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString())
5229
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString())
5230
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection3 : " & oSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString())
5231
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection4 : " & oSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString())
5232
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
5233
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
5234
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Fitting Count : " & _iFittingcnt)
5235
5236
5237
                _iFittingcnt = _iFittingcnt + 1
5238
                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
5239
                Dim oAttributeRow() As DataRow
5240
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sSymbolUid + "'")
5241
                If oAttribute_Dt.Rows.Count > 0 Then
5242
5243 bb2a0c79 Gyusu
                    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
5244 b08338e3 Gyusu
                        Dim oInstrument As LMInstrument
5245
                        oInstrument = oDatasource.GetInstrument(oSymbol.ModelItemID)
5246 bb2a0c79 Gyusu
                        Try
5247
                            If oAttributeRow.Length > 0 Then
5248
                                For Each oAttribute In oAttributeRow
5249
                                    Try
5250
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5251
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5252
                                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5253
                                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
5254
                                    Catch ex As Exception
5255
                                    End Try
5256
                                Next
5257
                                oInstrument.Commit()
5258
                            End If
5259
                        Catch ex As Exception
5260
                        End Try
5261
                    Else
5262 b08338e3 Gyusu
                        Try
5263
                            If oAttributeRow.Length > 0 And oSymbol IsNot Nothing Then
5264
                                For Each oAttribute In oAttributeRow
5265
                                    Try
5266
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5267
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5268 e4000111 Gyusu
5269 b08338e3 Gyusu
                                        If sPIDAttribute = "SIZE" Then
5270
5271
                                            'Nominal diamter1,2속성이름뭔지 찾아봐야됨 (2018-07-20)
5272
                                            If sPIDValue.Contains("x") Then
5273
                                                Dim sSplitSize() As String = sPIDValue.Split("x")
5274
                                                If sSplitSize.Count > 1 Then
5275
                                                    'Connection Point와 연결되어 있는 라인을 가져와서 라인프로퍼티를 변경
5276
                                                    Dim oConnector_1 As LMConnector = Nothing
5277
                                                    Dim oConnector_2 As LMConnector = Nothing
5278
                                                    If oSymbol IsNot Nothing Then
5279
                                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5280
                                                            For Each Tconnector In oSymbol.Connect1Connectors
5281
                                                                If Tconnector.ItemStatus = "Active" Then
5282
                                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5283
                                                                        oConnector_1 = Tconnector
5284
                                                                    End If
5285
                                                                End If
5286
                                                            Next
5287
                                                        End If
5288
                                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5289
                                                            For Each Tconnector In oSymbol.Connect1Connectors
5290
                                                                If Tconnector.ItemStatus = "Active" Then
5291
                                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5292
                                                                        oConnector_2 = Tconnector
5293
                                                                    End If
5294
                                                                End If
5295
                                                            Next
5296
                                                        End If
5297
                                                    End If
5298
                                                    Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(oConnector_1.ModelItemID)
5299
                                                    Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(oConnector_2.ModelItemID)
5300
                                                    If dAngle = 3.14 Then
5301
                                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(1)
5302
                                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(0)
5303
                                                    Else
5304
                                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(0)
5305
                                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(1)
5306
                                                    End If
5307 e4000111 Gyusu
5308
5309 b08338e3 Gyusu
                                                End If
5310 e4000111 Gyusu
5311 b08338e3 Gyusu
                                            Else
5312
                                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5313
                                                oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5314
                                            End If
5315
                                        Else
5316
                                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5317
                                            oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5318
                                        End If
5319 e4000111 Gyusu
5320 b08338e3 Gyusu
                                    Catch ex As Exception
5321
                                    End Try
5322
                                Next
5323
                                oSymbol.Commit()
5324
                            End If
5325
                        Catch ex As Exception
5326
                        End Try
5327
                    End If
5328
                End If
5329 e4000111 Gyusu
5330
5331
5332 b08338e3 Gyusu
            End If
5333 e4000111 Gyusu
5334
5335
5336 b08338e3 Gyusu
            'Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
5337
            'Dim sConnTypeNo As String = ""
5338
            '' Line과 연결되어있는 Symbol인지 확인
5339
            'Dim oLine_Dt As DataTable = GetPipeFromConnection(CDrawing, sSymbolUid, sConnTypeNo)
5340
            ''Symbol과 연결되어 있는 Symbol인지 확인
5341
            'Dim oSymbol_Dt As DataTable = GetSymbolFromConnection(CDrawing, sSymbolUid, sConnTypeNo)
5342
            'Dim oSymbol As LMSymbol = Nothing
5343
            'Dim sSPID As String = oSymbolRow(_XML_SYMBOL_SPID).ToString()
5344
            'Dim sSystemPath As String = oSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
5345
            'Dim oDatasource As Object = _Placement.PIDDataSource
5346
            'Dim sSymbolCompType As String = oSymbolRow(_XML_SYMBOL_TYPE).ToString()
5347 e4000111 Gyusu
5348 b08338e3 Gyusu
            'Dim dAngle As Double = 0.0
5349
            'If IsNumeric(oSymbolRow(_XML_SYMBOL_ANGLE).ToString()) Then
5350
            '    dAngle = Double.Parse(oSymbolRow(_XML_SYMBOL_ANGLE).ToString())
5351
            'End If
5352 e4000111 Gyusu
5353 b08338e3 Gyusu
            'Dim dLocationX As Double = 0.0
5354
            'Dim dLocationY As Double = 0.0
5355
            'Dim dX As Double = 0.0
5356
            'Dim dY As Double = 0.0
5357
            'Dim sOriginalPoint As String = oSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
5358
            'ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5359
            'dX = dLocationX
5360
            'dY = dLocationY
5361
            'ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
5362
            'Dim bCheckModeling As Boolean = False
5363
5364
            'If oLine_Dt.Rows.Count > 0 Then
5365
5366
            '    If sSPID <> "" Then
5367
            '        Dim dX1 As Double = 0
5368
            '        Dim dX2 As Double = 0
5369
            '        Dim dY1 As Double = 0
5370
            '        Dim dY2 As Double = 0
5371
            '        Dim oLMSymbol As LMSymbol = oDatasource.GetSymbol(sSPID)
5372
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
5373
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
5374
5375
            '        Dim dCalcPoint As Double = -1
5376
            '        Dim dModeling_X As Double = 0
5377
            '        Dim dModeling_Y As Double = 0
5378
            '        If dX1 <> 0 And dY1 <> 0 Then
5379
            '            dCalcPoint = Math.Abs(dX1 - dX) + Math.Abs(dY1 - dY)
5380
            '            dModeling_X = dX1
5381
            '            dModeling_Y = dY1
5382
            '        End If
5383
            '        If dX2 <> 0 And dY2 <> 0 Then
5384 e4000111 Gyusu
5385 b08338e3 Gyusu
            '            If (Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY) > dCalcPoint) Then
5386
            '                dCalcPoint = Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY)
5387
            '                dModeling_X = dX2
5388
            '                dModeling_Y = dY2
5389
            '            End If
5390
            '        End If
5391 e4000111 Gyusu
5392
5393
5394 b08338e3 Gyusu
            '        If dModeling_X <> 0 And dModeling_Y <> 0 Then
5395
            '            oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dModeling_X, dModeling_Y,, dAngle, ExistingItem:=oLMSymbol.AsLMAItem,
5396
            '                TargetItem:=oLMSymbol.AsLMRepresentation)
5397
            '            bCheckModeling = True
5398
            '        End If
5399 e4000111 Gyusu
5400
5401 b08338e3 Gyusu
            '    End If
5402
            'End If
5403
            'If oSymbol_Dt.Rows.Count > 0 Then
5404
            '    If sSPID <> "" Then
5405
            '        Dim dX1 As Double = 0
5406
            '        Dim dX2 As Double = 0
5407
            '        Dim dX3 As Double = 0
5408
            '        Dim dX4 As Double = 0
5409
            '        Dim dY1 As Double = 0
5410
            '        Dim dY2 As Double = 0
5411
            '        Dim dY3 As Double = 0
5412
            '        Dim dY4 As Double = 0
5413
            '        Dim oLMSymbol As LMSymbol = oDatasource.GetSymbol(sSPID)
5414
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
5415
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
5416
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 3, dX3, dY3)
5417
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 4, dX4, dY4)
5418
5419
            '        Dim dCalcPoint As Double = -1
5420
            '        Dim dModeling_X As Double = 0
5421
            '        Dim dModeling_Y As Double = 0
5422
            '        If dX1 <> 0 And dY1 <> 0 Then
5423
            '            dCalcPoint = Math.Abs(dX1 - dX) + Math.Abs(dY1 - dY)
5424
            '            dModeling_X = dX1
5425
            '            dModeling_Y = dY1
5426
            '        End If
5427
            '        If dX2 <> 0 And dY2 <> 0 Then
5428 41e4023e Gyusu
5429 b08338e3 Gyusu
            '            If (Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY) > dCalcPoint) Then
5430
            '                dCalcPoint = Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY)
5431
            '                dModeling_X = dX2
5432
            '                dModeling_Y = dY2
5433
            '            End If
5434
            '        End If
5435
            '        If dX3 <> 0 And dY3 <> 0 Then
5436
            '            If (Math.Abs(dX3 - dX) + Math.Abs(dY3 - dY) > dCalcPoint) Then
5437
            '                dCalcPoint = Math.Abs(dX3 - dX) + Math.Abs(dY3 - dY)
5438
            '                dModeling_X = dX3
5439
            '                dModeling_Y = dY3
5440
            '            End If
5441
            '        End If
5442
            '        If dX4 <> 0 And dY4 <> 0 Then
5443
            '            If (Math.Abs(dX4 - dX) + Math.Abs(dY4 - dY) > dCalcPoint) Then
5444
            '                dCalcPoint = Math.Abs(dX4 - dX) + Math.Abs(dY4 - dY)
5445
            '                dModeling_X = dX4
5446
            '                dModeling_Y = dY4
5447
            '            End If
5448
            '        End If
5449
            '        If dModeling_X <> 0 And dModeling_Y <> 0 Then
5450
            '            oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dModeling_X, dModeling_Y,, dAngle, ExistingItem:=oLMSymbol.AsLMAItem,
5451
            '                TargetItem:=oLMSymbol.AsLMRepresentation)
5452
            '            bCheckModeling = True
5453
            '        End If
5454 41e4023e Gyusu
5455 e4000111 Gyusu
5456 b08338e3 Gyusu
            '    End If
5457 e4000111 Gyusu
5458 b08338e3 Gyusu
            'End If
5459 e4000111 Gyusu
5460 b08338e3 Gyusu
            'If (oLine_Dt.Rows.Count = 0 And oSymbol_Dt.Rows.Count = 0) Or bCheckModeling = False Then
5461
            '    oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
5462
            '    SetListBoxItems(ListBox_Result, "Place Fittings..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
5463
            '    _iFittingcnt = _iFittingcnt + 1
5464
            'End If
5465
            'Dim oAttributeRow() As DataRow
5466
            'oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sSymbolUid + "'")
5467
            'If oAttribute_Dt.Rows.Count > 0 Then
5468
5469
            '    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
5470
            '        Dim oInstrument As LMInstrument
5471
            '        oInstrument = oDatasource.GetInstrument(oSymbol.ModelItemID)
5472
            '        Try
5473
            '            If oAttributeRow.Length > 0 Then
5474
            '                For Each oAttribute In oAttributeRow
5475
            '                    Try
5476
            '                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5477
            '                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5478
            '                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5479
            '                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
5480
            '                    Catch ex As Exception
5481
            '                    End Try
5482
            '                Next
5483
            '                oInstrument.Commit()
5484
            '            End If
5485
            '        Catch ex As Exception
5486
            '        End Try
5487
            '    Else
5488
            '        Try
5489
            '            If oAttributeRow.Length > 0 And oSymbol IsNot Nothing Then
5490
            '                For Each oAttribute In oAttributeRow
5491
            '                    Try
5492
            '                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5493
            '                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5494
5495
            '                        If sPIDAttribute = "SIZE" Then
5496
5497
            '                            'Nominal diamter1,2속성이름뭔지 찾아봐야됨 (2018-07-20)
5498
            '                            If sPIDValue.Contains("x") Then
5499
            '                                Dim sSplitSize() As String = sPIDValue.Split("x")
5500
            '                                If sSplitSize.Count > 1 Then
5501
            '                                    'Connection Point와 연결되어 있는 라인을 가져와서 라인프로퍼티를 변경
5502
            '                                    Dim oConnector_1 As LMConnector = Nothing
5503
            '                                    Dim oConnector_2 As LMConnector = Nothing
5504
            '                                    If oSymbol IsNot Nothing Then
5505
            '                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5506
            '                                            For Each Tconnector In oSymbol.Connect1Connectors
5507
            '                                                If Tconnector.ItemStatus = "Active" Then
5508
            '                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5509
            '                                                        oConnector_1 = Tconnector
5510
            '                                                    End If
5511
            '                                                End If
5512
            '                                            Next
5513
            '                                        End If
5514
            '                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5515
            '                                            For Each Tconnector In oSymbol.Connect1Connectors
5516
            '                                                If Tconnector.ItemStatus = "Active" Then
5517
            '                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5518
            '                                                        oConnector_2 = Tconnector
5519
            '                                                    End If
5520
            '                                                End If
5521
            '                                            Next
5522
            '                                        End If
5523
            '                                    End If
5524
            '                                    Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(oConnector_1.ModelItemID)
5525
            '                                    Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(oConnector_2.ModelItemID)
5526
            '                                    If dAngle = 3.14 Then
5527
            '                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(1)
5528
            '                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(0)
5529
            '                                    Else
5530
            '                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(0)
5531
            '                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(1)
5532
            '                                    End If
5533
5534
5535
            '                                End If
5536
5537
            '                            Else
5538
            '                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5539
            '                                oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5540
            '                            End If
5541
            '                        Else
5542
            '                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5543
            '                            oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5544
            '                        End If
5545
5546
            '                    Catch ex As Exception
5547
            '                    End Try
5548
            '                Next
5549
            '                oSymbol.Commit()
5550
            '            End If
5551
            '        Catch ex As Exception
5552
            '        End Try
5553
            '    End If
5554
            'End If
5555
        Catch ex As Exception
5556
        End Try
5557
    End Sub
5558 e4000111 Gyusu
5559
5560
5561
    Private Function AutoModeling() As Boolean
5562
        Try
5563 76f465d0 Gyusu
            _AllLine_DT = Line_Dt()
5564
            _AllSymbol_DT = Symbol_Dt()
5565 79326880 Gyusu
            _ModelingLine_Dt = Line_Dt()
5566 76f465d0 Gyusu
5567 e4000111 Gyusu
            _CompleteConvert = False
5568
            Label_Progress.Text = "0%"
5569
            SetListBoxItems(ListBox_Result, " Auto converting 시작....")
5570 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 시작....")
5571 e4000111 Gyusu
            Dim oDwg_Dt As DataTable = LoadAllDrawing()
5572 b08338e3 Gyusu
            _Log_File = "AutoConverting_" + DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmmss")
5573 e4000111 Gyusu
            _allItem = GetAllCheckNodeCount()
5574 76f465d0 Gyusu
            _Itemcnt = 0
5575 e4000111 Gyusu
            '1.Equipment
5576
            '2.Piping OPC
5577
            '3.OPC 시작되는 Line
5578 bb2a0c79 Gyusu
            InitAutoRouting()
5579 e4000111 Gyusu
            EquipmentModeling(oDwg_Dt)
5580 bb2a0c79 Gyusu
            PipingModeling()
5581
5582
            '   PipeLine_Fitting_Modeling()
5583 e4000111 Gyusu
5584 171ac39d Gyusu
            SetProgressbar(ProgressBar_Status, 100)
5585 41e4023e Gyusu
            Label_Progress.Text = "100%"
5586 171ac39d Gyusu
            SetListBoxItems(ListBox_Result, " Auto converting 완료")
5587 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 완료")
5588 54b98e09 Gyusu
            _CompleteConvert = True
5589 171ac39d Gyusu
            Return True
5590
        Catch ex As Exception
5591
            Return False
5592
        End Try
5593
    End Function
5594
5595
5596
5597 54b98e09 Gyusu
    Private Sub ThreadConvert()
5598 559daf6d Gyusu
        If _DrawingsList IsNot Nothing Then
5599
            If _DrawingsList.Count > 0 Then
5600
                AutoModeling()
5601
            End If
5602 171ac39d Gyusu
        End If
5603 e282643f Gyusu
    End Sub
5604
5605 54b98e09 Gyusu
    Private Sub ThreadOPCRemove()
5606
        While _CompleteConvert = False
5607
            Dim oFindOPC As New FindOpc
5608
            oFindOPC.RemoveOPCDlg()
5609
        End While
5610 e282643f Gyusu
5611 54b98e09 Gyusu
    End Sub
5612 171ac39d Gyusu
5613 e282643f Gyusu
5614
    Private Function OpenDrawing(ByVal oDt As DataTable, ByVal sDwgName As String) As String
5615
        Dim oRows As DataRow() = oDt.Select("[Name] = '" & sDwgName & "'")
5616
        Dim oPath As String = ""
5617
        If oRows.Length > 0 Then
5618
            oPath = oRows(0).Item("Path").ToString()
5619
        End If
5620
        Return oPath
5621
    End Function
5622
5623 272662f9 Gyusu
    Private Sub LoadXmlToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadXmlToolStripMenuItem.Click
5624 3b7a4470 Gyusu
5625 171ac39d Gyusu
        If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
5626 54b98e09 Gyusu
            LoadDB()
5627 171ac39d Gyusu
            LoadXmlItem(FolderBrowserDialog1.SelectedPath)
5628
        End If
5629
    End Sub
5630
    Private Sub LoadXmlItem(ByVal sFolderPath As String)
5631
        _DrawingsList = New List(Of Drawing)
5632
        Dim sfileEntries As String() = Directory.GetFiles(sFolderPath)
5633
        If Tree_Result.Nodes.Count > 0 Then
5634
            Tree_Result.Nodes(0).Nodes.Clear()
5635
            For Each sfileName In sfileEntries
5636
                Dim sExtension As String = Path.GetExtension(sfileName)
5637
                If sExtension = ".xml" Then
5638
                    Dim sDwgName As String = Path.GetFileNameWithoutExtension(sfileName)
5639
                    Dim sDwgPath As String = sfileName
5640
                    Dim oNode As TreeNode = Tree_Result.Nodes(0).Nodes.Add(sDwgPath, sDwgName, 15)
5641
                    Dim oDwg As Drawing = AddSymbolItem(sDwgPath, oNode)
5642 bb2a0c79 Gyusu
5643 171ac39d Gyusu
                    _DrawingsList.Add(oDwg)
5644
                End If
5645
            Next
5646
            Tree_Result.Nodes(0).Expand()
5647
        End If
5648
    End Sub
5649 272662f9 Gyusu
5650 e4000111 Gyusu
    Private Sub GenerateRelation(ByRef oDwg_Ds As Drawing)
5651
        Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos
5652
        Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos
5653
        Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos
5654
        Dim oRelation As New GenerateRelation()
5655
        For Each oLinelist In oLineLists
5656 bb2a0c79 Gyusu
            oRelation.CalcLineConnectionItem_Equal(oLinelist.Dt_Line, oLineLists)
5657
            oRelation.CalcLineConnectionItem_NonEqual(oLinelist.Dt_Line, oLineLists)
5658
            oRelation.CalcSymbolConnectionItem_Equal(oLinelist.Dt_Symbol, oLineLists)
5659
            oRelation.CalcSymbolConnectionItem_NonEqual(oLinelist.Dt_Symbol, oLineLists)
5660 e4000111 Gyusu
        Next
5661
    End Sub
5662
5663
5664 20c84e05 Gyusu
    ''' <summary>
5665
    '''  XML Tree 구조 생성 
5666
    ''' </summary>
5667
    ''' <param name="sDwgPath"></param>
5668 171ac39d Gyusu
    Private Function AddSymbolItem(ByVal sDwgPath As String, ByVal oParentNode As TreeNode) As Drawing
5669
        Dim oDwg_Ds As Drawing = LoadSymbolInXml(sDwgPath)
5670 e4000111 Gyusu
5671 76f465d0 Gyusu
        'SetConnectionInfo()
5672 b08338e3 Gyusu
        '  GenerateRelation(oDwg_Ds)
5673 e4000111 Gyusu
5674 54b98e09 Gyusu
        If oDwg_Ds IsNot Nothing Then
5675
            Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos
5676
5677
            Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos
5678 3acffcee Gyusu
5679
            Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos
5680
5681 54b98e09 Gyusu
            Dim oPipe As Boolean = False
5682
            Dim oFitting As Boolean = False
5683
            'PipeLine 구분
5684
5685
            For Each oLinelist In oLineLists
5686
                Dim sLineNoUid As String = oLinelist.Uid
5687
                Dim sLineNo As String = oLinelist.Text
5688
                Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo)
5689
                For Each oLineRow In oLinelist.Dt_Line.Rows
5690
                    Dim sLineUid As String = oLineRow(_XML_LINE_UID)
5691
                    Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe")
5692 76f5e1a8 Gyusu
                    Dim bValidLine As Boolean = oLineRow(_XML_LINE_ValieLine)
5693 9c86a823 Gyusu
5694
5695 76f5e1a8 Gyusu
                    If bValidLine = False Then
5696
                        oLineNoNode.ForeColor = Color.Red
5697
                        oPipeNode.ForeColor = Color.Red
5698 9c86a823 Gyusu
                    Else
5699
5700
                        Dim bLineType As String = oLineRow(_XML_LINE_TYPE)
5701
                        Dim bLineColor As Color = GetPipeColor(bLineType)
5702
                        If bLineType <> "Primary" Then
5703 3e63328a Gyusu
                            '      MessageBox.Show("")
5704 9c86a823 Gyusu
                        End If
5705
                        oPipeNode.ForeColor = bLineColor
5706 76f5e1a8 Gyusu
                    End If
5707 54b98e09 Gyusu
                    oPipeNode.Tag = sLineNoUid
5708
                Next
5709
                For Each oSymbolRow In oLinelist.Dt_Symbol.Rows
5710
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5711
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
5712
                    Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName)
5713 9c86a823 Gyusu
5714 54b98e09 Gyusu
                    oSymbolNode.Tag = sLineNoUid
5715
                Next
5716
            Next
5717 3acffcee Gyusu
5718 54b98e09 Gyusu
            For Each oEqplist In oEqpLists
5719
                Dim sEqpUid As String = oEqplist.Uid
5720
                Dim sEqpNo As String = "EQUIPMENT"
5721
                Dim oEqpNode As TreeNode = oParentNode.Nodes.Add(sEqpUid, sEqpNo)
5722 d039e347 Gyusu
5723 54b98e09 Gyusu
5724
                For Each oSymbolRow In oEqplist.Dt_Equipment.Rows
5725
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5726
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
5727
                    Dim oSymbolNode As TreeNode = oEqpNode.Nodes.Add(sSymbolUid, sSymbolName)
5728
                    oSymbolNode.Tag = sEqpUid
5729
                Next
5730 171ac39d Gyusu
            Next
5731 3acffcee Gyusu
            Dim sTrimLine As String = "TrimLineNos"
5732
            Dim iTrimLinecnt As Integer = 1
5733
            For Each oTrimLinelist In oTrimLineLists
5734
                Dim sLineNoUid As String = oTrimLinelist.Uid
5735
                Dim sLineNo As String = sTrimLine & "_" & iTrimLinecnt
5736
                Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo)
5737
                For Each oLineRow In oTrimLinelist.Dt_Line.Rows
5738
                    Dim sLineUid As String = oLineRow(_XML_LINE_UID)
5739
                    Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe")
5740 76f5e1a8 Gyusu
                    Dim bValidLine As Boolean = oLineRow(_XML_LINE_ValieLine)
5741
                    If bValidLine = False Then
5742
                        oLineNoNode.ForeColor = Color.Red
5743
                        oPipeNode.ForeColor = Color.Red
5744 9c86a823 Gyusu
                    Else
5745
                        Dim bLineType As String = oLineRow(_XML_LINE_TYPE)
5746
                        If bLineType <> "Primary" Then
5747 3e63328a Gyusu
                            '     MessageBox.Show("")
5748 9c86a823 Gyusu
                        End If
5749
                        Dim bLineColor As Color = GetPipeColor(bLineType)
5750
                        oPipeNode.ForeColor = bLineColor
5751 76f5e1a8 Gyusu
                    End If
5752 3acffcee Gyusu
                    oPipeNode.Tag = sLineNoUid
5753
                Next
5754
                For Each oSymbolRow In oTrimLinelist.Dt_Symbol.Rows
5755
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5756
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
5757
                    Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName)
5758
                    oSymbolNode.Tag = sLineNoUid
5759
                Next
5760
                iTrimLinecnt = iTrimLinecnt + 1
5761
            Next
5762
5763 54b98e09 Gyusu
        End If
5764
5765 171ac39d Gyusu
        Return oDwg_Ds
5766
    End Function
5767 272662f9 Gyusu
    Private Sub Tree_Result_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_Result.AfterCheck
5768
        If e.Node.Checked = True Then
5769
            For Each oNode As TreeNode In e.Node.Nodes
5770
                oNode.Checked = True
5771
            Next
5772
        Else
5773
            For Each oNode As TreeNode In e.Node.Nodes
5774
                oNode.Checked = False
5775
            Next
5776
        End If
5777
    End Sub
5778 171ac39d Gyusu
5779 559daf6d Gyusu
    Private Sub Btn_Setting_Click(sender As Object, e As EventArgs) Handles Btn_Setting.Click
5780
        Dim oSettings As Settings = New Settings()
5781
        oSettings.ShowDialog()
5782
    End Sub
5783 42c0013c Gyusu
5784
    Private Sub Btn_TestNozzle_Click(sender As Object, e As EventArgs) Handles Btn_TestNozzle.Click
5785
5786
        Dim sVessel_ID As String = "841D5E640AE5421B9A017DDC2E87FF11"
5787
        Dim objVessel As LMVessel
5788
        objVessel = _Placement.PIDDataSource.GetVessel(sVessel_ID)
5789
        Dim oVesselLocation As LMLocations = objVessel.Locations
5790
        Dim symVessel As LMSymbol = _Placement.PIDDataSource.GetSymbol(objVessel.Representations.Nth(1).Id)
5791
        Dim XCoordinate As String = symVessel.Attributes("XCoordinate").Value
5792
        Dim YCoordinate As String = symVessel.Attributes("YCoordinate").Value
5793
        symVessel.Attributes("XCoordinate").Value = XCoordinate + 0.01
5794
        symVessel.Attributes("YCoordinate").Value = YCoordinate + 0.01
5795
        symVessel.Commit()
5796
        Dim sValve_ID As String = "DB7B0CA8A2664A6BA7A9615764BA62B0"
5797
        Dim objValve As LMSymbol
5798
        Dim objValves As LMPipingComp = _Placement.PIDDataSource.GetPipingComp(sValve_ID)
5799
5800
        objValve = _Placement.PIDDataSource.GetSymbol(objValves.Representations.Nth(1).Id)
5801
        objValve.Commit()
5802
        Dim dVesselX As Double = XCoordinate
5803
        Dim dVesselY As Double = YCoordinate
5804
        Dim X1 As Double, Y1 As Double, X2 As Double, Y2 As Double
5805
5806
        _Placement.PIDConnectPointLocation(objValve, 1, X1, Y1)
5807
5808
        _Placement.PIDConnectPointLocation(objValve, 2, X2, Y2)
5809
5810
        Dim nozzlename As String = "\Equipment Components\Nozzles\Flanged Nozzle.sym"
5811
        Dim dCalc_x As Double = 0
5812
        Dim dCalc_y As Double = 0
5813
5814
        If dVesselX - X2 > 0 Then
5815
            dCalc_x = dVesselX - (dVesselX - X2)
5816
        Else
5817
            dCalc_x = dVesselX + (X2 - dVesselX)
5818
        End If
5819
        If dVesselY - Y2 > 0 Then
5820
            dCalc_y = dVesselY - (dVesselY - Y2)
5821
        Else
5822
            dCalc_y = dVesselY + (Y2 - dVesselY)
5823
        End If
5824
5825
        Dim objNozzle As LMSymbol = _Placement.PIDPlaceSymbol(nozzlename, dCalc_x, dCalc_y,
5826
            TargetItem:=symVessel.AsLMRepresentation)
5827
5828
        Dim blnSuccess As Boolean = _Placement.PIDConnectPointLocation(objNozzle, 1, X1, Y1)
5829
        blnSuccess = _Placement.PIDConnectPointLocation(objNozzle, 2, X1, Y1)
5830
5831
        objValve = _Placement.PIDPlaceSymbol(objValve.FileName, X1, Y1, ExistingItem:=objValve.AsLMAItem,
5832
          TargetItem:=objNozzle.AsLMRepresentation)
5833
5834
5835
5836
    End Sub
5837 39d43554 Gyusu
5838
    Private Sub Btn_SymbolLibrary_Click(sender As Object, e As EventArgs) Handles Btn_SymbolLibrary.Click
5839
        Dim oMapping As New Mapping(_PIDSymbol_DB)
5840
        oMapping.Show()
5841
    End Sub
5842 41e4023e Gyusu
5843
    Private Sub Btn_Stop_Click(sender As Object, e As EventArgs) Handles Btn_Stop.Click
5844
        Try
5845
            SetListBoxItems(ListBox_Result, " Auto converting 중지....")
5846 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 중지....")
5847 41e4023e Gyusu
            _Main_trd.Abort()
5848
            _Opc_trd.Abort()
5849
        Catch ex As Exception
5850
5851
        End Try
5852
    End Sub
5853 b08338e3 Gyusu
5854
    Private Sub AutoCheckTreeNode(ByVal iType As Integer, ByVal bCheck As Boolean)
5855
5856
        For Each oDrwing As TreeNode In Tree_Result.Nodes
5857
            For Each oDwgNode As TreeNode In oDrwing.Nodes
5858
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
5859
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
5860
                If CDrawing IsNot Nothing Then
5861
                    Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
5862
                    Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
5863
                    For Each oNode As TreeNode In oDwgNode.Nodes
5864
                        Dim iItemcnt As Integer = 0
5865
                        Dim sNodeUid As String = oNode.Name
5866
                        Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
5867
5868
                        If iType = 0 Then 'Symbol
5869
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
5870
                            If CLineNo IsNot Nothing Then
5871
                                Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
5872
                                For Each oSymbolRow In oSymbol_Dt.Rows
5873
                                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
5874
                                    For Each oSymbolNode As TreeNode In oNode.Nodes
5875
                                        Dim sSymbolNodeUid As String = oSymbolNode.Name
5876
                                        If sSymbolNodeUid = sSymbolUid Then
5877
                                            oSymbolNode.Checked = bCheck
5878
                                            Exit For
5879
                                        End If
5880
                                    Next
5881
                                Next
5882
                            End If
5883
                            Dim TrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
5884
                            If TrimLineNo IsNot Nothing Then
5885
                                Dim oSymbol_Dt As DataTable = TrimLineNo.Dt_Symbol
5886
                                For Each oSymbolRow In oSymbol_Dt.Rows
5887
                                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
5888
                                    For Each oSymbolNode As TreeNode In oNode.Nodes
5889
                                        Dim sSymbolNodeUid As String = oSymbolNode.Name
5890
                                        If sSymbolNodeUid = sSymbolUid Then
5891
                                            oSymbolNode.Checked = bCheck
5892
                                            Exit For
5893
                                        End If
5894
                                    Next
5895
                                Next
5896
                            End If
5897
                        End If
5898
                        If iType = 1 Then 'Line
5899
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
5900
                            If CLineNo IsNot Nothing Then
5901
                                Dim oLine_Dt As DataTable = CLineNo.Dt_Line
5902
                                For Each oLineRow In oLine_Dt.Rows
5903
                                    Dim sLineUid As String = oLineRow(_XML_LINE_UID).ToString()
5904
                                    For Each oLineNode As TreeNode In oNode.Nodes
5905
                                        Dim sLineNodeUid As String = oLineNode.Name
5906
                                        If sLineNodeUid = sLineUid Then
5907
                                            oLineNode.Checked = bCheck
5908
                                            Exit For
5909
                                        End If
5910
                                    Next
5911
                                Next
5912
                            End If
5913
                            Dim TrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
5914
                            If TrimLineNo IsNot Nothing Then
5915
                                Dim oLine_Dt As DataTable = TrimLineNo.Dt_Line
5916
                                For Each oLineRow In oLine_Dt.Rows
5917
                                    Dim sLineUid As String = oLineRow(_XML_SYMBOL_UID).ToString()
5918
                                    For Each oLineNode As TreeNode In oNode.Nodes
5919
                                        Dim sLineNodeUid As String = oLineNode.Name
5920
                                        If sLineNodeUid = sLineUid Then
5921
                                            oLineNode.Checked = bCheck
5922
                                            Exit For
5923
                                        End If
5924
                                    Next
5925
                                Next
5926
                            End If
5927
                        End If
5928
                        If iType = 2 Then 'Equipment
5929
                            Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid)
5930
                            If CEqpNo IsNot Nothing Then
5931
                                Dim oEqp_Dt As DataTable = CEqpNo.Dt_Equipment
5932
                                For Each oEqpRow In oEqp_Dt.Rows
5933
                                    Dim sEqpUid As String = oEqpRow(_XML_LINE_UID).ToString()
5934
                                    For Each oEqpNode As TreeNode In oNode.Nodes
5935
                                        Dim sEqpNodeUid As String = oEqpNode.Name
5936
                                        If sEqpNodeUid = sEqpUid Then
5937
                                            oEqpNode.Checked = bCheck
5938
                                            Exit For
5939
                                        End If
5940
                                    Next
5941
                                Next
5942
                            End If
5943
                        End If
5944
                    Next
5945
                End If
5946
            Next
5947
        Next
5948
5949
5950
    End Sub
5951
5952
5953
5954
    Private Sub Chk_Symbol_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Symbol.CheckedChanged
5955
        AutoCheckTreeNode(0, Chk_Symbol.Checked)
5956
    End Sub
5957
5958
    Private Sub Chk_Line_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Line.CheckedChanged
5959
        AutoCheckTreeNode(1, Chk_Line.Checked)
5960
    End Sub
5961
5962
    Private Sub Chk_Equipment_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Equipment.CheckedChanged
5963
        AutoCheckTreeNode(2, Chk_Equipment.Checked)
5964
    End Sub
5965 e282643f Gyusu
End Class
5966
5967
5968
Public Class DrawingInfo
5969
    Public mDrawingName As String
5970
    Public mSpID As String
5971
    Public mPath As String
5972 4f359afa Gyusu
End Class
5973 e282643f Gyusu
5974
5975
5976
클립보드 이미지 추가 (최대 크기: 500 MB)