Home > Back-end >  C builder opc programming
C builder opc programming

Time:10-23

Want to use the cb programming opc client recently, the online check "Delphi written in Automation interface opc client" according to the method in the article also import the type library opc DA Automation Wrapper, then define variables as follows:
The Variant FOPCServer;
FOPCServer=new TOPCServer (Application);
Under the normal should be operated on FOPCServer new variables, such as FOPCServer. The Connect (); (consider can connect)
But when compile errors [BCC32 Error] Unit7. CPP (28) : E2316 'Connect' is not a member of 'the Variant, but FOPCServer should now be TOPCServer this type, this type is the Connect () this function!
Consult everybody warrior!
With Delphi in a

Statement of OPC class and interface
FOPCServer: TOPCServer;
FOPCGroup: TOPCGroup;
FOPCb: OPCBrowser;
FOPCItems: OPCItems;//interface
FOPCItem: OPCItem;//interface

//access OPC Server list
The function TForm1. OPCServerList () : a Boolean;
Var OPCServerList OPCServerName: OleVariant;
J, I: integer;
The begin
Result:=false;
Try
FOPCServer:=TOPCServer. Create (Self);
OPCServerList:=FOPCServer. GetOPCServers; is equivalent to the red this passage compile wrong

CodePudding user response:

Lu onlookers, don't understand opc, good good study, day day up

CodePudding user response:

Are you using Delphi and c + + builder
Cb,
 FOPCServer=new TOPCServer (); 
OPCServerList=FOPCServer - & gt; GetOPCServers;

You see TOPCServer class definition, in an HPP file, look have GetOPCServers method, if not they may not call success.
GetOPCServers in another class, you search for import HPP generated file

CodePudding user response:

Internet has a lot of this kind of program, the original poster can search under reference

CodePudding user response:

OLE in the c + + Builder than some trouble in the Delphi,

OPCServerList:=FOPCServer. GetOPCServers;
Translate:
 OPCServerList=FOPCServer. OleFunction (" GetOPCServers "); 


FOPCServer. The Connect ();
Also must be written:
 FOPCServer. OleFunction (" Connect "); 
  • Related