프로젝트

일반

사용자정보

개정판 94c7557d

ID94c7557d1674c2b62126213ff6e635a1f4946e86
상위 cbd68817
하위 332b2280

gaqhf 이(가) 약 6년 전에 추가함

dev issue #707: backup 환경에서 개발하던 소스 전부 update

차이점 보기:

DTI_PID/SPPIDConverter/Main.vb
9 9

  
10 10
Public Class Main
11 11
    'Dim _Mapping_DB As DataTable = New DataTable()
12
    Dim _Mapping_DB As DataSet = New DataSet()
12
    Public _Mapping_DB As DataSet = New DataSet()
13 13
    Dim _Attribute_DB As DataTable = New DataTable()
14 14
    Dim _PIDSymbol_DB As DataTable = New DataTable()
15 15
    Dim _ResultModeling_DT As DataTable = New DataTable()
......
68 68
        End If
69 69
    End Sub
70 70

  
71
    Private Function GetDataFromMappingDB(ByVal sSymbolName As String, ByVal sColumn As String) As String
71
    Public Function GetDataFromMappingDB(ByVal sSymbolName As String, ByVal sColumn As String) As String
72 72
        Dim sValue As String = ""
73

  
74
        'Debug.WriteLine(_Mapping_DB.Tables.Count)
75

  
73 76
        For Each oDt As DataTable In _Mapping_DB.Tables
74 77
            If oDt.Rows.Count > 0 Then
75
                Dim oSelectRow() As DataRow = oDt.Select("[img_symbolname] = '" + sSymbolName + "'")
78
                Dim oSelectRow() As DataRow = oDt.Select("[Img_symbolname] = '" + sSymbolName + "'")
76 79
                If oSelectRow.Length = 1 Then
77 80
                    If sColumn = _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME Then
78 81
                        sValue = oSelectRow(0).Item("SYM FILE NAME").ToString()
......
114 117
                CDrawing.DwgName = oElement.Element(_XML_DWGNAME).Value
115 118
                CDrawing.Size = oElement.Element(_XML_DWGSIZE).Value
116 119
                SplitLocation(CDrawing.Size, _IMG_X, _IMG_Y)
117
                '' 이것이 무엇인지 확인 필요
118
                'CDrawing.Unit = oElement.Element(_XML_UNIT).Value
119 120

  
120 121
                CDrawing.LINES = LoadLines(oElement)
121 122
                CDrawing.SYMBOLS = LoadSymbols(oElement)
122 123
                CDrawing.LINENUMBERS = LoadLineNumbers(oElement)
123 124
                CDrawing.TRIMLINES = LoadTrimLines(oElement)
124

  
125

  
126
                'Dim oLineno_list As New List(Of Line_no)
127
                'Dim oEqp_list As New List(Of Eqp_no)
128
                'Dim oTrim_Lineno_list As New List(Of Line_no)
129
                'oLineno_list = LoadLineNo(oElement, _XML_CATEGORY_LINENO)
130
                'For Each oEqpNo As Object In oElement.Elements(_XML_CATEGORY_EQUIPMENT)
131
                '    Dim CEqp_no As Eqp_no = New Eqp_no()
132
                '    Dim oSymbol_Dt As DataTable = Symbol_Dt()
133
                '    Dim oAttribute_Dt As DataTable = Attribute_Dt()
134
                '    Dim sUid As String = ""
135
                '    For Each oSymbol As Object In oEqpNo.Elements(_XML_CATEGORY_SYMBOL)
136
                '        Try
137
                '            Dim oAddrow As DataRow = oSymbol_Dt.NewRow()
138
                '            Dim oEleObj As XElement
139
                '            Dim sParentName As String
140
                '            Dim sName As String
141
                '            Dim sLocation As String
142
                '            Dim sSize As String
143
                '            Dim sAngle As String
144
                '            Dim sOriginalPoint As String = ""
145
                '            Dim sConnectionPoint As String = ""
146
                '            Dim sConnectionUids As String = ""
147
                '            Dim sConnArray As String()
148
                '            Dim sSizeArray As String()
149
                '            Dim sLocationArray As String()
150
                '            Dim sChild As String = ""
151
                '            Dim dCenterPos_x As Double = 0.0
152
                '            Dim dCenterPos_y As Double = 0.0
153
                '            Dim dDwgCenterPos_x As Double = 0.0
154
                '            Dim dDwgCenterPos_y As Double = 0.0
155
                '            Dim dConn1Pos_x As Double = 0.0
156
                '            Dim dConn1Pos_y As Double = 0.0
157
                '            Dim dConn2Pos_x As Double = 0.0
158
                '            Dim dConn2Pos_y As Double = 0.0
159
                '            Dim dConn3Pos_x As Double = 0.0
160
                '            Dim dConn3Pos_y As Double = 0.0
161
                '            Dim dConn4Pos_x As Double = 0.0
162
                '            Dim dConn4Pos_y As Double = 0.0
163
                '            Dim dDwg_Conn1Pos_x As Double = 0.0
164
                '            Dim dDwg_Conn1Pos_y As Double = 0.0
165
                '            Dim dDwg_Conn2Pos_x As Double = 0.0
166
                '            Dim dDwg_Conn2Pos_y As Double = 0.0
167
                '            Dim dDwg_Conn3Pos_x As Double = 0.0
168
                '            Dim dDwg_Conn3Pos_y As Double = 0.0
169
                '            Dim dDwg_Conn4Pos_x As Double = 0.0
170
                '            Dim dDwg_Conn4Pos_y As Double = 0.0
171
                '            Dim sOwnerUid As String = ""
172
                '            oEleObj = oSymbol.Element(_XML_SYMBOL_UID)
173
                '            sUid = oEleObj.Value
174
                '            oEleObj = oSymbol.Element(_XML_SYMBOL_PARENT)
175
                '            sParentName = oEleObj.Value
176
                '            oEleObj = oSymbol.Element(_XML_SYMBOL_NAME)
177
                '            sName = oEleObj.Value
178
                '            oEleObj = oSymbol.Element(_XML_SYMBOL_LOCATION)
179
                '            sLocation = oEleObj.Value
180
                '            oEleObj = oSymbol.Element(_XML_SYMBOL_SIZE)
181
                '            sSize = oEleObj.Value
182
                '            oEleObj = oSymbol.Element(_XML_SYMBOL_ANGLE)
183
                '            sAngle = oEleObj.Value
184
                '            oEleObj = oSymbol.Element(_XML_SYMBOL_CONNECTIONPOINT)
185
                '            sConnectionPoint = oEleObj.Value
186
                '            oEleObj = oSymbol.Element(_XML_SYMBOL_CHILD)
187
                '            sChild = oEleObj.Value
188

  
189
                '            If sName = "NOZZLE" Then
190
                '                oEleObj = oSymbol.Element(_XML_SYMBOL_OWNER)
191
                '                sOwnerUid = oEleObj.Value
192
                '            End If
193
                '            Try
194
                '                oEleObj = oSymbol.Element(_XML_SYMBOL_ORIGINALPOINT)
195
                '                sOriginalPoint = oEleObj.Value
196
                '            Catch ex As Exception
197

  
198
                '            End Try
199
                '            oAddrow(_XML_SYMBOL_OWNER) = sOwnerUid
200
                '            oAddrow(_XML_SYMBOL_Conn1_Uid) = ""
201
                '            oAddrow(_XML_SYMBOL_Conn2_Uid) = ""
202
                '            oAddrow(_XML_SYMBOL_Conn3_Uid) = ""
203
                '            oAddrow(_XML_SYMBOL_Conn4_Uid) = ""
204
                '            ConvertPointBystring(sOriginalPoint, dCenterPos_x, dCenterPos_y)
205
                '            dDwgCenterPos_x = dCenterPos_x
206
                '            dDwgCenterPos_y = dCenterPos_y
207
                '            ConvertPointByImage(dDwgCenterPos_x, dDwgCenterPos_y, _IMG_X, _IMG_Y)
208
                '            oAddrow(_XML_SYMBOL_CENTERPOINT_X) = dCenterPos_x
209
                '            oAddrow(_XML_SYMBOL_CENTERPOINT_Y) = dCenterPos_y
210
                '            oAddrow(_XML_SYMBOL_DWG_CENTERPOINT_X) = dDwgCenterPos_x
211
                '            oAddrow(_XML_SYMBOL_DWG_CENTERPOINT_Y) = dDwgCenterPos_y
212
                '            sConnArray = sConnectionPoint.Split("/")
213
                '            sSizeArray = sSize.Split(",")
214
                '            sLocationArray = sLocation.Split(",")
215
                '            If sConnArray.Length > 4 Then
216
                '                MessageBox.Show(sConnArray.Length)
217
                '            End If
218
                '            For i = 0 To sConnArray.Length - 1
219
                '                If i = 0 Then
220
                '                    oAddrow(_XML_SYMBOL_Conn1_Point) = sConnArray(i)
221
                '                    ConvertPointBystring(sConnArray(i), dConn1Pos_x, dConn1Pos_y)
222
                '                    dDwg_Conn1Pos_x = dConn1Pos_x
223
                '                    dDwg_Conn1Pos_y = dConn1Pos_y
224
                '                    ConvertPointByImage(dDwg_Conn1Pos_x, dDwg_Conn1Pos_y, _IMG_X, _IMG_Y)
225
                '                    oAddrow(_XML_SYMBOL_CONN1_POINT_X) = dConn1Pos_x
226
                '                    oAddrow(_XML_SYMBOL_CONN1_POINT_Y) = dConn1Pos_y
227
                '                    oAddrow(_XML_SYMBOL_DWG_CONN1_POINT_X) = dDwg_Conn1Pos_x
228
                '                    oAddrow(_XML_SYMBOL_DWG_CONN1_POINT_Y) = dDwg_Conn1Pos_y
229
                '                ElseIf i = 1 Then
230
                '                    oAddrow(_XML_SYMBOL_Conn2_Point) = sConnArray(i)
231
                '                    ConvertPointBystring(sConnArray(i), dConn2Pos_x, dConn2Pos_y)
232
                '                    dDwg_Conn2Pos_x = dConn2Pos_x
233
                '                    dDwg_Conn2Pos_y = dConn2Pos_y
234
                '                    ConvertPointByImage(dDwg_Conn2Pos_x, dDwg_Conn2Pos_y, _IMG_X, _IMG_Y)
