OPC Server是用的simens net V8.2搭建的,能够和S7-314正常读写通讯。delhpi7.0环境中,添加了simens OPC DA automation 2.0,Active页面中有了三个控件:OPC server,OPCgroup,OPCgroups。在窗体中添加这三个控件,另外加了一个按钮,准备测试连接OPC server。现在只做了个按钮测试连接到OPC,运行时,按下按钮就报错。


全部代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OPCSiemensDAAutomation_TLB, OleServer;
type
TForm1 = class(TForm)
OPCServer1: TOPCServer;
OPCGroups1: TOPCGroups;
OPCGroup1: TOPCGroup;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Group:OPCGroup;
testItem:OPCItem;
OPCItems:string;
OPCItemsValues:string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
//连接OPC
OPCServer1.Connect1('xingyun-PC','');
//xingyun-PC是我的计算机名称,也是OPC server的名称。
OPCServer1.OPCGroups.DefaultGroupUpdateRate:=500;
Group:=OPCServer1.OPCGroups.Add('MyGroup');
testItem:=Group.OPCItems.AddItem('SCADA.YPA1_SILO_CHARGEWEIGHTACT.F_CV',1);
end;
end.
有哪位做个这类通讯,麻烦指导一下,不胜感激!!