Common property: gOPC

Top  Previous  Next

Common for all OPC Client controls.

gOPC property is a cascaded property.

Defines all OPC settings: OPC server, OPC Item ...

 

PROPERTY                                               DATA TYPE                                              NOTE

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 properties

 

View of property editor

 opc properti editor

 

 

 

 

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 supoorted 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 supoorted 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);

     

}