개정판 88bac50c
dev issue #498 : OPC 연결 임의로 완료
Change-Id: I77059d9cf7c135e74218646ff360445eeac87c85
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
493 | 493 |
Log.Write("Drawing name : " + drawingName); |
494 | 494 |
Log.Write("Drawing number : " + drawingNumber); |
495 | 495 |
newDrawing = application.Drawings.Add(document.Unit, document.Template, drawingNumber, drawingName); |
496 |
document.SPPID_DrawingNumber = drawingNumber; |
|
497 |
document.SPPID_DrawingName = drawingName; |
|
496 | 498 |
application.ActiveWindow.Fit(); |
497 | 499 |
Thread.Sleep(1000); |
498 | 500 |
application.ActiveWindow.Zoom = 2000; |
DTI_PID/SPPIDConverter/AutoModeling_OPC.cs | ||
---|---|---|
32 | 32 |
dynamic application; |
33 | 33 |
Ingr.RAD2D.Application radApp; |
34 | 34 |
List<SPPID_Document> allDocuments; |
35 |
DataTable drawingTable; |
|
36 | 35 |
|
37 |
public AutoModeling_OPC(List<SPPID_Document> allDocuments, dynamic application, Ingr.RAD2D.Application radApp, DataTable drawingTable)
|
|
36 |
public AutoModeling_OPC(List<SPPID_Document> allDocuments, dynamic application, Ingr.RAD2D.Application radApp) |
|
38 | 37 |
{ |
39 | 38 |
this.application = application; |
40 | 39 |
this.radApp = radApp; |
41 | 40 |
this.allDocuments = allDocuments; |
42 |
this.drawingTable = drawingTable; |
|
43 | 41 |
} |
44 | 42 |
|
45 | 43 |
public void Run() |
... | ... | |
80 | 78 |
BaseModel.Attribute pathAttribute = opc.ATTRIBUTES.Find(x => x.ATTRIBUTE == "PATH"); |
81 | 79 |
BaseModel.Attribute linkOPCAttribute = opc.ATTRIBUTES.Find(x => x.ATTRIBUTE == "LinkOPC"); |
82 | 80 |
|
83 |
DataRow[] rows = drawingTable.Select(string.Format("PATH = '{0}'", pathAttribute.VALUE));
|
|
84 |
if (rows.Length == 1 && OpenDrawing(rows[0]["DRAWINGNAME"].ToString()))
|
|
81 |
SPPID_Document targetDocument = allDocuments.Find(x => x.PATH == pathAttribute.VALUE);
|
|
82 |
if (targetDocument != null)
|
|
85 | 83 |
{ |
86 |
|
|
84 |
Symbol targetOPC = SPPIDUtil.FindObjectByUID(targetDocument, linkOPCAttribute.VALUE) as Symbol; |
|
85 |
if (targetOPC != null && OpenDrawing(targetDocument.SPPID_DrawingName)) |
|
86 |
{ |
|
87 |
LMSymbol targetLMOPC = dataSource.GetSymbol(targetOPC.SPPID.RepresentationId); |
|
88 |
if (targetLMOPC != null) |
|
89 |
{ |
|
90 |
int mirror = targetLMOPC.get_IsMirroredIndex(); |
|
91 |
double angle = Convert.ToDouble(targetLMOPC.get_RotationAngle()); |
|
92 |
double x = targetLMOPC.get_XCoordinate(); |
|
93 |
double y = targetLMOPC.get_YCoordinate(); |
|
94 |
LMSymbol newOPC = null; |
|
95 |
foreach (LMConnector LMConnector in targetLMOPC.Avoid1Connectors) |
|
96 |
{ |
|
97 |
_placement.PIDRemovePlacement(targetLMOPC.AsLMRepresentation()); |
|
98 |
ReleaseCOMObjects(targetLMOPC); |
|
99 |
newOPC = _placement.PIDPlaceSymbol(targetOPC.SPPID.MAPPINGNAME, x, y, Mirror: mirror, Rotation: angle, ExistingItem: pairOPC.AsLMAItem(), TargetItem: LMConnector); |
|
100 |
break; |
|
101 |
} |
|
102 |
|
|
103 |
if (newOPC == null) |
|
104 |
{ |
|
105 |
foreach (LMConnector LMConnector in targetLMOPC.Avoid2Connectors) |
|
106 |
{ |
|
107 |
_placement.PIDRemovePlacement(targetLMOPC.AsLMRepresentation()); |
|
108 |
ReleaseCOMObjects(targetLMOPC); |
|
109 |
newOPC = _placement.PIDPlaceSymbol(targetOPC.SPPID.MAPPINGNAME, x, y, Mirror: mirror, Rotation: angle, ExistingItem: pairOPC.AsLMAItem(), TargetItem: LMConnector); |
|
110 |
break; |
|
111 |
} |
|
112 |
} |
|
113 |
} |
|
114 |
} |
|
87 | 115 |
} |
88 | 116 |
} |
89 | 117 |
|
... | ... | |
106 | 134 |
bool result = false; |
107 | 135 |
try |
108 | 136 |
{ |
109 |
|
|
110 |
|
|
111 |
//dynamic doc = application.Drawings.OpenDrawing(drawingName); |
|
112 |
//doc.Activate(); |
|
137 |
dynamic doc = application.Drawings.OpenDrawing(drawingName); |
|
138 |
doc.Activate(); |
|
113 | 139 |
|
114 | 140 |
result = true; |
115 | 141 |
} |
DTI_PID/SPPIDConverter/BaseModel/Document.cs | ||
---|---|---|
63 | 63 |
{ |
64 | 64 |
try |
65 | 65 |
{ |
66 |
PATH = xmlPath; |
|
67 |
XElement xml = XElement.Load(xmlPath); |
|
68 |
DWGNAME = xml.Element("DWGNAME").Value; |
|
69 |
SIZE = xml.Element("SIZE").Value; |
|
70 |
|
|
71 |
SetText(xml.Element("TEXTINFOS")); |
|
72 |
SetNote(xml.Element("NOTES")); |
|
73 |
SetSymbol(xml.Element("SYMBOLS")); |
|
74 |
SetLine(xml.Element("LINEINFOS")); |
|
75 |
SetLineNumber(xml.Element("LINENOS")); |
|
76 |
SetTrimLine(xml.Element("TRIMLINENOS")); |
|
77 |
|
|
78 |
_Enable = true; |
|
66 |
if (xmlPath != null) |
|
67 |
{ |
|
68 |
PATH = xmlPath; |
|
69 |
XElement xml = XElement.Load(xmlPath); |
|
70 |
DWGNAME = xml.Element("DWGNAME").Value; |
|
71 |
SIZE = xml.Element("SIZE").Value; |
|
72 |
|
|
73 |
SetText(xml.Element("TEXTINFOS")); |
|
74 |
SetNote(xml.Element("NOTES")); |
|
75 |
SetSymbol(xml.Element("SYMBOLS")); |
|
76 |
SetLine(xml.Element("LINEINFOS")); |
|
77 |
SetLineNumber(xml.Element("LINENOS")); |
|
78 |
SetTrimLine(xml.Element("TRIMLINENOS")); |
|
79 |
|
|
80 |
_Enable = true; |
|
81 |
} |
|
79 | 82 |
} |
80 | 83 |
catch (Exception ex) |
81 | 84 |
{ |
DTI_PID/SPPIDConverter/ConverterDocking.cs | ||
---|---|---|
94 | 94 |
LMADataSource dataSource = new LMADataSource(); |
95 | 95 |
LMDrawings drawings = new LMDrawings(); |
96 | 96 |
|
97 |
try |
|
97 |
//try
|
|
98 | 98 |
{ |
99 | 99 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
100 | 100 |
_ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath; |
... | ... | |
128 | 128 |
|
129 | 129 |
List<SPPID_Document> allDocuments = new List<SPPID_Document>(); |
130 | 130 |
foreach (DataRow row in drawingTable.Rows) |
131 |
{ |
|
132 |
SPPID_Document document = JsonConvert.DeserializeObject<SPPID_Document>(row["DOCUMENT"].ToString()); |
|
133 |
allDocuments.Add(document); |
|
134 |
} |
|
131 |
allDocuments.Add((SPPID_Document)row["DOCUMENT"]); |
|
135 | 132 |
|
136 |
AutoModeling_OPC opc = new AutoModeling_OPC(allDocuments, application, radApp, drawingTable);
|
|
133 |
AutoModeling_OPC opc = new AutoModeling_OPC(allDocuments, application, radApp); |
|
137 | 134 |
opc.Run(); |
138 |
//dynamic doc = application.Drawings.OpenDrawing(drawingTable.Rows[0]["DRAWINGNAME"]); |
|
139 |
|
|
140 |
//doc.CloseDrawing(true); |
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
//radApp.Documents.Open(sPPID_DBInfo.PlantPath + @"\" + drawingTable.Rows[0]["SPPIDPATH"].ToString()); |
|
145 | 135 |
} |
146 | 136 |
} |
147 | 137 |
else |
... | ... | |
149 | 139 |
MessageBox.Show(Msg.ConnectionFail, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
150 | 140 |
} |
151 | 141 |
} |
152 |
catch (Exception ex) |
|
142 |
//catch (Exception ex)
|
|
153 | 143 |
{ |
154 |
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
|
144 |
//MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
|
|
155 | 145 |
} |
156 |
finally |
|
146 |
//finally
|
|
157 | 147 |
{ |
158 | 148 |
ReleaseCOMObjects(dataSource); |
159 | 149 |
ReleaseCOMObjects(drawings); |
... | ... | |
203 | 193 |
Placement _placement = new Placement(); |
204 | 194 |
LMADataSource dataSource = new LMADataSource();//placement.PIDDataSource; |
205 | 195 |
|
206 |
radApp.Documents.Open(@"\\192.168.0.85\Project_ID2\ID2CPChemSite\PID\P&ID Reference Data\Symbols\Instrumentation\Actuators\Actuator Handwheel.sym"); |
|
207 |
//MessageBox.Show(radApp.ActiveDocument.ActiveSheet.DrawingObjects.Count.ToString() + "\r\n" + radApp.Documents.Count); |
|
208 |
radApp.ActiveDocument.Close(false); |
|
209 |
radApp.Documents.Open(@"\\192.168.0.85\Project_ID2\ID2CPChemSite\PID\P&ID Reference Data\Symbols\Instrumentation\Actuators\Motor Actuator 270 STD.sym"); |
|
210 |
//MessageBox.Show(radApp.ActiveDocument.ActiveSheet.DrawingObjects.Count.ToString() + "\r\n" + radApp.Documents.Count); |
|
211 |
radApp.ActiveDocument.Close(false); |
|
196 |
//radApp.Documents.Open(@"\\192.168.0.85\Project_ID2\ID2CPChemSite\PID\P&ID Reference Data\Symbols\Instrumentation\Actuators\Actuator Handwheel.sym"); |
|
197 |
////MessageBox.Show(radApp.ActiveDocument.ActiveSheet.DrawingObjects.Count.ToString() + "\r\n" + radApp.Documents.Count); |
|
198 |
//radApp.ActiveDocument.Close(false); |
|
199 |
//radApp.Documents.Open(@"\\192.168.0.85\Project_ID2\ID2CPChemSite\PID\P&ID Reference Data\Symbols\Instrumentation\Actuators\Motor Actuator 270 STD.sym"); |
|
200 |
////MessageBox.Show(radApp.ActiveDocument.ActiveSheet.DrawingObjects.Count.ToString() + "\r\n" + radApp.Documents.Count); |
|
201 |
//radApp.ActiveDocument.Close(false); |
|
202 |
|
|
203 |
LMWSSites ss = new LMWSSites(); |
|
204 |
ss.Collect(dataSource); |
|
205 |
|
|
206 |
foreach (LMWSSite item in ss) |
|
207 |
{ |
|
208 |
string aa =item.get_Name(); |
|
209 |
foreach (LMPlantGroup P in item.PlantGroups) |
|
210 |
{ |
|
211 |
|
|
212 |
} |
|
213 |
} |
|
212 | 214 |
} |
213 | 215 |
[DllImport("user32.dll")] |
214 | 216 |
public static extern int FindWindow(string lpClassName, string lpWindowName); |
DTI_PID/SPPIDConverter/DB/Project_DB.cs | ||
---|---|---|
521 | 521 |
|
522 | 522 |
public static DataTable SelectDrawingInfo() |
523 | 523 |
{ |
524 |
DataTable dt = new DataTable(); |
|
524 |
DataTable dt = new DataTable() { Locale = CultureInfo.CurrentCulture };
|
|
525 | 525 |
Project_Info projectInfo = Project_Info.GetInstance(); |
526 | 526 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
527 | 527 |
{ |
... | ... | |
531 | 531 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
532 | 532 |
{ |
533 | 533 |
cmd.CommandText = string.Format("SELECT * FROM {0}",SPPID_DRAWING_INFO); |
534 |
//using (SQLiteDataAdapter da = new SQLiteDataAdapter(cmd)) |
|
535 |
// da.Fill(dt); |
|
534 | 536 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
535 |
dt.Load(dr); |
|
537 |
{ |
|
538 |
dt.Columns.Add("PATH", typeof(string)); |
|
539 |
dt.Columns.Add("DRAWINGNUMBER", typeof(string)); |
|
540 |
dt.Columns.Add("DRAWINGNAME", typeof(string)); |
|
541 |
dt.Columns.Add("DOCUMENT", typeof(SPPID.Model.SPPID_Document)); |
|
542 |
while (dr.Read()) |
|
543 |
{ |
|
544 |
DataRow row = dt.NewRow(); |
|
545 |
row["PATH"] = dr["PATH"]; |
|
546 |
row["DRAWINGNUMBER"] = dr["DRAWINGNUMBER"]; |
|
547 |
row["DRAWINGNAME"] = dr["DRAWINGNAME"]; |
|
548 |
string jsonString = (string)dr["DOCUMENT"]; |
|
549 |
JsonSerializerSettings settings = new JsonSerializerSettings |
|
550 |
{ |
|
551 |
NullValueHandling = NullValueHandling.Ignore, |
|
552 |
ObjectCreationHandling = ObjectCreationHandling.Replace |
|
553 |
}; |
|
554 |
SPPID.Model.SPPID_Document doc = JsonConvert.DeserializeObject<SPPID.Model.SPPID_Document>(jsonString, settings); |
|
555 |
row["DOCUMENT"] = doc; |
|
556 |
dt.Rows.Add(row); |
|
557 |
} |
|
558 |
//dt.Load(dr, LoadOption.Upsert); |
|
559 |
} |
|
560 |
|
|
536 | 561 |
} |
537 | 562 |
connection.Close(); |
538 | 563 |
} |
DTI_PID/SPPIDConverter/SPPIDModel/SPPID_Document.cs | ||
---|---|---|
30 | 30 |
public string DrawingNumber { get; set; } |
31 | 31 |
public string Unit { get; set; } |
32 | 32 |
public string Template { get; set; } |
33 |
public string SPPID_DrawingNumber { get; set; } |
|
34 |
public string SPPID_DrawingName { get; set; } |
|
33 | 35 |
|
34 | 36 |
public void SetSPPIDInfo() |
35 | 37 |
{ |
내보내기 Unified diff