hytos / DTI_PID / SPPIDConverter / AutoModeling_OPC.cs @ 1ed39474
이력 | 보기 | 이력해설 | 다운로드 (2.96 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using System.Data; |
7 |
using Llama; |
8 |
using Plaice; |
9 |
using Ingr.RAD2D.Interop.RAD2D; |
10 |
using Ingr.RAD2D.Internal; |
11 |
using Ingr.RAD2D.Helper; |
12 |
using Converter.BaseModel; |
13 |
using Converter.SPPID.Model; |
14 |
using Converter.SPPID.Properties; |
15 |
using Converter.SPPID.Util; |
16 |
using Converter.SPPID.DB; |
17 |
using Ingr.RAD2D.MacroControls.CmdCtrl; |
18 |
using Ingr.RAD2D; |
19 |
using System.Windows; |
20 |
using System.Threading; |
21 |
using System.Drawing; |
22 |
using Microsoft.VisualBasic; |
23 |
using Newtonsoft.Json; |
24 |
|
25 |
using DevExpress.XtraSplashScreen; |
26 |
namespace Converter.SPPID |
27 |
{ |
28 |
public class AutoModeling_OPC |
29 |
{ |
30 |
Placement _placement; |
31 |
LMADataSource dataSource; |
32 |
dynamic application; |
33 |
Ingr.RAD2D.Application radApp; |
34 |
List<SPPID_Document> allDocuments; |
35 |
|
36 |
public AutoModeling_OPC(List<SPPID_Document> allDocuments, dynamic application, Ingr.RAD2D.Application radApp) |
37 |
{ |
38 |
this.application = application; |
39 |
this.radApp = radApp; |
40 |
this.allDocuments = allDocuments; |
41 |
} |
42 |
|
43 |
public void Run() |
44 |
{ |
45 |
_placement = new Placement(); |
46 |
dataSource = _placement.PIDDataSource; |
47 |
|
48 |
foreach (var document in allDocuments) |
49 |
{ |
50 |
foreach (var opc in document.SYMBOLS) |
51 |
{ |
52 |
if ((opc.TYPE == "Piping OPC's" || |
53 |
opc.TYPE == "Instrument OPC's") && |
54 |
!string.IsNullOrEmpty(opc.SPPID.ModelItemID)) |
55 |
{ |
56 |
PairedOPCModeling(opc); |
57 |
} |
58 |
} |
59 |
} |
60 |
|
61 |
ReleaseCOMObjects(_placement); |
62 |
ReleaseCOMObjects(dataSource); |
63 |
} |
64 |
|
65 |
public void PairedOPCModeling(Symbol opc) |
66 |
{ |
67 |
bool result = false; |
68 |
LMOPC _LMOPC = dataSource.GetOPC(opc.SPPID.ModelItemID); |
69 |
LMOPC pairOPC = _LMOPC.pairedWithOPCObject; |
70 |
|
71 |
foreach (LMRepresentation rep in pairOPC.Representations) |
72 |
if (rep.DrawingID != "0") |
73 |
result = true; |
74 |
|
75 |
if (!result) |
76 |
{ |
77 |
// OPC Pair 찾아서 도면 오픈후 Pair 모델링 |
78 |
OpenDrawing(""); |
79 |
} |
80 |
|
81 |
|
82 |
|
83 |
|
84 |
ReleaseCOMObjects(_LMOPC); |
85 |
ReleaseCOMObjects(pairOPC); |
86 |
} |
87 |
|
88 |
public void ReleaseCOMObjects(params object[] objVars) |
89 |
{ |
90 |
int intNewRefCount = 0; |
91 |
foreach (object obj in objVars) |
92 |
{ |
93 |
if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj)) |
94 |
intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj); |
95 |
} |
96 |
} |
97 |
|
98 |
private void OpenDrawing(string drawingName) |
99 |
{ |
100 |
dynamic doc = application.Drawings.OpenDrawing(drawingName); |
101 |
doc.Activate(); |
102 |
|
103 |
} |
104 |
} |
105 |
} |