hytos / DTI_PID / SPPIDConverter / AutoModeling_OPC.cs @ 5483ff95
이력 | 보기 | 이력해설 | 다운로드 (2.96 KB)
1 | 69b7387a | gaqhf | 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 | 1ed39474 | gaqhf | List<SPPID_Document> allDocuments; |
35 | 69b7387a | gaqhf | |
36 | 1ed39474 | gaqhf | public AutoModeling_OPC(List<SPPID_Document> allDocuments, dynamic application, Ingr.RAD2D.Application radApp) |
37 | 69b7387a | gaqhf | { |
38 | this.application = application; |
||
39 | this.radApp = radApp; |
||
40 | 1ed39474 | gaqhf | this.allDocuments = allDocuments; |
41 | 69b7387a | gaqhf | } |
42 | |||
43 | 224535bb | gaqhf | public void Run() |
44 | 69b7387a | gaqhf | { |
45 | 1ed39474 | gaqhf | _placement = new Placement(); |
46 | dataSource = _placement.PIDDataSource; |
||
47 | 224535bb | gaqhf | |
48 | 1ed39474 | gaqhf | 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 | 69b7387a | gaqhf | |
61 | 1ed39474 | gaqhf | ReleaseCOMObjects(_placement); |
62 | ReleaseCOMObjects(dataSource); |
||
63 | } |
||
64 | 69b7387a | gaqhf | |
65 | 1ed39474 | gaqhf | public void PairedOPCModeling(Symbol opc) |
66 | { |
||
67 | bool result = false; |
||
68 | LMOPC _LMOPC = dataSource.GetOPC(opc.SPPID.ModelItemID); |
||
69 | LMOPC pairOPC = _LMOPC.pairedWithOPCObject; |
||
70 | 224535bb | gaqhf | |
71 | 1ed39474 | gaqhf | foreach (LMRepresentation rep in pairOPC.Representations) |
72 | if (rep.DrawingID != "0") |
||
73 | result = true; |
||
74 | 224535bb | gaqhf | |
75 | 1ed39474 | gaqhf | if (!result) |
76 | { |
||
77 | // OPC Pair 찾아서 도면 오픈후 Pair 모델링 |
||
78 | OpenDrawing(""); |
||
79 | } |
||
80 | 224535bb | gaqhf | |
81 | 1ed39474 | gaqhf | |
82 | |||
83 | 224535bb | gaqhf | |
84 | 1ed39474 | gaqhf | ReleaseCOMObjects(_LMOPC); |
85 | ReleaseCOMObjects(pairOPC); |
||
86 | 224535bb | gaqhf | } |
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 | 69b7387a | gaqhf | } |
97 | 1ed39474 | gaqhf | |
98 | private void OpenDrawing(string drawingName) |
||
99 | { |
||
100 | dynamic doc = application.Drawings.OpenDrawing(drawingName); |
||
101 | doc.Activate(); |
||
102 | |||
103 | } |
||
104 | 69b7387a | gaqhf | } |
105 | } |