프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Main.vb @ 1bfcc921

이력 | 보기 | 이력해설 | 다운로드 (314 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
                        '//2018.09.07 LMControl에 따라서 inconsitency가 달라지는듯 확인
2385
                        If sStartConnectionUid <> "" Then
2386
                            Dim oChangeRow() As DataRow = _ModelingLine_Dt.Select(_XML_LINE_UID & " = '" & sStartConnectionUid & "'")
2387
                            If oChangeRow.Length = 1 Then
2388
                                oChangeRow(0)(_XML_LINE_SPID) = sID_1
2389
                                oChangeRow(0)(_XML_LINE_LMCONNECTOR) = oAddConnector
2390
                            End If
2391
                        End If
2392
                        If sEndConnectionUid <> "" Then
2393
                            Dim oChangeRow() As DataRow = _ModelingLine_Dt.Select(_XML_LINE_UID & " = '" & sEndConnectionUid & "'")
2394
                            If oChangeRow.Length = 1 Then
2395
                                oChangeRow(0)(_XML_LINE_SPID) = sID_1
2396
                                oChangeRow(0)(_XML_LINE_LMCONNECTOR) = oAddConnector
2397
                            End If
2398
                        End If
2399 e38f99a7 Gyusu
                    Else
2400 1bfcc921 Gyusu
                        sReturnUid = ""
2401 e38f99a7 Gyusu
                    End If
2402 1bfcc921 Gyusu
                Catch ex As Exception
2403
                End Try
2404
            End If
2405
        Catch ex As Exception
2406
        End Try
2407
        Return sReturnUid
2408
        '현재 Uid 모델링
2409
    End Function
2410
    Private Sub AddLog(ByVal sUid As String, ByVal sSystemPath As String,
2411
                             ByVal dStart_Dwg_x As Double, ByVal dStart_Dwg_y As Double, ByVal dEnd_Dwg_x As Double, ByVal dEnd_Dwg_y As Double,
2412
                       ByVal sLineNoText As String, ByVal sConn1Uid As String, ByVal sConn2Uid As String)
2413
        SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dStart_Dwg_x & "," & dStart_Dwg_y & ") - (" & dEnd_Dwg_x & "," & dEnd_Dwg_y & ")..." & _iPipecnt & " count ")
2414
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
2415
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
2416
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & sConn1Uid)
2417
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & sConn2Uid)
2418
        'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
2419
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dStart_Dwg_x & "," & dStart_Dwg_y)
2420
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dEnd_Dwg_x & "," & dEnd_Dwg_y)
2421
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
2422
    End Sub
2423 b08338e3 Gyusu
2424 1bfcc921 Gyusu
    Private Sub AddAttribute(ByVal oPipeRun As LMPipeRun, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String)
2425
        Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
2426
        If oAttributeRow.Length > 0 Then
2427
            For Each oAttribute In oAttributeRow
2428
                Try
2429
                    Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
2430
                    Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
2431
                    If sPIDValue.Contains("'") Then
