hytos / DTI_PID / SPPIDConverter / AutoModeling_OPC.cs @ 71ba1ca3
이력 | 보기 | 이력해설 | 다운로드 (3.73 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 | 71ba1ca3 | gaqhf | DataTable drawingTable; |
36 | 69b7387a | gaqhf | |
37 | 71ba1ca3 | gaqhf | public AutoModeling_OPC(List<SPPID_Document> allDocuments, dynamic application, Ingr.RAD2D.Application radApp, DataTable drawingTable) |
38 | 69b7387a | gaqhf | { |
39 | this.application = application; |
||
40 | this.radApp = radApp; |
||
41 | 1ed39474 | gaqhf | this.allDocuments = allDocuments; |
42 | 71ba1ca3 | gaqhf | this.drawingTable = drawingTable; |
43 | 69b7387a | gaqhf | } |
44 | |||
45 | 224535bb | gaqhf | public void Run() |
46 | 69b7387a | gaqhf | { |
47 | 1ed39474 | gaqhf | _placement = new Placement(); |
48 | dataSource = _placement.PIDDataSource; |
||
49 | 224535bb | gaqhf | |
50 | 1ed39474 | gaqhf | foreach (var document in allDocuments) |
51 | { |
||
52 | foreach (var opc in document.SYMBOLS) |
||
53 | { |
||
54 | if ((opc.TYPE == "Piping OPC's" || |
||
55 | opc.TYPE == "Instrument OPC's") && |
||
56 | !string.IsNullOrEmpty(opc.SPPID.ModelItemID)) |
||
57 | { |
||
58 | PairedOPCModeling(opc); |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 | 69b7387a | gaqhf | |
63 | 1ed39474 | gaqhf | ReleaseCOMObjects(_placement); |
64 | ReleaseCOMObjects(dataSource); |
||
65 | } |
||
66 | 69b7387a | gaqhf | |
67 | 1ed39474 | gaqhf | public void PairedOPCModeling(Symbol opc) |
68 | { |
||
69 | bool result = false; |
||
70 | LMOPC _LMOPC = dataSource.GetOPC(opc.SPPID.ModelItemID); |
||
71 | LMOPC pairOPC = _LMOPC.pairedWithOPCObject; |
||
72 | 224535bb | gaqhf | |
73 | 1ed39474 | gaqhf | foreach (LMRepresentation rep in pairOPC.Representations) |
74 | if (rep.DrawingID != "0") |
||
75 | result = true; |
||
76 | 224535bb | gaqhf | |
77 | 1ed39474 | gaqhf | if (!result) |
78 | { |
||
79 | // OPC Pair 찾아서 도면 오픈후 Pair 모델링 |
||
80 | 71ba1ca3 | gaqhf | BaseModel.Attribute pathAttribute = opc.ATTRIBUTES.Find(x => x.ATTRIBUTE == "PATH"); |
81 | BaseModel.Attribute linkOPCAttribute = opc.ATTRIBUTES.Find(x => x.ATTRIBUTE == "LinkOPC"); |
||
82 | 224535bb | gaqhf | |
83 | 71ba1ca3 | gaqhf | DataRow[] rows = drawingTable.Select(string.Format("PATH = '{0}'", pathAttribute.VALUE)); |
84 | if (rows.Length == 1 && OpenDrawing(rows[0]["DRAWINGNAME"].ToString())) |
||
85 | { |
||
86 | |||
87 | } |
||
88 | } |
||
89 | 224535bb | gaqhf | |
90 | 1ed39474 | gaqhf | ReleaseCOMObjects(_LMOPC); |
91 | ReleaseCOMObjects(pairOPC); |
||
92 | 224535bb | gaqhf | } |
93 | |||
94 | public void ReleaseCOMObjects(params object[] objVars) |
||
95 | { |
||
96 | int intNewRefCount = 0; |
||
97 | foreach (object obj in objVars) |
||
98 | { |
||
99 | if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj)) |
||
100 | intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj); |
||
101 | } |
||
102 | 69b7387a | gaqhf | } |
103 | 1ed39474 | gaqhf | |
104 | 71ba1ca3 | gaqhf | private bool OpenDrawing(string drawingName) |
105 | 1ed39474 | gaqhf | { |
106 | 71ba1ca3 | gaqhf | bool result = false; |
107 | try |
||
108 | { |
||
109 | |||
110 | |||
111 | //dynamic doc = application.Drawings.OpenDrawing(drawingName); |
||
112 | //doc.Activate(); |
||
113 | |||
114 | result = true; |
||
115 | } |
||
116 | catch (Exception ex) |
||
117 | { |
||
118 | System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
||
119 | } |
||
120 | 1ed39474 | gaqhf | |
121 | 71ba1ca3 | gaqhf | return result; |
122 | 1ed39474 | gaqhf | } |
123 | 69b7387a | gaqhf | } |
124 | } |