デバイス
- OPCサーバーアクセス
OPCサーバーへのアクセス方法を紹介します。
まずは以下よりOPCクライアントをダウンロードしてインストールしてください。アカウントの作成が必要です。
OPC Foundation
- OPC Core Components 3.00 SDK
- OPC Core Components 3.00 Redistributable (x86)
その後、参照設定→COMタブより以下を選択してください。
「OPC DA Automation Wrapper」
// 接続
OPCServer opcServer = new OPCServer();
opcServer.Connect( "Takebishi.Dxp", string.Empty );
// 対象OPCタグの登録(サーバーにはすでに登録されていること)
OPCGroup opcGroup = opcServer.OPCGroups.Add( "Melsec1.Tracking" );
opcGroup.IsSubscribed = true;
OPCItem item = opcGroup.OPCItems.AddItem( "Melsec1.Tracking.Tag1", 1 );
// 書き込み
item.Write( 6 );
// 読み出し
object data;
object quality;
object time;
item.Read( 0, out data, out quality, out time );
// 切断
opcServer.Disconnect();