235
                '                    oAddrow(_XML_SYMBOL_CONN2_POINT_X) = dConn2Pos_x
236
                '                    oAddrow(_XML_SYMBOL_CONN2_POINT_Y) = dConn2Pos_y
237
                '                    oAddrow(_XML_SYMBOL_DWG_CONN2_POINT_X) = dDwg_Conn2Pos_x
238
                '                    oAddrow(_XML_SYMBOL_DWG_CONN2_POINT_Y) = dDwg_Conn2Pos_y
239
                '                ElseIf i = 2 Then
240
                '                    oAddrow(_XML_SYMBOL_Conn3_Point) = sConnArray(i)
241
                '                    ConvertPointBystring(sConnArray(i), dConn3Pos_x, dConn3Pos_y)
242
                '                    dDwg_Conn3Pos_x = dConn3Pos_x
243
                '                    dDwg_Conn3Pos_y = dConn3Pos_y
244
                '                    ConvertPointByImage(dDwg_Conn3Pos_x, dDwg_Conn3Pos_y, _IMG_X, _IMG_Y)
245
                '                    oAddrow(_XML_SYMBOL_CONN3_POINT_X) = dConn3Pos_x
246
                '                    oAddrow(_XML_SYMBOL_CONN3_POINT_Y) = dConn3Pos_y
247
                '                    oAddrow(_XML_SYMBOL_DWG_CONN3_POINT_X) = dDwg_Conn3Pos_x
248
                '                    oAddrow(_XML_SYMBOL_DWG_CONN3_POINT_Y) = dDwg_Conn3Pos_y
249
                '                ElseIf i = 3 Then
250
                '                    oAddrow(_XML_SYMBOL_Conn4_Point) = sConnArray(i)
251
                '                    ConvertPointBystring(sConnArray(i), dConn4Pos_x, dConn4Pos_y)
252
                '                    dDwg_Conn4Pos_x = dConn4Pos_x
253
                '                    dDwg_Conn4Pos_y = dConn4Pos_y
254
                '                    ConvertPointByImage(dDwg_Conn4Pos_x, dDwg_Conn4Pos_y, _IMG_X, _IMG_Y)
255
                '                    oAddrow(_XML_SYMBOL_CONN4_POINT_X) = dConn4Pos_x
256
                '                    oAddrow(_XML_SYMBOL_CONN4_POINT_Y) = dConn4Pos_y
257
                '                    oAddrow(_XML_SYMBOL_DWG_CONN4_POINT_X) = dDwg_Conn4Pos_x
258
                '                    oAddrow(_XML_SYMBOL_DWG_CONN4_POINT_Y) = dDwg_Conn4Pos_y
259
                '                End If
260
                '            Next
261

  
262
                '            Dim sXLength As String = ""
263
                '            Dim sYLength As String = ""
264
                '            Dim dMin_x As Double = 0
265
                '            Dim dMax_x As Double = 0
266
                '            Dim dMin_y As Double = 0
267
                '            Dim dMax_y As Double = 0
268

  
269
                '            For i = 0 To sSizeArray.Length - 1
270
                '                If i = 0 Then
271
                '                    sXLength = sSizeArray(i)
272
                '                ElseIf i = 1 Then
273
                '                    sYLength = sSizeArray(i)
274
                '                End If
275
                '            Next
276

  
277
                '            For i = 0 To sLocationArray.Length - 1
278
                '                If i = 0 Then
279
                '                    dMin_x = sLocationArray(i)
280
                '                    dMax_x = dMin_x + sXLength
281
                '                ElseIf i = 1 Then
282
                '                    'Y축은 반전
283
                '                    dMax_y = sLocationArray(i)
284
                '                    dMin_y = dMax_y + sYLength
285
                '                End If
286
                '            Next
287
                '            ConvertPointByImage(dMin_x, dMin_y, _IMG_X, _IMG_Y)
288
                '            ConvertPointByImage(dMax_x, dMax_y, _IMG_X, _IMG_Y)
289
                '            oAddrow(_XML_SYMBOL_MIN_X) = dMin_x
290
                '            oAddrow(_XML_SYMBOL_MAX_X) = dMax_x
291
                '            oAddrow(_XML_SYMBOL_MIN_Y) = dMin_y
292
                '            oAddrow(_XML_SYMBOL_MAX_Y) = dMax_y
293
                '            oAddrow(_XML_SYMBOL_UID) = sUid
294
                '            oAddrow(_XML_SYMBOL_NAME) = IO.Path.GetFileNameWithoutExtension(GetDataFromMappingDB(sParentName, _DB_COLUMN_MAPPING_SPPID_SYMBOLNAME))
295
                '            oAddrow(_XML_SYMBOL_LOCATION) = sLocation
296
                '            oAddrow(_XML_SYMBOL_SIZE) = sSize
297
                '            oAddrow(_XML_SYMBOL_ANGLE) = sAngle
298
                '            oAddrow(_XML_SYMBOL_SYSTEMPATH) = GetDataFromMappingDB(sParentName, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
299
                '            oAddrow(_XML_SYMBOL_TYPE) = GetDataFromMappingDB(sParentName, _DB_COLUMN_MAPPING_SPPID_COMPTPYE)
300
                '            oAddrow(_XML_SYMBOL_CLASS) = GetDataFromMappingDB(sParentName, _DB_COLUMN_MAPPING_SPPID_CLASS)
301
                '            oAddrow(_XML_SYMBOL_ORIGINALPOINT) = sOriginalPoint
302
                '            oAddrow(_XML_SYMBOL_CONNECTIONPOINT) = sConnectionPoint
303
                '            oAddrow(_XML_SYMBOL_DRAWING_TF) = "FALSE"
304
                '            oAddrow(_XML_SYMBOL_CHILD) = sChild
305
                '            '   _AllSymbol_DT.Rows.Add(oAddrow)
306
                '            oSymbol_Dt.Rows.Add(oAddrow)
307
                '        Catch ex As Exception
308
                '        End Try
309
                '    Next
310
                '    CEqp_no.Uid = sUid
311
                '    CEqp_no.Dt_Equipment = oSymbol_Dt
312
                '    CEqp_no.Dt_Attribute = oAttribute_Dt
313
                '    oEqp_list.Add(CEqp_no)
314
                'Next
315
                'oTrim_Lineno_list = LoadLineNo(oElement, _XML_CATEGORY_TRIM_LINENO)
316
                'CDrawing.Line_nos = oLineno_list
317
                'CDrawing.Eqp_nos = oEqp_list
318
                'CDrawing.TrimLine_nos = oTrim_Lineno_list
319

  
125
                CDrawing.TEXTS = LoadTexts(oElement)
320 126
            End If
321 127
            Return CDrawing
322 128
        Catch ex As Exception
......
483 289
                _line.TYPE = oLine.Element(_XML_LINEINFOS_LINE_TYPE).Value
484 290
                _line.AREA = oLine.Element(_XML_LINEINFOS_LINE_AREA).Value
485 291
                _line.CONNECTORS = GetConnector(oLine)
292
                _line.SPPIDMAPPINGNAME = GetPipeType(_line.TYPE)
293

  
294
                _line.AfterSetting()
295

  
486 296
                result.Add(_line)
487 297
            Catch ex As Exception
488

  
298
                Console.WriteLine(ex.Message)
489 299
            End Try
490 300
        Next
491 301

  
......
500 310
        For Each oSymbol As XElement In symbols.Elements(_XML_SYMBOLS_SYMBOL)
501 311
            Dim _symbol As Symbol = New Symbol()
502 312
            Try
313
                _symbol.ANGLE = oSymbol.Element(_XML_SYMBOLS_SYMBOL_ANGLE).Value
503 314
                _symbol.UID = oSymbol.Element(_XML_SYMBOLS_SYMBOL_UID).Value
504 315
                _symbol.NAME = oSymbol.Element(_XML_SYMBOLS_SYMBOL_NAME).Value
505 316
                _symbol.TYPE = oSymbol.Element(_XML_SYMBOLS_SYMBOL_TYPE).Value
......
507 318
                _symbol.CONNECTORS = GetConnector(oSymbol)
508 319
                _symbol.LOCATION = oSymbol.Element(_XML_SYMBOLS_SYMBOL_LOCATION).Value
509 320
                _symbol.SIZE = oSymbol.Element(_XML_SYMBOLS_SYMBOL_SIZE).Value
510
                _symbol.ANGLE = oSymbol.Element(_XML_SYMBOLS_SYMBOL_ANGLE).Value
511 321
                _symbol.PARENT = oSymbol.Element(_XML_SYMBOLS_SYMBOL_PARENT).Value
512 322
                _symbol.CHILD = oSymbol.Element(_XML_SYMBOLS_SYMBOL_CHILD).Value
513 323
                _symbol.HASINSTRUMENTLABEL = oSymbol.Element(_XML_SYMBOLS_SYMBOL_HASINSTRUMENTLABEL).Value
514 324
                _symbol.AREA = oSymbol.Element(_XML_SYMBOLS_SYMBOL_AREA).Value
515 325
                _symbol.CURRENTPOINTMODEINDEX = oSymbol.Element(_XML_SYMBOLS_SYMBOL_CURRENTPOINTMODEINDEX).Value
