jeudi 8 février 2007

OPC Miscellaneous

After I briefly overviewed the most known OPC specifications, I would like to give you an idea about important OPC miscellaneous that will be frequently used in the coming blogs.

What are the OPC Servers types?
There are two types of OPC Servers: in-process and out-process servers.
In-process servers are written in form of a Dynamic Link Library (DLL) loaded in the OPC Client’s process space.
Thus, each OPC Client application manages its own Server instance.
Whereas, out-process servers are standalone applications. Therefore, an out-process server is written in form of an executable. It can be launched by any OPC Client locally or remotely. In multiple OPC connections, all OPC Clients connect to the same instance of the OPC Server’s application. This allows OPC Server application to share data between all its OPC Clients.
In-process servers are better than out-process servers in term of speed and performance.

How OPC components communicate locally and remotely?
OPC components can communicate on the same machine through LPC (Local Procedure Call).
They can also communicate on distributed computers using RPC (Remote Procedure Call).

How can the OPC Server be launched?
An OPC Server can be launched as an executable or run on background as Windows service.
Like any service, the OPC Server’s service can be managed (start, stop, pause) from the Service Control Manager (SCM).

What do you mean by DCOMCNFG?
Microsoft offers a Windows built-in tool called DCOMCNFG used to define DCOM settings for COM applications.
You can launch it by typing dcomcnfg on Start | Run.
DCOMCNFG window is mainly composed of the following tabs:
- Default Properties: to enable/disable DCOM and set the default communication properties for DCOM (authentication level and impersonation level). The authentication level specifies if the authentication of the caller is requested. If it is the case, you have to set the permission to honor (authentication only at the connection step, at every call, etc).
The impersonation level specifies whether the applications can determine who is calling them; and in which manner the identity of the caller is used.
- Default COM Security: to set permissions for the users that can access COM applications and those who can launch them.
- Default Protocols: to order by priority the network protocol to be used by DCOM. "Connection-oriented TCP/IP" is the default setting.

Using DCOMCNFG, you can either set a general configuration to be applied to all COM applications installed on the local machine or define custom configuration for a specific application.

In Windows XP, DCOMCNFG window layout differs a little bit from Windows 2000.
You need just to:
- Double-click "Components services"
- Expand Computers node. You will get the "My Computer" node.
- From the contextual menu, click "Properties" to get a window for general configuration
If you want to define specific settings, double-click on "My Computer" node and expand the "DCOM config" entry. Then, you select the application you are interested in and click on the contextual menu "Properties".

What is an AppID?
DCOMCNFG lists only applications that have an AppID. It is a GUID that uniquely identifies the application executable.
AppIDs are stored in the Registry under the HKEY_CLASSES_ROOT\AppID key.
Each application’s AppID entry groups all settings for distributed COM objects hosted by the application executable. We can enumerate these settings: AccessPermission, AuthenticationLevel and LaunchPermission.

What is a CLSID? ProgID?
A CLSID is a 128 bit number that uniquely identify a software component. There are 218 possible unique values. This large number makes the probability to find two equal CLSIDs very small.
CLSIDs are generated by the Microsoft’ useful tool called GUIDGEN.exe (based on the COM call CoCreateGuid).
Back to OPC standard, every OPC Server should have its own CLSID.
So that any OPC Client can identify the OPC Server to which it wants to connect.
But, this identifier is quite difficult to manipulate and remember for more than one OPC Server. To make things easier, an OPC Server is rather identified by a human readable name of string type called ProgID. Generally, the ProgID format is as follows: ...

What are callbacks?
In asynchronous communication, the OPC Client does not receive the final results when receiving the request result (success/failure). The request is processed in two steps: call and callback. For example: Read request
- Firstly, the OPC Server returns a preliminary error codes and no values (call).
- Secondly, the OPC Server sends a callback to the OPC Client with the requested values in case of success.
Giving this scenario, the OPC Server and OPC Client roles are reversed. In fact, the OPC Server behaves as a COM client and the OPC Client as a COM object.
This is very important to understand because we should take it in our account when configuring DCOM. Any bad DCOM configuration may cause a problem of not receiving data changes at the OPC Client side.

What is OPCENUM?
OPCENUM is the OPC Server Browser. It is a COM object (Server) that offers interfaces for browsing local and remote OPC Servers. OPC Foundation published until now versions 1.1 and 1.2.
OPCENUM can run as an executable or a Windows Service.
Before using it, you should register it.
Apply this command line "opcenum.exe /RegServer" to register OPCENUM as an executable.
Or, this command line "opcenum.exe /Service" to register OPCENUM as a service.

What is Registry?
The Windows Registry is a database that stores all your system information and settings.
This includes all hardware, installations, operating system, users, etc. It also contains all registered OPC Servers (server type: local or in-process, full path, implemented categories and vendor information).
For example, any change made through DCOMCNFG is saved to the Registry.

Thus, the Registry reflects the current configuration of your system.

How can we update the Registry content?
We can update the Registry content in different ways:
- Applying a *.reg file, you will be prompted to confirm changes
- Programmatically: by using the Windows 32-Bit Registry API: it contains functions starting with RegXXX
- From the Registry window: type regedit (Start | Run) and manipulate Registry entries graphically

How can we modify the Registry access privileges?
Assume you are logged with an Administrator account.
You can define the permissions for the Registry by using the tool Regedt32.
To run it, click Start | Run and type Regedt32.
Windows XP integrated this utility into Regedit.exe.

Can we access the Registry of a remote machine? How?
It is possible if you have the privileges to access the remote Registry.
Launch the Registry Editor through:
Run => regedit => File => Connect Network Registry…

If you need additional definition or clarification, please do not hesitate to contact me at hassen.kouki@gmail.com. I will be more than happy to answer you within hours.

1 commentaire:

olivia crasta a dit…

wonderful blog entry :)
thank you for this...it was useful as i am working on the development of a simple opc client.