2. items, it is sent immediately to the clients. In this mode, the repeat the procedure of requesting to establish a connection,
clients don't need to poll, but still waiting. The setted minimum waiting for data, closing the connection process.
value of maximum waiting time is the server's maximum 2) Cache and history data storage rarely mentioned: For
response time, while server will increase the burden of waiting. the caching mechanism, OPC XML protocol has only outlined
2) Data Management Optimization a function of data cache, no mention of how to design caching
When the clients request to the server, they and the server mechanism and how to store. The storage of historical data is
enter a loosely coupled relationship. Clients can request that done by the relational database, but, the amount of XML-DA
some of the properties are set to optimize the relationship data per day grows in the level of GB, and relational database
between the server and the clients and increase server can not complete such a massive task of real-time data storage.
management data. These properties include:
III. IMPROVEMENT AND IMPLEMENTATION OF OPC XML-
RequestedSamplingRate
DA SERVER
EnableBuffering
DeadBand Regarding the traditional OPC XML-DA server design
By RequestedSamplingRate property, the clients can flaws, this paper made the following improvements:
recommend a suitable SamplingRate (sampling time) to server 1) Subscription mechanism: this paper designed
according to their refresh rate. In the case of multiple clients,
asynchronous subscription mechanism based on .net, to
by setting EnableBuffering property to true, the server can save
all the changed values which are collected within the actual release processing threads of the server-side in time and to
sampling time into one buffer,then sends to the clients achieve the long connection between client and server based
according to the client sampling time, to avoid unnecessary on comet. In order to overcome the excessive background
data transmission.DeadBand attribute is used to determine if threads caused by long connecting, and excessive resource
the value has changed, and only the values changed exceed consumption, net interface is extended, therefore, the client
DeadBand are taken as changed. request is no longer assign to thread directly, but is added to a
thread queue in background thread pool through the hash
C. Traditional OPC XML-DA server's Architecture algorithm, for a thread to service multiple requests.
OPC XML-DA server's architechture[6] can be classified as 2) Cache and history data storage: the non-relational
service monitoring module, the data processing modules, OPC database mongoDB is used to store real-time and historical
DA interface module. Its functions are: data. Server subscribe for information to all lower nodes. The
1) Service monitoring modules: Monitor OPC XML-DA information is stored in the memory buffer, and updated when
client's SOAP request, receive data from data buffer; start the the node value changes. Historical data is compressed raw data,
corresponding data processing module to process the received which stores only the updated node information.
data, and publish the completed XML document through the B. Subscription mechanism
HTTP protocol. OPC XML-DA uses a pseudo-callback mechanism. Call
2) Data Management Optimization: Responsible for the back the subscribe process is expensive for the system and not
interpretation of the received XML format SOAP message, and very good to reduce the amount and frequency of data
conversion between XML and OPC , and conversion between exchange. Combine .net platform features and Comet principle,
the data specification and service types of XML document and this paper have achieved the server push subscription
OPC interface protocol , and to complete the assembly , split, mechanism in web service, whose operating mechanism is
and resolution of XML documents and OPC data formats shown in Figure 3.
according to communication requirements.
3) OPC DA interface module: To achieve OPC DA client,
and complete access to data on the underlying device. OPC
client defines the transfer of information and access methods
between the business layer and between OPC server, and
complete data exchange with OPC server.
D. Flaws in traditional OPC XML-DA server
Traditional design XML-DA server has two major flaws:
1) Subscription mechanism: OPC XML-DA subscription
is the pseudo callback mechanism. The connection between
client and server are low coupling, cross-platform, Non-
permanent, and can not provide a callback mechanism. The
subscription mechanism is still based on the client's repeated Figure 3. Comet subscription mechanism
polling. Every time, in order to get data, the client needs to
2882
3. In this mode, after the client subscribes to request, the C. Cache and history data storage
server and client establish connection. The server find the data- For high-performance XML-DA servers, the rational use
update request then return the data immediately. If the data of caching mechanism will significantly improve system
update still do not arrive when time out, then return time out performance. In this paper, non-relational database mongoDB
mark to the client. After receives the timeout mark from the is used to build data module including cache and history data
server, client automatically connect to the server. After the storage.
client cancels the subscription, the server stops the connection
with the client. MongoDB[7] is an open sourced, storage-for-document
database. MongoDB is easy to store data with object types,
With the asynchronous subscription, the requested data are including documents-insert objects and number group, and suit
returned only if the data is updated, therefore, the amount and for a large number of data to insert real-timely, update and
frequency of data exchange are significantly reduced. And query, and have the ability to copy and high scalability the
because that a reasonable timeout is set, connection times are application programme needed to do real-time data storage.
less than traditional XML-DA subscription. However, when a
high number of concurrent clients happening, because that the In this paper, buffer memory for real-time data is
server is assigned a process for each request thread. established, and all the node information is subscribed from
OPC DA server through OPC DA client interface. For the first
Therefore, we have achieved and expanded on .Net subscription, all node information saved as a document; later
IAsyncHttpHandler interface based on asynchronous IO when the data is updated, the updated data is stored as a
communication. The so-called asynchronous IO is that the document ,therefore, the compression storage of raw data is
thread which the server assigned can be released back to the achieved. The storage format of nodes is a Bson (Binary-
thread pool to serve other requests. The request sended by the encoded Serialization Object Notation) document, as shown in
client is monitored by self-defined programme and processed Figure 5.
in BeginProcessRequest method, and join this request to the
thread queue, the thread handle their own requests in the queue
circularly, then return the contents of the response to the client
by the EndProcessRequest way. When a request reaches
timeout, the thread will remove the request. The operating
mechanism is shown in Figure 4.
Figure 5. mongoDB nodes information stored in the document
Data module handling mechanism shown in Figure 6:
1) When the client sends a request, mongoDB memory
buffer is searched. If there is no cache, OPC DA client
Figure 4. .Net asynchronous HTTP connection mechanism subscribe all the node's information from the DA server.
2) If there is cache, the node information user requests is
The key code is as follows: extracted from the cache and return.
public class CometAsyncHandler : IHttpAsyncHandler{ 3) Whenever the DA server push to send data the memory
buffer is updated. At same time only the latest node
BeginProcessRequest(HttpContext ct, AsyncCallback cb, information store as a document.
object extraData){
// Generate a an asynchronous return variable from context
CometResult result = new CometResult(ct, cb, extraData);
// Add the request into a thread queue the thread pool
CometThreadPool.QueueRequest(new CometRequest(this));}
EndProcessRequest(IAsyncResult result){
// Write stream to the response and return to the client
serializer.WriteObject(result..OutputStream,result.Response);
result.HttpContext.Response.End();}}
2883
4. Figure 6. Data processing module activity diagram has fast response speed, no major change in performance and
keep a more stable service. Test data prove that the new server
The key code is as follows: has outstanding performance in a large data flow and high
Public class DataHelper {// Data processing class concurrency.
Public Array GetData(list){
TABLE I. THE COMPARISON OF TEST RESULTS
// Get the latest data of specified node
Node / Server the the the the
if(NodeInfoCacheHelper.GetCurrent()!=null) { request type fastest slowest average number of
response response response requests
// If the memory buffer is not empty (ms) (ms) (ms) being
interrupted
return TransferData(NodeCacheHelper.GetCur(),list) }
1000/ Traditional 390 440 410 0
// Extract request data from the buffer 30 server
1000/ new server 320 410 330 0
else{ 30
1000/ Traditional 480 800 640 30
Array array = NodeInfoCacheHelper.BeginGetData(); 300 server
// Start to subscribe all nodes and to return the latest data. 1000/ new server 370 500 440 2
300
return TransferData(array,list);}}} 5000/ Traditional 440 550 470 2
30 server
5000/ new server 330 520 400 0
IV. INTEGRATION TEST 30
5000/ Traditional 470 900 760 40
A. Test platform and the method 300 server
5000/ new server 550 650 600 3
The testing platform: 300
OPC DA SERVER: wincc server and Intel Pentium D
CPU2.8GHz win2003 operating system V. SUMMARY
OPC XML-DA standard is a current development trend
XML DA SERVER: Intel Pentium D CPU2.8GHz win2003 for OPC and is a good method to achieve long-range and cross-
server operating system platform data exchange. In this paper, a high-performance OPC
CLIENT: Intel Pentium D CPU2.8GHz, winxp operating XML-DA server is built, which has achieved effective real-
system time management to the underlying control system, and
improved the industrial on-site data access flexibility, and
Test method:To perform 4 groups of reading and increased remote access to data from the on-site, and offered an
subscription, namely 1000 nodes / 30 requests, 1000 nodes / effective solution for industrial real-time control. It has great
300 requests, 50 nodes / 30 requests, 5000 nodes / 300 significance for improving the on-site industrial management.
requests. The request frequency is 1s, server refresh rate is 1s.
Read operation tests the fastest response time, the slowest
response time, average response time. Subscription operation REFERENCES
tests server resource consumption and the number of requests
to be interrupted. [1] OPC Foundation.OPC XML-DA specification,version 1.01
[EB/OL].(2004-12-18).
http://www.opcfoundation.org/DownloadFile.aspx?CM=3&RI=231&C
B. Test Results N=KEY&CI=283&CU=20.
Test results are shown in Table 2. In the case of small [2] Peng Jin,Wang Jin Biu, “A OPC Specification-- OPC XML-DA”
number of requests (30), with the number of nodes increasing metallurgical automation,vol. 28(1), pp. 6-9,2004.
from 1000 to 5000, no significant change happened in response [3] SHONNARD A. Understanding SOAP [EB/OL].[2009-12-20].
time, and the response is quick. Therefore, it is confirmed that http://msdn.microsoft.com/en-us/library/ms995800.aspx.
the increase in the number of nodes will not have much impact [4] Yuan xiaofang, Wang dong, “Subscribe to the realization of the
on both the traditional server and the new server, and they both mechanism analysis in OPC” Computer Engineering and Applications,
vol. 45(1), pp. 89-91,2009.
have a good frequency response. But once a large number of
[5] Liu li, Wang wenhai., “Realize the remote OPC real-time monitoring
concurrent requests (300) happen, the node number increases of research and design based on XML-DA” Control and Instruments
from 1000 to 5000, the traditional server, which has too many in Chemical Industry, vol.34(2), pp. 32-35, 2007.
threads, will seriously slow down the response speed. When [6] Kang lingyan Wang jinlin and Zuo zejun, “Process of information
the performance dramatically change, there are many requests integration method based on the OPC-XML” Computer Engineering,
are interrupted. With the same conditions, the new server still vol.35(10), pp. 283-285, 2009.
[7] MongoDB. http://www.mongodb.org.
2884