326
                _symbol.SPPIDMAPPINGNAME = GetDataFromMappingDB(_symbol.PARENT, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
327

  
328
                _symbol.AfterSetting()
516 329

  
517 330
                result.Add(_symbol)
518 331
            Catch ex As Exception
519

  
332
                Console.WriteLine(ex.Message)
520 333
            End Try
521 334
        Next
522 335

  
......
532 345
            Dim _lineNo As LineNumber = New LineNumber()
533 346
            Try
534 347
                _lineNo.UID = oLineNo.Element(_XML_LINEINFOS_LINE_UID).Value
535

  
348
                _lineNo.ANGLE = oLineNo.Element("ANGLE").Value
349
                _lineNo.TEXT = oLineNo.Element("TEXT").Value
536 350
                _lineNo.SYMBOLRUNITEMS = GetSymbolRunItems(oLineNo)
537 351
                _lineNo.LINERUNITEMS = GetLineRunItems(oLineNo)
352
                If oLineNo.Element("CONNLINE") IsNot Nothing Then
353
                    _lineNo.CONNECTLINE = oLineNo.Element("CONNLINE").Value
354
                End If
355
                _lineNo.LOCATION = oLineNo.Element("LOCATION").Value
356

  
357
                Console.WriteLine("임시 Line Number Labeling and Attribute")
358
                _lineNo.SPPIDMAPPINGNAME = "\Piping\Labels - Piping Segments\Line Number.sym"
359

  
360
                For Each attrElement As XElement In oLineNo.Elements("ATTRIBUTE")
361
                    Dim attr As Attribute = New Attribute()
362
                    attr.UID = attrElement.Attribute("UID").Value
363
                    attr.NAME = attrElement.Attribute("DisplayAttribute").Value.Replace(" ", "")
364
                    If attrElement.Value <> "None" Then
365
                        attr.VALUE = attrElement.Value
366
                    Else
367
                        attr.VALUE = ""
368
                    End If
369
                    _lineNo.ATTRIBUTES.Add(attr)
370
                Next
371

  
372
                _lineNo.AfterSetting()
538 373

  
539 374
                result.Add(_lineNo)
540 375
            Catch ex As Exception
541

  
376
                Console.WriteLine(ex.Message)
542 377
            End Try
543 378
        Next
544 379

  
......
567 402
        Return result
568 403
    End Function
569 404

  
570
    Private Function GetSymbolRunItems(ByVal oElement As XElement) As List(Of String)
571
        Dim result As List(Of String) = New List(Of String)
405
    Private Function LoadTexts(ByVal oElement As XElement) As List(Of Text)
406
        Dim result As List(Of Text) = New List(Of Text)
407

  
408
        Dim textInfos As XElement = oElement.Element(_XML_TEXTINFOS)
409

  
410
        For Each oText As XElement In textInfos.Elements("ATTRIBUTE")
411
            Dim _text As Text = New Text()
412
            Try
413
                _text.UID = oText.Element("UID").Value
414
                _text.NAME = oText.Element("NAME").Value
415
                _text.LOCATION = oText.Element("LOCATION").Value
416
                _text.TEXT = oText.Element("VALUE").Value
417
                _text.ANGLE = oText.Element("ANGLE").Value
418
                _text.AREA = oText.Element("AREA").Value
419

  
420
                If oText.Element("OWNER") IsNot Nothing Then
421
                    _text.OWNER = oText.Element("OWNER").Value
422
                End If
423

  
424
                Console.WriteLine("임시 Text Labeling")
425
                If _text.NAME = "TEXT" Then
426
                    _text.SPPIDMAPPINGNAME = "\Design\Annotation\Labels\Drawing Notes Label.sym"
427
                ElseIf _text.NAME = "SIZE" Then
428
                    '_text.SPPIDMAPPINGNAME = "\Piping\Labels - Piping Components\Nominal Diameter.sym"
429
                End If
572 430

  
573
        Dim oRun As XElement = oElement.Element(_XML_RUN)
574 431

  
575
        For Each oSymbol As XElement In oRun.Elements(_XML_RUN_SYMBOL)
576
            result.Add(oSymbol.Element(_XML_SYMBOLS_SYMBOL_UID))
432
                _text.AfterSetting()
433

  
434
                result.Add(_text)
435
            Catch ex As Exception
436
                Console.WriteLine(ex.Message)
437
            End Try
577 438
        Next
578 439

  
579 440
        Return result
580 441
    End Function
581 442

  
582
    Private Function GetLineRunItems(ByVal oElement As XElement) As List(Of String)
443
    Private Function GetSymbolRunItems(ByVal oElement As XElement) As List(Of String)
583 444
        Dim result As List(Of String) = New List(Of String)
584

  
585 445
        Dim oRun As XElement = oElement.Element(_XML_RUN)
446
        If oRun IsNot Nothing Then
447
            For Each oSymbol As XElement In oRun.Elements(_XML_RUN_SYMBOL)
448
                result.Add(oSymbol.Element(_XML_SYMBOLS_SYMBOL_UID))
449
            Next
450
        End If
451
        Return result
452
    End Function
586 453

  
587
        For Each oLine As XElement In oRun.Elements(_XML_RUN_LINE)
588
            result.Add(oLine.Element(_XML_LINEINFOS_LINE_UID))
589
        Next
590

  
454
    Private Function GetLineRunItems(ByVal oElement As XElement) As List(Of String)
455
        Dim result As List(Of String) = New List(Of String)
456
        Dim oRun As XElement = oElement.Element(_XML_RUN)
457
        If oRun IsNot Nothing Then
458
            For Each oLine As XElement In oRun.Elements(_XML_RUN_LINE)
459
                result.Add(oLine.Element(_XML_LINEINFOS_LINE_UID))
460
            Next
461
        End If
591 462
        Return result
592 463
    End Function
593 464

  
......
965 836
        Dim calcx As Double = 0
966 837
        Dim calcy As Double = 0
967 838
        calcx = (dX * _DWG_X) / dDwgX 'Math.Round((dX * _DWG_X) / dDwgX, 2)
968
        'calcx = Math.Round(calcx, 4, MidpointRounding.)
969 839
        calcx = Math.Truncate(calcx * 1000) / 1000
970 840
        calcy = _DWG_Y - ((dY * _DWG_Y) / dDwgY) '_DWG_Y - Math.Round((dY * _DWG_Y) / dDwgY, 2)
971
        '   calcy = Math.Round(calcy, 4)
972 841
        calcy = Math.Truncate(calcy * 1000) / 1000
973 842
        dX = calcx
974 843
        dY = calcy
......
1047 916
        Me.ProgressBar_Status.Visible = True
1048 917
        ProgressBar_Status.Maximum = 100
1049 918
        ProgressBar_Status.Value = 0
1050
        InitItemCount()
919

  
1051 920
        _Main_trd = New Thread(AddressOf ThreadConvert)
1052 921
        _Main_trd.IsBackground = True
1053 922
        _Main_trd.Start()
......
1191 1060
    Dim _DrawLine_Dt As DataTable = DrawLind_Dt()
1192 1061

  
1193 1062

  
1194
    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)
1195
        Dim oAddRow = _DrawLine_Dt.NewRow()
1196
        oAddRow(_XML_LINE_UID) = sUid
1197
        oAddRow(_XML_LINE_STARTPOINT_X) = dStart_x
1198
        oAddRow(_XML_LINE_STARTPOINT_Y) = dStart_y
1199
        oAddRow(_XML_LINE_ENDPOINT_X) = dEnd_x
1200
        oAddRow(_XML_LINE_ENDPOINT_Y) = dEnd_y
1201
        _DrawLine_Dt.Rows.Add(oAddRow)
1202
    End Sub
1203

  
1204 1063
    Private Sub PlaceEquipment(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal sEqpName As String)
1205 1064
        Try
1206 1065
            Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'")
......
1272 1131
        End Try
1273 1132
    End Sub
1274 1133

  
1275
    Private Function PlacePipingOPC(ByVal sUid As String, ByVal oOPCRow As DataRow, ByVal oAttribute_Dt As DataTable, ByVal sLineNoText As String) As LMSymbol
1276
        Try
1277
            Dim oAttributeRow() As DataRow
1278
            If oAttribute_Dt.Rows.Count > 0 Then
1279
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
1280
            End If
1281
            Dim oDatasource As Object = _Placement.PIDDataSource
1282
            Dim sSymbolCompType As String = oOPCRow(_XML_SYMBOL_TYPE).ToString()
1283
            Dim sSystemPath As String = oOPCRow(_XML_SYMBOL_SYSTEMPATH).ToString()
1284
            Dim sClass As String = oOPCRow(_XML_SYMBOL_CLASS).ToString()
1285
            Dim sLocation As String = oOPCRow(_XML_SYMBOL_LOCATION).ToString()
1286
            Dim sOriginalPoint As String = oOPCRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
1287
            Dim dAngle As Double = 0.0
1288
            If IsNumeric(oOPCRow(_XML_SYMBOL_ANGLE).ToString()) Then
1289
                dAngle = Double.Parse(oOPCRow(_XML_SYMBOL_ANGLE).ToString())
1290
            End If
1291

  
1292
            Dim dLocationX As Double = 0.0
1293
            Dim dLocationY As Double = 0.0
1294
            Dim dX As Double = 0.0
1295
            Dim dY As Double = 0.0
1296
            Dim oLMSymbol As LMSymbol = Nothing
1297
            If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
1298
                dX = dLocationX
1299
                dY = dLocationY
1300
                ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1301
                _iPipintOpccnt = _iPipintOpccnt + 1
1302
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1303
                '모델링된 형상은 Drawing True 로 처리
1304
                oOPCRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
1305
                SetListBoxItems(ListBox_Result, "Place Piping OPC.." & sUid & " (" & dLocationX & "," & dLocationY & ")..." & _iPipintOpccnt & " count ")
1306
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Piping OPC : " & sUid & "")
1307
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
1308
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oOPCRow(_XML_SYMBOL_Conn1_Uid).ToString())
1309
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oOPCRow(_XML_SYMBOL_Conn2_Uid).ToString())
1310
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1311
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OriginalPoint : " & dLocationX & "," & dLocationY)
1312
                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "OPC Count : " & _iPipintOpccnt)
1313

  
1314
                Dim dConn_X1 As Double, dConn_Y1 As Double, dConn_X2 As Double, dConn_Y2 As Double
1315
                _Placement.PIDConnectPointLocation(oLMSymbol, 1, dConn_X1, dConn_Y1)
1316
                _Placement.PIDConnectPointLocation(oLMSymbol, 2, dConn_X2, dConn_Y2)
1317

  
1318
                'Dim oAddrow As DataRow = _ResultModeling_DT.NewRow()
1319
                'oAddrow(_Modeling_Uid) = sUid
1320
                'oAddrow(_Modeling_Location_X) = dLocationX
1321
                'oAddrow(_Modeling_Location_Y) = dLocationY
1322
                'oAddrow(_Modeling_LineNoUid) = sLineUid
1323
                'oAddrow(_Modeling_Type) = sSymbolCompType
1324
                'oAddrow(_Modeling_Connection1_X) = dConn_X1
1325
                'oAddrow(_Modeling_Connection1_Y) = dConn_Y1
1326
                'oAddrow(_Modeling_Connection2_X) = dConn_X2
1327
                'oAddrow(_Modeling_Connection2_X) = dConn_Y2
1328
                'oAddrow(_Modeling_LMSymbol) = oLMSymbol
1329

  
1330
                '_ResultModeling_DT.Rows.Add(oAddrow)
1331
            End If
1332
            _Itemcnt = _Itemcnt + 1
