The Factorysoft OPC Server
Recently looking at OPC things, the beginning of the Pan of the "COM Principle and Application", the book bought a day ago, A few years ago the leadership in the configuration of the King 6.03 inside add our company's equipment driver, to the Beijing configuration King's headquarters went to a trip, did not contact how to do the configuration of the King's Drive, asked the reception of our mm manager, she said very simple, used to COM and C + +, the afternoon went to the bookstore bought back, Later on the installation of the development package research, the book did not see the driver has been written, has been put to the present.
Later to do industrial control of the upper, Siemens PLC use the most, so the upper software chose WINCC. Old multi-project to communicate with other manufacturers of equipment through the serial port, but WINCC support device driver is relatively small, Now wincc6.0 inside support add MSComm control read and write serial port, have no chance to try the effect how, at that time with is wincc5.0 or 5.1 (Do not know MSComm control can use), it can be as OPC server can also as OPC client, Just want to do a program through the serial port to obtain the field data, as OPC client, the data into WINCC inside. Used a few times always feel what is wrong, like to be an OPC server. This implementation of the OPC server code parts do not have to change, as long as to do with the field equipment to communicate that part of the can, now think of a better way is to add the driver, how to realize now there is no idea, this part first put the OPC server and then slowly after the change.
"COM principle and application" look very coarse, look after there is no impression, the main is only to see no practice, their own direct write OPC Server a bit difficult, some places have not figured out, so I found a development package first familiar with, finally found the Factorysoft OPC Server from the Internet Development Toolkit, with all the source.
The following is a reference to the documentation in the development package
A COM server can be either in-process or out-of-process. An in-process server was a DLL with certain predefined entry points. An out-of-process server was an executable file (. exe). Out-of-process servers is referred to as local if they reside on the same computer as the client, and as a remote when th EY is running on a different computer and communicating over a network. Distributed COM (DCOM) provides for remote servers.
In-process servers is faster than out-of-process servers. COM is involved in creating an object in the first place, and the interface pointer is a real pointer to a class in the SA Me address space. Therefore, after a object is created, calling functions on it are as fast as calling any C + + object ' s virtual function. One drawback to using in-process servers in the Automation industry arises when multiple OPC clients want to connect to yo ur server and collect data, for example, through a serial COM port. The problem is this because a COM port cannot be opened more than once, the first in-process server can use the COM port T o Communicate, but the next time a client connects to the server, the server operates in a different address space and can Not use the COM port. This was a common issue to DLLs. If a server needs to use a non-sharable resource, then an in-process server is the most likely ruled out; However, if a server uses a sharable resource, such as a network connection or a plug-in BoARD, then an in-process server had a significant speed advantage. At this time, in-process servers also is not remotable, which means, DCOM cannot give network access to the server. In addition, in-process servers has no user interface; Therefore, a separate configuration program was required if server configuration is needed. If A separate configuration program was used, however, the in-process servers cannot see the configuration changes. This isn't a trivial problem, but it can be solved.
Out-of-process servers is stand-alone programs that host COM objects. These servers may is existing programs that is making data available to clients, or they may is servers that need Exclusi ve access to a resource, such as a COM port. An out-of-process server has a user interface. The Modbus server ' s user interface provides a means for configuring the tags in the server. An out-of-process server was remotable through DCOM, which allows clients on the same computer or across a network, or even The Internet, to access OPC data in the server. A central point of communication can often cache data with a more efficient manner.
The main disadvantage to using a out-of-process server is speed. COM is involved in marshalling data from one process to another in a, that's transparent to the client. There is a additional proxy/stub DLL that handles marshalling of the OPC interfaces which needs to be distributed and Reg Istered.
Feel out-of-process more suitable for making equipment communication OPC server. Let's start with the simplest of things.
The Factorysoft OPC server (fsserver) DLL provides an easy-to-use interface to hide the details of the OPC server, or to paste the original look pleasing to the eye, the following brief
The Factorysoft OPC Server (fsserver) DLL provides an Easy-to-use interface by hiding the details that is common to most OPC servers. The division between application and Fsserver DLL are at a high level. Through a very simple interface, an application handles reading and writing data Through it protocol, while the Fsserver DLL serves data through OPC. The interface allows this DLL is added to existing applications as well as new ones. Fsserver also hides OPC details so this any kind of application can use it, including Windows SDK, MFC, console Applicatio NS, and services.
The Fsserver DLL creates a thread that runs its own message loop and registers it COM objects for free-threaded use. IT handles all OPC communications. It just relies on the application to provide names and data for tags. It supports all required OPC Custom 2.0 interfaces as well as the optional Browse interface.
The Shell example for 2.0 includes a hierarchy of names for browsing and it matches names to find existing items.