프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Main.vb @ 9b5d4527

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