1333
            Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
1334
            SetProgressbar(ProgressBar_Status, dCalcProgressValue)
1335
            Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
1336
            Return oLMSymbol
1337
        Catch ex As Exception
1338

  
1339
        End Try
1340
        Return Nothing
1341

  
1342
    End Function
1343

  
1344 1134
    Private Sub AddProgress()
1345 1135
        _Itemcnt = _Itemcnt + 1
1346 1136
        Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
1347 1137
        SetProgressbar(ProgressBar_Status, dCalcProgressValue)
1348 1138
        Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
1349 1139
    End Sub
1350
    Private Function DrawSymbol(ByVal sUid As String, ByVal oSymbol_Dt As DataTable, ByVal oAttribute_Dt As DataTable, ByVal oLine_Dt As DataTable) As Boolean
1351
        Try
1352

  
1353
            Dim oSymbolRow() As DataRow = oSymbol_Dt.Select(_XML_SYMBOL_UID & " = '" + sUid + "'")
1354
            Dim oAttributeRow() As DataRow
1355
            If oAttribute_Dt.Rows.Count > 0 Then
1356
                oAttributeRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sUid + "'")
1357
            End If
1358 1140

  
1359
            If oSymbolRow.Length > 0 Then
1360
                Dim oDatasource As Object = _Placement.PIDDataSource
1361
                Dim sSymbolCompType As String = oSymbolRow(0)(_XML_SYMBOL_TYPE).ToString()
1362
                Dim sSystemPath As String = oSymbolRow(0)(_XML_SYMBOL_SYSTEMPATH).ToString()
1363
                Dim sClass As String = oSymbolRow(0)(_XML_SYMBOL_CLASS).ToString()
1364
                Dim sLocation As String = oSymbolRow(0)(_XML_SYMBOL_LOCATION).ToString()
1365
                Dim sOriginalPoint As String = oSymbolRow(0)(_XML_SYMBOL_ORIGINALPOINT).ToString()
1366
                Dim dAngle As Double = 0.0
1367
                If IsNumeric(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString()) Then
1368
                    dAngle = Double.Parse(oSymbolRow(0)(_XML_SYMBOL_ANGLE).ToString())
1369
                End If
1370 1141

  
1371
                Dim objSymbol As LMSymbol
1372
                Dim dLocationX As Double = 0.0
1373
                Dim dLocationY As Double = 0.0
1374
                Dim dX As Double = 0.0
1375
                Dim dY As Double = 0.0
1142
    Dim _라인보정기준값 As Integer = 10
1376 1143

  
1377
                If ConvertPointBystring(sOriginalPoint, dLocationX, dLocationY) Then
1378
                    dX = dLocationX
1379
                    dY = dLocationY
1380
                    If sSymbolCompType = "" Or sSymbolCompType = "Piping OPC's" Then
1381
                        FindConnectionLine(oLine_Dt, dX, dY)
1382
                    End If
1383 1144

  
1384
                    ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1385
                    Dim oInstrument As LMInstrument
1386
                    If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
1387
                        _iInstrumentcnt = _iInstrumentcnt + 1
1388
                        objSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1389
                        SetListBoxItems(ListBox_Result, "Place Instrument..(" & dLocationX & "," & dLocationY & ")..." & _iInstrumentcnt & " count ")
1390
                        oInstrument = oDatasource.GetInstrument(objSymbol.ModelItemID)
1391
                        Try
1392
                            If oAttributeRow.Length > 0 Then
1393
                                For Each oAttribute In oAttributeRow
1394
                                    Try
1395
                                        Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
1396
                                        Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
1397
                                        Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
1398
                                        oInstrument.Attributes(sSPPIDAttribute).Value = sPIDValue
1399
                                    Catch ex As Exception
1145
    Private Function GetAllCheckNodeCount() As Integer
1146
        _allItem = 0
1147
        For i = 0 To Tree_Result.Nodes.Count - 1
1148
            For j = 0 To Tree_Result.Nodes(i).Nodes.Count - 1
1149
                For k = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes.Count - 1
1150
                    For l = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes.Count - 1
1151
                        If Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes(l).Checked = True Then
1152
                            _allItem = _allItem + 1
1153
                        End If
1154
                    Next
1155
                Next
1156
            Next
1157
        Next
1158
        Return _allItem
1159
    End Function
1400 1160

  
1401
                                    End Try
1402 1161

  
1403
                                Next
1404
                                oInstrument.Commit()
1405
                            End If
1406
                        Catch ex As Exception
1407
                        End Try
1408
                    ElseIf sSymbolCompType.ToUpper() = _DB_FITTINGS.ToUpper() Then
1409
                        _iValvecnt = _iValvecnt + 1
1410
                        _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1411
                        SetListBoxItems(ListBox_Result, "Place Valve..(" & dLocationX & "," & dLocationY & ")..." & _iValvecnt & " count ")
1412

  
1413
                    ElseIf sSymbolCompType.ToUpper() = _SYMBOL_FITTINGS.ToUpper() Then
1414
                        _iFittingcnt = _iFittingcnt + 1
1415
                        If sSystemPath.Contains(",") Then
1416

  
1417
                            Dim sDuplicatePath As String() = sSystemPath.Split(",")
1418
                            Dim sMainSymbol As String = ""
1419
                            Dim sSubSymbol As String = ""
1420
                            For Each sPath In sDuplicatePath
1421
                                If sMainSymbol = "" Then
1422
                                    sMainSymbol = sPath.Replace(vbLf, "")
1162
    Private Sub ManualCheckNode(ByRef oDt As DataTable)
1163
        For Each oDrwing As TreeNode In Tree_Result.Nodes
1164
            For Each oDwgNode As TreeNode In oDrwing.Nodes
1165
                For Each oNode As TreeNode In oDwgNode.Nodes
1166
                    For Each oSymbolNode As TreeNode In oNode.Nodes
1167
                        Dim sUid As String = oSymbolNode.Name
1168
                        'Dim oSelectRows() As DataRow = oDt.Select("[" & _XML_SYMBOL_UID & "] = '" & sUid &
1169
                        '                                      "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False'")
1170
                        If oSymbolNode.Checked Then
1171
                            Dim oSelectRows() As DataRow = oDt.Select("[" & _XML_SYMBOL_UID & "] = '" & sUid & "'")
1172
                            If oSelectRows.Length = 1 Then
1173
                                oSelectRows(0)(_XML_SYMBOL_DRAWING_TF) = "FALSE"
1174
                                If oSymbolNode.Checked Then
1175
                                    oSelectRows(0)(_XML_SYMBOL_Check) = "TRUE"
1423 1176
                                Else
1424
                                    sSubSymbol = sPath.Replace(vbLf, "")
1177
                                    oSelectRows(0)(_XML_SYMBOL_Check) = "FALSE"
1425 1178
                                End If
1426
                            Next
1427
                            Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle)
1428
                            Dim dConnpos_x As Double = 0.0
1429
                            Dim dConnpos_y As Double = 0.0
1430
                            _Placement.PIDConnectPointLocation(oSymbolObj, 2, dConnpos_x, dConnpos_y)
1431
                            '   _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y, dAngle, TargetItem:=oSymbolObj.AsLMRepresentation)
1432
                            _Placement.PIDPlaceSymbol(sSubSymbol, dConnpos_x, dConnpos_y,, dAngle)
1433

  
1434
                        Else
1435
                            _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1179
                            End If
1436 1180
                        End If
1181
                    Next
1182
                Next
1183
            Next
1184
        Next
1437 1185

  
1186
    End Sub
1438 1187

  
1439
                        SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
1440
                    ElseIf sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() And sClass.ToUpper() = _SYMBOL_ACTUATORS.ToUpper() Then
1441
                        _iFittingcnt = _iFittingcnt + 1
1442
                        Dim sDuplicatePath As String() = sSystemPath.Split(",")
1443
                        Dim sMainSymbol As String = ""
1444
                        Dim sSubSymbol As String = ""
1445
                        For Each sPath In sDuplicatePath
1446
                            If sMainSymbol = "" Then
1447
                                sMainSymbol = sPath.Replace(vbLf, "")
1448
                            Else
1449
                                sSubSymbol = sPath.Replace(vbLf, "")
1450
                            End If
1451
                        Next
1452
                        Dim oSymbolObj As LMSymbol = _Placement.PIDPlaceSymbol(sMainSymbol, dX, dY, , dAngle)
1453
                        Dim dSymbolpos_x As Double = oSymbolObj.XCoordinate
1454
                        Dim dSymbolpos_y As Double = oSymbolObj.YCoordinate
1455
                        _Placement.PIDPlaceSymbol(sSubSymbol, dSymbolpos_x, dSymbolpos_y, , dAngle, TargetItem:=oSymbolObj.AsLMAItem)
1188
    Private Function GetChildSymbolDirection(ByVal sDirection As String) As Double
1189
        Dim sReturnDirection As String = ""
1190
        If sDirection.ToUpper() = "RIGHT" Then
1191
            Return 3.14
1192
        ElseIf sDirection.ToUpper() = "LEFT" Then
1193
            Return 0
1194
        ElseIf sDirection.ToUpper = "DOWN" Then
1195
            Return 1.57
1196
        ElseIf sDirection.ToUpper() = "UP" Then
1197
            Return 4.71
1198
        Else
1199
            Return 0
1200
        End If
1201
    End Function
1456 1202

  
1457
                    Else
1458
                        _iFittingcnt = _iFittingcnt + 1
1459
                        _Placement.PIDPlaceSymbol(sSystemPath, dX, dY, , dAngle)
1460
                        SetListBoxItems(ListBox_Result, "Place Fitting..(" & dLocationX & "," & dLocationY & ")..." & _iFittingcnt & " count ")
1203
    Private Function CheckExistModeling(ByVal oRow As DataRow) As String
1204
        If oRow(_XML_LINE_DRAWING_TF).ToString() = "FALSE" And oRow(_XML_LINE_Check).ToString() = "TRUE" Then
1205
            Return oRow(_XML_LINE_UID).ToString()
1206
        End If
1207
        Return String.Empty
1208
    End Function
1209

  
1210

  
1211
    Private Sub AddLog(ByVal sUid As String, ByVal sSystemPath As String,
1212
                             ByVal dStart_Dwg_x As Double, ByVal dStart_Dwg_y As Double, ByVal dEnd_Dwg_x As Double, ByVal dEnd_Dwg_y As Double,
1213
                       ByVal sLineNoText As String, ByVal sConn1Uid As String, ByVal sConn2Uid As String)
