/** * Initialize OPC */ public void InitializeOPC(string strProdID, string strServerAddress) { int iResFunc = 0; m_opcMgr = new opcMgrClass(); m_opcMgr.opcSetLogDirectory(Application.StartupPath + "\\NetIFLog"); //iResFunc = m_opcMgr.opcRegSvrEx("C:\\UsrAppConf.xml", "OPCsoft.opcSvrTS.1", "", "", 5); iResFunc = m_opcMgr.opcRegSvrEx("C:\\UsrAppConf.xml", strProdID, strServerAddress, "", 5); if (iResFunc == 1) { this.m_MainClass.m_Define_Class.isOpcCon = true; Console.WriteLine("OpcRegSvrEx() Success!"); } else { this.m_MainClass.m_Define_Class.isOpcCon = false; Console.WriteLine("OpcRegSvrEx() Failed! Error Code:" + iResFunc); } }
public void getOpcGetTagList(string strProdID, string strServerAddress) { int iResFunc = 0; int iIdx = 0; opcMgrClass opcMgr = new opcMgrClass(); object oTagName = new object[1]; object oTagDataType = new object[1]; //iResFunc = opcMgr.opcGetTagList(ref oTagName, ref oTagDataType, "OPCsoft.opcSvrTS.1", "", "1"); iResFunc = opcMgr.opcGetTagList(ref oTagName, ref oTagDataType, strProdID, strServerAddress, "1"); if (iResFunc < 1) { Console.WriteLine("[Error} getOpcGetTagList"); return; } //this.m_MainClass.m_MainForm.tbOPC_Group.Text = objReadVals[0].ToString(); //this.m_MainClass.m_MainForm.txtOPCReadData_2.Text = objReadVals[1].ToString(); this.m_MainClass.m_MainForm.radGridView13.TableElement.BeginUpdate(); this.m_MainClass.m_MainForm.radGridView13.Rows.Clear(); Array o = (Array)oTagName; Array oDT = (Array)oTagDataType; for (int i = 0; i < oDT.Length; i++) { this.m_MainClass.m_MainForm.radGridView13.Rows.AddNew(); this.m_MainClass.m_MainForm.radGridView13.Rows[i].Cells["No"].Value = i + 1; this.m_MainClass.m_MainForm.radGridView13.Rows[i].Cells["TagName"].Value = o.GetValue(i).ToString(); this.m_MainClass.m_MainForm.radGridView13.Rows[i].Cells["Data"].Value = oDT.GetValue(i).ToString(); } this.m_MainClass.m_MainForm.radGridView13.TableElement.EndUpdate(); }