dOPC Client Toolkit Help file
TdOPCItems.OPCAddItems Method
C++
public: __fastcall boolean OPCAddItems(
    TdOPCItemList ItemList, 
    boolean aAdd = true
);
C#
public boolean OPCAddItems(
    TdOPCItemList ItemList, 
    boolean aAdd
);
Visual Basic
Public Function OPCAddItems(
    ItemList As TdOPCItemList, 
    aAdd As boolean = true
) As boolean

OPCAddItems is intended to provide the mechanism to add multiple items to the TdOPCServer with one call to reduce the DCOM and XML calls.

The result will be True on successful execution, otherwise False.

procedure AddItems(G: TdOPCGroup; ItemNames: TStrings);
var
 IL   : TdOPCItemList;
 Item : TdOPCItem;
 i    : Integer;
begin
  IL := TdOPCItemList.create;
  for i := 0 to ItemNames.Count-1 do
  begin
    Item := TdOPCItem(G.OPCItems.Add);
    Item.ItemID := ItemNames[i];
    IL.Add(Item);
  end;
  G.OPCItems.OPCAddItems(IL);
  for i := 0 to IL.Count-1 do
    if IL[i].LastError <> S_OK then
      Beep;
  IL.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Itemlist: TStringlist;
  MyGroup : tdOPCGroup;
begin
  Itemlist := TStringlist.Create;
  Itemlist.Add('Random.String');
  Itemlist.Add('Random.Int1');
  Itemlist.Add('Random.NoExists');
  MyGroup := dOPCServer1.OPCGroups.Add('MyGroup');
  AddItems(MyGroup, Itemlist);
  Itemlist.Free;
end;
What do you think about this topic? Send feedback!
Copyright © 2001-2014 Kassl GmbH (http://www.kassl.de). All rights reserved.