2432
                        sPIDValue = sPIDValue.Replace("'", """")
2433 e38f99a7 Gyusu
                    End If
2434 1bfcc921 Gyusu
                    Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
2435
                    oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
2436
                Catch ex As Exception
2437
                End Try
2438
            Next
2439
            oPipeRun.Commit()
2440
        End If
2441
    End Sub
2442 b08338e3 Gyusu
2443 1bfcc921 Gyusu
    Private Sub AddModelingDT(ByVal sUid As String, ByVal sModelID As String, ByVal oCurrentConnector As LMConnector,
2444
                              ByVal dStart_Dwg_x As Double, ByVal dStart_Dwg_y As Double,
2445
                              ByVal dEnd_Dwg_x As Double, ByVal dEnd_Dwg_y As Double)
2446
        Dim oAddRow As DataRow = _ModelingLine_Dt.NewRow
2447
        oAddRow(_XML_LINE_UID) = sUid
2448
        oAddRow(_XML_LINE_SPID) = sModelID
2449
        oAddRow(_XML_LINE_LMCONNECTOR) = oCurrentConnector
2450
        oAddRow(_XML_LINE_DRAWING_TF) = "TRUE"
2451
        oAddRow(_XML_LINE_DWG_STARTPOINT_X) = dStart_Dwg_x
2452
        oAddRow(_XML_LINE_DWG_STARTPOINT_Y) = dStart_Dwg_y
2453
        oAddRow(_XML_LINE_DWG_ENDPOINT_X) = dEnd_Dwg_x
2454
        oAddRow(_XML_LINE_DWG_ENDPOINT_Y) = dEnd_Dwg_y
2455
        _ModelingLine_Dt.Rows.Add(oAddRow)
2456
    End Sub
2457 f9b63682 Gyusu
2458 1bfcc921 Gyusu
    Private Function JoinPipeRun(ByVal sID_1 As String, ByVal sID_2 As String) As Boolean
2459
        Try
2460
            Dim objSurvivorItem As LMAItem = Nothing
2461
            Dim oPipeRun1 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_1)
2462
            Dim oPipeRun2 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_2)
2463
            _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
2464
            Return True
2465
        Catch ex As Exception
2466
            Return False
2467
        End Try
2468
    End Function
2469 73bfb231 Gyusu
2470
2471 1bfcc921 Gyusu
    Private Function LineModeling(ByVal objInputs As PlaceRunInputs, ByVal sSystemPath As String) As LMConnector
2472
        Dim oCurrentConnector As LMConnector = Nothing
2473
        Dim objItem As LMAItem
2474
        objItem = _Placement.PIDCreateItem(sSystemPath)
2475
        Try
2476
            oCurrentConnector = _Placement.PIDPlaceRun(objItem, objInputs)
2477
            AddProgress()
2478
        Catch ex As Exception
2479
        End Try
2480
        Return oCurrentConnector
2481
    End Function
2482 f9b63682 Gyusu
2483 1bfcc921 Gyusu
    Private Sub InstumentLineModeling(ByVal CLineNo As Line_no, ByVal oNode As TreeNode)
2484
        If CLineNo IsNot Nothing Then
2485
            Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2486
            Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2487
            Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute
2488
            Dim oDrawLinenoLabel As Boolean = False
2489
            For Each oSymbolNode As TreeNode In oNode.Nodes
2490
                If oSymbolNode.Checked Then
2491
                    Try
2492
                        Dim sUid As String = oSymbolNode.Name
2493
                        Dim sLineNoUid As String = CLineNo.Uid
2494
                        Dim sReturnUid = sUid
2495
                        '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2496
                        While True
2497
                            Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2498
                                               _XML_SYMBOL_Check & "] = 'TRUE' And [" & _XML_LINE_ValieLine & "] = 'True'")
2499
                            If oLineRows.Count > 0 Then
2500
                                Dim sPipeType As String = oLineRows(0)(_XML_LINE_TYPE).ToString()
2501
                                If sPipeType.ToUpper() <> "PRIMARY" Then
2502
                                    sReturnUid = FinalLineModeling(oLineRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2503
                                Else
2504
                                    sReturnUid = ""
2505
                                End If
2506
                            Else
2507
                                sReturnUid = ""
2508
                            End If
2509
                            If sReturnUid = "" Then
2510
                                Exit While
2511
                            End If
2512
                        End While
2513
                    Catch ex As Exception
2514
                    End Try
2515 76f465d0 Gyusu
                End If
2516 1bfcc921 Gyusu
            Next
2517
        End If
2518
    End Sub
2519 76f465d0 Gyusu
2520 1bfcc921 Gyusu
    Private Sub PipeLineModeling(ByVal CLineNo As Line_no, ByVal oNode As TreeNode)
2521
        If CLineNo IsNot Nothing Then
2522
            Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2523
            Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2524
            Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute
2525
            Dim oDrawLinenoLabel As Boolean = False
2526
            Try
2527
                ManualCheckNode(oLine_Dt)
2528
                ManualCheckNode(oSymbol_Dt)
2529
            Catch ex As Exception
2530
            End Try
2531
            For Each oSymbolNode As TreeNode In oNode.Nodes
2532
                If oSymbolNode.Checked Then
2533
                    Try
2534
                        Dim sUid As String = oSymbolNode.Name
2535
                        Dim sLineNoUid As String = CLineNo.Uid
2536
                        Dim sReturnUid = sUid
2537
                        '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2538
                        While True
2539
                            Dim oLineRows As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False' And [" &
2540
                                               _XML_SYMBOL_Check & "] = 'TRUE' And [" & _XML_LINE_ValieLine & "] = 'True'")
2541
                            If oLineRows.Count > 0 Then
2542
                                Dim sPipeType As String = oLineRows(0)(_XML_LINE_TYPE).ToString()
2543
                                If sPipeType.ToUpper() = "PRIMARY" Then
2544
                                    sReturnUid = FinalLineModeling(oLineRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2545
                                Else
2546
                                    sReturnUid = ""
2547 b82166d4 Gyusu
                                End If
2548 76f465d0 Gyusu
2549 1bfcc921 Gyusu
                            Else
2550
                                sReturnUid = ""
2551 b82166d4 Gyusu
                            End If
2552 1bfcc921 Gyusu
                            If sReturnUid = "" Then
2553
                                Exit While
2554
                            End If
2555
                        End While
2556
                    Catch ex As Exception
2557
                    End Try
2558
                End If
2559
            Next
2560
        End If
2561
    End Sub
2562 b82166d4 Gyusu
2563 1bfcc921 Gyusu
    Private Sub InstrumentSymbolModeling(ByVal CLineNo As Line_no, ByVal oNode As TreeNode)
2564
        If CLineNo IsNot Nothing Then
2565
            Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2566
            Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2567
            Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute
2568
            Dim oDrawLinenoLabel As Boolean = False
2569
            Try
2570
                ManualCheckNode(oLine_Dt)
2571
                ManualCheckNode(oSymbol_Dt)
2572
            Catch ex As Exception
2573
            End Try
2574
            For Each oSymbolNode As TreeNode In oNode.Nodes
2575
                If oSymbolNode.Checked Then
2576
                    Try
2577
                        Dim sUid As String = oSymbolNode.Name
2578
                        Dim sLineNoUid As String = CLineNo.Uid
2579
                        Dim sReturnUid = sUid
2580
                        '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2581
                        Dim oSymbolRows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'FALSE' And [" &
2582
                                                                           _XML_SYMBOL_Check & "] = 'TRUE'")
2583
                        If oSymbolRows.Count > 0 Then
2584
                            Dim sSymbolType As String = oSymbolRows(0)(_XML_SYMBOL_TYPE).ToString().ToUpper()
2585
                            If sSymbolType = "INSTRUMENT" Then
2586
                                sReturnUid = FinalSymbolModeling(oSymbolRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2587
                            End If
2588
                        Else
2589
                            sReturnUid = ""
2590 b82166d4 Gyusu
                        End If
2591 1bfcc921 Gyusu
                        If sReturnUid = "" Then
2592 b82166d4 Gyusu
                        End If
2593 1bfcc921 Gyusu
                    Catch ex As Exception
2594
                    End Try
2595 76f465d0 Gyusu
                End If
2596 1bfcc921 Gyusu
            Next
2597
        End If
2598
    End Sub
2599 b82166d4 Gyusu
2600 1bfcc921 Gyusu
    Private Sub PipeSymbolModeling(ByVal CLineNo As Line_no, ByVal oNode As TreeNode)
2601
        If CLineNo IsNot Nothing Then
2602
            Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2603
            Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2604
            Dim oAttribute_Dt As DataTable = CLineNo.Dt_Attribute
2605
            Dim oDrawLinenoLabel As Boolean = False
2606
            Try
2607
                ManualCheckNode(oLine_Dt)
2608
                ManualCheckNode(oSymbol_Dt)
2609 76f465d0 Gyusu
            Catch ex As Exception
2610
            End Try
2611 1bfcc921 Gyusu
            For Each oSymbolNode As TreeNode In oNode.Nodes
2612
                If oSymbolNode.Checked Then
2613
                    Try
2614
                        Dim sUid As String = oSymbolNode.Name
2615
                        Dim sLineNoUid As String = CLineNo.Uid
2616
                        Dim sReturnUid = sUid
2617
                        '  FinalModeling(sUid, oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2618
                        Dim oSymbolRows As DataRow() = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "]= '" & sReturnUid & "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'FALSE' And [" &
2619
                                                                           _XML_SYMBOL_Check & "] = 'TRUE'")
2620
                        If oSymbolRows.Count > 0 Then
2621
                            Dim sSymbolType As String = oSymbolRows(0)(_XML_SYMBOL_TYPE).ToString().ToUpper()
2622
                            If sSymbolType <> "INSTRUMENT" Then
2623
                                sReturnUid = FinalSymbolModeling(oSymbolRows(0), oLine_Dt, oSymbol_Dt, oAttribute_Dt)
2624
                            End If
2625
                        Else
2626
                            sReturnUid = ""
2627
                        End If
2628
                        If sReturnUid = "" Then
2629
                        End If
2630
                    Catch ex As Exception
2631
                    End Try
2632
                End If
2633
            Next
2634
        End If
2635
    End Sub
2636 bb2a0c79 Gyusu
2637
    Private Sub PipingModeling()
2638 e4000111 Gyusu
2639 171ac39d Gyusu
        Try
2640
            For Each oDrwing As TreeNode In Tree_Result.Nodes
2641
                For Each oDwgNode As TreeNode In oDrwing.Nodes
2642
                    Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
2643 54b98e09 Gyusu
                    Dim CDrawing As Drawing = GetDrawing(sDwgName)
2644
                    If CDrawing IsNot Nothing Then
2645 e4000111 Gyusu
                        Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
2646
                        Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
2647 1bfcc921 Gyusu
2648
                        'PipeModeling
2649 e4000111 Gyusu
                        For Each oNode As TreeNode In oDwgNode.Nodes
2650
                            Dim iItemcnt As Integer = 0
2651
                            Dim sNodeUid As String = oNode.Name
2652
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2653
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2654 1bfcc921 Gyusu
                            PipeLineModeling(CLineNo, oNode)
2655 76f465d0 Gyusu
                            Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2656 1bfcc921 Gyusu
                            PipeLineModeling(CTrimLineNo, oNode)
2657 76f465d0 Gyusu
                        Next
2658 3acffcee Gyusu
2659 1bfcc921 Gyusu
                        'Instrument Modeling
2660 76f465d0 Gyusu
                        For Each oNode As TreeNode In oDwgNode.Nodes
2661
                            Dim iItemcnt As Integer = 0
2662
                            Dim sNodeUid As String = oNode.Name
2663
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2664
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2665 1bfcc921 Gyusu
                            InstrumentSymbolModeling(CLineNo, oNode)
2666 76f465d0 Gyusu
                            Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2667 1bfcc921 Gyusu
                            InstrumentSymbolModeling(CTrimLineNo, oNode)
2668 4e016f5d Gyusu
                        Next
2669
2670 1bfcc921 Gyusu
                        'Instrument Line Modeling
2671 4e016f5d Gyusu
                        For Each oNode As TreeNode In oDwgNode.Nodes
2672
                            Dim iItemcnt As Integer = 0
2673
                            Dim sNodeUid As String = oNode.Name
2674
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2675
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2676 1bfcc921 Gyusu
                            InstumentLineModeling(CLineNo, oNode)
2677 4e016f5d Gyusu
                            Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2678 1bfcc921 Gyusu
                            InstumentLineModeling(CTrimLineNo, oNode)
2679
                        Next
2680 4e016f5d Gyusu
2681 1bfcc921 Gyusu
                        'Symbol Modeling
2682
                        For Each oNode As TreeNode In oDwgNode.Nodes
2683
                            Dim iItemcnt As Integer = 0
2684
                            Dim sNodeUid As String = oNode.Name
2685
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2686
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2687
                            PipeSymbolModeling(CLineNo, oNode)
2688
                            Dim CTrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2689
                            PipeSymbolModeling(CTrimLineNo, oNode)
2690 b08338e3 Gyusu
                        Next
2691
                    End If
2692
                Next
2693
            Next
2694
        Catch ex As Exception
2695
2696
        End Try
2697
    End Sub
2698
2699
2700
    Private Sub FindNearPoint(ByVal oOPCSymbol As LMSymbol, ByRef dNear_x As Double, ByRef dNear_y As Double)
2701
        Dim oConnectionPoints_x(4) As Double
2702
        Dim oConnectionPoints_y(4) As Double
2703
2704
        Try
2705
            _Placement.PIDConnectPointLocation(oOPCSymbol, 1, oConnectionPoints_x(0), oConnectionPoints_y(0))
2706
            _Placement.PIDConnectPointLocation(oOPCSymbol, 2, oConnectionPoints_x(1), oConnectionPoints_y(1))
2707
            _Placement.PIDConnectPointLocation(oOPCSymbol, 3, oConnectionPoints_x(2), oConnectionPoints_y(2))
2708
            _Placement.PIDConnectPointLocation(oOPCSymbol, 4, oConnectionPoints_x(3), oConnectionPoints_y(3))
2709
            Dim iNearPoint As Integer = 0
2710
            Dim dGap As Double = 0
2711
            For i = 0 To 3
2712
                If dGap = 0 Then
2713
                    iNearPoint = i
2714
                    dGap = Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y)
2715
                Else
2716
                    If dGap >= Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y) Then
2717
                        iNearPoint = i
2718
                        dGap = Math.Abs(oConnectionPoints_x(i) - dNear_x) + Math.Abs(oConnectionPoints_y(i) - dNear_y)
2719
                    End If
2720
                End If
2721
            Next
2722
            dNear_x = oConnectionPoints_x(iNearPoint)
2723
            dNear_y = oConnectionPoints_y(iNearPoint)
2724
        Catch ex As Exception
2725 e4000111 Gyusu
2726 bb2a0c79 Gyusu
        End Try
2727 e4000111 Gyusu
2728 bb2a0c79 Gyusu
    End Sub
2729
2730 9c86a823 Gyusu
    Private Function GetPipeColor(ByVal sType As String) As Color
2731
        If sType.ToUpper() = "ELECTRIC" Then
2732
            Return Color.DarkOrange
2733
        ElseIf sType.ToUpper() = "CONNECT TO PROCESS" Then
2734 b82166d4 Gyusu
            Return Color.Green
2735 9c86a823 Gyusu
        ElseIf sType.ToUpper() = "SOFTWARE" Then
2736
            Return Color.Blue
2737
        ElseIf sType.ToUpper() = "PNEUMATIC" Then
2738
            Return Color.Gray
2739
        Else
2740
            Return Color.Black
2741
        End If
2742
    End Function
2743
2744 bb2a0c79 Gyusu
    Private Function GetPipeType(ByVal sType As String) As String
2745
        Dim sSystempath As String = "\Piping\Routing\Process Lines\Primary Piping.sym" ' oPipeRow(0)(_XML_LINE_SYSTEMPATH).ToString()
2746
        If sType.ToUpper() = "ELECTRIC" Then
2747
            sSystempath = "\Instrumentation\Signal Line\Electric.sym"
2748
        ElseIf sType.ToUpper() = "CONNECT TO PROCESS" Then
2749
            sSystempath = "\Instrumentation\Signal Line\Connect to Process.sym"
2750 9c86a823 Gyusu
        ElseIf sType.ToUpper() = "SOFTWARE" Then
2751
            sSystempath = "\Instrumentation\Signal Line\Software Link.sym"
2752
        ElseIf sType.ToUpper() = "PNEUMATIC" Then
2753
            sSystempath = "\Instrumentation\Signal Line\Pneumatic.sym"
2754 bb2a0c79 Gyusu
        Else
2755
        End If
2756
        Return sSystempath
2757
    End Function
2758
2759
    Private Sub InitAutoRouting()
2760
        For Each oDrwing As TreeNode In Tree_Result.Nodes
2761
            For Each oDwgNode As TreeNode In oDrwing.Nodes
2762
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
2763
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
2764
                If CDrawing IsNot Nothing Then
2765
                    Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
2766
                    Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
2767
                    SetListBoxItems(ListBox_Result, "Place " & CDrawing.DwgName & "....")
2768 b08338e3 Gyusu
2769 bb2a0c79 Gyusu
                    For Each oNode As TreeNode In oDwgNode.Nodes
2770
                        Dim iItemcnt As Integer = 0
2771
                        Dim sNodeUid As String = oNode.Name
2772
                        Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
2773
                        Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
2774
                        If CLineNo IsNot Nothing Then
2775
                            Dim oLine_Dt As DataTable = CLineNo.Dt_Line
2776
                            Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
2777
2778
                            For Each oLineRow In oLine_Dt.Rows
2779 76f465d0 Gyusu
                                ' oLineRow(_XML_LINE_UID) = ""
2780
                                oLineRow(_XML_LINE_SPID) = ""
2781
                                oLineRow(_XML_LINE_LMCONNECTOR) = Nothing
2782
                                oLineRow(_XML_LINE_LMCONNECTOR_1) = Nothing
2783
                                oLineRow(_XML_LINE_LMCONNECTOR_2) = Nothing
2784
                                oLineRow(_XML_LINE_DRAWING_TF) = "FALSE"
2785 76f5e1a8 Gyusu
                                oLineRow(_XML_LINE_Check) = "FALSE"
2786 76f465d0 Gyusu
                            Next
2787
                            For Each oSymbolRow In oSymbol_Dt.Rows
2788
                                '   oSymbolRow(_XML_SYMBOL_UID) = ""
2789
                                oSymbolRow(_XML_SYMBOL_SPID) = ""
2790
                                oSymbolRow(_XML_SYMBOL_LMSYMBOL) = Nothing
2791
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_1) = Nothing
2792
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_2) = Nothing
2793
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_3) = Nothing
2794
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_4) = Nothing
2795 76f5e1a8 Gyusu
                                oSymbolRow(_XML_SYMBOL_Check) = "FALSE"
2796 76f465d0 Gyusu
                                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
2797
2798
                            Next
2799
2800
                        End If
2801
2802
                        Dim CTRIMLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
2803
                        If CTRIMLineNo IsNot Nothing Then
2804
                            Dim oLine_Dt As DataTable = CTRIMLineNo.Dt_Line
2805
                            Dim oSymbol_Dt As DataTable = CTRIMLineNo.Dt_Symbol
2806
2807
                            For Each oLineRow In oLine_Dt.Rows
2808
                                ' oLineRow(_XML_LINE_UID) = ""
2809 bb2a0c79 Gyusu
                                oLineRow(_XML_LINE_SPID) = ""
2810 76f465d0 Gyusu
                                oLineRow(_XML_LINE_LMCONNECTOR) = Nothing
2811
                                oLineRow(_XML_LINE_LMCONNECTOR_1) = Nothing
2812
                                oLineRow(_XML_LINE_LMCONNECTOR_2) = Nothing
2813 bb2a0c79 Gyusu
                                oLineRow(_XML_LINE_DRAWING_TF) = "FALSE"
2814 76f5e1a8 Gyusu
                                oLineRow(_XML_LINE_Check) = "FALSE"
2815 bb2a0c79 Gyusu
                            Next
2816
                            For Each oSymbolRow In oSymbol_Dt.Rows
2817 76f465d0 Gyusu
                                '   oSymbolRow(_XML_SYMBOL_UID) = ""
2818 bb2a0c79 Gyusu
                                oSymbolRow(_XML_SYMBOL_SPID) = ""
2819 76f465d0 Gyusu
                                oSymbolRow(_XML_SYMBOL_LMSYMBOL) = Nothing
2820
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_1) = Nothing
2821
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_2) = Nothing
2822
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_3) = Nothing
2823
                                oSymbolRow(_XML_SYMBOL_LMCONNECTOR_4) = Nothing
2824 76f5e1a8 Gyusu
                                oSymbolRow(_XML_SYMBOL_Check) = "FALSE"
2825 bb2a0c79 Gyusu
                                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
2826 76f465d0 Gyusu
2827 bb2a0c79 Gyusu
                            Next
2828
2829
                        End If
2830
                    Next
2831
                End If
2832
            Next
2833
        Next
2834
    End Sub
2835
2836
2837
2838
2839
2840
2841 79326880 Gyusu
    Private Function CheckBranchLine(ByVal dStartX As Double, ByVal dStartY As Double,
2842 bb2a0c79 Gyusu
                                ByRef dEndX As Double, ByRef dEndY As Double, ByRef sBranchType As String, ByRef oLMConnector As LMConnector) As Boolean
2843
2844
        Try
2845 79326880 Gyusu
2846
            For Each oModelrow In _ModelingLine_Dt.Rows
2847
                'Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
2848
                'Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
2849 bb2a0c79 Gyusu
                Dim dModelStartX As Double
2850
                Dim dModelStartY As Double
2851
                Dim dModelEndX As Double
2852
                Dim dModelEndY As Double
2853 79326880 Gyusu
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
2854
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
2855
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
2856
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
2857
                'ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
2858
                'ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
2859
                'ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
2860
                'ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
2861 bb2a0c79 Gyusu
                Dim dGap As Double = 0.0002
2862
                Dim d기준x As Double = (dModelStartX + dModelEndX) / 2
2863
                Dim d기준y As Double = (dModelStartY + dModelEndY) / 2
2864
                Try
2865
                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
2866
                Catch ex As Exception
2867
2868
                End Try
2869
                Dim oRun As LMPipeRun = Nothing
2870
                Try
2871
2872
                    oRun = _Placement.PIDDataSource.GetPipeRun(oLMConnector.ModelItemID)
2873
                    Dim dResultCalc As Double = -1
2874
                    For Each objRep In oRun.Representations
2875
                        If objRep.Attributes("RepresentationType").Value = "Connector" And objRep.Attributes("ItemStatus").Value = "Active" Then
2876
                            Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
2877
                            For Each objConnectorVertex In objConnector.ConnectorVertices
2878
                                Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
2879
                                Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
2880
                                Dim dStartCalc As Double = Math.Abs(dStartX - dConn_X) + Math.Abs(dStartY - dConn_Y)
2881
2882
                                If dResultCalc > dStartCalc Or dResultCalc = -1 Then
2883
                                    dResultCalc = dStartCalc
2884
                                    oLMConnector = objConnector
2885
                                    d기준x = dConn_X
2886
                                    d기준y = dConn_Y
2887
                                End If
2888
                                Dim dEndCalc As Double = Math.Abs(dEndX - dConn_X) + Math.Abs(dEndY - dConn_Y)
2889
                                If dResultCalc > dEndCalc Then
2890
                                    dResultCalc = dEndCalc
2891
                                    oLMConnector = objConnector
2892
                                    d기준x = dConn_X
2893
                                    d기준y = dConn_Y
2894
                                End If
2895
                            Next
2896
                        End If
2897
                    Next
2898
                    '        _Placement.PIDConnectPointLocation(oRun, 1, dModelStartX, dModelEndX)
2899
                    '       _Placement.PIDConnectPointLocation(oRun, 2, dModelEndX, dModelEndY)
2900
                Catch ex As Exception
2901
                End Try
2902
2903
2904
                'Dim sSPID As String = oModelrow(_XML_LINE_SPID).ToString()
2905
                'Dim oPipeRun As LMPipeRun = _Placement.PIDDataSource.Get PipeRun(sSPID)
2906
                'If dModelStartX + dGap > dStartX And dModelStartX - dGap < dStartX And
2907
                '        dModelStartY + dGap > dStartY And dModelStartY - dGap < dStartY Then
2908
                '    dStartX = dModelStartX
2909
                '    dStartY = dModelStartY
2910
                'ElseIf dModelEndX + dGap > dStartX And dModelEndX - dGap < dStartX And
2911
                '        dModelEndY + dGap > dStartY And dModelEndY - dGap < dStartY Then
2912
                '    dStartX = dModelEndX
2913
                '    dStartY = dModelEndY
2914
                'End If
2915
2916
                'Vetical
2917
                If Math.Abs(dModelStartX - dModelEndX) <= Math.Abs(dModelStartY - dModelEndY) Then
2918
                    If Math.Abs(dStartX - dEndX) >= Math.Abs(dStartY - dEndY) Then
2919
                        'Horizontal 
2920
                        ' dGap = 0.0002 'Math.Abs(dStartX - dEndX) / 20
2921
                        '기준선의 Y범위안에 가로선이 포함되어야됨
2922
                        If (dModelStartY + dGap >= dStartY And dModelEndY - dGap <= dStartY) Or
2923
                            (dModelStartY - dGap <= dStartY And dModelEndY + dGap >= dStartY) And
2924
                            (dModelStartY + dGap >= dEndY And dModelEndY - dGap <= dEndY) Or
2925
                            (dModelStartY - dGap <= dEndY And dModelEndY + dGap >= dEndY) Then
2926
                            '기준선보다 왼쪽에 가로선이 있을때
2927
                            If d기준x >= dStartX And d기준x >= dEndX Then
2928
                                If dStartX >= dEndX Then
2929
                                    'dStartX 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
2930
                                    If dStartX + dGap >= d기준x Then
2931
                                        dStartX = d기준x
2932
                                        sBranchType = "1"
2933
                                        Return True
2934
                                    End If
2935
                                Else
2936
                                    'dEndX 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
2937
                                    If dEndX + dGap >= d기준x Then
2938
                                        dEndX = d기준x
2939
                                        sBranchType = "2"
2940
                                        Return True
2941
                                    End If
2942
                                End If
2943
                                '기준선보다 오른쪽에 가로선이 있을때
2944
                            ElseIf d기준x <= dStartX And d기준x <= dEndX Then
2945
                                If dStartX >= dEndX Then
2946
                                    'dEndX 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
2947
                                    If dEndX - dGap <= d기준x Then
2948
                                        dEndX = d기준x
2949
                                        sBranchType = "2"
2950
                                        Return True
2951
                                    End If
2952
                                Else
2953
                                    'dStartX 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
2954
                                    If dStartX - dGap <= d기준x Then
2955
                                        dStartX = d기준x
2956
                                        sBranchType = "1"
2957
                                        Return True
2958
                                    End If
2959
                                End If
2960
                            Else
2961
                                '기준선과 세로선이 겹칠때
2962
                                If (d기준x >= dStartX And d기준x <= dEndX) Or
2963
                                        (d기준x <= dStartX And d기준x >= dEndX) Then
2964
                                    If (dModelStartY <= dStartY And dModelEndY >= dEndY) Or
2965
                                        (dModelStartY >= dStartY And dModelEndY <= dEndY) Then
2966
                                        '기준선이 dStartX와 dEndX중 어느쪽에 가까운지 확인
2967
                                        '가로선의 왼쪽점과 기준선이 가까울때는 gap만큼 뺐을때 기준선보다 작은지확인
2968
                                        '가로선의 오른쪽점과 기준선이 가까울때는 gap만큼 더했을때 기준선보다 큰지확인
2969
                                        If Math.Abs(d기준x - dStartX) >= Math.Abs(d기준x - dEndX) Then
2970
                                            'EndX점이 기준선과 더 가까이 있음
2971
                                            If dStartX >= dEndX Then
2972
                                                '가로선의 왼쪽점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
2973
                                                If dEndX - dGap <= d기준x Then
2974
                                                    dEndX = d기준x
2975
                                                    sBranchType = "4"
2976
                                                    Return True
2977
                                                End If
2978
                                            Else
2979
                                                '가로선의 오른쪽점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
2980
                                                If dEndX + dGap >= d기준x Then
2981
                                                    dEndX = d기준x
2982
                                                    sBranchType = "4"
2983
                                                    Return True
2984
                                                End If
2985
2986
                                            End If
2987
                                        Else
2988
                                            'dStartX점이 기준선과 더 가까이 있음
2989
                                            If dStartX >= dEndX Then
2990
                                                '가로선의 오른쪽점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
2991
                                                If dStartX + dGap >= d기준x Then
2992
                                                    dStartX = d기준x
2993
                                                    sBranchType = "3"
2994
                                                    Return True
2995
                                                End If
2996
2997
                                            Else
2998
                                                '가로선의 왼쪽점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
2999
                                                If dStartX - dGap <= d기준x Then
3000
                                                    dStartX = d기준x
3001
                                                    sBranchType = "3"
3002
                                                    Return True
3003
                                                End If
3004
                                            End If
3005
                                        End If
3006
                                    End If
3007
3008
                                End If
3009
                            End If
3010
                        End If
3011
3012
                    End If
3013 79326880 Gyusu
                Else
3014 bb2a0c79 Gyusu
                    'Horizontal
3015
                    If Math.Abs(dModelStartX - dModelEndX) >= Math.Abs(dModelStartY - dModelEndY) Then
3016
                        'Vertical
3017
                        If Math.Abs(dStartX - dEndX) <= Math.Abs(dStartY - dEndY) Then
3018
                            '  dGap = 0.0015 'Math.Abs(dStartY - dEndY) / 80
3019
3020
                            '기준선의 X범위안에 세로선이 포함되어야됨
3021
                            If ((dModelStartX + dGap >= dStartX And dModelEndX - dGap <= dStartX) Or
3022
                            (dModelStartX - dGap <= dStartX And dModelEndX + dGap >= dStartX)) And
3023
                            ((dModelStartX + dGap >= dEndX And dModelEndX - dGap <= dEndX) Or
3024
                            (dModelStartX - dGap <= dEndX And dModelEndX + dGap >= dEndX)) Then
3025
3026
                                '가로선보다 아래에 세로선이 있을때
3027
                                If d기준y >= dStartY And d기준y >= dEndY Then
3028
                                    If dStartY >= dEndY Then
3029
                                        'dStartY 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3030
                                        If dStartY + dGap >= d기준y Then
3031
                                            dStartY = d기준y
3032
                                            sBranchType = "3"
3033
                                            Return True
3034
                                        End If
3035
                                    Else
3036
                                        'dEndY 좌표를 기준으로 Gap만큼 더했을때 기준선보다 큰지 확인
3037
                                        If dEndY + dGap >= d기준y Then
3038
                                            dEndY = d기준y
3039
3040
                                            If Math.Abs(dEndX - dModelStartX) > Math.Abs(dEndX - dModelEndX) Then
3041
                                                dEndX = dModelEndX
3042
                                            Else
3043
                                                dEndX = dModelStartX
3044
                                            End If
3045
3046
                                            sBranchType = "4"
3047
                                            Return True
3048
                                        End If
3049
                                    End If
3050
                                    '기준선보다 위에 세로선이 있을때
3051
                                ElseIf d기준y <= dStartY And d기준y <= dEndY Then
3052
                                    If dStartY >= dEndY Then
3053
                                        'dEndY 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3054
                                        If dEndY - dGap <= d기준y Then
3055
                                            dEndY = d기준y
3056
                                            sBranchType = "4"
3057
                                            Return True
3058
                                        End If
3059
                                    Else
3060
                                        'dStartY 좌표를 기준으로 Gap만큼 뺐을때 기준선보다 작은지 확인
3061
                                        If dStartY - dGap <= d기준y Then
3062
                                            dStartY = d기준y
3063
                                            sBranchType = "3"
3064
                                            Return True
3065
                                        End If
3066
                                    End If
3067
                                Else
3068
                                    '기준선과 세로선이 겹칠때
3069
                                    If (d기준y >= dStartY And d기준y <= dEndY) Or
3070
                                            (d기준y <= dStartY And d기준y >= dEndY) Then
3071
                                        '기준선이 dStartY와 dEndY중 어느쪽에 가까운지 확인
3072
                                        '세로선의 윗점과 기준선이 가까울때는 gap만큼 뺐을때 기준선보다 작은지확인
3073
                                        '세로선의 아래점과 기준선이 가까울때는 gap만큼 더했을때 기준선보다 큰지확인
3074
                                        If (dModelStartX <= dStartX And dModelEndX >= dEndX) Or
3075
                                            (dModelStartX >= dStartX And dModelEndX <= dEndX) Then
3076
                                            If Math.Abs(d기준y - dStartY) >= Math.Abs(d기준y - dEndY) Then
3077
                                                'Endy점이 기준선과 더 가까이 있음
3078
                                                If dStartY >= dEndY Then
3079
                                                    '세로선의 아래점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3080
                                                    If dEndY + dGap >= d기준y Then
3081
                                                        dEndY = d기준y
3082
                                                        sBranchType = "4"
3083
                                                        Return True
3084
                                                    End If
3085
                                                Else
3086
                                                    '세로선의 윗점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3087
                                                    If dEndY - dGap <= d기준y Then
3088
                                                        dEndY = d기준y
3089
                                                        sBranchType = "4"
3090
                                                        Return True
3091
                                                    End If
3092
                                                End If
3093
                                            Else
3094
                                                'dStartY점이 기준선과 더 가까이 있음
3095
                                                If dStartY >= dEndY Then
3096
                                                    '세로선의 윗점과 기준선이 가까우므로 gap만큼 뺐을때 기준선보다 작은지확인
3097
                                                    If dStartY - dGap <= d기준y Then
3098
                                                        dStartY = d기준y
3099
                                                        sBranchType = "3"
3100
                                                        Return True
3101
                                                    End If
3102
                                                Else
3103
                                                    '세로선의 아래점과 기준선이 가까우므로 gap만큼 더했을때 기준선보다 큰지확인
3104
                                                    If dStartY + dGap >= d기준y Then
3105
                                                        dStartY = d기준y
3106
                                                        sBranchType = "3"
3107
                                                        Return True
3108
                                                    End If
3109
                                                End If
3110
                                            End If
3111
                                        End If
3112
3113
                                    End If
3114
                                End If
3115
                            End If
3116
                        End If
3117
                    End If
3118
                End If
3119
            Next
3120
        Catch ex As Exception
3121
3122
        End Try
3123
        oLMConnector = Nothing
3124
        Return False
3125
    End Function
3126
3127 76f465d0 Gyusu
    Private Function CheckConnectionSymbolToSymbol(ByVal oModelingLineRows() As DataRow, ByRef dX As Double, ByRef dY As Double,
3128
                                  ByRef oLMConnector As LMConnector) As Boolean
3129
        Dim bConnectionFlag As Boolean = False
3130
        Try
3131
            For Each oModelrow In oModelingLineRows
3132
                Dim d기준x As Double = dX
3133
                Dim d기준y As Double = dY
3134
                Dim dGap As Double = 0.0002
3135
                Dim oRun As LMPipeRun = Nothing
3136
                Try
3137
                    Dim oLMSymbol As LMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3138
                    Dim dX1 As Double = 0.0
3139
                    Dim dY1 As Double = 0.0
3140
                    Dim dX2 As Double = 0.0
3141
                    Dim dY2 As Double = 0.0
3142
                    For Each oConnector In oLMSymbol.Connect1Connectors
3143
                        oLMConnector = oConnector
3144
                    Next
3145
                    '  oRun = _Placement.PIDDataSource.GetPipeRun(oLMSymbol.Connect1Connectors.Nth(1).ModelItemID)
3146
                    _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
3147
                    _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
3148
                    If Math.Abs(dX - dX1) < dGap And Math.Abs(dY - dY1) < dGap Then
3149
                        dX = dX1
3150
                        dY = dY1
3151
                        bConnectionFlag = True
3152
                        Exit For
3153
                    End If
3154
                    If Math.Abs(dX - dX2) < dGap And Math.Abs(dY - dY2) < dGap Then
3155
                        dX = dX2
3156
                        dY = dY2
3157
                        bConnectionFlag = True
3158
                        Exit For
3159
                    End If
3160
3161
                    'For Each oConnector In oLMSymbol.Connect1Connectors
3162
                    '    For Each objConnectorVertex In oConnector.ConnectorVertices
3163
                    '        Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3164
                    '        Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3165
                    '        If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3166
                    '            oLMConnector = oConnector
3167
                    '            dX = dConn_X
3168
                    '            dY = dConn_Y
3169
                    '            bConnectionFlag = True
3170
                    '            Exit For
3171
                    '        End If
3172
                    '    Next
3173
                    'Next
3174
3175
                    'For Each oConnector In oLMSymbol.Connect2Connectors
3176
                    '    For Each objConnectorVertex In oConnector.ConnectorVertices
3177
                    '        Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3178
                    '        Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3179
                    '        If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3180
                    '            oLMConnector = oConnector
3181
                    '            dX = dConn_X
3182
                    '            dY = dConn_Y
3183
                    '            bConnectionFlag = True
3184
                    '            Exit For
3185
                    '        End If
3186
                    '    Next
3187
                    'Next
3188
3189
3190
                    'If oRun IsNot Nothing Then
3191
                    '    Dim dResultCalc As Double = -1
3192
                    '    For Each objRep In oRun.Representations
3193
                    '        Dim sRepresentationType As String = objRep.Attributes("RepresentationType").Value
3194
                    '        If objRep.Attributes("RepresentationType").Value = "Connector" Or
3195
                    '            objRep.Attributes("RepresentationType").Value = "Symbol" And
3196
                    '             objRep.Attributes("ItemStatus").Value = "Active" Then
3197
                    '            Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
3198
                    '            For Each objConnectorVertex In objConnector.ConnectorVertices
3199
                    '                Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3200
                    '                Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3201
                    '                If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3202
                    '                    oLMConnector = objConnector
3203
                    '                    d기준x = dConn_X
3204
                    '                    d기준y = dConn_Y
3205
                    '                    bConnectionFlag = True
3206
                    '                    Exit For
3207
                    '                End If
3208
                    '            Next
3209
                    '        End If
3210
                    '    Next
3211
                    'End If
3212
3213
                Catch ex As Exception
3214
                End Try
3215
            Next
3216
3217
        Catch ex As Exception
3218
3219
        End Try
3220
        Return bConnectionFlag
3221
    End Function
3222
3223
    Private Function CheckConnectionSymbolToLine(ByVal oModelingLineRows() As DataRow, ByRef dX As Double, ByRef dY As Double,
3224
ByVal dCenterX As Double, ByVal dCenterY As Double, ByRef oLMConnector As LMConnector) As LMSymbol
3225
        Dim bConnectionFlag As Boolean = False
3226
        Dim oLMSymbol As LMSymbol = Nothing
3227
        Try
3228
3229 e38f99a7 Gyusu
            For Each oModelrow In _ModelingSymbol_Dt.Rows
3230
                Dim dMinx As Double = oModelrow(_XML_SYMBOL_MIN_X)
3231
                Dim dMaxx As Double = oModelrow(_XML_SYMBOL_MAX_X)
3232
                Dim dMiny As Double = oModelrow(_XML_SYMBOL_MIN_Y)
3233
                Dim dMaxy As Double = oModelrow(_XML_SYMBOL_MAX_Y)
3234 76f465d0 Gyusu
                Dim dGap As Double = 0.001
3235 e38f99a7 Gyusu
                If dMinx <= dX And dMaxx >= dX And dMiny <= dY And dMaxy >= dY Then
3236
                    oLMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3237 76f465d0 Gyusu
                    Dim dX1 As Double = 0.0
3238
                    Dim dY1 As Double = 0.0
3239
                    Dim dX2 As Double = 0.0
3240
                    Dim dY2 As Double = 0.0
3241 e38f99a7 Gyusu
                    Dim dX3 As Double = 0.0
3242
                    Dim dY3 As Double = 0.0
3243
                    Dim dX4 As Double = 0.0
3244
                    Dim dY4 As Double = 0.0
3245
                    Dim dX5 As Double = 0.0
3246
                    Dim dY5 As Double = 0.0
3247
                    Dim dX6 As Double = 0.0
3248
                    Dim dY6 As Double = 0.0
3249
                    Dim dX7 As Double = 0.0
3250
                    Dim dY7 As Double = 0.0
3251
                    Dim dX8 As Double = 0.0
3252
                    Dim dY8 As Double = 0.0
3253 76f465d0 Gyusu
                    _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
3254
                    _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
3255 e38f99a7 Gyusu
                    _Placement.PIDConnectPointLocation(oLMSymbol, 3, dX3, dY3)
3256
                    _Placement.PIDConnectPointLocation(oLMSymbol, 4, dX4, dY4)
3257
                    _Placement.PIDConnectPointLocation(oLMSymbol, 5, dX5, dY5)
3258
                    _Placement.PIDConnectPointLocation(oLMSymbol, 6, dX6, dY6)
3259
                    _Placement.PIDConnectPointLocation(oLMSymbol, 7, dX7, dY7)
3260
                    _Placement.PIDConnectPointLocation(oLMSymbol, 8, dX8, dY8)
3261
3262
                    If Math.Abs(dX - dX1) <= dGap And Math.Abs(dY - dY1) <= dGap Then
3263 76f465d0 Gyusu
                        dX = dX1
3264
                        dY = dY1
3265 e38f99a7 Gyusu
                    ElseIf Math.Abs(dX - dX2) <= dGap And Math.Abs(dY - dY2) <= dGap Then
3266 76f465d0 Gyusu
                        dX = dX2
3267
                        dY = dY2
3268 e38f99a7 Gyusu
                    ElseIf Math.Abs(dX - dX3) <= dGap And Math.Abs(dY - dY3) <= dGap Then
3269
                        dX = dX3
3270
                        dY = dY3
3271
                    ElseIf Math.Abs(dX - dX4) <= dGap And Math.Abs(dY - dY4) <= dGap Then
3272
                        dX = dX4
3273
                        dY = dY4
3274
                    ElseIf Math.Abs(dX - dX5) <= dGap And Math.Abs(dY - dY5) <= dGap Then
3275
                        dX = dX5
3276
                        dY = dY5
3277
                    ElseIf Math.Abs(dX - dX6) <= dGap And Math.Abs(dY - dY6) <= dGap Then
3278
                        dX = dX6
3279
                        dY = dY6
3280
                    ElseIf Math.Abs(dX - dX7) <= dGap And Math.Abs(dY - dY7) <= dGap Then
3281
                        dX = dX7
3282
                        dY = dY7
3283
                    ElseIf Math.Abs(dX - dX8) <= dGap And Math.Abs(dY - dY8) <= dGap Then
3284
                        dX = dX8
3285
                        dY = dY8
3286 76f465d0 Gyusu
                    End If
3287
                End If
3288
            Next
3289 b08338e3 Gyusu
3290 e38f99a7 Gyusu
3291
3292
            'For Each oModelrow In oModelingLineRows
3293
            '    Dim d기준x As Double = dCenterX
3294
            '    Dim d기준y As Double = dCenterY
3295
            '    Dim dGap As Double = 0.001
3296
            '    Dim oRun As LMPipeRun = Nothing
3297
            '    Dim dCheckGap As Double = 0
3298
            '    Try
3299
3300
            '        Dim dX1 As Double = 0.0
3301
            '        Dim dY1 As Double = 0.0
3302
            '        Dim dX2 As Double = 0.0
3303
            '        Dim dY2 As Double = 0.0
3304
            '        '  oRun = _Placement.PIDDataSource.GetPipeRun(oLMSymbol.Connect1Connectors.Nth(1).ModelItemID)
3305
            '        oLMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3306
            '        For Each oConnector In oLMSymbol.Connect1Connectors
3307
            '            oLMConnector = oConnector
3308
            '        Next
3309
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
3310
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
3311
            '        '  If Math.Abs(dX - dX1) < dGap And Math.Abs(dY - dY1) < dGap And
3312
            '        If Math.Abs(d기준x - dX1) < dCheckGap And Math.Abs(d기준y - dY1) < dCheckGap Or dCheckGap = 0 Then
3313
            '            dX = dX1
3314
            '            dY = dY1
3315
            '            bConnectionFlag = True
3316
            '            dCheckGap = Math.Abs(d기준x - dX1) + Math.Abs(d기준y - dY1)
3317
            '        End If
3318
            '        'If Math.Abs(dX - dX2) < dGap And Math.Abs(dY - dY2) < dGap And
3319
            '        '  Math.Abs(d기준x - dX2) < dCheckGap And Math.Abs(d기준y - dY2 < dCheckGap) Or dCheckGap = 0 Then
3320
            '        If Math.Abs(d기준x - dX2) < dCheckGap And Math.Abs(d기준y - dY2) < dCheckGap Or dCheckGap = 0 Then
3321
            '            dX = dX2
3322
            '            dY = dY2
3323
            '            bConnectionFlag = True
3324
            '        End If
3325
3326
            '    Catch ex As Exception
3327
            '    End Try
3328
            '    If bConnectionFlag Then
3329
            '        oLMSymbol = oModelrow(_XML_SYMBOL_LMSYMBOL)
3330
            '    Else
3331
            '        oLMSymbol = Nothing
3332
            '    End If
3333
            'Next
3334
3335 76f465d0 Gyusu
        Catch ex As Exception
3336 b08338e3 Gyusu
3337 76f465d0 Gyusu
        End Try
3338 b08338e3 Gyusu
3339 76f465d0 Gyusu
        Return oLMSymbol
3340
    End Function
3341 b08338e3 Gyusu
3342 3b7a4470 Gyusu
    ''' <summary>
3343
    ''' 라인과 라인이 만나는점이 브런치점인지 확인, 오차범위내 라인보정
3344
    ''' </summary>
3345
    ''' <param name="oModelingLineRows"></param>
3346
    ''' <param name="dStartX"></param>
3347
    ''' <param name="dStartY"></param>
3348
    ''' <param name="dEndX"></param>
3349
    ''' <param name="dEndY"></param>
3350
    ''' <param name="oLMConnector"></param>
3351
    ''' <returns></returns>
3352
    Private Function CheckBranchLine(ByVal oModelingLineRows As DataRowCollection, ByRef dStartX As Double, ByRef dStartY As Double,
3353
                                     ByRef dEndX As Double, ByRef dEndY As Double, ByRef oLMConnector As LMConnector) As String
3354
        Dim bConnectionFlag As Boolean = False
3355
        Dim sBranchDirection As String = ""
3356
        Try
3357
            For Each oModelrow In oModelingLineRows
3358
                Dim dModelStartX As Double
3359
                Dim dModelStartY As Double
3360
                Dim dModelEndX As Double
3361
                Dim dModelEndY As Double
3362 73bfb231 Gyusu
                Dim dGap As Double = 0.002
3363 3b7a4470 Gyusu
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3364
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3365
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3366
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3367
3368
                '기존라인이 X축방향이라면 현재선은 Y축방향이 되어야됨
3369
                If Math.Abs(dModelStartX - dModelEndX) > Math.Abs(dModelStartY - dModelEndY) And
3370
                    Math.Abs(dStartX - dEndX) < Math.Abs(dStartY - dEndY) Then
3371
3372
                    '기본라인의 X축영역안에 현재선이 있어야됨
3373
                    '      If dModelEndY > dModelStartY Then
3374
                    If (dStartX < dModelEndX And dStartX > dModelStartX) Or
3375
                            (dStartX > dModelEndX And dStartX < dModelStartX) Then
3376
                        '[오차범위 수정]
3377
                        '현재선의 Y축방향이 기존라인의 X축방향을 통과하는지 확인
3378
                        If dStartY < dEndY Then
3379
                            If dEndY > dModelStartY And dModelStartY > dStartY Then
3380
                                If dEndY - dModelStartY > dModelStartY - dStartY Then
3381
                                    '위쪽으로 라인이 나와있을때
3382
                                    '현재선 중 작은 Y좌표를 오차범위만큼 더했을때 기존라인의 Y축보다 큰지확인 
3383
                                    'Y축보다 클경우 작은 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 큰 Y좌표에 더한다.
3384 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3385 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartY - dStartY
3386
                                        dEndY = dEndY + dAddPoint
3387
                                        dStartY = dModelStartY
3388
                                        sBranchDirection = "START"
3389 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3390
                                        Exit For
3391 3b7a4470 Gyusu
                                    End If
3392
                                Else
3393
                                    '아래쪽으로 라인이 나와있을때
3394
                                    '현재선 중 큰 Y좌표를 오차범위만큼 뺐을때 기존라인의 Y축보다 작은지확인 
3395
                                    'Y축보다 작을경우 큰 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 작은 Y좌표에 뺀다.
3396 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3397 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dEndY - dModelStartY
3398
                                        dStartY = dStartY - dAddPoint
3399
                                        dEndY = dModelStartY
3400
                                        sBranchDirection = "END"
3401 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3402
                                        Exit For
3403 3b7a4470 Gyusu
                                    End If
3404
                                End If
3405
                            Else
3406
                                '현재선의 Y축방향이 기존라인의 X축방향에 못미치는지 확인
3407
                                If dStartY > dModelStartY Then
3408
                                    '기존라인보다 위쪽에 현재선이 있을때
3409 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3410 3b7a4470 Gyusu
                                        '오차범위만큼 작은 y좌표를 뺐을때 기존라인보다 아래쪽에 있을경우 오차보정
3411
                                        Dim dAddPoint As Double = dStartY - dModelStartY
3412
                                        dEndY = dEndY - dAddPoint
3413
                                        dStartY = dModelStartY
3414
                                        sBranchDirection = "START"
3415 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3416
                                        Exit For
3417 3b7a4470 Gyusu
                                    End If
3418
                                Else
3419
                                    '기존라인보다 아래쪽에 현재선이 있을때
3420 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3421 3b7a4470 Gyusu
                                        '오차범위만큼 큰 y좌표를 더했을때 기존라인보다 위쪽에 있을경우 오차보정
3422
                                        Dim dAddPoint As Double = dModelStartY - dEndY
3423
                                        dEndY = dModelStartY
3424
                                        dStartY = dStartY + dAddPoint
3425
                                        sBranchDirection = "END"
3426 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3427
                                        Exit For
3428 3b7a4470 Gyusu
                                    End If
3429
                                End If
3430
                            End If
3431
                        Else
3432
                            If dEndY < dModelStartY And dModelStartY < dStartY Then
3433
                                If dModelStartY - dEndY < dStartY - dModelStartY Then
3434
                                    '위쪽으로 라인이 나와있을때
3435
                                    '현재선 중 작은 Y좌표를 오차범위만큼 더했을때 기존라인의 Y축보다 큰지확인 
3436
                                    'Y축보다 클경우 작은 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 큰 Y좌표에 더한다.
3437 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3438 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartY - dEndY
3439
                                        dStartY = dStartY + dAddPoint
3440
                                        dEndY = dModelStartY
3441
                                        sBranchDirection = "END"
3442 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3443
                                        Exit For
3444 3b7a4470 Gyusu
                                    End If
3445
                                Else
3446
                                    '아래쪽으로 라인이 나와있을때
3447
                                    '현재선 중 큰 Y좌표를 오차범위만큼 뺐을때 기존라인의 Y축보다 작은지확인 
3448
                                    'Y축보다 작을경우 큰 Y좌표를 기존라인의 Y축에 맞추고 더한 길이만큼 작은 Y좌표에 뺀다.
3449 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3450 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dStartY - dModelStartY
3451
                                        dEndY = dEndY - dAddPoint
3452
                                        dStartY = dModelStartY
3453
                                        sBranchDirection = "START"
3454 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3455
                                        Exit For
3456 3b7a4470 Gyusu
                                    End If
3457
                                End If
3458
                            Else
3459
                                If dEndY > dModelStartY Then
3460
                                    '기존라인보다 우측에 현재선이 있을때
3461 73bfb231 Gyusu
                                    If Math.Abs(dEndY - dModelStartY) <= dGap Then
3462 3b7a4470 Gyusu
                                        '오차범위만큼 작은 x좌표를 뺐을때 기존라인보다 좌측에 있을경우 오차보정
3463
                                        Dim dAddPoint As Double = dEndY - dModelStartY
3464
                                        dStartY = dStartY - dAddPoint
3465
                                        dEndY = dModelStartY
3466
                                        sBranchDirection = "END"
3467 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3468
                                        Exit For
3469 3b7a4470 Gyusu
                                    End If
3470
                                Else
3471
                                    '기존라인보다 좌측에 현재선이 있을때
3472 73bfb231 Gyusu
                                    If Math.Abs(dStartY - dModelStartY) <= dGap Then
3473 3b7a4470 Gyusu
                                        '오차범위만큼 큰 x좌표를 더했을때 기존라인보다 우측에 있을경우 오차보정
3474
                                        Dim dAddPoint As Double = dModelStartY - dStartY
3475
                                        dStartY = dModelStartY
3476
                                        dEndY = dEndY + dAddPoint
3477
                                        sBranchDirection = "START"
3478 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3479
                                        Exit For
3480 3b7a4470 Gyusu
                                    End If
3481
                                End If
3482
                            End If
3483
                        End If
3484
                    End If
3485
                    '기존라인이 Y축방향이라면 현재선은 X축방향이 되어야됨
3486
                ElseIf Math.Abs(dModelStartX - dModelEndX) < Math.Abs(dModelStartY - dModelEndY) And
3487
                Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then
3488
3489
                    '기본라인의 Y축영역안에 현재선이 있어야됨
3490
                    '      If dModelEndY > dModelStartY Then
3491
                    If (dStartY < dModelEndY And dStartY > dModelStartY) Or
3492
                            (dStartY > dModelEndY And dStartY < dModelStartY) Then
3493
                        '[오차범위 수정]
3494
                        '현재선의 X축방향이 기존라인의 Y축방향을 통과하는지 확인
3495
                        If dStartX < dEndX Then
3496
                            If dEndX > dModelStartX And dModelStartX > dStartX Then
3497
                                If dEndX - dModelStartX > dModelStartX - dStartX Then
3498
                                    '우측으로 라인이 나와있을때
3499
                                    '현재선 중 작은 X좌표를 오차범위만큼 더했을때 기존라인의 X축보다 큰지확인 
3500
                                    'X축보다 클경우 작은 X좌표를 기존라인의 X축에 맞추고 더한 길이만큼 큰 X좌표에 더한다.
3501 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3502 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartX - dStartX
3503
                                        dEndX = dEndX + dAddPoint
3504
                                        dStartX = dModelStartX
3505
                                        sBranchDirection = "START"
3506 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3507
                                        Exit For
3508 3b7a4470 Gyusu
                                    End If
3509
                                Else
3510
                                    '좌측으로 라인이 나와있을때
3511
                                    '현재선 중 큰 X좌표를 오차범위만큼 뺐을때 기존라인의 X축보다 작은지확인 
3512
                                    'X축보다 작을경우 큰 X좌표를 기존라인의 X축에 맞추고 뺀 길이만큼 작은 X좌표에 뺀다.
3513 73bfb231 Gyusu
                                    If Math.Abs(dEndX - dModelStartX) <= dGap Then
3514 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dEndX - dModelStartX
3515
                                        dStartX = dStartX - dAddPoint
3516
                                        dEndX = dModelStartX
3517
                                        sBranchDirection = "END"
3518 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3519
                                        Exit For
3520 3b7a4470 Gyusu
                                    End If
3521
                                End If
3522
                            Else
3523
                                '현재선의 X축방향이 기존라인의 Y축방향에 못미치는지 확인
3524
                                If dStartX > dModelStartX Then
3525
                                    '기존라인보다 우측에 현재선이 있을때
3526 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3527 3b7a4470 Gyusu
                                        '오차범위만큼 작은 x좌표를 뺐을때 기존라인보다 좌측에 있을경우 오차보정
3528
                                        Dim dAddPoint As Double = dStartX - dModelStartX
3529
                                        dEndX = dEndX - dAddPoint
3530
                                        dStartX = dModelStartX
3531
                                        sBranchDirection = "START"
3532 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3533
                                        Exit For
3534 3b7a4470 Gyusu
                                    End If
3535
                                Else
3536
                                    '기존라인보다 좌측에 현재선이 있을때
3537 73bfb231 Gyusu
                                    If Math.Abs(dEndX - dModelStartX) <= dGap Then
3538 3b7a4470 Gyusu
                                        '오차범위만큼 큰 x좌표를 더했을때 기존라인보다 우측에 있을경우 오차보정
3539
                                        Dim dAddPoint As Double = dModelStartX - dEndX
3540
                                        dEndX = dModelStartX
3541
                                        dStartX = dStartX + dAddPoint
3542
                                        sBranchDirection = "END"
3543 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3544
                                        Exit For
3545 3b7a4470 Gyusu
                                    End If
3546
                                End If
3547
                            End If
3548
                        Else
3549
                            If dEndX < dModelStartX And dModelStartX < dStartX Then
3550
                                If dModelStartX - dEndX < dStartX - dModelStartX Then
3551
                                    '우측으로 라인이 나와있을때
3552
                                    '현재선 중 작은 X좌표를 오차범위만큼 더했을때 기존라인의 X축보다 큰지확인 
3553
                                    'X축보다 클경우 작은 X좌표를 기존라인의 X축에 맞추고 더한 길이만큼 큰 X좌에 더한다.
3554 73bfb231 Gyusu
                                    If Math.Abs(dModelStartX - dEndX) <= dGap Then
3555 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dModelStartX - dEndX
3556
                                        dStartX = dStartX + dAddPoint
3557
                                        dEndX = dModelStartX
3558
                                        sBranchDirection = "END"
3559 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3560
                                        Exit For
3561 3b7a4470 Gyusu
                                    End If
3562
                                Else
3563
                                    '좌측으로 라인이 나와있을때
3564
                                    '현재선 중 큰 X좌표를 오차범위만큼 뺐을때 기존라인의 X축보다 작은지확인 
3565
                                    'X축보다 작을경우 큰 X좌표를 기존라인의 X축에 맞추고 뺀 길이만큼 작은 X좌표에 뺀다.
3566 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3567 3b7a4470 Gyusu
                                        Dim dAddPoint As Double = dStartX - dModelStartX
3568
                                        dEndX = dEndX - dAddPoint
3569
                                        dStartX = dModelStartX
3570
                                        sBranchDirection = "START"
3571 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3572
                                        Exit For
3573 3b7a4470 Gyusu
                                    End If
3574
3575
                                End If
3576
                            Else
3577
                                If dEndX > dModelStartX Then
3578
                                    '기존라인보다 우측에 현재선이 있을때
3579 73bfb231 Gyusu
                                    If Math.Abs(dEndX - dModelStartX) <= dGap Then
3580 3b7a4470 Gyusu
                                        '오차범위만큼 작은 x좌표를 뺐을때 기존라인보다 좌측에 있을경우 오차보정
3581
                                        Dim dAddPoint As Double = dEndX - dModelStartX
3582
                                        dStartX = dStartX - dAddPoint
3583
                                        dEndX = dModelStartX
3584
                                        sBranchDirection = "END"
3585 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3586
                                        Exit For
3587 3b7a4470 Gyusu
                                    End If
3588
                                Else
3589
                                    '기존라인보다 좌측에 현재선이 있을때
3590 73bfb231 Gyusu
                                    If Math.Abs(dStartX - dModelStartX) <= dGap Then
3591 3b7a4470 Gyusu
                                        '오차범위만큼 큰 x좌표를 더했을때 기존라인보다 우측에 있을경우 오차보정
3592
                                        Dim dAddPoint As Double = dModelStartX - dStartX
3593
                                        dStartX = dModelStartX
3594
                                        dEndX = dEndX + dAddPoint
3595
                                        sBranchDirection = "START"
3596 73bfb231 Gyusu
                                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3597
                                        Exit For
3598 3b7a4470 Gyusu
                                    End If
3599
                                End If
3600
                            End If
3601
                        End If
3602
                    End If
3603
                End If
3604
            Next
3605
        Catch ex As Exception
3606
            bConnectionFlag = False
3607
            oLMConnector = Nothing
3608
        End Try
3609
        Return sBranchDirection
3610
3611
    End Function
3612
3613 79326880 Gyusu
    Private Function UpdateCheckBranchLine(ByRef dX As Double, ByRef dY As Double,
3614 1bfcc921 Gyusu
                                  ByRef oLMConnector As LMConnector, ByRef sUid As String) As Boolean
3615
        Dim bCheckBranchItem As Boolean = False
3616 79326880 Gyusu
        Dim iGapCheck As Integer = 0
3617
        Try
3618
            For Each oModelrow In _ModelingLine_Dt.Rows
3619
                Dim d기준x As Double = dX
3620
                Dim d기준y As Double = dY
3621
                Dim dGap As Double = 0.001
3622
                Dim oRun As LMPipeRun = Nothing
3623
                Dim dModelStartX As Double
3624
                Dim dModelStartY As Double
3625
                Dim dModelEndX As Double
3626
                Dim dModelEndY As Double
3627
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3628
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3629
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3630
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3631
                d기준x = (dModelStartX + dModelEndX) / 2
3632
                d기준y = (dModelStartY + dModelEndY) / 2
3633
3634
3635 1bfcc921 Gyusu
3636 79326880 Gyusu
                Dim dMax_X As Double = 0.0
3637
                Dim dMax_Y As Double = 0.0
3638
                Dim dMin_X As Double = 0.0
3639
                Dim dMin_Y As Double = 0.0
3640
                If dModelEndX > dModelStartX Then
3641
                    dMax_X = dModelEndX
3642
                    dMin_X = dModelStartX
3643
                Else
3644
                    dMax_X = dModelStartX
3645
                    dMin_X = dModelEndX
3646
                End If
3647
3648
                If dModelEndY > dModelStartY Then
3649
                    dMax_Y = dModelEndY
3650
                    dMin_Y = dModelStartY
3651
                Else
3652
                    dMax_Y = dModelStartY
3653
                    dMin_Y = dModelEndY
3654
                End If
3655
3656
                If dX <= dMax_X + dGap And dX >= dMin_X - dGap And
3657
                  dY <= dMax_Y + dGap And dY >= dMin_Y - dGap Then
3658
                    If Math.Abs(dMax_X - dMin_X) > Math.Abs(dMax_Y - dMin_Y) Then
3659
                        dY = dMax_Y
3660
                    Else
3661
                        dX = dMax_X
3662
                    End If
3663 1bfcc921 Gyusu
3664
3665
                    Try
3666
                        Dim sModelItemID As String = oModelrow(_XML_LINE_SPID).ToString()
3667
                        sUid = oModelrow(_XML_LINE_UID).ToString()
3668
                        oRun = _Placement.PIDDataSource.GetPipeRun(sModelItemID)
3669
                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3670
                    Catch ex As Exception
3671
                    End Try
3672
                    Try
3673
                        If oRun IsNot Nothing Then
3674
                            Dim dResultCalc As Double = -1
3675
3676
                            For Each objRep In oRun.Representations
3677
                                Dim sAttriName As String
3678
                                For Each objAttr In objRep.Attributes
3679
                                    sAttriName = objAttr.name
3680
                                Next
3681
                                If objRep.RepresentationType = "Connector" Then
3682
                                    Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
3683
                                    Dim sItemStatus As String = objConnector.Attributes("ItemStatus").Value
3684
                                    Dim sModelTypeName As String = objConnector.ModelItemObject.Attributes("ItemTypeName").Value
3685
3686
                                    'Dim dConn_SX As Double = 0
3687
                                    'Dim dConn_SY As Double = 0
3688
                                    'Dim dConn_EX As Double = 0
3689
                                    'Dim dConn_EY As Double = 0
3690
                                    Dim dConn_X As Double = 0
3691
                                    Dim dConn_Y As Double = 0
3692
                                    For Each objConnectorVertex In objConnector.ConnectorVertices
3693
                                        dConn_X = objConnectorVertex.Attributes("XCoordinate").Value
3694
                                        dConn_Y = objConnectorVertex.Attributes("YCoordinate").Value
3695
                                        'If dConn_SX = 0 Then
3696
                                        '    dConn_SX = objConnectorVertex.Attributes("XCoordinate").Value
3697
                                        '    dConn_SY = objConnectorVertex.Attributes("YCoordinate").Value
3698
                                        'Else
3699
                                        '    dConn_EX = objConnectorVertex.Attributes("XCoordinate").Value
3700
                                        '    dConn_EY = objConnectorVertex.Attributes("YCoordinate").Value
3701
                                        'End If
3702
                                        Dim dCalc As Double = Math.Abs(dConn_X - dX) + Math.Abs(dConn_Y - dY)
3703
                                        If dResultCalc = -1 Or dResultCalc > dCalc Then
3704
                                            dResultCalc = dCalc
3705
                                            oLMConnector = objConnector
3706
                                            bCheckBranchItem = True
3707
                                        End If
3708
3709
3710
3711
                                        'If dConn_EX <> 0 And dConn_EY <> 0 Then
3712
                                        '    If dConn_SX >= dX And dConn_EX <= dX And dConn_SY >= dY And dConn_EY <= dY Then
3713
                                        '        oLMConnector = objConnector
3714
                                        '        Exit For
3715
                                        '    ElseIf dConn_SX <= dX And dConn_EX >= dX And dConn_SY <= dY And dConn_EY >= dY Then
3716
                                        '        oLMConnector = objConnector
3717
                                        '        Exit For
3718
                                        '    Else
3719
                                        '        If dConn_EX > 0 Then
3720
                                        '            dConn_SX = dConn_EX
3721
                                        '            dConn_SY = dConn_EY
3722
                                        '        End If
3723
                                        '    End If
3724
                                        'End If
3725
3726
                                    Next
3727
                                    'If oLMConnector IsNot Nothing Then
3728
                                    '    Exit For
3729
                                    'End If
3730
                                End If
3731
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
3750
3751
3752
                    '    oUid = oModelrow(_XML_LINE_UID).ToString()
3753 b82166d4 Gyusu
                    ' Dim oID As String = oModelrow(_XML_LINE_SPID)
3754 1bfcc921 Gyusu
                    '    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3755 b82166d4 Gyusu
                    '    oID = oLMConnector.ModelItemID
3756
                    '  oLMConnector = _Placement.PIDDataSource.GetConnector(oID)
3757 1bfcc921 Gyusu
                    'If oLMConnector IsNot Nothing Then
3758
                    '    Exit For
3759
                    'End If
3760 79326880 Gyusu
                End If
3761
3762
3763
            Next
3764
        Catch ex As Exception
3765 1bfcc921 Gyusu
            bCheckBranchItem = False
3766 79326880 Gyusu
            oLMConnector = Nothing
3767
        End Try
3768 1bfcc921 Gyusu
        Return bCheckBranchItem
3769 79326880 Gyusu
    End Function
3770
3771 3b7a4470 Gyusu
    ''' <summary>
3772
    ''' 라인과 특정 포인트에 커넥션을 확인하는 메서드
3773
    ''' </summary>
3774
    ''' <param name="oModelingLineRows"></param>
3775
    ''' <param name="dX"></param>
3776
    ''' <param name="dY"></param>
3777
    ''' <param name="oLMConnector"></param>
3778
    ''' <param name="dPreConnX"></param>
3779
    ''' <param name="dPreConnY"></param>
3780
    ''' <returns></returns>
3781
3782 79326880 Gyusu
    Private Function CheckConnectionLine(ByRef dX As Double, ByRef dY As Double,
3783 b82166d4 Gyusu
                                  ByRef oLMConnector As LMConnector, ByRef sUid As String) As Boolean
3784 b08338e3 Gyusu
        Dim bConnectionFlag As Boolean = False
3785 76f465d0 Gyusu
        Dim iGapCheck As Integer = 0
3786 b08338e3 Gyusu
        Try
3787 79326880 Gyusu
            For Each oModelrow In _ModelingLine_Dt.Rows
3788 76f465d0 Gyusu
                Dim d기준x As Double = dX
3789
                Dim d기준y As Double = dY
3790 1bfcc921 Gyusu
                Dim dGap As Double = 0.001
3791 76f465d0 Gyusu
                Dim oRun As LMPipeRun = Nothing
3792 b08338e3 Gyusu
                Dim dModelStartX As Double
3793
                Dim dModelStartY As Double
3794
                Dim dModelEndX As Double
3795
                Dim dModelEndY As Double
3796 76f465d0 Gyusu
                dModelStartX = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3797
                dModelStartY = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3798
                dModelEndX = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3799
                dModelEndY = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3800
                d기준x = (dModelStartX + dModelEndX) / 2
3801
                d기준y = (dModelStartY + dModelEndY) / 2
3802 79326880 Gyusu
3803
                Dim bCheckEqual As Boolean = False
3804
                If dX <= dModelStartX + dGap And dX >= dModelStartX - dGap And
3805
                        dY <= dModelStartY + dGap And dY >= dModelStartY - dGap Then
3806
                    bCheckEqual = True
3807
                ElseIf dX <= dModelEndX + dGap And dX >= dModelEndX - dGap And
3808
                        dY <= dModelEndY + dGap And dY >= dModelEndY - dGap Then
3809
                    bCheckEqual = True
3810
                End If
3811
                If bCheckEqual Then
3812
                    Try
3813
                        oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
3814 b82166d4 Gyusu
                        sUid = oModelrow(_XML_LINE_UID)
3815 79326880 Gyusu
                        oRun = _Placement.PIDDataSource.GetPipeRun(oLMConnector.ModelItemID)
3816
                    Catch ex As Exception
3817
                    End Try
3818
                    Try
3819
                        If oRun IsNot Nothing Then
3820
                            Dim dResultCalc As Double = -1
3821
                            For Each objRep In oRun.Representations
3822
                                If objRep.Attributes("RepresentationType").Value = "Connector" And objRep.Attributes("ItemStatus").Value = "Active" Then
3823
                                    Dim objConnector As LMConnector = _Placement.PIDDataSource.GetConnector(objRep.ID)
3824
                                    For Each objConnectorVertex In objConnector.ConnectorVertices
3825
                                        Dim dConn_X As Double = objConnectorVertex.Attributes("XCoordinate").Value
3826
                                        Dim dConn_Y As Double = objConnectorVertex.Attributes("YCoordinate").Value
3827
                                        If Math.Abs(dX - dConn_X) < dGap And Math.Abs(dY - dConn_Y) < dGap Then
3828
                                            oLMConnector = objConnector
3829
                                            dX = dConn_X
3830
                                            dY = dConn_Y
3831
                                            bConnectionFlag = True
3832
                                        End If
3833
                                    Next
3834
                                End If
3835
                            Next
3836
                        End If
3837
                    Catch ex As Exception
3838
                    End Try
3839
                Else
3840
                End If
3841 b08338e3 Gyusu
            Next
3842
        Catch ex As Exception
3843 76f465d0 Gyusu
            bConnectionFlag = False
3844
            oLMConnector = Nothing
3845 b08338e3 Gyusu
        End Try
3846
        Return bConnectionFlag
3847
    End Function
3848
3849 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
3850
        '현재선의 방향을 보고 상대라인이 직교되는 방향인지 체크
3851
        '오차범위를 줘서 현재선을 통과하는지 체크
3852
        '통과하는 상대라인 갯수를 먼저 구한다음 라인 갯수만큼 라인을 그린다.
3853
        Dim bCheckBranchLine As Boolean = False
3854
        Dim sCurrentDirection As String = ""
3855
3856
        Dim oModel_Dt As New DataTable()
3857
        oModel_Dt.Columns.Add("X")
3858
        oModel_Dt.Columns.Add("Y")
3859
        oModel_Dt.Columns.Add("Type")
3860
        oModel_Dt.Columns.Add("SPID")
3861
        Dim dGap = 0.001
3862
        If Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then
3863
            sCurrentDirection = "X"
3864
            If dStartX > dEndX Then
3865
                Dim dTempX As Double = dEndX
3866
                dEndX = dStartX
3867
                dStartX = dTempX
3868
                Dim dTempY As Double = dEndY
3869
                dEndY = dStartY
3870
                dStartY = dTempY
3871
            End If
3872
            '현재선이 X축방향
3873
            Try
3874
                For Each oModelrow In _ModelingLine_Dt.Rows
3875
                    Dim dModelStart_X As Double = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3876
                    Dim dModelStart_Y As Double = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3877
                    Dim dModelEnd_X As Double = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3878
                    Dim dModelEnd_Y As Double = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3879
                    Dim sSPID As String = oModelrow(_XML_LINE_SPID)
3880
                    If dStartX < dModelStart_X And dStartX < dModelEnd_X And
3881
                       dEndX > dModelStart_X And dEndX > dModelEnd_X Then
3882
                        Dim dAddX As Double = 0
3883
                        Dim dAddY As Double = dModelStart_Y
3884
                        Dim sType As String = ""
3885
                        If dStartY = dModelStart_Y Then
3886
                            dAddX = dModelStart_X
3887
                        ElseIf dStartY = dModelEnd_Y Then
3888
                            dAddX = dModelEnd_X
3889
                        ElseIf dStartY <= dModelStart_Y + dGap And dStartY >= dModelStart_Y - dGap Then
3890
                            dAddX = dModelStart_X
3891
                            If dStartY > dModelStart_Y Then
3892
                                sType = "AddLine"
3893
                            End If
3894
                        ElseIf dStartY <= dModelEnd_Y + dGap And dStartY >= dModelEnd_Y - dGap Then
3895
                            dAddX = dModelEnd_X
3896
                            If dStartY > dModelEnd_Y Then
3897
                                sType = "AddLine"
3898
                            End If
3899
                        End If
3900
                        If dAddX <> 0 Then
3901
                            Dim oDatarow As DataRow = oModel_Dt.NewRow()
3902
                            oDatarow("X") = dAddX
3903
                            oDatarow("Y") = dAddY
3904
                            oDatarow("Type") = sType
3905
                            oDatarow("SPID") = sSPID
3906
                            oModel_Dt.Rows.Add(oDatarow)
3907
                        End If
3908
                    End If
3909
                Next
3910
            Catch ex As Exception
3911
            End Try
3912
        Else
3913
            '현재선이 y축방향
3914
            sCurrentDirection = "Y"
3915
            Try
3916
                For Each oModelrow In _ModelingLine_Dt.Rows
3917
                    Dim dModelStart_X As Double = oModelrow(_XML_LINE_DWG_STARTPOINT_X)
3918
                    Dim dModelStart_Y As Double = oModelrow(_XML_LINE_DWG_STARTPOINT_Y)
3919
                    Dim dModelEnd_X As Double = oModelrow(_XML_LINE_DWG_ENDPOINT_X)
3920
                    Dim dModelEnd_Y As Double = oModelrow(_XML_LINE_DWG_ENDPOINT_Y)
3921
                    Dim sSPID As String = oModelrow(_XML_LINE_SPID)
3922
                    If dStartY < dModelStart_Y And dStartY < dModelEnd_Y And
3923
                       dEndY > dModelStart_Y And dEndY > dModelEnd_Y Then
3924
                        Dim dAddX As Double = dModelStart_X
3925
                        Dim dAddY As Double = 0
3926
                        Dim sType As String = ""
3927
                        If dStartX = dModelStart_X Then
3928
                            dAddY = dModelStart_Y
3929
                        ElseIf dStartX = dModelEnd_X Then
3930
                            dAddY = dModelEnd_Y
3931
                        ElseIf dStartX <= dModelStart_X + dGap And dStartX >= dModelStart_X - dGap Then
3932
                            dAddY = dModelStart_Y
3933
                            If dStartX > dModelStart_X Then
3934
                                sType = "AddLine"
3935
                            End If
3936
                        ElseIf dStartX <= dModelEnd_X + dGap And dStartX >= dModelEnd_X - dGap Then
3937
                            dAddY = dModelEnd_Y
3938
                            If dStartX > dModelEnd_X Then
3939
                                sType = "AddLine"
3940
                            End If
3941
                        End If
3942
                        If dAddX <> 0 Then
3943
                            Dim oDatarow As DataRow = oModel_Dt.NewRow()
3944
                            oDatarow("X") = dAddX
3945
                            oDatarow("Y") = dAddY
3946
                            oDatarow("Type") = sType
3947
                            oDatarow("SPID") = sSPID
3948
                            oModel_Dt.Rows.Add(oDatarow)
3949
                        End If
3950
                    End If
3951
                Next
3952
            Catch ex As Exception
3953
            End Try
3954
        End If
3955
        If oModel_Dt.Rows.Count > 0 Then
3956
            If sCurrentDirection = "X" Then
3957
                'X좌표 정렬
3958
                oModel_Dt.DefaultView.Sort = "X desc"
3959
                oModel_Dt = oModel_Dt.DefaultView.ToTable(True)
3960
            Else
3961
                'Y좌표 정렬
3962
                oModel_Dt.DefaultView.Sort = "Y desc"
3963
                oModel_Dt = oModel_Dt.DefaultView.ToTable(True)
3964
            End If
3965
            Dim oLMConnector As LMConnector = Nothing
3966
            Dim oPreLMConnector As LMConnector = Nothing
3967
            Dim dStartFlag As Boolean = True
3968
            For Each oModelRow In oModel_Dt.Rows
3969
                Dim objInputs As PlaceRunInputs
3970
                objInputs = New PlaceRunInputs
3971
                Dim dX As Double = oModelRow("X")
3972
                Dim dY As Double = oModelRow("Y")
3973
                Dim sType As String = oModelRow("Type")
3974
                Dim sUid As String = ""
3975
                CheckConnectionLine(dX, dY, oLMConnector, sUid)
3976
                If oLMConnector IsNot Nothing Then
3977
                    If dStartFlag Then
3978
                        objInputs.AddPoint(dStartX, dStartY)
3979
                        objInputs.AddConnectorTarget(oLMConnector, dX, dY)
3980
                    Else
3981
                        objInputs.AddConnectorTarget(oPreLMConnector, dStartX, dStartY)
3982
                        objInputs.AddConnectorTarget(oLMConnector, dX, dY)
3983
                    End If
3984
                    oPreLMConnector = LineModeling(objInputs, sSystemPath)
3985
                    '모델링후 StartX를 현재 X로 변경
3986
                    dStartX = dX
3987
                    dStartY = dY
3988
                End If
3989
            Next
3990
            If oPreLMConnector IsNot Nothing Then
3991
                Dim objInputs As PlaceRunInputs
3992
                objInputs = New PlaceRunInputs
3993
                objInputs.AddConnectorTarget(oPreLMConnector, dStartX, dStartY)
3994
                objInputs.AddPoint(dEndX, dEndY)
3995
                LineModeling(objInputs, sSystemPath)
3996
            End If
3997
        End If
3998
        Return bCheckBranchLine
3999
    End Function
4000
4001
4002 b08338e3 Gyusu
    Private Function CheckLineBranch(ByVal oLine_Dt As DataTable, ByRef dX As Double, ByRef dY As Double,
4003
                                     ByVal sDirection As String, ByRef oLMConnector As LMConnector) As Boolean
4004
4005
        Dim oModelingLineRows() As DataRow = oLine_Dt.Select("[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And " &
4006
                                                                "[" & _XML_LINE_SPID & "] <> ''")
4007
4008
        Dim bConnectionFlag As Boolean = False
4009
        Try
4010
            For Each oModelrow In oModelingLineRows
4011
                Dim sStartPoint As String = oModelrow(_XML_LINE_STARTPOINT)
4012
                Dim sEndPoint As String = oModelrow(_XML_LINE_ENDPOINT)
4013
                Dim dModelStartX As Double
4014
                Dim dModelStartY As Double
4015
                Dim dModelEndX As Double
4016
                Dim dModelEndY As Double
4017
                ConvertPointBystring(sStartPoint, dModelStartX, dModelStartY)
4018
                ConvertPointBystring(sEndPoint, dModelEndX, dModelEndY)
4019
                ConvertPointByImage(dModelStartX, dModelStartY, _IMG_X, _IMG_Y)
4020
                ConvertPointByImage(dModelEndX, dModelEndY, _IMG_X, _IMG_Y)
4021
                Dim dGap As Double = 0.0002
4022
4023
                If Math.Abs(dModelStartX - dModelEndX) <= Math.Abs(dModelStartY - dModelEndY) Then
4024
                    'Vertical
4025
                    If sDirection = "X" Then
4026
                        'x Direction Line
4027
                        If (dModelStartY + dGap >= dY And dModelEndY - dGap <= dY) Or
4028
                        (dModelStartY - dGap <= dY And dModelEndY + dGap >= dY) Then
4029
                            If (dX > dModelStartX And dX < dModelEndX) Or (dX > dModelEndX And dX < dModelStartX) Then
4030
                                If Math.Abs(dX - dModelStartX) > Math.Abs(dX - dModelEndX) Then
4031
                                    dX = dModelEndX
4032
                                Else
4033
                                    dX = dModelStartX
4034
                                End If
4035
                                Try
4036
                                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
4037
                                Catch ex As Exception
4038
4039
                                End Try
4040
                                bConnectionFlag = True
4041
                            End If
4042
                        End If
4043
                    End If
4044
                Else
4045
                    'Horizontal 
4046
                    If sDirection = "Y" Then
4047
                        If (dModelStartX + dGap >= dX And dModelEndX - dGap <= dX) Or
4048
                       (dModelStartX - dGap <= dX And dModelEndX + dGap >= dX) Then
4049
                            If (dY > dModelStartY And dY < dModelEndY) Or (dY > dModelEndY And dY < dModelStartY) Then
4050
                                If Math.Abs(dY - dModelStartY) > Math.Abs(dY - dModelEndY) Then
4051
                                    dY = dModelEndY
4052
                                Else
4053
                                    dY = dModelStartY
4054
                                End If
4055
                                Try
4056
                                    oLMConnector = oModelrow(_XML_LINE_LMCONNECTOR)
4057
                                Catch ex As Exception
4058
                                End Try
4059
                                bConnectionFlag = True
4060
                            End If
4061
                        End If
4062
                    End If
4063
                End If
4064
            Next
4065
        Catch ex As Exception
4066
        End Try
4067
        Return bConnectionFlag
4068
    End Function
4069
    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,
4070
                              ByVal sLineNoUid As String, ByVal sLineUid As String, ByVal sSystemPath As String, ByRef oLMConnector As LMConnector) As Boolean
4071 76f465d0 Gyusu
        'Try
4072
        '    Dim oDatasource As Object = _Placement.PIDDataSource
4073
        '    Dim oPipeRun As LMPipeRun = Nothing
4074
        '    Dim objInputs As PlaceRunInputs
4075
        '    objInputs = New PlaceRunInputs
4076
        '    Dim objItem As LMAItem
4077
        '    '       Dim objConnector As LMConnector
4078
4079
        '    Dim oStartLineRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sStartLineUid & "' And " &
4080
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4081
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4082
        '    If oStartLineRow.Length = 0 Then
4083
        '        oStartLineRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sStartLineUid & "' And " &
4084
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4085
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4086
        '    End If
4087
        '    Dim oEndLineRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sEndLineUid & "' And " &
4088
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4089
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4090
4091
        '    oEndLineRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sEndLineUid & "' And " &
4092
        '                                                            "[" & _XML_LINE_DRAWING_TF & "] = 'TRUE' And" &
4093
        '                                                                  "[" & _XML_LINE_SPID & "] <> ''")
4094
        '    Dim sStartConnectionType As String = ""
4095
        '    Dim sEndConnectionType As String = ""
4096
4097
        '    Dim oStartLMConnector As LMConnector = Nothing
4098
        '    Dim oEndLMConnector As LMConnector = Nothing
4099
        '    Dim oDirectionLine As String = ""
4100
4101
        '    If Math.Abs(dStart_x - dEnd_x) > Math.Abs(dStart_y - dEnd_y) Then
4102
        '        oDirectionLine = "X"
4103
        '    Else
4104
        '        oDirectionLine = "Y"
4105
        '    End If
4106 b08338e3 Gyusu
4107 76f465d0 Gyusu
        '    Dim bCheckFlag As Boolean = False
4108 b08338e3 Gyusu
4109 76f465d0 Gyusu
        '    Dim bStartCheckFlag As Boolean = CheckConnectionLine(oStartLineRow, dStart_x, dStart_y, oStartLMConnector)
4110
        '    If bStartCheckFlag = False Then
4111
        '        bStartCheckFlag = CheckConnectionLine(oStartLineRow, dEnd_x, dEnd_y, oStartLMConnector)
4112
        '        bCheckFlag = True
4113
        '    End If
4114
        '    Dim bEndCheckFlag As Boolean = CheckConnectionLine(oEndLineRow, dEnd_x, dEnd_y, oEndLMConnector)
4115 b08338e3 Gyusu
4116 76f465d0 Gyusu
        '    If bEndCheckFlag = False Then
4117 b08338e3 Gyusu
4118 76f465d0 Gyusu
        '        bEndCheckFlag = CheckConnectionLine(oEndLineRow, dStart_x, dStart_y, oEndLMConnector)
4119
        '        bCheckFlag = True
4120
        '    End If
4121 b08338e3 Gyusu
4122 76f465d0 Gyusu
        '    If bStartCheckFlag = True And bEndCheckFlag = False Then
4123
        '        If bCheckFlag Then
4124
        '            objInputs.AddConnectorTarget(oStartLMConnector, dEnd_x, dEnd_y)
4125
        '            objInputs.AddPoint(dStart_x, dStart_y)
4126
        '        Else
4127
        '            objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
4128
        '            objInputs.AddPoint(dEnd_x, dEnd_y)
4129
        '        End If
4130
4131
        '    ElseIf bStartCheckFlag = False And bEndCheckFlag = True Then
4132
        '        If bCheckFlag Then
4133
4134
        '            objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
4135
        '            objInputs.AddPoint(dEnd_x, dEnd_y)
4136
        '        Else
4137
        '            objInputs.AddPoint(dStart_x, dStart_y)
4138
        '            objInputs.AddConnectorTarget(oStartLMConnector, dEnd_x, dEnd_y)
4139
        '        End If
4140
4141
        '    ElseIf bStartCheckFlag = True And bEndCheckFlag = True Then
4142
        '        objInputs.AddConnectorTarget(oStartLMConnector, dStart_x, dStart_y)
4143
        '        objInputs.AddConnectorTarget(oEndLMConnector, dEnd_x, dEnd_y)
4144
        '    Else
4145
        '        objInputs.AddPoint(dStart_x, dStart_y)
4146
        '        objInputs.AddPoint(dEnd_x, dEnd_y)
4147
        '    End If
4148
        '    SetListBoxItems(ListBox_Result, "Place Pipe..(" & dStart_x & "," & dStart_y & ") - (" & dEnd_x & "," & dEnd_y & ")..." & _iPipecnt & " count ")
4149
        '    _iPipecnt = _iPipecnt + 1
4150
        '    objItem = _Placement.PIDCreateItem(sSystemPath)
4151
        '    oLMConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4152 b08338e3 Gyusu
4153 76f465d0 Gyusu
        '    Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + sLineUid + "'")
4154
        '    If oUpdateRow.Length = 1 Then
4155
        '        oUpdateRow(0)(_XML_LINE_SPID) = oLMConnector.ModelItemID
4156
        '        oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = oLMConnector
4157 b08338e3 Gyusu
4158 76f465d0 Gyusu
        '        oUpdateRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4159
        '    End If
4160 b08338e3 Gyusu
4161 76f465d0 Gyusu
        '    oPipeRun = oDatasource.GetPipeRun(oLMConnector.ModelItemID)
4162
4163
        '    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4164
        '    If oAttributeRow.Length > 0 Then
4165
        '        For Each oAttribute In oAttributeRow
4166
        '            Try
4167
        '                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4168
        '                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4169
        '                If sPIDValue.Contains("'") Then
4170
        '                    sPIDValue = sPIDValue.Replace("'", """")
4171
        '                End If
4172
        '                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4173
        '                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4174
        '            Catch ex As Exception
4175
        '            End Try
4176
        '        Next
4177
        '        oPipeRun.Commit()
4178
        '    End If
4179
        '    Dim sID_1 As String = ""
4180
        '    Dim sID_2 As String = ""
4181
        '    If oStartLMConnector IsNot Nothing Then
4182
        '        sID_1 = oStartLMConnector.ModelItemID
4183
        '        sID_2 = oLMConnector.ModelItemID
4184
        '    ElseIf oEndLMConnector IsNot Nothing Then
4185
        '        sID_1 = oEndLMConnector.ModelItemID
4186
        '        sID_2 = oLMConnector.ModelItemID
4187
        '    End If
4188
        '    If sID_1 <> "" And sID_2 <> "" Then
4189
        '        Dim objSurvivorItem As LMAItem = Nothing
4190
        '        Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(sID_1)
4191
        '        Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(sID_2)
4192
        '        _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
4193
        '    End If
4194
        '    Return True
4195
        'Catch ex As Exception
4196
        '    Return False
4197
        'End Try
4198 b08338e3 Gyusu
4199
    End Function
4200
4201
    Private Function LineToLineModeling(ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable,
4202
                                        ByVal oAttribute_Dt As DataTable, ByVal sConnLineUid As String, ByVal sType As String,
4203
                                        ByRef oLMConnector As LMConnector) As String
4204
        Dim sReturnUid As String = ""
4205
        Try
4206
            Dim sLineUid As String = ""
4207
4208
            Dim iConnType As Integer = 0
4209
4210
            Dim sStartpoint As String = ""
4211
            Dim sEndpoint As String = ""
4212 bb2a0c79 Gyusu
            Dim dOriginalStart_x As Double = 0.0
4213
            Dim dOriginalStart_y As Double = 0.0
4214
            Dim dOriginalEnd_x As Double = 0.0
4215
            Dim dOriginalEnd_y As Double = 0.0
4216
4217 b08338e3 Gyusu
            Dim dStart_x As Double = 0
4218
            Dim dStart_y As Double = 0
4219
            Dim dEnd_x As Double = 0
4220
            Dim dEnd_y As Double = 0
4221
            Dim sStartLineUid As String = sConnLineUid
4222
            Dim sEndLineUid As String = ""
4223
            Dim sDirection As String = ""
4224
            Dim sSystemPath As String = GetPipeType(sType)
4225
4226
            Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" & sConnLineUid & "' And " &
4227
                                                                    "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4228
                                                                     "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4229
                                                                     "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4230
            If oPipeRow.Length > 0 Then
4231 bb2a0c79 Gyusu
                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4232
                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4233 e4000111 Gyusu
                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4234
                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4235 b08338e3 Gyusu
                ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4236
                ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4237
                If dStart_x = 0 And dStart_y = 0 Then
4238
                    dStart_x = dOriginalStart_x
4239
                    dStart_y = dOriginalStart_y
4240
                    dEnd_x = dOriginalEnd_x
4241
                    dEnd_y = dOriginalEnd_y
4242
                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4243
                        sDirection = "X"
4244
                    Else
4245
                        sDirection = "Y"
4246
                    End If
4247
                    oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4248
                    sLineUid = sConnLineUid
4249
                End If
4250
            End If
4251 bb2a0c79 Gyusu
4252 b08338e3 Gyusu
            While True
4253
                sLineUid = ""
4254
                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sConnLineUid + "' And " &
4255 f9b63682 Gyusu
                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4256
                                            "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4257
                                            "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4258 b08338e3 Gyusu
4259
                If oPipeRow.Length = 0 Then
4260
                    oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sConnLineUid + "' And " &
4261 f9b63682 Gyusu
                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4262
                                            "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4263
                                            "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4264 bb2a0c79 Gyusu
                Else
4265 b08338e3 Gyusu
                    'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4266
                    'sConnLineUid = sLineUid
4267
                    sLineUid = sConnLineUid
4268
                    sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4269
                    iConnType = 1
4270
                End If
4271
4272
                If oPipeRow.Length > 0 Then
4273
                    If sLineUid = "" Then
4274
                        'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4275
                        'sConnLineUid = sLineUid
4276
                        sLineUid = sConnLineUid
4277
                        sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4278
                        iConnType = 2
4279
                    End If
4280
                    If iConnType = 1 Then
4281
4282
                    ElseIf iConnType = 2 Then
4283
4284
                    End If
4285
                    sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4286
                    sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4287
                    ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4288
                    ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4289
                    ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4290
                    ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4291
4292
                    If dStart_x = 0 And dStart_y = 0 Then
4293
                        dStart_x = dOriginalStart_x
4294
                        dStart_y = dOriginalStart_y
4295
                        dEnd_x = dOriginalEnd_x
4296
                        dEnd_y = dOriginalEnd_y
4297
                        If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4298
                            sDirection = "X"
4299
                        Else
4300
                            sDirection = "Y"
4301
                        End If
4302
                        sType = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4303
                        sSystemPath = GetPipeType(sType)
4304
                    Else
4305
                        If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4306
                            If sDirection = "Y" Then
4307
                                '방향이 바꼈음 Y - > X
4308
                                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4309
                                sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4310
                                dStart_x = dOriginalStart_x
4311
                                dStart_y = dOriginalStart_y
4312
                                dEnd_x = dOriginalEnd_x
4313
                                dEnd_y = dOriginalEnd_y
4314
                                sStartLineUid = sConnLineUid
4315
                            Else
4316
                                dEnd_x = dOriginalEnd_x
4317
                                dEnd_y = dOriginalEnd_y
4318
                            End If
4319
                            sDirection = "X"
4320
                        Else
4321
                            If sDirection = "X" Then
4322
                                '방향이 바꼈음 X - > Y
4323
                                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4324
                                sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4325
                                dStart_x = dOriginalStart_x
4326
                                dStart_y = dOriginalStart_y
4327
                                dEnd_x = dOriginalEnd_x
4328
                                dEnd_y = dOriginalEnd_y
4329
                                sStartLineUid = sConnLineUid
4330
                            Else
4331
4332
                                dEnd_x = dOriginalEnd_x
4333
                                dEnd_y = dOriginalEnd_y
4334
                            End If
4335
                            sDirection = "Y"
4336
                        End If
4337
                    End If
4338
                    '            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4339
                Else
4340
                    If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then
4341
                        LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4342
                         sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4343
                    End If
4344
                    sReturnUid = sConnLineUid
4345
                    Exit While
4346
                End If
4347
            End While
4348
4349
            If sStartLineUid <> "" And sEndLineUid <> "" Then
4350
                LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4351
                             sLineNoUid, sLineUid, sSystemPath, oLMConnector)