1214
        SetListBoxItems(ListBox_Result, "Place Pipe.." & sUid & " (" & dStart_Dwg_x & "," & dStart_Dwg_y & ") - (" & dEnd_Dwg_x & "," & dEnd_Dwg_y & ")..." & _iPipecnt & " count ")
1215
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & sUid)
1216
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
1217
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & sConn1Uid)
1218
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & sConn2Uid)
1219
        'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1220
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "StartPoint : " & dStart_Dwg_x & "," & dStart_Dwg_y)
1221
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "EndPoint : " & dEnd_Dwg_x & "," & dEnd_Dwg_y)
1222
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Pipe Count : " & _iPipecnt)
1223
    End Sub
1224

  
1225
    Private Sub AddAttribute(ByVal oPipeRun As LMPipeRun, ByVal oAttribute_Dt As DataTable, ByVal sLineNoUid As String)
1226
        Dim oAttributeRow() As DataRow = oAttribute_Dt.Select(_XML_ATTRIBUTE_UID & " = '" + sLineNoUid + "'")
1227
        If oAttributeRow.Length > 0 Then
1228
            For Each oAttribute In oAttributeRow
1229
                Try
1230
                    Dim sPIDAttribute As String = oAttribute(_XML_ATTRIBUTE_NAME).ToString()
1231
                    Dim sPIDValue As String = oAttribute(_XML_ATTRIBUTE_VALUE).ToString()
1232
                    If sPIDValue.Contains("'") Then
