OPC Client Components for .NET
easiest way to access OPC servers
8 years award

OPC client with C#


  Products
    OPC Client Components
      - Basic Package
      - Pro Package
    Classic OPC DA     Connector
    OPC UA Connectorsales and new
   
With our OPC Client components, it's child's play to create an opc client application with C# in .NET environment.
In most cases, you don't need even one line of code.
The OPC client control connects to PLC address through OPC Server automatically.

How to connect OPC servers with C#

Normally understanding the answer of " How to connect opc servers with C# ?" is very difficult, because you will need to have good understanding of OPC servers and advanced programming experience, plus big time to spend.
The difficulty of such operation on the majority of programmers motivated us to design this elegant and time saver Toolkit, with which connecting to opc server with C# is a very easy and normal operation for all programmers, just import controls, drag and drop them, set gOPC property, and you are connected.

How to create OPC client with C# example

Here we list an example that gives you a good idea of how much easy connecting to OPC server with C# using our components is.

OPC Client Components Properties


PROPERTYDATA TYPENOTE

gOPC.AccessType

String

Read only. Access type of selected OPC Item. RO, RW, WO

gOPC.AutoConnect

Boolean

Whether control will connect to server automatically or not

gOPC.Connected

Boolean

Read only.

gOPC.DataType

String

Read only. Data type of selected OPC Item. Int32, UInt16, Bool...

gOPC.DeadBand

Double

Only for UA server nodes. If value change is smaller than this limit, server does not send it to control, so control is unaware of it.

gOPC.PLCID

String

An auxiliary parameter for grouping controls.

gOPC.PLCValue

Double

Exact value of PLC address.

gOPC.ServerClassic.ItemID

String

ItemID of target Classic OPC Item

gOPC.ServerClassic.ServerName

String

Name of target Classic OPC DA server

gOPC.ServerType

gOPCServerType

UA or Classic

gOPC.ServerUA.ConnectionEndpoint

String

Endpoint of UA server

gOPC.ServerUA.NodeID

String

NodeID of target OPC UA Node.

gOPC.UpdateRate

Integer

Miliseconds. Update rate of PLCValue


View of properties

 OPC client C#

View of property editor

 Connect to OPC server



C# code examples

//Normally you do not need code. Just set properties by means of property editor in design time.

//If you set ItemID or UA NodeID by code, note that AccessType and DataType properties are not set correctly.

string accessType=gBitCheckBox.gOPC.AccessType;

gBitCheckBox.gOPC.AutoConnect= true;

bool connected=gBitCheckBox.gOPC.Connected;

string dataType=gBitCheckBox.gOPC.DataType;

gBitCheckBox.gOPC.Deadband=10;

gBitCheckBox.gOPC.PLCID= "1";

gBitCheckBox.gOPC.PLCValue=1256; //This does not mean that you write this value to PLC address through OPC server.

gBitCheckBox.gOPC.ServerType= gOPCServerType.Classic;

gBitCheckBox.gOPC.UpdateRate=500;

 

 

Security settings for UA Servers

OPC UA Client applications should use a security settings set supported by UA Server. Otherwise connection request will be refused.

Security settings of Gelecek OPC Client Components are centralized. You do not need to make security settings fro each control.


Before doing anything about security settings, check what security options are supported by UA server.

 

The easiest way  to make security settings is using a gGlobalSettings control on main form of your application. Look here.

 

Otherwise you need to use code in main form's Load event. Example is below:

 

//Main forms Load event

private void Form1_Load(object sender, EventArgs e)

{

//Repeat this code for all UA servers that you want OPC Client Controls to connect to.

GelecekCommon.gUserAuthentication user_authentication= new GelecekCommon.gUserAuthentication();

user_authentication.UserAuthenticationType=GelecekCommon.gUserAuthenticationType.UsernameAndPassword; //set supported type

user_authentication.Username= "User"//set supported user name

user_authentication.Password= "password"//set supported password


GelecekCommon.gOPCUAServerSecuritySettings security_settings= new GelecekCommon.gOPCUAServerSecuritySettings();


security_settings.SecurityMode=GelecekCommon.gSecurityMode.None; //set supported mode

security_settings.SecurityPolicy=GelecekCommon.gSecurityPolicy.None; //set supported policy

security_settings.UserAuthentication=user_authentication;


GelecekCommon.gGlobalObjects.ConnectionManager.gSetUASecuritySettingsForThisUAServer("opc.tcp://gul-pc:51210/UA/SampleServer", security_settings);

}

For more details and explanations see help file

Use flexibility of C# to create an OPC client project with our OPC client components.

Home Purchase Downloads Support Contact
Copyright © 1995-2015 Gelecek Software. All Rights Reserved.