4352
                dStart_x = 0
4353
                dStart_y = 0
4354
                dEnd_x = 0
4355
                dEnd_y = 0
4356
            End If
4357
        Catch ex As Exception
4358
4359
        End Try
4360
4361
        Return sReturnUid
4362
    End Function
4363
4364
4365
    'Private Function LineToLineModeling(ByVal sLineNoUid As String, ByVal oLine_Dt As DataTable,
4366
    '                                    ByVal oAttribute_Dt As DataTable, ByVal sConnLineUid As String, ByVal sType As String) As String
4367
    '    Dim sReturnUid As String = ""
4368
    '    Try
4369
    '        Dim sLineUid As String = ""
4370
4371
    '        Dim iConnType As Integer = 0
4372
4373
    '        Dim sStartpoint As String = ""
4374
    '        Dim sEndpoint As String = ""
4375
    '        Dim dOriginalStart_x As Double = 0.0
4376
    '        Dim dOriginalStart_y As Double = 0.0
4377
    '        Dim dOriginalEnd_x As Double = 0.0
4378
    '        Dim dOriginalEnd_y As Double = 0.0
4379
4380
    '        Dim dStart_x As Double = 0
4381
    '        Dim dStart_y As Double = 0
4382
    '        Dim dEnd_x As Double = 0