1233
                        sPIDValue = sPIDValue.Replace("'", """")
1461 1234
                    End If
1235
                    Dim sSPPIDAttribute As String = GetAttributeMapping(sPIDAttribute, _DB_COLUMN_ATTRIBUTE_SPPID_ATTRIBUTE)
1236
                    oPipeRun.Attributes(sSPPIDAttribute).Value = sPIDValue
1237
                Catch ex As Exception
1238
                End Try
1239
            Next
1240
            oPipeRun.Commit()
1241
        End If
1242
    End Sub
1462 1243

  
1463
                End If
1464
                _Itemcnt = _Itemcnt + 1
1465
                Dim dCalcProgressValue As Double = (_Itemcnt / _allItem) * 100
1466
                SetProgressbar(ProgressBar_Status, dCalcProgressValue)
1467
                Label_Progress.Text = Math.Round(dCalcProgressValue, 0) & "%"
1468
            End If
1244
    Private Sub AddModelingDT(ByVal sUid As String, ByVal sModelID As String, ByVal oCurrentConnector As LMConnector,
1245
                              ByVal dStart_Dwg_x As Double, ByVal dStart_Dwg_y As Double,
1246
                              ByVal dEnd_Dwg_x As Double, ByVal dEnd_Dwg_y As Double)
1247
        Dim oAddRow As DataRow = _ModelingLine_Dt.NewRow
1248
        oAddRow(_XML_LINE_UID) = sUid
1249
        oAddRow(_XML_LINE_SPID) = sModelID
1250
        oAddRow(_XML_LINE_LMCONNECTOR) = oCurrentConnector
1251
        oAddRow(_XML_LINE_DRAWING_TF) = "TRUE"
1252
        oAddRow(_XML_LINE_DWG_STARTPOINT_X) = dStart_Dwg_x
1253
        oAddRow(_XML_LINE_DWG_STARTPOINT_Y) = dStart_Dwg_y
1254
        oAddRow(_XML_LINE_DWG_ENDPOINT_X) = dEnd_Dwg_x
1255
        oAddRow(_XML_LINE_DWG_ENDPOINT_Y) = dEnd_Dwg_y
1256
        _ModelingLine_Dt.Rows.Add(oAddRow)
1257
    End Sub
1469 1258

  
1259
    Private Function JoinPipeRun(ByVal sID_1 As String, ByVal sID_2 As String) As Boolean
1260
        Try
1261
            Dim objSurvivorItem As LMAItem = Nothing
1262
            Dim oPipeRun1 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_1)
1263
            Dim oPipeRun2 As LMPipeRun = _Placement.PIDDataSource.GetPipeRun(sID_2)
1264
            _Placement.PIDJoinRuns(oPipeRun1, oPipeRun2)
1265
            Return True
1470 1266
        Catch ex As Exception
1471 1267
            Return False
1472 1268
        End Try
1473 1269
    End Function
1474 1270

  
1475 1271

  
1476
    Private Sub FindConnectionLine(ByVal oLine_Dt As DataTable, ByRef dx As Double, ByRef dy As Double)
1477

  
1272
    Private Function LineModeling(ByVal objInputs As PlaceRunInputs, ByVal sSystemPath As String) As LMConnector
1273
        Dim oCurrentConnector As LMConnector = Nothing
1274
        Dim objItem As LMAItem
1275
        objItem = _Placement.PIDCreateItem(sSystemPath)
1478 1276
        Try
1479
            For Each oRow In oLine_Dt.Rows
1480
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1481
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1482
                Dim d기준s_x As Double = 0
1483
                Dim d기준s_y As Double = 0
1484
                Dim d기준e_x As Double = 0
1485
                Dim d기준e_y As Double = 0
1486
                ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1487
                ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1488
                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
1489
                    dx = d기준s_x
1490
                    dy = d기준s_y
1491
                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
1492
                    dx = d기준e_x
1493
                    dy = d기준e_y
1494
                End If
1495
            Next
1277
            oCurrentConnector = _Placement.PIDPlaceRun(objItem, objInputs)
1278
            AddProgress()
1496 1279
        Catch ex As Exception
1497 1280
        End Try
1498
    End Sub
1281
        Return oCurrentConnector
1282
    End Function
1499 1283

  
1500

  
1501
    Dim _라인보정기준값 As Integer = 10
1502

  
1503
    Private Function 라인보정(ByRef oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double,
1504
                                      ByRef dex As Double, ByRef dey As Double)
1505
        Try
1506
            Dim bCheck라인 As Boolean = False
1507
            '일치하는 Line 찾기
1508
            For Each oRow In oLine_Dt.Rows
1509
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1510
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1511
                Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1512
                If sBUid <> sUid Then
1513
                    Dim d기준s_x As Double = 0
1514
                    Dim d기준s_y As Double = 0
1515
                    Dim d기준e_x As Double = 0
1516
                    Dim d기준e_y As Double = 0
1517
                    ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1518
                    ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1519

  
1520
                    If (dsx = d기준s_x And dsy = d기준s_y) Or (dsx = d기준e_x And dsy = d기준e_y) Or
1521
                       (dex = d기준s_x And dey = d기준s_y) Or (dex = d기준e_x And dey = d기준e_y) Then
1522
                        bCheck라인 = True
1523
                    End If
1524
                End If
1525
            Next
1526

  
1527
            If bCheck라인 = False Then
1528
                For Each oRow In oLine_Dt.Rows
1529
                    Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1530
                    Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1531
                    Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1532
                    If sBUid <> sUid Then
1533
                        Dim d기준s_x As Double = 0
1534
                        Dim d기준s_y As Double = 0
1535
                        Dim d기준e_x As Double = 0
1536
                        Dim d기준e_y As Double = 0
1537
                        ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1538
                        ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1539
                        If ((dsx - _라인보정기준값 <= d기준s_x And dsx + _라인보정기준값 >= d기준s_x) And (dsy - _라인보정기준값 <= d기준s_y And dsy + _라인보정기준값 >= d기준s_y)) Then
1540
                            oRow(_XML_LINE_STARTPOINT) = dsx & "," & dsy
1541
                            bCheck라인 = True
1542
                            Exit For
1543
                        ElseIf ((dsx - _라인보정기준값 <= d기준e_x And dsx + _라인보정기준값 >= d기준e_x) And (dsy - _라인보정기준값 <= d기준e_y And dsy + _라인보정기준값 >= d기준e_y)) Then
1544
                            oRow(_XML_LINE_ENDPOINT) = dsx & "," & dsy
1545
                            bCheck라인 = True
1546
                            Exit For
1547
                        ElseIf ((dex - _라인보정기준값 <= d기준s_x And dex + _라인보정기준값 >= d기준s_x) And (dey - _라인보정기준값 <= d기준s_y And dey + _라인보정기준값 >= d기준s_y)) Then
1548
                            oRow(_XML_LINE_STARTPOINT) = dex & "," & dey
1549
                            bCheck라인 = True
1550
                            Exit For
1551
                        ElseIf ((dex - _라인보정기준값 <= d기준e_x And dex + _라인보정기준값 >= d기준e_x) And (dey - _라인보정기준값 <= d기준e_y And dey + _라인보정기준값 >= d기준e_y)) Then
1552
                            oRow(_XML_LINE_ENDPOINT) = dex & "," & dey
1553
                            bCheck라인 = True
1554
                            Exit For
1555
                        End If
1556

  
1557
                    End If
1558
                Next
1559
            End If
1560

  
1561
            Return bCheck라인
1562
        Catch ex As Exception
1563
            Return False
1564
        End Try
1565

  
1566

  
1567
    End Function
1568

  
1569
    Private Function FindOverlapLine(ByVal oLine_Dt As DataTable, ByVal sUid As String, ByRef dsx As Double, ByRef dsy As Double,
1570
                                      ByRef dex As Double, ByRef dey As Double)
1571
        Try
1572
            Dim bCheckOverlap As Boolean = False
1573
            For Each oRow In oLine_Dt.Rows
1574
                Dim sStartpoint As String = oRow(_XML_LINE_STARTPOINT).ToString()
1575
                Dim sEndpoint As String = oRow(_XML_LINE_ENDPOINT).ToString()
1576
                Dim sBUid As String = oRow(_XML_LINE_UID).ToString()
1577
                If sBUid <> sUid Then
1578
                    Dim d기준s_x As Double = 0
1579
                    Dim d기준s_y As Double = 0
1580
                    Dim d기준e_x As Double = 0
1581
                    Dim d기준e_y As Double = 0
1582
                    ConvertPointBystring(sStartpoint, d기준s_x, d기준s_y)
1583
                    ConvertPointBystring(sEndpoint, d기준e_x, d기준e_y)
1584
                    If (d기준s_x <= dsx And d기준e_x >= dex And
1585
                        d기준s_y <= dsy And d기준e_y >= dey) Then
1586
                        '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1587
                        If dsy - d기준s_y > d기준e_y - dey Then
1588
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1589
                            If dResultCalc < 10 Then
1590
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1591
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1592
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1593
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1594
                                If dCalcStartY = 0 Then
1595
                                    dey = d기준e_y
1596
                                Else
1597
                                    dey = dCalcStartY
1598
                                End If
1599
                            End If
1600
                        Else
1601
                            '  Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1602
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1603
                            If dResultCalc < 10 Then
1604
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1605
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1606
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1607
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1608
                                If dCalcStartY = 0 Then
1609
                                    dsy = d기준s_y
1610
                                Else
1611
                                    dsy = dCalcStartY
1612
                                End If
1613
                            End If
1614
                        End If
1615
                        bCheckOverlap = True
1616
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1617
                            d기준s_y <= dey And d기준e_y >= dsy Then
1618
                        '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1619
                        If dey - d기준s_y > d기준e_y - dsy Then
1620
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1621
                            If dResultCalc < 10 Then
1622
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1623
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1624
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1625
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1626
                                If dCalcStartY = 0 Then
1627
                                    dsy = d기준e_y
1628
                                Else
1629
                                    dsy = dCalcStartY
1630
                                End If
1631

  
1632
                            End If
1633
                            '겹쳐서 오버되는 길이가 오버되지 않는 길이의 10%미만일때 겹치는 y축좌표를 겹치는점까지 설정
1634
                        Else
1635
                            '  Dim dResultCalc As Double = (Math.Abs((dsy - d기준s_y)) / Math.Abs((d기준e_y - dey))) * 100
1636
                            Dim dResultCalc As Double = ((d기준e_y - dey) / (dsy - d기준s_y)) * 100
1637
                            If dResultCalc < 10 Then
1638
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1639
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1640
                                Dim dCalcStartX As Double = Math.Abs(dsx - d기준s_x)
1641
                                Dim dCalcStartY As Double = (dCalcY * dCalcStartX) / dCalcX
1642
                                If dCalcStartY = 0 Then
1643
                                    dey = d기준e_y
1644
                                Else
1645
                                    dey = dCalcStartY
1646
                                End If
1647
                            End If
1648
                        End If
1649
                        bCheckOverlap = True
1650
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1651
                            d기준s_y <= dey And d기준e_y >= dsy Then
1652

  
1653
                        If dsx - d기준s_x > d기준e_x - dex Then
1654
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1655
                            If dResultCalc < 10 Then
1656
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1657
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1658
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1659
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1660
                                If dCalcStartX = 0 Then
1661
                                    dex = d기준e_x
1662
                                Else
1663
                                    dex = dCalcStartX
1664
                                End If
1665
                            End If
1666
                        Else
1667
                            '  Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1668
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1669
                            If dResultCalc < 10 Then
1670
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1671
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1672
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1673
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1674
                                If dCalcStartX = 0 Then
1675
                                    dsx = d기준s_x
1676
                                Else
1677
                                    dsx = dCalcStartX
1678
                                End If
1679
                            End If
1680
                        End If
1681
                        bCheckOverlap = True
1682
                    ElseIf (d기준s_x <= dsx And d기준e_x >= dex) And
1683
                            d기준s_y <= dey And d기준e_y >= dsy Then
1684

  
1685
                        If dex - d기준s_x > d기준e_x - dsx Then
1686
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1687
                            If dResultCalc < 10 Then
1688
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1689
                                Dim dCalcY As Double = Math.Abs(d기준s_y - d기준e_y)
1690
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1691
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1692
                                If dCalcStartX = 0 Then
1693
                                    dsx = d기준e_x
1694
                                Else
1695
                                    dsx = dCalcStartX
1696
                                End If
1697
                            End If
1698
                        Else
1699
                            ' Dim dResultCalc As Double = ((dsy - d기준s_y) / (d기준e_y - dey)) * 100
1700
                            Dim dResultCalc As Double = ((d기준e_x - dex) / (dsx - d기준s_x)) * 100
1701
                            If dResultCalc < 10 Then
1702
                                Dim dCalcX As Double = Math.Abs(d기준e_x - d기준s_x)
1703
                                Dim dCalcY As Double = Math.Abs(d기준e_y - d기준s_y)
1704
                                Dim dCalcStartY As Double = Math.Abs(dsy - d기준s_y)
1705
                                Dim dCalcStartX As Double = (dCalcX * dCalcStartY) / dCalcY
1706
                                If dCalcStartX = 0 Then
1707
                                    dex = d기준s_x
1708
                                Else
1709
                                    dex = dCalcStartX
1710
                                End If
1711
                            End If
1712

  
1713
                        End If
1714
                        bCheckOverlap = True
1715
                    End If
1716
                End If
1717
            Next
1718

  
1719
            Return bCheckOverlap
1720
        Catch ex As Exception
1721
            Return False
1722
        End Try
1723
    End Function
1724

  
1725
    Private Sub CalcSperateLine(ByRef dStartX As Double, ByRef dStartY As Double,
1726
                                      ByRef dEndX As Double, ByRef dEndY As Double)
1727
        Try
1728
            Dim dRange As Double = 1 'Line 전체 길이의 10%씩 늘이기
1729
            If Math.Abs(dStartX - dEndX) > Math.Abs(dStartY - dEndY) Then
1730
                Dim dCalc_x As Double = Math.Abs(dStartX - dEndX) * 0.1
1731
                If dStartX > dEndX Then
1732
                    dStartX = dStartX + dCalc_x
1733
                    dEndX = dEndX - dCalc_x
1734
                Else
1735
                    dEndX = dEndX + dCalc_x
1736
                    dStartX = dStartX - dCalc_x
1737
                End If
1738
            Else
1739
                Dim dCalc_y As Double = Math.Abs(dStartY - dEndY) * 0.1
1740
                If dStartY > dEndY Then
1741
                    dStartY = dStartY + dCalc_y
1742
                    dEndY = dEndY - dCalc_y
1743
                Else
1744
                    dEndY = dEndY + dCalc_y
1745
                    dStartY = dStartY - dCalc_y
1746
                End If
1747
            End If
1748

  
1749
        Catch ex As Exception
1750

  
1751
        End Try
1752

  
1753

  
1754
    End Sub
1755

  
1756
    Private Function DrawLineNo(ByVal oPipeRun_Dt As DataTable, ByVal CLine_No As Line_no) As Boolean
1757
        Try
1758
            Dim oDatasource As Object = _Placement.PIDDataSource
1759
            Dim sLocation = CLine_No.Location
1760
            Dim dLocationx As Double = 0.0
1761
            Dim dLocationy As Double = 0.0
1762
            Dim dX As Double = 0.0
1763
            Dim dY As Double = 0.0
1764
            If ConvertPointBystring(sLocation, dLocationx, dLocationy) Then
1765
                dX = dLocationx
1766
                dY = dLocationy
1767
                For Each oRow In oPipeRun_Dt.Rows
1768
                    Dim dStartx As Double = Double.Parse(oRow("startx").ToString())
1769
                    Dim dStarty As Double = Double.Parse(oRow("starty").ToString())
1770
                    Dim dEndx As Double = Double.Parse(oRow("endx").ToString())
1771
                    Dim dEndy As Double = Double.Parse(oRow("endy").ToString())
1772
                    Dim dStartSum As Double = Math.Abs(dStartx - dLocationx) + Math.Abs(dStarty - dLocationy)
1773
                    Dim dEndSum As Double = Math.Abs(dEndx - dLocationx) + Math.Abs(dEndy - dLocationy)
1774
                    If dStartSum > dEndSum Then
1775
                        oRow("value") = dEndSum
1776
                    Else
1777
                        oRow("value") = dStartSum
1778
                    End If
1779
                Next
1780
                Dim dataView As New DataView(oPipeRun_Dt)
1781
                dataView.Sort = " value asc"
1782
                Dim oDt As DataTable = dataView.ToTable()
1783
                If oDt.Rows.Count > 0 Then
1784
                    Try
1785
                        Dim oPiperun As LMPipeRun = CType(oDt.Rows(0)("Piperun"), LMPipeRun)
1786
                        ConvertPointByImage(dX, dY, _IMG_X, _IMG_Y)
1787
                        Dim dLineNoLocation(2) As Double
1788
                        dLineNoLocation(1) = dX
1789
                        dLineNoLocation(2) = dY
1790
                        'Label
1791
                        Dim sSystemPath As String = CLine_No.SystemPath
1792
                        Dim dAngle As Double = CLine_No.Angle
1793
                        Dim labelpersist As LMLabelPersist
1794
                        For Each representation In oPiperun.Representations
1795
                            If representation.RepresentationType = "Connector" Then
1796
                                labelpersist = _Placement.PIDPlaceLabel(sSystemPath,
1797
                                dLineNoLocation,, dAngle, LabeledItem:=representation)
1798
                                _iPipeLineNocnt = _iPipeLineNocnt + 1
1799
                                SetListBoxItems(ListBox_Result, "Place PipeLineNo Label.." & CLine_No.Uid & " (" & dLocationx & "," & dLocationy & ")..." & _iPipeLineNocnt & " count ")
1800
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Pipe : " & CLine_No.Uid & "")
1801
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & CLine_No.Text)
1802
                                'ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
1803
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Origina lPoint : " & dLocationx & "," & dLocationy)
1804
                                ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "PipeLineNo Count : " & _iPipeLineNocnt)
1805
                            End If
1806
                        Next
1807
                    Catch ex As Exception
1808
                    End Try
1809
                End If
1810
                Return True
1811
            Else
1812
                Return False
1813
            End If
1814
        Catch ex As Exception
1815
            Return False
1816
        End Try
1817
    End Function
1818

  
1819

  
1820
    Private Sub InitItemCount()
1821
        _iPipeLineNocnt = 0
1822
        _iPipecnt = 1
1823
        _iFittingcnt = 1
1824
        _iValvecnt = 0
1825
        _iInstrumentcnt = 0
1826
        _iEquipmentcnt = 0
1827
        _iNozzlecnt = 1
1828
        _iPipintOpccnt = 0
1829
    End Sub
1830

  
1831
    Private Function GetAllCheckNodeCount() As Integer
1832
        _allItem = 0
1833
        For i = 0 To Tree_Result.Nodes.Count - 1
1834
            For j = 0 To Tree_Result.Nodes(i).Nodes.Count - 1
1835
                For k = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes.Count - 1
1836
                    For l = 0 To Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes.Count - 1
1837
                        If Tree_Result.Nodes(i).Nodes(j).Nodes(k).Nodes(l).Checked = True Then
1838
                            _allItem = _allItem + 1
1839
                        End If
1840
                    Next
1841
                Next
1842
            Next
1843
        Next
1844
        Return _allItem
1845
    End Function
1846

  
1847

  
1848
    ''' <summary>
1849
    ''' Equipment 모델링
1850
    ''' </summary>
1851
    Private Sub EquipmentModeling(ByVal oDwg_Dt As DataTable)
1852
        For Each oDrwing As TreeNode In Tree_Result.Nodes
1853
            For Each oDwgNode As TreeNode In oDrwing.Nodes
1854
                Dim sDwgName As String = Path.GetFileNameWithoutExtension(oDwgNode.Text)
1855
                Dim CDrawing As Drawing = GetDrawing(sDwgName)
1856
                If CDrawing IsNot Nothing Then
1857
                    If OpenSPPID(oDwg_Dt, oDwgNode.Text) Then
1858

  
1859
                        For Each oNode As TreeNode In oDwgNode.Nodes
1860
                            Dim iItemcnt As Integer = 0
1861
                            Dim sNodeUid As String = oNode.Name
1862
                            Dim oPipeRun_Dt As DataTable = PipeRun_Dt()
1863
                            '1.Equipment
1864
                            '2.Piping OPC
1865
                            '3.OPC 시작되는 Line
1866
                            'Equipment 생성
1867
                            Dim CEqpNo As Eqp_no = GetEqpNo(CDrawing, sNodeUid)
1868
                            If CEqpNo IsNot Nothing Then
1869
                                Dim oSymbol_Dt As DataTable = CEqpNo.Dt_Equipment
1870
                                Dim oAttribute_Dt As DataTable = CEqpNo.Dt_Attribute
1871
                                For Each oSymbolNode As TreeNode In oNode.Nodes
1872
                                    If oSymbolNode.Checked Then
1873
                                        Dim sUid As String = oSymbolNode.Name
1874
                                        PlaceEquipment(sUid, oSymbol_Dt, oAttribute_Dt, CEqpNo.Text)
1875
                                    End If
1876
                                Next
1877
                            End If
1878
                        Next
1879
                    End If
1880
                End If
1881
            Next
1882
        Next
1883
    End Sub
1884

  
1885
    Private Sub ManualCheckNode(ByRef oDt As DataTable)
1886
        For Each oDrwing As TreeNode In Tree_Result.Nodes
1887
            For Each oDwgNode As TreeNode In oDrwing.Nodes
1888
                For Each oNode As TreeNode In oDwgNode.Nodes
1889
                    For Each oSymbolNode As TreeNode In oNode.Nodes
1890
                        Dim sUid As String = oSymbolNode.Name
1891
                        'Dim oSelectRows() As DataRow = oDt.Select("[" & _XML_SYMBOL_UID & "] = '" & sUid &
1892
                        '                                      "' And [" & _XML_SYMBOL_DRAWING_TF & "] = 'False'")
1893
                        If oSymbolNode.Checked Then
1894
                            Dim oSelectRows() As DataRow = oDt.Select("[" & _XML_SYMBOL_UID & "] = '" & sUid & "'")
1895
                            If oSelectRows.Length = 1 Then
1896
                                oSelectRows(0)(_XML_SYMBOL_DRAWING_TF) = "FALSE"
1897
                                If oSymbolNode.Checked Then
1898
                                    oSelectRows(0)(_XML_SYMBOL_Check) = "TRUE"
1899
                                Else
1900
                                    oSelectRows(0)(_XML_SYMBOL_Check) = "FALSE"
1901
                                End If
1902
                            End If
1903
                        End If
1904
                    Next
1905
                Next
1906
            Next
1907
        Next
1908

  
1909
    End Sub
1910

  
1911
    Private Function FinalSymbolModeling(ByVal oCurrentSymbolRow As DataRow, ByVal oLine_Dt As DataTable, ByVal oSymbol_Dt As DataTable,
1912
                                  ByVal oAttribute_Dt As DataTable) As String
1913
        Dim sReturnUid As String = ""
1914
        Dim sOriginalPoint As String = ""
1915
        Dim dOriginal_x As Double = 0.0
1916
        Dim dOriginal_y As Double = 0.0
1917
        Dim dConn1_x As Double = 0.0
1918
        Dim dConn1_y As Double = 0.0
1919
        Dim dConn2_x As Double = 0.0
1920
        Dim dConn2_y As Double = 0.0
1921
        Dim dConn3_x As Double = 0.0
1922
        Dim dConn3_y As Double = 0.0
1923
        Dim dConn4_x As Double = 0.0
1924
        Dim dConn4_y As Double = 0.0
1925
        Dim sUid As String = oCurrentSymbolRow(_XML_SYMBOL_UID)
1926
        Dim sSystemPath As String = oCurrentSymbolRow(_XML_SYMBOL_SYSTEMPATH).ToString()
1927
        Dim dAngle As Double = oCurrentSymbolRow(_XML_SYMBOL_ANGLE)
1928
        Dim sLineNoText As String = oCurrentSymbolRow(_XML_LINENO_TEXT)
1929
        Dim sLineNoUid As String = oCurrentSymbolRow(_XML_LINE_LINENOUID).ToString()
1930
        sOriginalPoint = oCurrentSymbolRow(_XML_SYMBOL_ORIGINALPOINT).ToString()
1931
        Dim sSymbolCompType As String = oCurrentSymbolRow(_XML_SYMBOL_TYPE).ToString()
1932
        ConvertPointBystring(sOriginalPoint, dOriginal_x, dOriginal_y)
1933
        ConvertPointByImage(dOriginal_x, dOriginal_y, _IMG_X, _IMG_Y)
1934
        Dim sChildItem As String = oCurrentSymbolRow(_XML_SYMBOL_CHILD)
1935
        'Connection 정보 체크, 모델링 되어 있는지 유무
1936
        '양 커넥션의 모델링 유무를 체크한다.
1937
        Dim sConn1Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString()
1938
        Dim sConn2Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString()
1939
        Dim sConn3Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString()
1940
        Dim sConn4Uid As String = oCurrentSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString()
1941
        Dim sConn1Type As String = ""
1942
        Dim sConn2Type As String = ""
1943
        Dim sConn3Type As String = ""
1944
        Dim sConn4Type As String = ""
1945
        Dim oConn1Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn1Uid & "'")
1946
        If oConn1Rows.Length = 0 Then
1947
            oConn1Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn1Uid & "'")
1948
            If oConn1Rows.Length = 1 Then
1949
                sConn1Type = "Line"
1950
            End If
1951
        Else
1952
            sConn1Type = "Symbol"
1953
        End If
1954

  
1955
        Dim oConn2Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn2Uid & "'")
1956
        If oConn2Rows.Length = 0 Then
1957
            oConn2Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn2Uid & "'")
1958
            If oConn2Rows.Length = 1 Then
1959
                sConn2Type = "Line"
1960
            End If
1961
        Else
1962
            sConn2Type = "Symbol"
1963
        End If
1964

  
1965
        Dim oConn3Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn3Uid & "'")
1966
        If oConn3Rows.Length = 0 Then
1967
            oConn3Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn3Uid & "'")
1968
            If oConn3Rows.Length = 1 Then
1969
                sConn3Type = "Line"
1970
            End If
1971
        Else
1972
            sConn3Type = "Symbol"
1973
        End If
1974

  
1975
        Dim oConn4Rows() As DataRow = oSymbol_Dt.Select("[" & _XML_SYMBOL_UID & "] = '" & sConn4Uid & "'")
1976
        If oConn4Rows.Length = 0 Then
1977
            oConn4Rows = oLine_Dt.Select("[" & _XML_LINE_UID & "] = '" & sConn4Uid & "'")
1978
            If oConn4Rows.Length = 1 Then
1979
                sConn4Type = "Line"
1980
            End If
1981
        Else
1982
            sConn4Type = "Symbol"
1983
        End If
1984

  
1985
        Dim oStartLMConnector As LMConnector = Nothing
1986
        Dim oEndLMConnector As LMConnector = Nothing
1987
        Dim objInputs As PlaceRunInputs
1988
        objInputs = New PlaceRunInputs
1989
        Dim iModelingType As Integer = 0
1990
        If sConn1Type <> "" Then
1991
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn1_Point).ToString(), dConn1_x, dConn1_y)
1992
        End If
1993
        If sConn2Type <> "" Then
1994
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn2_Point).ToString(), dConn2_x, dConn2_y)
1995
        End If
1996
        If sConn3Type <> "" Then
1997
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn3_Point).ToString(), dConn3_x, dConn3_y)
1998
        End If
1999
        If sConn4Type <> "" Then
2000
            ConvertPoint(oCurrentSymbolRow(_XML_SYMBOL_Conn4_Point).ToString(), dConn4_x, dConn4_y)
2001
        End If
2002

  
2003
        Dim sFirstUid As String = ""
2004
        Dim sSecondUid As String = ""
2005
        Dim oLMSymbol As LMSymbol = Nothing
2006
        Dim dPreConn_x As Double = 0
2007
        Dim dPreConn_y As Double = 0
2008
        Dim sStartConnectionUid As String = ""
2009
        Dim sEndConnectionUid As String = ""
2010
        If sConn1Type <> "" And sConn2Type <> "" Then
2011
            If sConn1Type = "Line" Then
2012
                CheckConnectionLine(dConn1_x, dConn1_y, oStartLMConnector, sStartConnectionUid)
2013
            Else
2014
                CheckConnectionSymbolToSymbol(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector)
2015
            End If
2016

  
2017
            If sConn2Type = "Line" Then
2018
                CheckConnectionLine(dConn2_x, dConn2_y, oEndLMConnector, sEndConnectionUid)
2019
            Else
2020
                CheckConnectionSymbolToSymbol(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector)
2021
            End If
2022

  
2023
            sFirstUid = CheckExistModeling(oConn1Rows(0))
2024
            sSecondUid = CheckExistModeling(oConn2Rows(0))
2025
            Dim oCurrentLMConnector As LMConnector = Nothing
2026

  
2027
        ElseIf sConn1Type <> "" And sConn2Type = "" Then
2028
            If sConn1Type = "Line" Then
2029
                CheckConnectionLine(dConn1_x, dConn1_y, oStartLMConnector, sStartConnectionUid)
2030
            Else
2031
                CheckConnectionSymbolToSymbol(oConn1Rows, dConn1_x, dConn1_y, oStartLMConnector)
2032
                dOriginal_x = dConn1_x
2033
                dOriginal_y = dConn1_y
2034
            End If
2035

  
2036
            sFirstUid = CheckExistModeling(oConn1Rows(0))
2037

  
2038
        ElseIf sConn1Type = "" And sConn2Type <> "" Then
2039

  
2040
            If sConn1Type = "Line" Then
2041
                CheckConnectionLine(dConn2_x, dConn2_y, oEndLMConnector, sEndConnectionUid)
2042
            Else
2043
                CheckConnectionSymbolToSymbol(oConn2Rows, dConn2_x, dConn2_y, oEndLMConnector)
2044
                dOriginal_x = dConn2_x
2045
                dOriginal_y = dConn2_y
2046
            End If
2047
            sSecondUid = CheckExistModeling(oConn2Rows(0))
2048

  
2049
        ElseIf sConn3Type <> "" And sConn4Type <> "" Then
2050
            If sConn1Type = "Line" Then
2051
                CheckConnectionLine(dConn3_x, dConn3_y, oStartLMConnector, sStartConnectionUid)
2052
            Else
2053
                CheckConnectionSymbolToSymbol(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector)
2054
            End If
2055

  
2056
            If sConn2Type = "Line" Then
2057
                CheckConnectionLine(dConn4_x, dConn4_y, oEndLMConnector, sEndConnectionUid)
2058
            Else
2059
                CheckConnectionSymbolToSymbol(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector)
2060
            End If
2061

  
2062
            sFirstUid = CheckExistModeling(oConn3Rows(0))
2063
            sSecondUid = CheckExistModeling(oConn4Rows(0))
2064

  
2065
        ElseIf sConn3Type <> "" And sConn4Type = "" Then
2066
            If sConn1Type = "Line" Then
2067
                CheckConnectionLine(dConn3_x, dConn3_y, oStartLMConnector, sStartConnectionUid)
2068
            Else
2069
                CheckConnectionSymbolToSymbol(oConn3Rows, dConn3_x, dConn3_y, oStartLMConnector)
2070
                dOriginal_x = dConn3_x
2071
                dOriginal_y = dConn3_y
2072
            End If
2073

  
2074
            sFirstUid = CheckExistModeling(oConn3Rows(0))
2075

  
2076
        ElseIf sConn3Type = "" And sConn4Type <> "" Then
2077
            If sConn2Type = "Line" Then
2078
                CheckConnectionLine(dConn4_x, dConn4_y, oEndLMConnector, sEndConnectionUid)
2079
            Else
2080
                CheckConnectionSymbolToSymbol(oConn4Rows, dConn4_x, dConn4_y, oEndLMConnector)
2081
                dOriginal_x = dConn4_x
2082
                dOriginal_y = dConn4_y
2083
            End If
2084

  
2085
            sSecondUid = CheckExistModeling(oConn4Rows(0))
2086

  
2087
        Else
2088

  
2089
        End If
2090

  
2091
        If sFirstUid <> "" And sSecondUid <> "" Then
2092
            sReturnUid = sSecondUid
2093
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
2094
            sReturnUid = sFirstUid
2095
        ElseIf sFirstUid <> "" And sSecondUid = "" Then
2096
            sReturnUid = sFirstUid
2097
        ElseIf sSecondUid <> "" And sFirstUid = "" Then
2098
            sReturnUid = sSecondUid
2099
        ElseIf sSecondUid <> "" And sFirstUid = "" Then
2100
            sReturnUid = sSecondUid
2101
        Else
2102
            sReturnUid = ""
2103
        End If
2104

  
2105
        If sSymbolCompType.ToUpper() = _SYMBOL_INSTUMENT.ToUpper() Then
2106
            oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2107
            oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2108
        Else
2109
            If oStartLMConnector IsNot Nothing And oEndLMConnector IsNot Nothing Then
2110
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2111
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2112
            ElseIf oStartLMConnector IsNot Nothing And oEndLMConnector Is Nothing Then
2113
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle,,
2114
                            TargetItem:=oStartLMConnector.AsLMAItem)
2115
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2116
            ElseIf oStartLMConnector Is Nothing And oEndLMConnector IsNot Nothing Then
2117
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle,,
2118
                TargetItem:=oEndLMConnector.AsLMAItem)
2119
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2120
            Else
2121
                oLMSymbol = _Placement.PIDPlaceSymbol(sSystemPath, dOriginal_x, dOriginal_y,, dAngle)
2122
                oCurrentSymbolRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2123
            End If
2124
        End If
2125

  
2126
        '모델링 된 Symbol 데이터 테이블 저장
2127
        Dim oAddRow As DataRow = _ModelingSymbol_Dt.NewRow
2128
        oAddRow(_XML_SYMBOL_SPID) = oLMSymbol.ModelItemID
2129
        oAddRow(_XML_SYMBOL_LMSYMBOL) = oLMSymbol
2130
        oAddRow(_XML_SYMBOL_DRAWING_TF) = "TRUE"
2131
        oAddRow(_XML_SYMBOL_CENTERPOINT_X) = dOriginal_x
2132
        oAddRow(_XML_SYMBOL_CENTERPOINT_Y) = dOriginal_y
2133
        oAddRow(_XML_SYMBOL_MIN_X) = oCurrentSymbolRow(_XML_SYMBOL_MIN_X)
2134
        oAddRow(_XML_SYMBOL_MAX_X) = oCurrentSymbolRow(_XML_SYMBOL_MAX_X)
2135
        oAddRow(_XML_SYMBOL_MIN_Y) = oCurrentSymbolRow(_XML_SYMBOL_MIN_Y)
2136
        oAddRow(_XML_SYMBOL_MAX_Y) = oCurrentSymbolRow(_XML_SYMBOL_MAX_Y)
2137
        _ModelingSymbol_Dt.Rows.Add(oAddRow)
2138

  
2139
        If sChildItem <> "" Then
2140
            Dim sConn1_Systempath As String = ""
2141
            Dim sConn2_Systempath As String = ""
2142
            Dim sConn1_Angle As Double = 0
2143
            Dim sConn2_Angle As Double = 0
2144

  
2145
            For Each sDirection In sChildItem.Split("/")
2146
                Dim iType As Integer = 0
2147
                For Each sType In sDirection.Split(",")
2148
                    If sConn1_Systempath = "" Then
2149

  
2150
                        If iType = 0 Then
2151
                            sConn1_Angle = GetChildSymbolDirection(sType)
2152
                            iType = iType + 1
2153
                        Else
2154
                            Dim sStartpoint As String = oCurrentSymbolRow(_XML_SYMBOL_Conn1_Point).ToString()
2155
                            ConvertPointBystring(sStartpoint, dConn1_x, dConn1_y)
2156
                            ConvertPointByImage(dConn1_x, dConn1_y, _IMG_X, _IMG_Y)
2157
                            sConn1_Systempath = GetDataFromMappingDB(sType, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
2158
                            Dim dChildConn1_x As Double = 0
2159
                            Dim dChildConn1_y As Double = 0
2160

  
2161
                            If oLMSymbol IsNot Nothing Then
2162
                                _Placement.PIDConnectPointLocation(oLMSymbol, 1, dChildConn1_x, dChildConn1_y)
2163
                                _Placement.PIDPlaceSymbol(sConn1_Systempath, dChildConn1_x, dChildConn1_y,, sConn1_Angle,,
2164
                                 TargetItem:=oLMSymbol.AsLMAItem)
2165
                            Else
2166
                                _Placement.PIDPlaceSymbol(sConn1_Systempath, dConn1_x, dConn1_y,, sConn1_Angle,,)
2167
                            End If
2168
                        End If
2169

  
2170
                    Else
2171
                        If iType = 0 Then
2172
                            sConn2_Angle = GetChildSymbolDirection(sType)
2173
                            iType = iType + 1
2174
                        Else
2175
                            Dim sEndPoint As String = oCurrentSymbolRow(_XML_SYMBOL_Conn2_Point).ToString()
2176
                            ConvertPointBystring(sEndPoint, dConn2_x, dConn2_y)
2177
                            ConvertPointByImage(dConn2_x, dConn2_y, _IMG_X, _IMG_Y)
2178
                            sConn2_Systempath = GetDataFromMappingDB(sType, _DB_COLUMN_MAPPING_SPPID_SYSTEMPATH)
2179

  
2180
                            Dim dChildConn2_x As Double = 0
2181
                            Dim dChildConn2_y As Double = 0
2182

  
2183
                            If oLMSymbol IsNot Nothing Then
2184
                                _Placement.PIDConnectPointLocation(oLMSymbol, 2, dChildConn2_x, dChildConn2_y)
2185
                                _Placement.PIDPlaceSymbol(sConn1_Systempath, dChildConn2_x, dChildConn2_y,, sConn2_Angle,,
2186
                                        TargetItem:=oLMSymbol.AsLMAItem)
2187
                            Else
2188
                                _Placement.PIDPlaceSymbol(sConn2_Systempath, dChildConn2_x, dChildConn2_y,, sConn2_Angle,,)
2189
                            End If
2190

  
2191
                        End If
2192
                    End If
2193
                Next
2194
            Next
2195
        End If
2196

  
2197
        AddProgress()
2198

  
2199
        SetListBoxItems(ListBox_Result, "Place Fitting.." & sUid & " (" & dOriginal_x & "," & dOriginal_y & ")..." & _iFittingcnt & " count ")
2200
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Place Fitting : " & sUid)
2201
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "LineNo : " & sLineNoText)
2202
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "ModelingType : " & iModelingType)
2203
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn1_Point : " & dConn1_x & "," & dConn1_y)
2204
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn2_Point : " & dConn2_x & "," & dConn2_y)
2205
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn3_Point : " & dConn3_x & "," & dConn3_y)
2206
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Conn4_Point : " & dConn4_x & "," & dConn4_y)
2207
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection1 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn1_Uid).ToString())
2208
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection2 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn2_Uid).ToString())
2209
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection3 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn3_Uid).ToString())
2210
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Connection4 : " & oCurrentSymbolRow(_XML_SYMBOL_Conn4_Uid).ToString())
2211
        ComUtil.MessageLog.CEventLog.Log_Write_Update(_Log_Path, _Log_File, "Angle : " & dAngle)
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff