dOPC Client Toolkit
Close
dOPCDA.TdOPCDAClient
dOPCDA_TdOPCDAClientdOPCDA_TdOPCDAClientdOPCDA_TdOPCDAClientdOPCDA_TdOPCDAClient

Class to connect to an OPC Server. 

 

TdOPCDAClient = class(TdOPCClient);
class TdOPCDAClient : public TdOPCClient;

TdOPCDAClient is a component to connect, control, browse, read and write data from any installed OPC Data Access (DA) Unified Architecture (UA) or OPC Classic COM based 1.x, 2.x , 3.x or OPC XML DA servers.

To build OPC DA client programs you have to create a TdOPCDAClient object first in order to get references to other objects. It contains the TdOPCGroups collection and also provides a TdOPCBrowser object. At first the ServerName has to be defined then the client can connect to the OPC Data Access Interface (see the TdOPCClient.Connect method or TdOPCClient.Active property). Then the TdOPCDAClient object can be used to obtain general information about an OPC server and to create and manipulate the TdOPCGroups object or to navigate with the TdOPCBrowser.

This example shows you how simple it is to connect to an OPC server with the dOPC Client Toolkit. It is based on our dOPC Simulation Server, but it's a trivial matter to change to any other OPC Server. You will find this example program also in our example programs, folder "verySimple". 

If you want to add a huge amount of OPC items to a OPC Group (TdOPCGroup) please look at the example program "BulkRead"

unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, dOPCDA, dOPCComn, dOPCIntf; type TForm1 = class(TForm) Memo1: TMemo; Panel1: TPanel; bStart: TButton; OPCClient: TdOPCDAClient; procedure OPCClientDatachange(Sender: TObject; ItemList: TdOPCItemList); procedure bStartClick(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.DFM} // connect to the OPC server procedure TForm1.bStartClick(Sender: TObject); var G : TdOPCGroup; begin OPCClient.Servername := 'dOPCSim.Kassl.Simulation'; // select your OPC Server G := OPCClient.OPCGroups.Add('testgroup'); // make your own new group G.OPCItems.AddItem('Random.String'); // add new OPC Item to group OPCClient.Active := true; // let's go end; // the OPC server sends OnDatachange events procedure TForm1.OPCClientDatachange(Sender: TObject; ItemList: TdOPCItemList); var i : integer; begin for i := 0 to Itemlist.Count-1 do // for all changed Items Memo1.Lines.Add(TimetoStr(Itemlist[i].TimeStamp)+': '+ Itemlist[i].ItemName +'->'+ Itemlist[i].ValueStr +' ('+ Itemlist[i].QualityAsString+')' ); // shows the changed OPC Item in the memo end; end.
Kassl GmbH Copyright © 2024. All rights reserved.