4383
    '        Dim dEnd_y As Double = 0
4384
    '        Dim sStartLineUid As String = sConnLineUid
4385
    '        Dim sEndLineUid As String = ""
4386
    '        Dim sDirection As String = ""
4387
    '        Dim sSystemPath As String = GetPipeType(sType)
4388
4389
    '        Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_UID & " = '" & sConnLineUid & "' And " &
4390
    '                                                                "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4391
    '                                                                 "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4392
    '                                                                 "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4393
    '        If oPipeRow.Length > 0 Then
4394
    '            sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4395
    '            sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4396
    '            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4397
    '            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4398
    '            ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4399
    '            ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4400
    '            If dStart_x = 0 And dStart_y = 0 Then
4401
    '                dStart_x = dOriginalStart_x
4402
    '                dStart_y = dOriginalStart_y
4403
    '                dEnd_x = dOriginalEnd_x
4404
    '                dEnd_y = dOriginalEnd_y
4405
    '                If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4406
    '                    sDirection = "X"
4407
    '                Else
4408
    '                    sDirection = "Y"
4409
    '                End If
4410
    '                oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4411
    '                sLineUid = sConnLineUid
4412
    '            End If
4413
    '        End If
4414
4415
    '        While True
4416
    '            sLineUid = ""
4417
    '            oPipeRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sConnLineUid + "' And " &
4418
    '                                                                "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4419
    '                                                                         "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4420
    '                                                                         "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4421
4422
    '            If oPipeRow.Length = 0 Then
4423
    '                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sConnLineUid + "' And " &
4424
    '                                         "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And" &
4425
    '                                       "[" & _XML_SYMBOL_Check & "] = 'TRUE' And " &
4426
    '                                      "[" & _XML_SYMBOL_TYPE & "] = '" & sType & "'")
4427
    '            Else
4428
    '                'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4429
    '                'sConnLineUid = sLineUid
4430
    '                sLineUid = sConnLineUid
4431
    '                sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4432
    '                iConnType = 1
4433
    '            End If
4434
4435
    '            If oPipeRow.Length > 0 Then
4436
    '                If sLineUid = "" Then
4437
    '                    'sLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4438
    '                    'sConnLineUid = sLineUid
4439
    '                    sLineUid = sConnLineUid
4440
    '                    sConnLineUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4441
    '                    iConnType = 2
4442
    '                End If
4443
    '                If iConnType = 1 Then
4444
4445
    '                ElseIf iConnType = 2 Then
4446
4447
    '                End If
4448
    '                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4449
    '                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4450
    '                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4451
    '                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4452
    '                ConvertPointByImage(dOriginalStart_x, dOriginalStart_y, _IMG_X, _IMG_Y)
4453
    '                ConvertPointByImage(dOriginalEnd_x, dOriginalEnd_y, _IMG_X, _IMG_Y)
4454
4455
4456
4457
    '                If dStart_x = 0 And dStart_y = 0 Then
4458
    '                    dStart_x = dOriginalStart_x
4459
    '                    dStart_y = dOriginalStart_y
4460
    '                    dEnd_x = dOriginalEnd_x
4461
    '                    dEnd_y = dOriginalEnd_y
4462
    '                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4463
    '                        sDirection = "X"
4464
    '                    Else
4465
    '                        sDirection = "Y"
4466
    '                    End If
4467
    '                    sType = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4468
    '                    sSystemPath = GetPipeType(sType)
4469
    '                Else
4470
    '                    If Math.Abs(dOriginalStart_x - dOriginalEnd_x) > Math.Abs(dOriginalStart_y - dOriginalEnd_y) Then
4471
    '                        If sDirection = "Y" Then
4472
    '                            '방향이 바꼈음 Y - > X
4473
    '                            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4474
    '                            sLineNoUid, sLineUid, sSystemPath)
4475
    '                            dStart_x = dOriginalStart_x
4476
    '                            dStart_y = dOriginalStart_y
4477
    '                            dEnd_x = dOriginalEnd_x
4478
    '                            dEnd_y = dOriginalEnd_y
4479
    '                            sStartLineUid = sConnLineUid
4480
    '                        Else
4481
    '                            dEnd_x = dOriginalEnd_x
4482
    '                            dEnd_y = dOriginalEnd_y
4483
    '                        End If
4484
    '                        sDirection = "X"
4485
    '                    Else
4486
    '                        If sDirection = "X" Then
4487
    '                            '방향이 바꼈음 X - > Y
4488
    '                            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4489
    '                            sLineNoUid, sLineUid, sSystemPath)
4490
    '                            dStart_x = dOriginalStart_x
4491
    '                            dStart_y = dOriginalStart_y
4492
    '                            dEnd_x = dOriginalEnd_x
4493
    '                            dEnd_y = dOriginalEnd_y
4494
    '                            sStartLineUid = sConnLineUid
4495
    '                        Else
4496
4497
    '                            dEnd_x = dOriginalEnd_x
4498
    '                            dEnd_y = dOriginalEnd_y
4499
    '                        End If
4500
    '                        sDirection = "Y"
4501
    '                    End If
4502
    '                End If
4503
    '                '            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4504
    '            Else
4505
    '                If dStart_x <> 0 And dStart_y <> 0 And dEnd_x <> 0 And dEnd_y <> 0 Then
4506
    '                    LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4507
    '                     sLineNoUid, sLineUid, sSystemPath)
4508
    '                End If
4509
4510
4511
    '                sReturnUid = sConnLineUid
4512
    '                Exit While
4513
    '            End If
4514
    '        End While
4515
4516
    '        If sStartLineUid <> "" And sEndLineUid <> "" Then
4517
    '            LineModeling(oLine_Dt, oAttribute_Dt, sStartLineUid, sEndLineUid, dStart_x, dStart_y, dEnd_x, dEnd_y,
4518
    '                         sLineNoUid, sLineUid, sSystemPath)
4519
    '            dStart_x = 0
4520
    '            dStart_y = 0
4521
    '            dEnd_x = 0
4522
    '            dEnd_y = 0
4523
    '        End If
4524
    '    Catch ex As Exception
4525
4526
    '    End Try
4527
4528
    '    Return sReturnUid
4529
    'End Function
4530
4531
4532
    Private Function SymbolToLine_Modeling(ByVal oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String,
4533
                                       ByVal sSymbolUid As String, ByVal oLMSymbol As LMSymbol) As String
4534
4535
4536
        Dim oDatasource As Object = _Placement.PIDDataSource
4537
        Dim oPipeRun As LMPipeRun = Nothing
4538
        Dim objItem As LMAItem
4539
        Dim objConnector As LMConnector
4540
        Dim objInputs As PlaceRunInputs
4541
        objInputs = New PlaceRunInputs
4542
4543
4544
        Dim sPipeUid As String = ""
4545
        Dim iConnType As Integer = 0
4546
        Dim sStartpoint As String = ""
4547
        Dim sEndpoint As String = ""
4548
        Dim dOriginalStart_x As Double = 0.0
4549
        Dim dOriginalStart_y As Double = 0.0
4550
        Dim dOriginalEnd_x As Double = 0.0
4551
        Dim dOriginalEnd_y As Double = 0.0
4552
        Dim dStart_x As Double = 0.0
4553
        Dim dStart_y As Double = 0.0
4554
        Dim dEnd_x As Double = 0.0
4555
        Dim dEnd_y As Double = 0.0
4556
4557
        Dim sReturnUid As String = ""
4558
        Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sSymbolUid + "' And " &
4559
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4560
                                                                                  _XML_SYMBOL_Check & "] = 'TRUE'")
4561
        If oPipeRow.Length = 0 Then
4562
            oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sSymbolUid + "' And " &
4563
                                     "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4564
                                    _XML_SYMBOL_Check & "] = 'TRUE'")
4565
        Else
4566
            sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4567
            iConnType = 1
4568
        End If
4569
4570
        If oPipeRow.Length = 1 Then
4571
            If sPipeUid = "" Then
4572
                sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4573
                iConnType = 2
4574
            End If
4575
            sReturnUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4576
            sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4577
            sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4578
            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4579
            dStart_x = dOriginalStart_x
4580
            dStart_y = dOriginalStart_y
4581
            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4582
            dEnd_x = dOriginalEnd_x
4583
            dEnd_y = dOriginalEnd_y
4584
            ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4585
            ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4586
            'OPC Connection Point가져와서 연결(2018-07-12)
4587
            If iConnType = 1 Then
4588
                FindNearPoint(oLMSymbol, dStart_x, dStart_y)
4589
                objInputs.AddSymbolTarget(oLMSymbol, dStart_x, dStart_y)
4590
                objInputs.AddPoint(dEnd_x, dEnd_y)
4591
            Else
4592
                FindNearPoint(oLMSymbol, dEnd_x, dEnd_y)
4593
                objInputs.AddSymbolTarget(oLMSymbol, dEnd_x, dEnd_y)
4594
                objInputs.AddPoint(dStart_x, dStart_y)
4595
            End If
4596
            oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4597
4598
            Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4599
            Dim sSystemPath As String = GetPipeType(sType)
4600
4601
4602
4603
4604
            objItem = _Placement.PIDCreateItem(sSystemPath)
4605
            objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4606
            oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
4607
            Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4608
            If oAttributeRow.Length > 0 Then
4609
                For Each oAttribute In oAttributeRow
4610
                    Try
4611
                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4612
                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4613
                        If sPIDValue.Contains("'") Then
4614
                            sPIDValue = sPIDValue.Replace("'", """")
4615
                        End If
4616
                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4617
                        oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4618
                    Catch ex As Exception
4619
                    End Try
4620
                Next
4621
                oPipeRun.Commit()
4622
            End If
4623
        End If
4624
        Return sReturnUid
4625
    End Function
4626
4627
    Private Function LineToSymbol_Modeling(ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String,
4628
                                       ByVal sLineUid As String, ByVal oLMConnector As LMConnector, ByRef oLMSymbol As LMSymbol) As String
4629
4630
4631
        Dim oDatasource As Object = _Placement.PIDDataSource
4632
        Dim objItem As LMAItem
4633
        Dim objConnector As LMConnector
4634
        Dim objInputs As PlaceRunInputs
4635
        objInputs = New PlaceRunInputs
4636
4637
4638
        Dim sSymbolUid As String = ""
4639
        Dim iConnType As Integer = 0
4640
        Dim dOriginalPoint_x As Double = 0.0
4641
        Dim dORiginalPoint_y As Double = 0.0
4642
        Dim dX As Double = 0.0
4643
        Dim dY As Double = 0.0
4644
        Dim sReturnUid As String = ""
4645
        Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn1_Uid & " = '" + sLineUid + "' And " &
4646
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4647
                                                                                  _XML_SYMBOL_Check & "] = 'TRUE'")
4648
        If oSymbolRow.Length = 0 Then
4649
            oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
4650
                                                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4651
                                                                                 _XML_SYMBOL_Check & "] = 'TRUE'")
4652
            If oSymbolRow.Length = 0 Then
4653
                oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
4654
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4655
                                                                          _XML_SYMBOL_Check & "] = 'TRUE'")
4656
                If oSymbolRow.Length = 0 Then
4657
                    oSymbolRow = oSymbol_Dt.Select(_XML_SYMBOL_Conn2_Uid & " = '" + sLineUid + "' And " &
4658
                                                   "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' " &
4659
                                                            _XML_SYMBOL_Check & "] = 'TRUE'")
4660
                    If oSymbolRow.Length = 0 Then
4661
4662
                    Else
4663
                        sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4664
                        iConnType = 4
4665
                    End If
4666
                Else
4667
                    sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4668
                    iConnType = 3
4669
                End If
4670
            Else
4671
                sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4672
                iConnType = 2
4673
            End If
4674
4675
        Else
4676
            sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4677
            iConnType = 1
4678
        End If
4679
4680
        If oSymbolRow.Length = 1 Then
4681
            If sSymbolUid = "" Then
4682
                sSymbolUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4683
                iConnType = 2
4684
            End If
4685
            sReturnUid = oSymbolRow(0)(_XML_SYMBOL_UID).ToString()
4686
            Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
4687
            ConvertPointBystring(sOriginalPoint, dOriginalPoint_x, dORiginalPoint_y)
4688
            dX = dOriginalPoint_x
4689
            dY = dORiginalPoint_y
4690
            ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
4691
            'OPC Connection Point가져와서 연결(2018-07-12)
4692
4693
            oSymbolRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4694
4695
            Dim sType As String = oSymbolRow(0)(_XML_LINE_TYPE).ToString()
4696
            Dim sSystemPath As String = GetPipeType(sType)
4697
4698
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, ExistingItem:=oLMConnector.AsLMAItem,
4699
          TargetItem:=oLMSymbol.AsLMAItem)
4700
4701
            Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4702
            If oAttributeRow.Length > 0 Then
4703
                For Each oAttribute In oAttributeRow
4704
                    Try
4705
                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4706
                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4707
                        If sPIDValue.Contains("'") Then
4708
                            sPIDValue = sPIDValue.Replace("'", """")
4709
                        End If
4710
                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4711
                        oLMSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
4712
                    Catch ex As Exception
4713
                    End Try
4714
                Next
4715
            End If
4716
        End If
4717
        Return sReturnUid
4718
    End Function
4719
4720
4721
    Private Sub OPCTOLineRouting(ByRef oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oOPCSymbol As LMSymbol,
4722
                            ByVal sOPCUid As String, ByVal sLineNoUid As String)
4723
        Try
4724
            Dim oDatasource As Object = _Placement.PIDDataSource
4725
            Dim objItem As LMAItem
4726
            Dim objConnector As LMConnector
4727
            Dim objInputs As PlaceRunInputs
4728
            objInputs = New PlaceRunInputs
4729
            Dim dOriginalStart_x As Double = 0.0
4730
            Dim dOriginalStart_y As Double = 0.0
4731
            Dim dOriginalEnd_x As Double = 0.0
4732
            Dim dOriginalEnd_y As Double = 0.0
4733
            Dim dStart_x As Double = 0.0
4734
            Dim dStart_y As Double = 0.0
4735
            Dim dEnd_x As Double = 0.0
4736
            Dim dEnd_y As Double = 0.0
4737
4738
            Dim oPipeRun As LMPipeRun = Nothing
4739
            Dim sStartpoint As String = ""
4740
            Dim sEndpoint As String = ""
4741
            Dim iConnType As Integer = 0
4742
            Dim oPipeRow() As DataRow = oLine_Dt.Select(_XML_LINE_Conn1_Uid & " = '" + sOPCUid + "' And [" &
4743
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
4744
            Dim sPipeUid As String = ""
4745
            If oPipeRow.Length = 0 Then
4746
                oPipeRow = oLine_Dt.Select(_XML_LINE_Conn2_Uid & " = '" + sOPCUid + "' And [" &
4747
                        _XML_SYMBOL_Check & "] = 'TRUE'")
4748
            Else
4749
                sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4750
                iConnType = 1
4751
            End If
4752
            Dim oAddUid_List As New List(Of String)
4753
            If oPipeRow.Length = 1 Then
4754
                If sPipeUid = "" Then
4755
                    sPipeUid = oPipeRow(0)(_XML_LINE_UID).ToString()
4756
                    iConnType = 2
4757
                End If
4758
                oAddUid_List.Add(sPipeUid)
4759
                sStartpoint = oPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4760
                sEndpoint = oPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4761
                ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4762
                dStart_x = dOriginalStart_x
4763
                dStart_y = dOriginalStart_y
4764
                ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4765
                dEnd_x = dOriginalEnd_x
4766
                dEnd_y = dOriginalEnd_y
4767
                ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4768
                ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4769
4770
                'OPC Connection Point가져와서 연결(2018-07-12)
4771
                If iConnType = 1 Then
4772
                    FindNearPoint(oOPCSymbol, dStart_x, dStart_y)
4773
                    objInputs.AddSymbolTarget(oOPCSymbol, dStart_x, dStart_y)
4774
                    objInputs.AddPoint(dEnd_x, dEnd_y)
4775
                Else
4776
                    FindNearPoint(oOPCSymbol, dEnd_x, dEnd_y)
4777
                    objInputs.AddSymbolTarget(oOPCSymbol, dEnd_x, dEnd_y)
4778 bb2a0c79 Gyusu
                    objInputs.AddPoint(dStart_x, dStart_y)
4779
                End If
4780
                oPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4781
4782
                While True
4783
                    '    objInputs.Clear()
4784
                    Dim oAddPipeRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" + sPipeUid + "' and " &
4785
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4786
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
4787
                    If oAddPipeRow.Length = 0 Then
4788
                        oAddPipeRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" + sPipeUid + "' and " &
4789
                                                                 "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4790
                                                                                       _XML_SYMBOL_Check & "] = 'TRUE'")
4791
                        sPipeUid = ""
4792
                    Else
4793
                        iConnType = 1
4794
                        sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4795
                    End If
4796
                    If oAddPipeRow.Length = 1 Then
4797
                        If sPipeUid = "" Then
4798
                            sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4799
                            iConnType = 2
4800
                        End If
4801
                        oAddUid_List.Add(sPipeUid)
4802
                        sStartpoint = oAddPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4803
                        sEndpoint = oAddPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4804
                        ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4805
                        dStart_x = dOriginalStart_x
4806
                        dStart_y = dOriginalStart_y
4807
                        ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4808
                        dEnd_x = dOriginalEnd_x
4809
                        dEnd_y = dOriginalEnd_y
4810
                        ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4811
                        ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4812
                        If iConnType = 1 Then
4813
                            objInputs.AddPoint(dEnd_x, dEnd_y)
4814
                            ' objInputs.AddPoint(dStart_x, dStart_y)
4815
                        Else
4816
                            'objInputs.AddConnectorTarget(objConnector, dStart_x, dStart_y)
4817
                            '  objInputs.AddPoint(dStart_x, dStart_y)
4818
                            '  objInputs.AddPoint(dEnd_x, dEnd_y)
4819
                            objInputs.AddPoint(dStart_x, dStart_y)
4820
                        End If
4821 e4000111 Gyusu
4822 bb2a0c79 Gyusu
                        oAddPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
4823
                    Else
4824
                        Exit While
4825
                    End If
4826 e4000111 Gyusu
4827 bb2a0c79 Gyusu
                End While
4828
                Dim sType As String = oPipeRow(0)(_XML_LINE_TYPE).ToString()
4829
                Dim sSystemPath As String = GetPipeType(sType)
4830 e4000111 Gyusu
4831 bb2a0c79 Gyusu
                objItem = _Placement.PIDCreateItem(sSystemPath)
4832
                objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4833
                For i = 0 To oAddUid_List.Count - 1
4834
                    Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + oAddUid_List(i) + "'")
4835
                    If oUpdateRow.Length = 1 Then
4836
                        oUpdateRow(0)(_XML_LINE_SPID) = objConnector.ModelItemID
4837
                        oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = objConnector
4838
                    End If
4839
                Next
4840
4841
4842
                oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
4843
                Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4844
                If oAttributeRow.Length > 0 Then
4845
                    For Each oAttribute In oAttributeRow
4846
                        Try
4847
                            Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4848
                            Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4849
                            If sPIDValue.Contains("'") Then
4850
                                sPIDValue = sPIDValue.Replace("'", """")
4851
                            End If
4852
                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4853
                            oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4854
                        Catch ex As Exception
4855
                        End Try
4856
                    Next
4857
                    oPipeRun.Commit()
4858
                End If
4859
4860
            End If
4861
4862
        Catch ex As Exception
4863
        End Try
4864
    End Sub
4865
4866
    Private Function AddUidList중복체크(ByVal sUidList As List(Of String), ByVal sAddUid As String) As Boolean
4867 e4000111 Gyusu
4868 bb2a0c79 Gyusu
        For Each sUid In sUidList
4869
            If sUid = sAddUid Then
4870
                Return False
4871
            End If
4872
        Next
4873
        Return True
4874
    End Function
4875
4876 b08338e3 Gyusu
    Private Sub LineRouting(ByRef oLine_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String, ByVal sLineNoText As String)
4877 bb2a0c79 Gyusu
        Try
4878
            Dim oDatasource As Object = _Placement.PIDDataSource
4879
            Dim objItem As LMAItem
4880
            Dim objConnector As LMConnector
4881
            Dim objInputs As PlaceRunInputs
4882
            objInputs = New PlaceRunInputs
4883
            Dim dOriginalStart_x As Double = 0.0
4884
            Dim dOriginalStart_y As Double = 0.0
4885
            Dim dOriginalEnd_x As Double = 0.0
4886
            Dim dOriginalEnd_y As Double = 0.0
4887
            Dim dStart_x As Double = 0.0
4888
            Dim dStart_y As Double = 0.0
4889
            Dim dEnd_x As Double = 0.0
4890
            Dim dEnd_y As Double = 0.0
4891
            Dim oPipeRun As LMPipeRun = Nothing
4892
            Dim sStartpoint As String = ""
4893
            Dim sEndpoint As String = ""
4894
            Dim iConnType As Integer = 0
4895
            Dim pLMConnector As LMConnector = Nothing
4896
            For Each oLinerow In oLine_Dt.Rows
4897
                objInputs.Clear()
4898 b08338e3 Gyusu
                Dim sCheck As String = oLinerow(_XML_LINE_DRAWING_TF).ToString()
4899
                If sCheck = "FALSE" Then
4900
                    Dim sUid As String = oLinerow(_XML_LINE_UID).ToString()
4901
                    sStartpoint = oLinerow(_XML_LINE_STARTPOINT).ToString()
4902
                    sEndpoint = oLinerow(_XML_LINE_ENDPOINT).ToString()
4903
                    ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4904
                    dStart_x = dOriginalStart_x
4905
                    dStart_y = dOriginalStart_y
4906
                    ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4907
                    dEnd_x = dOriginalEnd_x
4908
                    dEnd_y = dOriginalEnd_y
4909
                    ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4910
                    ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4911 bb2a0c79 Gyusu
4912 b08338e3 Gyusu
                    objInputs.AddPoint(dStart_x, dStart_y)
4913
                    objInputs.AddPoint(dEnd_x, dEnd_y)
4914 bb2a0c79 Gyusu
                    Dim sType As String = oLinerow(_XML_LINE_TYPE).ToString()
4915
                    Dim sSystemPath As String = GetPipeType(sType)
4916
                    objItem = _Placement.PIDCreateItem(sSystemPath)
4917
                    objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
4918 b08338e3 Gyusu
                    SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dOriginalStart_x & "," & dOriginalStart_y & ") - (" & dOriginalEnd_x & "," & dOriginalEnd_y & ")..." & _iPipecnt & " count ")
4919
4920
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
4921
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
4922
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oLinerow(_XML_SYMBOL_Conn1_Uid).ToString())
4923
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oLinerow(_XML_SYMBOL_Conn2_Uid).ToString())
4924
                    'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
4925
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dOriginalStart_x & "," & dOriginalStart_y)
4926
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dOriginalEnd_x & "," & dOriginalEnd_y)
4927
                    ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
4928
4929
                    _iPipecnt = _iPipecnt + 1
4930
                    oLinerow(_XML_LINE_SPID) = objConnector.ModelItemID
4931
                    oLinerow(_XML_LINE_LMCONNECTOR) = objConnector
4932
4933
                    oLinerow(_XML_LINE_DRAWING_TF) = "TRUE"
4934 bb2a0c79 Gyusu
                    oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
4935
4936
                    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
4937
                    If oAttributeRow.Length > 0 Then
4938
                        For Each oAttribute In oAttributeRow
4939
                            Try
4940
                                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
4941
                                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
4942
                                If sPIDValue.Contains("'") Then
4943
                                    sPIDValue = sPIDValue.Replace("'", """")
4944
                                End If
4945
                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
4946
                                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
4947
                            Catch ex As Exception
4948
                            End Try
4949
                        Next
4950
                        oPipeRun.Commit()
4951
                    End If
4952
                End If
4953
4954
4955
4956
4957
4958 b08338e3 Gyusu
                'Dim sPipeUid As String = oLinerow(_XML_LINE_UID).ToString()
4959
                'Dim sCheckModeling As Boolean = False
4960
                'objInputs.Clear()
4961
                'Dim oAddUid_List As New List(Of String)
4962
                'Try
4963
                '    Dim oAddPipeRow() As DataRow = oLine_Dt.Select("[" & _XML_LINE_Conn1_Uid & "] = '" + sPipeUid + "' and " &
4964
                '                                            "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4965
                '                                            _XML_SYMBOL_Check & "] = 'TRUE'")
4966
                '    If oAddPipeRow.Length = 0 Then
4967
                '        oAddPipeRow = oLine_Dt.Select("[" & _XML_LINE_Conn2_Uid & "] = '" + sPipeUid + "' and " &
4968
                '                                        "[" & _XML_LINE_DRAWING_TF & "] = 'FALSE' And [" &
4969
                '                                        _XML_SYMBOL_Check & "] = 'TRUE'")
4970
                '        sPipeUid = ""
4971
                '    Else
4972
                '        iConnType = 1
4973
                '        sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4974
                '    End If
4975
                '    If oAddPipeRow.Length = 1 Then
4976
                '        sCheckModeling = True
4977
                '        If sPipeUid = "" Then
4978
                '            sPipeUid = oAddPipeRow(0)(_XML_LINE_UID).ToString()
4979
                '            iConnType = 2
4980
                '        End If
4981
                '        If AddUidList중복체크(oAddUid_List, sPipeUid) Then
4982
                '            oAddUid_List.Add(sPipeUid)
4983
                '        End If
4984
                '        sStartpoint = oAddPipeRow(0)(_XML_LINE_STARTPOINT).ToString()
4985
                '        sEndpoint = oAddPipeRow(0)(_XML_LINE_ENDPOINT).ToString()
4986
                '        ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
4987
                '        dStart_x = dOriginalStart_x
4988
                '        dStart_y = dOriginalStart_y
4989
                '        ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
4990
                '        dEnd_x = dOriginalEnd_x
4991
                '        dEnd_y = dOriginalEnd_y
4992
                '        ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
4993
                '        ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
4994
                '        Dim sBranchType As String = ""
4995
                '        If (CheckBranchLine(oLine_Dt, dStart_x, dStart_y, dEnd_x, dEnd_y, sBranchType, pLMConnector)) Then
4996
                '            Try
4997
                '                If pLMConnector Is Nothing Then
4998
                '                    objInputs.AddPoint(dStart_x, dStart_y)
4999
                '                    objInputs.AddPoint(dEnd_x, dEnd_y)
5000
                '                Else
5001
                '                    If sBranchType = "1" Then
5002
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
5003
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
5004
                '                    ElseIf sBranchType = "2" Then
5005
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
5006
                '                        objInputs.AddPoint(dStart_x, dStart_y)
5007
                '                    ElseIf sBranchType = "3" Then
5008
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
5009
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
5010
                '                    ElseIf sBranchType = "4" Then
5011
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
5012
                '                        objInputs.AddPoint(dStart_x, dStart_y)
5013
                '                    End If
5014
                '                End If
5015
                '            Catch ex As Exception
5016
                '            End Try
5017
                '        Else
5018
                '            objInputs.AddPoint(dStart_x, dStart_y)
5019
                '            objInputs.AddPoint(dEnd_x, dEnd_y)
5020
                '        End If
5021
                '        oAddPipeRow(0)(_XML_LINE_DRAWING_TF) = "TRUE"
5022
                '    Else
5023
                '        Dim CheckTF As String = oLinerow(_XML_LINE_DRAWING_TF).ToString()
5024
                '        Dim CheckSelect As String = oLinerow(_XML_LINE_Check).ToString()
5025
                '        If CheckTF = "FALSE" And CheckSelect = "TRUE" Then
5026
                '            sPipeUid = oLinerow(_XML_LINE_UID).ToString()
5027
                '            oAddUid_List.Clear()
5028
                '            oAddUid_List.Add(sPipeUid)
5029
                '            sCheckModeling = True
5030
                '            sStartpoint = oLinerow(_XML_LINE_STARTPOINT).ToString()
5031
                '            sEndpoint = oLinerow(_XML_LINE_ENDPOINT).ToString()
5032
                '            ConvertPointBystring(sStartpoint, dOriginalStart_x, dOriginalStart_y)
5033
                '            dStart_x = dOriginalStart_x
5034
                '            dStart_y = dOriginalStart_y
5035
                '            ConvertPointBystring(sEndpoint, dOriginalEnd_x, dOriginalEnd_y)
5036
                '            dEnd_x = dOriginalEnd_x
5037
                '            dEnd_y = dOriginalEnd_y
5038
                '            ConvertPointByImage(dStart_x, dStart_y, _IMG_X, _IMG_Y)
5039
                '            ConvertPointByImage(dEnd_x, dEnd_y, _IMG_X, _IMG_Y)
5040
                '            Dim sBranchType As String = ""
5041
                '            If (CheckBranchLine(oLine_Dt, dStart_x, dStart_y, dEnd_x, dEnd_y, sBranchType, pLMConnector)) Then
5042
                '                Try
5043
                '                    If sBranchType = "1" Then
5044
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
5045
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
5046
                '                    ElseIf sBranchType = "2" Then
5047
                '                        objInputs.AddPoint(dStart_x, dStart_y)
5048
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
5049
                '                    ElseIf sBranchType = "3" Then
5050
                '                        objInputs.AddPoint(dEnd_x, dEnd_y)
5051
                '                        objInputs.AddConnectorTarget(pLMConnector, dStart_x, dStart_y)
5052
                '                    ElseIf sBranchType = "4" Then
5053
                '                        objInputs.AddPoint(dStart_x, dStart_y)
5054
                '                        objInputs.AddConnectorTarget(pLMConnector, dEnd_x, dEnd_y)
5055
                '                    End If
5056
                '                Catch ex As Exception
5057
5058
                '                End Try
5059
                '            Else
5060
                '                objInputs.AddPoint(dStart_x, dStart_y)
5061
                '                objInputs.AddPoint(dEnd_x, dEnd_y)
5062
                '            End If
5063
                '            oLinerow(_XML_LINE_DRAWING_TF) = "TRUE"
5064
                '        End If
5065
                '    End If
5066
                'Catch ex As Exception
5067
                'End Try
5068
                'If sCheckModeling Then
5069
                '    Dim sType As String = oLinerow(_XML_LINE_TYPE).ToString()
5070
                '    Dim sSystemPath As String = GetPipeType(sType)
5071
                '    objItem = _Placement.PIDCreateItem(sSystemPath)
5072
                '    objConnector = _Placement.PIDPlaceRun(objItem, objInputs)
5073
                '    For i = 0 To oAddUid_List.Count - 1
5074
                '        Dim oUpdateRow As DataRow() = oLine_Dt.Select(_XML_LINE_UID & " = '" + oAddUid_List(i) + "'")
5075
                '        If oUpdateRow.Length = 1 Then
5076
                '            oUpdateRow(0)(_XML_LINE_SPID) = objConnector.ModelItemID
5077
                '            oUpdateRow(0)(_XML_LINE_LMCONNECTOR) = objConnector
5078
                '        End If
5079
                '    Next
5080
5081
                '    oPipeRun = oDatasource.GetPipeRun(objConnector.ModelItemID)
5082
                '    oAddUid_List.Clear()
5083
5084
                '    Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
5085
                '    If oAttributeRow.Length > 0 Then
5086
                '        For Each oAttribute In oAttributeRow
5087
                '            Try
5088
                '                Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5089
                '                Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5090
                '                If sPIDValue.Contains("'") Then
5091
                '                    sPIDValue = sPIDValue.Replace("'", """")
5092
                '                End If
5093
                '                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5094
                '                oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
5095
                '            Catch ex As Exception
5096
                '            End Try
5097
                '        Next
5098
                '        oPipeRun.Commit()
5099
                '    End If
5100
5101
                '    If pLMConnector IsNot Nothing Then
5102
                '        Dim sID_1 As String = pLMConnector.ModelItemID
5103
                '        Dim sID_2 As String = objConnector.ModelItemID
5104
                '        Dim objSurvivorItem As LMAItem = Nothing
5105
                '        Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(sID_1)
5106
                '        Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(sID_2)
5107
                '        _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
5108
                '        '     oDatasource.CommitTransaction()
5109
                '        '_Placement.PIDAutoJoin(oPipeRun1.AsLMAItem, AutoJoinEndConstants.autoJoin_End, objSurvivorItem)
5110
                '        'oPipeRun1.Commit()
5111
                '        'oDatasource.CommitTransaction()
5112
                '        'objSurvivorItem = Nothing
5113
                '        '_Placement.PIDAutoJoin(oPipeRun2.AsLMAItem, AutoJoinEndConstants.autoJoin_Start, objSurvivorItem)
5114
                '        'oPipeRun2.Commit()
5115
                '        'oDatasource.CommitTransaction()
5116
                '    End If
5117
                '    sCheckModeling = False
5118
                '  End If
5119
            Next
5120 bb2a0c79 Gyusu
        Catch ex As Exception
5121
        End Try
5122
    End Sub
5123 e4000111 Gyusu
5124 b08338e3 Gyusu
5125
    Private Sub SymbolModeling(ByVal CDrawing As Drawing, ByVal oLine_DT As DataTable, ByVal oSymbolRow As DataRow, ByVal oAttribute_Dt As DataTable,
5126
                               ByVal sLineNoText As String)
5127 bb2a0c79 Gyusu
        Try
5128 b08338e3 Gyusu
5129
            Dim sCheckModeling As String = oSymbolRow(_XML_SYMBOL_DRAWING_TF).ToString()
5130
            If sCheckModeling = "FALSE" Then
5131
                Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5132
                Dim oSymbol As LMSymbol = Nothing
5133
                Dim sSPID As String = oSymbolRow(_XML_SYMBOL_SPID).ToString()
5134
                Dim sSystemPath As String = oSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
5135 bb2a0c79 Gyusu
                Dim oDatasource As Object = _Placement.PIDDataSource
5136
                Dim sSymbolCompType As String = oSymbolRow(_XML_SYMBOL_TYPE).ToString()
5137
                Dim dLocationX As Double = 0.0
5138
                Dim dLocationY As Double = 0.0
5139
                Dim dX As Double = 0.0
5140
                Dim dY As Double = 0.0
5141 b08338e3 Gyusu
                Dim sOriginalPoint As String = oSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
5142
                ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5143
                dX = dLocationX
5144
                dY = dLocationY
5145
                ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
5146
5147
                Dim dAngle As Double = oSymbolRow(_XML_SYMBOL_ANGLE)
5148
5149
5150
                'Dim oDatarow() As DataRow = oLine_DT.Select("[" & _XML_LINE_Conn1_Uid & "] = '" & sSymbolUid & "'")
5151
                'If oDatarow.Length = 0 Then
5152
                '    oDatarow = oLine_DT.Select("[" & _XML_LINE_Conn2_Uid & "] = '" & sSymbolUid & "'")
5153
                'End If
5154
                'Dim dFix_X As Double = 0.0
5155
                'Dim dFix_Y As Double = 0.0
5156
                'If oDatarow.Length > 0 Then
5157
                '    If dAngle <> 0 Then
5158
                '        sOriginalPoint = oDatarow(0)(_XML_LINE_STARTPOINT).ToString()
5159
                '        ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5160
5161
                '        ConvertPointByImage(dLocationX, dLocationY, _IMG_X, _IMG_Y)
5162
                '        dX = dLocationX
5163
                '    Else
5164
                '        sOriginalPoint = oDatarow(0)(_XML_LINE_STARTPOINT).ToString()
5165
                '        ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5166
                '        ConvertPointByImage(dLocationX, dLocationY, _IMG_X, _IMG_Y)
5167
                '        dY = dLocationY
5168
                '    End If
5169
5170
                'End If
5171
5172
5173
5174
                oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY,, dAngle)
5175
                SetListBoxItems(ListBox_Result, "Place Fitting.." & sSymbolUid & " (" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
5176
5177
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Fitting : " & sSymbolUid)
5178
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
5179
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString())
5180
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString())
5181
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection3 : " & oSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString())
5182
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection4 : " & oSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString())
5183
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
5184
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
5185
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Fitting Count : " & _iFittingcnt)
5186
5187
5188
                _iFittingcnt = _iFittingcnt + 1
5189
                oSymbolRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
5190
                Dim oAttributeRow() As DataRow
5191
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sSymbolUid + "'")
5192
                If oAttribute_Dt.Rows.Count > 0 Then
5193
5194 bb2a0c79 Gyusu
                    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
5195 b08338e3 Gyusu
                        Dim oInstrument As LMInstrument
5196
                        oInstrument = oDatasource.GetInstrument(oSymbol.ModelItemID)
5197 bb2a0c79 Gyusu
                        Try
5198
                            If oAttributeRow.Length > 0 Then
5199
                                For Each oAttribute In oAttributeRow
5200
                                    Try
5201
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5202
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5203
                                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5204
                                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
5205
                                    Catch ex As Exception
5206
                                    End Try
5207
                                Next
5208
                                oInstrument.Commit()
5209
                            End If
5210
                        Catch ex As Exception
5211
                        End Try
5212
                    Else
5213 b08338e3 Gyusu
                        Try
5214
                            If oAttributeRow.Length > 0 And oSymbol IsNot Nothing Then
5215
                                For Each oAttribute In oAttributeRow
5216
                                    Try
5217
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5218
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5219 e4000111 Gyusu
5220 b08338e3 Gyusu
                                        If sPIDAttribute = "SIZE" Then
5221
5222
                                            'Nominal diamter1,2속성이름뭔지 찾아봐야됨 (2018-07-20)
5223
                                            If sPIDValue.Contains("x") Then
5224
                                                Dim sSplitSize() As String = sPIDValue.Split("x")
5225
                                                If sSplitSize.Count > 1 Then
5226
                                                    'Connection Point와 연결되어 있는 라인을 가져와서 라인프로퍼티를 변경
5227
                                                    Dim oConnector_1 As LMConnector = Nothing
5228
                                                    Dim oConnector_2 As LMConnector = Nothing
5229
                                                    If oSymbol IsNot Nothing Then
5230
                                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5231
                                                            For Each Tconnector In oSymbol.Connect1Connectors
5232
                                                                If Tconnector.ItemStatus = "Active" Then
5233
                                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5234
                                                                        oConnector_1 = Tconnector
5235
                                                                    End If
5236
                                                                End If
5237
                                                            Next
5238
                                                        End If
5239
                                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5240
                                                            For Each Tconnector In oSymbol.Connect1Connectors
5241
                                                                If Tconnector.ItemStatus = "Active" Then
5242
                                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5243
                                                                        oConnector_2 = Tconnector
5244
                                                                    End If
5245
                                                                End If
5246
                                                            Next
5247
                                                        End If
5248
                                                    End If
5249
                                                    Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(oConnector_1.ModelItemID)
5250
                                                    Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(oConnector_2.ModelItemID)
5251
                                                    If dAngle = 3.14 Then
5252
                                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(1)
5253
                                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(0)
5254
                                                    Else
5255
                                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(0)
5256
                                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(1)
5257
                                                    End If
5258 e4000111 Gyusu
5259
5260 b08338e3 Gyusu
                                                End If
5261 e4000111 Gyusu
5262 b08338e3 Gyusu
                                            Else
5263
                                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5264
                                                oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5265
                                            End If
5266
                                        Else
5267
                                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5268
                                            oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5269
                                        End If
5270 e4000111 Gyusu
5271 b08338e3 Gyusu
                                    Catch ex As Exception
5272
                                    End Try
5273
                                Next
5274
                                oSymbol.Commit()
5275
                            End If
5276
                        Catch ex As Exception
5277
                        End Try
5278
                    End If
5279
                End If
5280 e4000111 Gyusu
5281
5282
5283 b08338e3 Gyusu
            End If
5284 e4000111 Gyusu
5285
5286
5287 b08338e3 Gyusu
            'Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
5288
            'Dim sConnTypeNo As String = ""
5289
            '' Line과 연결되어있는 Symbol인지 확인
5290
            'Dim oLine_Dt As DataTable = GetPipeFromConnection(CDrawing, sSymbolUid, sConnTypeNo)
5291
            ''Symbol과 연결되어 있는 Symbol인지 확인
5292
            'Dim oSymbol_Dt As DataTable = GetSymbolFromConnection(CDrawing, sSymbolUid, sConnTypeNo)
5293
            'Dim oSymbol As LMSymbol = Nothing
5294
            'Dim sSPID As String = oSymbolRow(_XML_SYMBOL_SPID).ToString()
5295
            'Dim sSystemPath As String = oSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
5296
            'Dim oDatasource As Object = _Placement.PIDDataSource
5297
            'Dim sSymbolCompType As String = oSymbolRow(_XML_SYMBOL_TYPE).ToString()
5298 e4000111 Gyusu
5299 b08338e3 Gyusu
            'Dim dAngle As Double = 0.0
5300
            'If IsNumeric(oSymbolRow(_XML_SYMBOL_ANGLE).ToString()) Then
5301
            '    dAngle = Double.Parse(oSymbolRow(_XML_SYMBOL_ANGLE).ToString())
5302
            'End If
5303 e4000111 Gyusu
5304 b08338e3 Gyusu
            'Dim dLocationX As Double = 0.0
5305
            'Dim dLocationY As Double = 0.0
5306
            'Dim dX As Double = 0.0
5307
            'Dim dY As Double = 0.0
5308
            'Dim sOriginalPoint As String = oSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
5309
            'ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY)
5310
            'dX = dLocationX
5311
            'dY = dLocationY
5312
            'ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
5313
            'Dim bCheckModeling As Boolean = False
5314
5315
            'If oLine_Dt.Rows.Count > 0 Then
5316
5317
            '    If sSPID <> "" Then
5318
            '        Dim dX1 As Double = 0
5319
            '        Dim dX2 As Double = 0
5320
            '        Dim dY1 As Double = 0
5321
            '        Dim dY2 As Double = 0
5322
            '        Dim oLMSymbol As LMSymbol = oDatasource.GetSymbol(sSPID)
5323
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
5324
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
5325
5326
            '        Dim dCalcPoint As Double = -1
5327
            '        Dim dModeling_X As Double = 0
5328
            '        Dim dModeling_Y As Double = 0
5329
            '        If dX1 <> 0 And dY1 <> 0 Then
5330
            '            dCalcPoint = Math.Abs(dX1 - dX) + Math.Abs(dY1 - dY)
5331
            '            dModeling_X = dX1
5332
            '            dModeling_Y = dY1
5333
            '        End If
5334
            '        If dX2 <> 0 And dY2 <> 0 Then
5335 e4000111 Gyusu
5336 b08338e3 Gyusu
            '            If (Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY) > dCalcPoint) Then
5337
            '                dCalcPoint = Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY)
5338
            '                dModeling_X = dX2
5339
            '                dModeling_Y = dY2
5340
            '            End If
5341
            '        End If
5342 e4000111 Gyusu
5343
5344
5345 b08338e3 Gyusu
            '        If dModeling_X <> 0 And dModeling_Y <> 0 Then
5346
            '            oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dModeling_X, dModeling_Y,, dAngle, ExistingItem:=oLMSymbol.AsLMAItem,
5347
            '                TargetItem:=oLMSymbol.AsLMRepresentation)
5348
            '            bCheckModeling = True
5349
            '        End If
5350 e4000111 Gyusu
5351
5352 b08338e3 Gyusu
            '    End If
5353
            'End If
5354
            'If oSymbol_Dt.Rows.Count > 0 Then
5355
            '    If sSPID <> "" Then
5356
            '        Dim dX1 As Double = 0
5357
            '        Dim dX2 As Double = 0
5358
            '        Dim dX3 As Double = 0
5359
            '        Dim dX4 As Double = 0
5360
            '        Dim dY1 As Double = 0
5361
            '        Dim dY2 As Double = 0
5362
            '        Dim dY3 As Double = 0
5363
            '        Dim dY4 As Double = 0
5364
            '        Dim oLMSymbol As LMSymbol = oDatasource.GetSymbol(sSPID)
5365
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 1, dX1, dY1)
5366
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 2, dX2, dY2)
5367
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 3, dX3, dY3)
5368
            '        _Placement.PIDConnectPointLocation(oLMSymbol, 4, dX4, dY4)
5369
5370
            '        Dim dCalcPoint As Double = -1
5371
            '        Dim dModeling_X As Double = 0
5372
            '        Dim dModeling_Y As Double = 0
5373
            '        If dX1 <> 0 And dY1 <> 0 Then
5374
            '            dCalcPoint = Math.Abs(dX1 - dX) + Math.Abs(dY1 - dY)
5375
            '            dModeling_X = dX1
5376
            '            dModeling_Y = dY1
5377
            '        End If
5378
            '        If dX2 <> 0 And dY2 <> 0 Then
5379 41e4023e Gyusu
5380 b08338e3 Gyusu
            '            If (Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY) > dCalcPoint) Then
5381
            '                dCalcPoint = Math.Abs(dX2 - dX) + Math.Abs(dY2 - dY)
5382
            '                dModeling_X = dX2
5383
            '                dModeling_Y = dY2
5384
            '            End If
5385
            '        End If
5386
            '        If dX3 <> 0 And dY3 <> 0 Then
5387
            '            If (Math.Abs(dX3 - dX) + Math.Abs(dY3 - dY) > dCalcPoint) Then
5388
            '                dCalcPoint = Math.Abs(dX3 - dX) + Math.Abs(dY3 - dY)
5389
            '                dModeling_X = dX3
5390
            '                dModeling_Y = dY3
5391
            '            End If
5392
            '        End If
5393
            '        If dX4 <> 0 And dY4 <> 0 Then
5394
            '            If (Math.Abs(dX4 - dX) + Math.Abs(dY4 - dY) > dCalcPoint) Then
5395
            '                dCalcPoint = Math.Abs(dX4 - dX) + Math.Abs(dY4 - dY)
5396
            '                dModeling_X = dX4
5397
            '                dModeling_Y = dY4
5398
            '            End If
5399
            '        End If
5400
            '        If dModeling_X <> 0 And dModeling_Y <> 0 Then
5401
            '            oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dModeling_X, dModeling_Y,, dAngle, ExistingItem:=oLMSymbol.AsLMAItem,
5402
            '                TargetItem:=oLMSymbol.AsLMRepresentation)
5403
            '            bCheckModeling = True
5404
            '        End If
5405 41e4023e Gyusu
5406 e4000111 Gyusu
5407 b08338e3 Gyusu
            '    End If
5408 e4000111 Gyusu
5409 b08338e3 Gyusu
            'End If
5410 e4000111 Gyusu
5411 b08338e3 Gyusu
            'If (oLine_Dt.Rows.Count = 0 And oSymbol_Dt.Rows.Count = 0) Or bCheckModeling = False Then
5412
            '    oSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
5413
            '    SetListBoxItems(ListBox_Result, "Place Fittings..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
5414
            '    _iFittingcnt = _iFittingcnt + 1
5415
            'End If
5416
            'Dim oAttributeRow() As DataRow
5417
            'oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sSymbolUid + "'")
5418
            'If oAttribute_Dt.Rows.Count > 0 Then
5419
5420
            '    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
5421
            '        Dim oInstrument As LMInstrument
5422
            '        oInstrument = oDatasource.GetInstrument(oSymbol.ModelItemID)
5423
            '        Try
5424
            '            If oAttributeRow.Length > 0 Then
5425
            '                For Each oAttribute In oAttributeRow
5426
            '                    Try
5427
            '                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5428
            '                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5429
            '                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5430
            '                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
5431
            '                    Catch ex As Exception
5432
            '                    End Try
5433
            '                Next
5434
            '                oInstrument.Commit()
5435
            '            End If
5436
            '        Catch ex As Exception
5437
            '        End Try
5438
            '    Else
5439
            '        Try
5440
            '            If oAttributeRow.Length > 0 And oSymbol IsNot Nothing Then
5441
            '                For Each oAttribute In oAttributeRow
5442
            '                    Try
5443
            '                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
5444
            '                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
5445
5446
            '                        If sPIDAttribute = "SIZE" Then
5447
5448
            '                            'Nominal diamter1,2속성이름뭔지 찾아봐야됨 (2018-07-20)
5449
            '                            If sPIDValue.Contains("x") Then
5450
            '                                Dim sSplitSize() As String = sPIDValue.Split("x")
5451
            '                                If sSplitSize.Count > 1 Then
5452
            '                                    'Connection Point와 연결되어 있는 라인을 가져와서 라인프로퍼티를 변경
5453
            '                                    Dim oConnector_1 As LMConnector = Nothing
5454
            '                                    Dim oConnector_2 As LMConnector = Nothing
5455
            '                                    If oSymbol IsNot Nothing Then
5456
            '                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5457
            '                                            For Each Tconnector In oSymbol.Connect1Connectors
5458
            '                                                If Tconnector.ItemStatus = "Active" Then
5459
            '                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5460
            '                                                        oConnector_1 = Tconnector
5461
            '                                                    End If
5462
            '                                                End If
5463
            '                                            Next
5464
            '                                        End If
5465
            '                                        If oSymbol.Connect1Connectors.Count >= 1 Then
5466
            '                                            For Each Tconnector In oSymbol.Connect1Connectors
5467
            '                                                If Tconnector.ItemStatus = "Active" Then
5468
            '                                                    If Tconnector.ModelItemObject.ItemTypeName = "PipeRun" Then
5469
            '                                                        oConnector_2 = Tconnector
5470
            '                                                    End If
5471
            '                                                End If
5472
            '                                            Next
5473
            '                                        End If
5474
            '                                    End If
5475
            '                                    Dim oPipeRun1 As LMPipeRun = oDatasource.GetPipeRun(oConnector_1.ModelItemID)
5476
            '                                    Dim oPipeRun2 As LMPipeRun = oDatasource.GetPipeRun(oConnector_2.ModelItemID)
5477
            '                                    If dAngle = 3.14 Then
5478
            '                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(1)
5479
            '                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(0)
5480
            '                                    Else
5481
            '                                        oPipeRun1.Attributes("NominalDiameter").Value = sSplitSize(0)
5482
            '                                        oPipeRun2.Attributes("NominalDiameter").Value = sSplitSize(1)
5483
            '                                    End If
5484
5485
5486
            '                                End If
5487
5488
            '                            Else
5489
            '                                Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5490
            '                                oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5491
            '                            End If
5492
            '                        Else
5493
            '                            Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
5494
            '                            oSymbol.Attributes(sSPPIDAttribute).Value = sPIDValue
5495
            '                        End If
5496
5497
            '                    Catch ex As Exception
5498
            '                    End Try
5499
            '                Next
5500
            '                oSymbol.Commit()
5501
            '            End If
5502
            '        Catch ex As Exception
5503
            '        End Try
5504
            '    End If
5505
            'End If
5506
        Catch ex As Exception
5507
        End Try
5508
    End Sub
5509 e4000111 Gyusu
5510
5511
5512
    Private Function AutoModeling() As Boolean
5513
        Try
5514 e38f99a7 Gyusu
            '_AllLine_DT = Line_Dt()
5515
            '_AllSymbol_DT = Symbol_Dt()
5516 79326880 Gyusu
            _ModelingLine_Dt = Line_Dt()
5517 e38f99a7 Gyusu
            _ModelingSymbol_Dt = Symbol_Dt()
5518 e4000111 Gyusu
            _CompleteConvert = False
5519
            Label_Progress.Text = "0%"
5520
            SetListBoxItems(ListBox_Result, " Auto converting 시작....")
5521 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 시작....")
5522 e4000111 Gyusu
            Dim oDwg_Dt As DataTable = LoadAllDrawing()
5523 b08338e3 Gyusu
            _Log_File = "AutoConverting_" + DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmmss")
5524 e4000111 Gyusu
            _allItem = GetAllCheckNodeCount()
5525 76f465d0 Gyusu
            _Itemcnt = 0
5526 e4000111 Gyusu
            '1.Equipment
5527
            '2.Piping OPC
5528
            '3.OPC 시작되는 Line
5529 bb2a0c79 Gyusu
            InitAutoRouting()
5530 e4000111 Gyusu
            EquipmentModeling(oDwg_Dt)
5531 bb2a0c79 Gyusu
            PipingModeling()
5532
5533
            '   PipeLine_Fitting_Modeling()
5534 e4000111 Gyusu
5535 171ac39d Gyusu
            SetProgressbar(ProgressBar_Status, 100)
5536 41e4023e Gyusu
            Label_Progress.Text = "100%"
5537 171ac39d Gyusu
            SetListBoxItems(ListBox_Result, " Auto converting 완료")
5538 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 완료")
5539 54b98e09 Gyusu
            _CompleteConvert = True
5540 171ac39d Gyusu
            Return True
5541
        Catch ex As Exception
5542
            Return False
5543
        End Try
5544
    End Function
5545
5546
5547
5548 54b98e09 Gyusu
    Private Sub ThreadConvert()
5549 559daf6d Gyusu
        If _DrawingsList IsNot Nothing Then
5550
            If _DrawingsList.Count > 0 Then
5551 b82166d4 Gyusu
                'TestBranchLine()
5552 559daf6d Gyusu
                AutoModeling()
5553
            End If
5554 171ac39d Gyusu
        End If
5555 e282643f Gyusu
    End Sub
5556
5557 54b98e09 Gyusu
    Private Sub ThreadOPCRemove()
5558
        While _CompleteConvert = False
5559
            Dim oFindOPC As New FindOpc
5560
            oFindOPC.RemoveOPCDlg()
5561
        End While
5562 e282643f Gyusu
5563 54b98e09 Gyusu
    End Sub
5564 171ac39d Gyusu
5565 e282643f Gyusu
5566
    Private Function OpenDrawing(ByVal oDt As DataTable, ByVal sDwgName As String) As String
5567
        Dim oRows As DataRow() = oDt.Select("[Name] = '" & sDwgName & "'")
5568
        Dim oPath As String = ""
5569
        If oRows.Length > 0 Then
5570
            oPath = oRows(0).Item("Path").ToString()
5571
        End If
5572
        Return oPath
5573
    End Function
5574
5575 272662f9 Gyusu
    Private Sub LoadXmlToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadXmlToolStripMenuItem.Click
5576 3b7a4470 Gyusu
5577 171ac39d Gyusu
        If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
5578 54b98e09 Gyusu
            LoadDB()
5579 171ac39d Gyusu
            LoadXmlItem(FolderBrowserDialog1.SelectedPath)
5580
        End If
5581
    End Sub
5582
    Private Sub LoadXmlItem(ByVal sFolderPath As String)
5583
        _DrawingsList = New List(Of Drawing)
5584
        Dim sfileEntries As String() = Directory.GetFiles(sFolderPath)
5585
        If Tree_Result.Nodes.Count > 0 Then
5586
            Tree_Result.Nodes(0).Nodes.Clear()
5587
            For Each sfileName In sfileEntries
5588
                Dim sExtension As String = Path.GetExtension(sfileName)
5589
                If sExtension = ".xml" Then
5590
                    Dim sDwgName As String = Path.GetFileNameWithoutExtension(sfileName)
5591
                    Dim sDwgPath As String = sfileName
5592
                    Dim oNode As TreeNode = Tree_Result.Nodes(0).Nodes.Add(sDwgPath, sDwgName, 15)
5593
                    Dim oDwg As Drawing = AddSymbolItem(sDwgPath, oNode)
5594 bb2a0c79 Gyusu
5595 171ac39d Gyusu
                    _DrawingsList.Add(oDwg)
5596
                End If
5597
            Next
5598
            Tree_Result.Nodes(0).Expand()
5599
        End If
5600
    End Sub
5601 272662f9 Gyusu
5602 e4000111 Gyusu
    Private Sub GenerateRelation(ByRef oDwg_Ds As Drawing)
5603
        Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos
5604
        Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos
5605
        Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos
5606
        Dim oRelation As New GenerateRelation()
5607
        For Each oLinelist In oLineLists
5608 bb2a0c79 Gyusu
            oRelation.CalcLineConnectionItem_Equal(oLinelist.Dt_Line, oLineLists)
5609
            oRelation.CalcLineConnectionItem_NonEqual(oLinelist.Dt_Line, oLineLists)
5610
            oRelation.CalcSymbolConnectionItem_Equal(oLinelist.Dt_Symbol, oLineLists)
5611
            oRelation.CalcSymbolConnectionItem_NonEqual(oLinelist.Dt_Symbol, oLineLists)
5612 e4000111 Gyusu
        Next
5613
    End Sub
5614
5615
5616 20c84e05 Gyusu
    ''' <summary>
5617
    '''  XML Tree 구조 생성 
5618
    ''' </summary>
5619
    ''' <param name="sDwgPath"></param>
5620 171ac39d Gyusu
    Private Function AddSymbolItem(ByVal sDwgPath As String, ByVal oParentNode As TreeNode) As Drawing
5621
        Dim oDwg_Ds As Drawing = LoadSymbolInXml(sDwgPath)
5622 e4000111 Gyusu
5623 69558c5f Gyusu
5624
5625 76f465d0 Gyusu
        'SetConnectionInfo()
5626 b08338e3 Gyusu
        '  GenerateRelation(oDwg_Ds)
5627 e4000111 Gyusu
5628 54b98e09 Gyusu
        If oDwg_Ds IsNot Nothing Then
5629
            Dim oLineLists As List(Of Line_no) = oDwg_Ds.Line_nos
5630
5631
            Dim oEqpLists As List(Of Eqp_no) = oDwg_Ds.Eqp_nos
5632 3acffcee Gyusu
5633
            Dim oTrimLineLists As List(Of Line_no) = oDwg_Ds.TrimLine_nos
5634
5635 54b98e09 Gyusu
            Dim oPipe As Boolean = False
5636
            Dim oFitting As Boolean = False
5637
            'PipeLine 구분
5638
5639
            For Each oLinelist In oLineLists
5640
                Dim sLineNoUid As String = oLinelist.Uid
5641
                Dim sLineNo As String = oLinelist.Text
5642
                Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo)
5643
                For Each oLineRow In oLinelist.Dt_Line.Rows
5644
                    Dim sLineUid As String = oLineRow(_XML_LINE_UID)
5645
                    Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe")
5646 76f5e1a8 Gyusu
                    Dim bValidLine As Boolean = oLineRow(_XML_LINE_ValieLine)
5647 9c86a823 Gyusu
5648
5649 76f5e1a8 Gyusu
                    If bValidLine = False Then
5650
                        oLineNoNode.ForeColor = Color.Red
5651
                        oPipeNode.ForeColor = Color.Red
5652 9c86a823 Gyusu
                    Else
5653
5654
                        Dim bLineType As String = oLineRow(_XML_LINE_TYPE)
5655
                        Dim bLineColor As Color = GetPipeColor(bLineType)
5656
                        If bLineType <> "Primary" Then
5657 3e63328a Gyusu
                            '      MessageBox.Show("")
5658 9c86a823 Gyusu
                        End If
5659
                        oPipeNode.ForeColor = bLineColor
5660 76f5e1a8 Gyusu
                    End If
5661 54b98e09 Gyusu
                    oPipeNode.Tag = sLineNoUid
5662
                Next
5663
                For Each oSymbolRow In oLinelist.Dt_Symbol.Rows
5664
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5665
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
5666
                    Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName)
5667 9c86a823 Gyusu
5668 54b98e09 Gyusu
                    oSymbolNode.Tag = sLineNoUid
5669
                Next
5670
            Next
5671 3acffcee Gyusu
5672 54b98e09 Gyusu
            For Each oEqplist In oEqpLists
5673
                Dim sEqpUid As String = oEqplist.Uid
5674
                Dim sEqpNo As String = "EQUIPMENT"
5675
                Dim oEqpNode As TreeNode = oParentNode.Nodes.Add(sEqpUid, sEqpNo)
5676 d039e347 Gyusu
5677 54b98e09 Gyusu
5678
                For Each oSymbolRow In oEqplist.Dt_Equipment.Rows
5679
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5680
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
5681
                    Dim oSymbolNode As TreeNode = oEqpNode.Nodes.Add(sSymbolUid, sSymbolName)
5682
                    oSymbolNode.Tag = sEqpUid
5683
                Next
5684 171ac39d Gyusu
            Next
5685 3acffcee Gyusu
            Dim sTrimLine As String = "TrimLineNos"
5686
            Dim iTrimLinecnt As Integer = 1
5687
            For Each oTrimLinelist In oTrimLineLists
5688
                Dim sLineNoUid As String = oTrimLinelist.Uid
5689
                Dim sLineNo As String = sTrimLine & "_" & iTrimLinecnt
5690
                Dim oLineNoNode As TreeNode = oParentNode.Nodes.Add(sLineNoUid, sLineNo)
5691
                For Each oLineRow In oTrimLinelist.Dt_Line.Rows
5692
                    Dim sLineUid As String = oLineRow(_XML_LINE_UID)
5693
                    Dim oPipeNode As TreeNode = oLineNoNode.Nodes.Add(sLineUid, "Pipe")
5694 76f5e1a8 Gyusu
                    Dim bValidLine As Boolean = oLineRow(_XML_LINE_ValieLine)
5695
                    If bValidLine = False Then
5696
                        oLineNoNode.ForeColor = Color.Red
5697
                        oPipeNode.ForeColor = Color.Red
5698 9c86a823 Gyusu
                    Else
5699
                        Dim bLineType As String = oLineRow(_XML_LINE_TYPE)
5700
                        If bLineType <> "Primary" Then
5701 3e63328a Gyusu
                            '     MessageBox.Show("")
5702 9c86a823 Gyusu
                        End If
5703
                        Dim bLineColor As Color = GetPipeColor(bLineType)
5704
                        oPipeNode.ForeColor = bLineColor
5705 76f5e1a8 Gyusu
                    End If
5706 3acffcee Gyusu
                    oPipeNode.Tag = sLineNoUid
5707
                Next
5708
                For Each oSymbolRow In oTrimLinelist.Dt_Symbol.Rows
5709
                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID)
5710
                    Dim sSymbolName As String = oSymbolRow(_XML_SYMBOL_NAME)
5711
                    Dim oSymbolNode As TreeNode = oLineNoNode.Nodes.Add(sSymbolUid, sSymbolName)
5712
                    oSymbolNode.Tag = sLineNoUid
5713
                Next
5714
                iTrimLinecnt = iTrimLinecnt + 1
5715
            Next
5716
5717 54b98e09 Gyusu
        End If
5718
5719 171ac39d Gyusu
        Return oDwg_Ds
5720
    End Function
5721 272662f9 Gyusu
    Private Sub Tree_Result_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_Result.AfterCheck
5722
        If e.Node.Checked = True Then
5723
            For Each oNode As TreeNode In e.Node.Nodes
5724
                oNode.Checked = True
5725
            Next
5726
        Else
5727
            For Each oNode As TreeNode In e.Node.Nodes
5728
                oNode.Checked = False
5729
            Next
5730
        End If
5731
    End Sub
5732 171ac39d Gyusu
5733 559daf6d Gyusu
    Private Sub Btn_Setting_Click(sender As Object, e As EventArgs) Handles Btn_Setting.Click
5734
        Dim oSettings As Settings = New Settings()
5735
        oSettings.ShowDialog()
5736
    End Sub
5737 42c0013c Gyusu
5738 b82166d4 Gyusu
5739
    Private Sub TestBranchLine()
5740
        Dim objPlacement As Placement
5741
        objPlacement = New Placement
5742
        Dim PipeRunLocation As String
5743
        Dim objItem As LMAItem
5744
        Dim objConnector As LMConnector
5745
        Dim objInputs As PlaceRunInputs
5746
        Dim objSymbol As LMSymbol
5747
        Dim ValveLocation As String
5748
        PipeRunLocation = "\Piping\Routing\Process Lines\Primary Piping.sym"
5749
        objInputs = New PlaceRunInputs
5750
        objInputs.AddPoint(0.1, 0.1)
5751
        objInputs.AddPoint(0.2, 0.1)
5752
        objItem = objPlacement.PIDCreateItem(PipeRunLocation)
5753
        objConnector = objPlacement.PIDPlaceRun(objItem, objInputs)
5754
        ValveLocation = "\Piping\Valves\2 Way Common\Ball Valve.sym"
5755
        objSymbol = objPlacement.PIDPlaceSymbol(ValveLocation, 0.15, 0.3, , 1.57)
5756
        objInputs = New PlaceRunInputs
5757
        objInputs.AddConnectorTarget(objConnector, 0.15, 0.1)
5758
        '   objInputs.AddConnectorTarget(objConnector, 0.12, 0.1)
5759
        objInputs.AddPoint(0.15, 0.15)
5760
        objInputs.AddPoint(0.12, 0.15)
5761
        objInputs.AddPoint(0.12, 0.2)
5762
        objInputs.AddPoint(0.15, 0.2)
5763
        objInputs.AddSymbolTarget(objSymbol, 0.15, 0.3)
5764
        objItem = objPlacement.PIDCreateItem(PipeRunLocation)
5765
        objConnector = objPlacement.PIDPlaceRun(objItem, objInputs)
5766
5767
        objInputs = New PlaceRunInputs
5768
        objInputs.AddConnectorTarget(objConnector, 0.17, 0.1)
5769
        objInputs.AddPoint(0.17, 0.15)
5770
        objItem = objPlacement.PIDCreateItem(PipeRunLocation)
5771
        objConnector = objPlacement.PIDPlaceRun(objItem, objInputs)
5772
5773
        objInputs = New PlaceRunInputs
5774
        objInputs.AddConnectorTarget(objConnector, 0.19, 0.1)
5775
        objInputs.AddPoint(0.19, 0.15)
5776
        objItem = objPlacement.PIDCreateItem(PipeRunLocation)
5777
        objConnector = objPlacement.PIDPlaceRun(objItem, objInputs)
5778
5779
        objInputs = New PlaceRunInputs
5780
        objInputs.AddConnectorTarget(objConnector, 0.12, 0.1)
5781
        objInputs.AddPoint(0.12, 0.15)
5782
        objItem = objPlacement.PIDCreateItem(PipeRunLocation)
5783
        objConnector = objPlacement.PIDPlaceRun(objItem, objInputs)
5784
    End Sub
5785
5786 42c0013c Gyusu
    Private Sub Btn_TestNozzle_Click(sender As Object, e As EventArgs) Handles Btn_TestNozzle.Click
5787
5788
        Dim sVessel_ID As String = "841D5E640AE5421B9A017DDC2E87FF11"
5789
        Dim objVessel As LMVessel
5790
        objVessel = _Placement.PIDDataSource.GetVessel(sVessel_ID)
5791
        Dim oVesselLocation As LMLocations = objVessel.Locations
5792
        Dim symVessel As LMSymbol = _Placement.PIDDataSource.GetSymbol(objVessel.Representations.Nth(1).Id)
5793
        Dim XCoordinate As String = symVessel.Attributes("XCoordinate").Value
5794
        Dim YCoordinate As String = symVessel.Attributes("YCoordinate").Value
5795
        symVessel.Attributes("XCoordinate").Value = XCoordinate + 0.01
5796
        symVessel.Attributes("YCoordinate").Value = YCoordinate + 0.01
5797
        symVessel.Commit()
5798
        Dim sValve_ID As String = "DB7B0CA8A2664A6BA7A9615764BA62B0"
5799
        Dim objValve As LMSymbol
5800
        Dim objValves As LMPipingComp = _Placement.PIDDataSource.GetPipingComp(sValve_ID)
5801
5802
        objValve = _Placement.PIDDataSource.GetSymbol(objValves.Representations.Nth(1).Id)
5803
        objValve.Commit()
5804
        Dim dVesselX As Double = XCoordinate
5805
        Dim dVesselY As Double = YCoordinate
5806
        Dim X1 As Double, Y1 As Double, X2 As Double, Y2 As Double
5807
5808
        _Placement.PIDConnectPointLocation(objValve, 1, X1, Y1)
5809
5810
        _Placement.PIDConnectPointLocation(objValve, 2, X2, Y2)
5811
5812
        Dim nozzlename As String = "\Equipment Components\Nozzles\Flanged Nozzle.sym"
5813
        Dim dCalc_x As Double = 0
5814
        Dim dCalc_y As Double = 0
5815
5816
        If dVesselX - X2 > 0 Then
5817
            dCalc_x = dVesselX - (dVesselX - X2)
5818
        Else
5819
            dCalc_x = dVesselX + (X2 - dVesselX)
5820
        End If
5821
        If dVesselY - Y2 > 0 Then
5822
            dCalc_y = dVesselY - (dVesselY - Y2)
5823
        Else
5824
            dCalc_y = dVesselY + (Y2 - dVesselY)
5825
        End If
5826
5827
        Dim objNozzle As LMSymbol = _Placement.PIDPlaceSymbol(nozzlename, dCalc_x, dCalc_y,
5828
            TargetItem:=symVessel.AsLMRepresentation)
5829
5830
        Dim blnSuccess As Boolean = _Placement.PIDConnectPointLocation(objNozzle, 1, X1, Y1)
5831
        blnSuccess = _Placement.PIDConnectPointLocation(objNozzle, 2, X1, Y1)
5832
5833
        objValve = _Placement.PIDPlaceSymbol(objValve.FileName, X1, Y1, ExistingItem:=objValve.AsLMAItem,
5834
          TargetItem:=objNozzle.AsLMRepresentation)
5835
5836
5837
5838
    End Sub
5839 39d43554 Gyusu
5840
    Private Sub Btn_SymbolLibrary_Click(sender As Object, e As EventArgs) Handles Btn_SymbolLibrary.Click
5841
        Dim oMapping As New Mapping(_PIDSymbol_DB)
5842
        oMapping.Show()
5843
    End Sub
5844 41e4023e Gyusu
5845
    Private Sub Btn_Stop_Click(sender As Object, e As EventArgs) Handles Btn_Stop.Click
5846
        Try
5847
            SetListBoxItems(ListBox_Result, " Auto converting 중지....")
5848 b08338e3 Gyusu
            ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, " Auto converting 중지....")
5849 41e4023e Gyusu
            _Main_trd.Abort()
5850
            _Opc_trd.Abort()
5851
        Catch ex As Exception
5852
5853
        End Try
5854
    End Sub
5855 b08338e3 Gyusu
5856
    Private Sub AutoCheckTreeNode(ByVal iType As Integer, ByVal bCheck As Boolean)
5857
5858
        For Each oDrwing As TreeNode In Tree_Result.Nodes
5859
            For Each oDwgNode As TreeNode In oDrwing.Nodes
5860
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
5861
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
5862
                If CDrawing IsNot Nothing Then
5863
                    Dim iAllLineNoCount As Integer = Tree_Result.Nodes.Count ' GetCheckNodeCount(oLinenoNode)
5864
                    Dim iPipingOPC_count As Integer = 0 ' GetCheckNodeCount(oLinenoNode)
5865
                    For Each oNode As TreeNode In oDwgNode.Nodes
5866
                        Dim iItemcnt As Integer = 0
5867
                        Dim sNodeUid As String = oNode.Name
5868
                        Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
5869
5870
                        If iType = 0 Then 'Symbol
5871
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
5872
                            If CLineNo IsNot Nothing Then
5873
                                Dim oSymbol_Dt As DataTable = CLineNo.Dt_Symbol
5874
                                For Each oSymbolRow In oSymbol_Dt.Rows
5875
                                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
5876
                                    For Each oSymbolNode As TreeNode In oNode.Nodes
5877
                                        Dim sSymbolNodeUid As String = oSymbolNode.Name
5878
                                        If sSymbolNodeUid = sSymbolUid Then
5879
                                            oSymbolNode.Checked = bCheck
5880
                                            Exit For
5881
                                        End If
5882
                                    Next
5883
                                Next
5884
                            End If
5885
                            Dim TrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
5886
                            If TrimLineNo IsNot Nothing Then
5887
                                Dim oSymbol_Dt As DataTable = TrimLineNo.Dt_Symbol
5888
                                For Each oSymbolRow In oSymbol_Dt.Rows
5889
                                    Dim sSymbolUid As String = oSymbolRow(_XML_SYMBOL_UID).ToString()
5890
                                    For Each oSymbolNode As TreeNode In oNode.Nodes
5891
                                        Dim sSymbolNodeUid As String = oSymbolNode.Name
5892
                                        If sSymbolNodeUid = sSymbolUid Then
5893
                                            oSymbolNode.Checked = bCheck
5894
                                            Exit For
5895
                                        End If
5896
                                    Next
5897
                                Next
5898
                            End If
5899
                        End If
5900
                        If iType = 1 Then 'Line
5901
                            Dim CLineNo As Line_no = GetLineNo(CDrawing, sNodeUid)
5902
                            If CLineNo IsNot Nothing Then
5903
                                Dim oLine_Dt As DataTable = CLineNo.Dt_Line
5904
                                For Each oLineRow In oLine_Dt.Rows
5905
                                    Dim sLineUid As String = oLineRow(_XML_LINE_UID).ToString()
5906
                                    For Each oLineNode As TreeNode In oNode.Nodes
5907
                                        Dim sLineNodeUid As String = oLineNode.Name
5908
                                        If sLineNodeUid = sLineUid Then
5909
                                            oLineNode.Checked = bCheck
5910
                                            Exit For
5911
                                        End If
5912
                                    Next
5913
                                Next
5914
                            End If
5915
                            Dim TrimLineNo As Line_no = GetTrimLineNo(CDrawing, sNodeUid)
5916
                            If TrimLineNo IsNot Nothing Then
5917
                                Dim oLine_Dt As DataTable = TrimLineNo.Dt_Line
5918
                                For Each oLineRow In oLine_Dt.Rows
5919
                                    Dim sLineUid As String = oLineRow(_XML_SYMBOL_UID).ToString()
5920
                                    For Each oLineNode As TreeNode In oNode.Nodes
5921
                                        Dim sLineNodeUid As String = oLineNode.Name
5922
                                        If sLineNodeUid = sLineUid Then
5923
                                            oLineNode.Checked = bCheck
5924
                                            Exit For
5925
                                        End If
5926
                                    Next
5927
                                Next
5928
                            End If
5929
                        End If
5930
                        If iType = 2 Then 'Equipment
5931
                            Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid)
5932
                            If CEqpNo IsNot Nothing Then
5933
                                Dim oEqp_Dt As DataTable = CEqpNo.Dt_Equipment
5934
                                For Each oEqpRow In oEqp_Dt.Rows
5935
                                    Dim sEqpUid As String = oEqpRow(_XML_LINE_UID).ToString()
5936
                                    For Each oEqpNode As TreeNode In oNode.Nodes
5937
                                        Dim sEqpNodeUid As String = oEqpNode.Name
5938
                                        If sEqpNodeUid = sEqpUid Then
5939
                                            oEqpNode.Checked = bCheck
5940
                                            Exit For
5941
                                        End If
5942
                                    Next
5943
                                Next
5944
                            End If
5945
                        End If
5946
                    Next
5947
                End If
5948
            Next
5949
        Next
5950
5951
5952
    End Sub
5953
5954
5955
5956
    Private Sub Chk_Symbol_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Symbol.CheckedChanged
5957
        AutoCheckTreeNode(0, Chk_Symbol.Checked)
5958
    End Sub
5959
5960
    Private Sub Chk_Line_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Line.CheckedChanged
5961
        AutoCheckTreeNode(1, Chk_Line.Checked)
5962
    End Sub
5963
5964
    Private Sub Chk_Equipment_CheckedChanged(sender As Object, e As EventArgs) Handles Chk_Equipment.CheckedChanged
5965
        AutoCheckTreeNode(2, Chk_Equipment.Checked)
5966
    End Sub
5967 e282643f Gyusu
End Class
5968
5969
5970
Public Class DrawingInfo
5971
    Public mDrawingName As String
5972
    Public mSpID As String
5973
    Public mPath As String
5974 4f359afa Gyusu
End Class
5975 e282643f Gyusu
5976
5977
5978
클립보드 이미지 추가 (최대 크기: 500 MB)