The article introduces the design of real-time database system in the construction of real-time monitoring system for industrial control automation process. According to the characteristics of the real-time database system, the key technologies such as the functional module, storage structure, transaction scheduling and concurrency control of the real-time database are analyzed and the specific implementation methods are given. In the implementation process, multimedia timers, memory-mapped files, multi-threading, synchronization objects and other technologies are used to ensure the stability and strong real-time performance of the system.
1 Introduction
The characteristics of modern industry require real-time monitoring of the entire process, high-speed real-time data processing, long-term historical data storage, and integration and sharing of production information. To meet the above requirements for the processing of production data, a large number of distributed control system (DCS) and relational database technologies cannot completely solve the problem. DCS data storage capacity is limited, and heterogeneous DCS in the enterprise cannot effectively share data. The relational database data processing speed is low, and the production process data cannot be stored in time and efficiently.
In order to solve the above problems, the real-time database is introduced into the industrial control system as a key supporting technology. During the operation of production equipment, the real-time database system collects the operation data of the equipment in real time, grasps the operation status of the device at any time, and through real-time monitoring and analysis of the key data of the production process, the problems that occur are processed in real time to make the production running remain balanced. The real-time database is also a bridge connecting the industrial production control system and the enterprise's upper management system. The enterprise can provide the same data platform for business decision-making, planning and scheduling, advanced process control, quality monitoring and other sub-systems through the data platform provided by the real-time database system.
2 Real-time database system concepts and characteristics
Real-time database system (RTDBS) is a database system whose transactions and data can have timing characteristics or explicit timing restrictions. The correctness of the system depends not only on the logical result, but also on the time when the logical result is generated. For real-time database systems, data consistency and periodicity of execution are important goals. Since real-time data is often collected in a real-time system at a fixed time period, the corresponding control system must also periodically process data and Respond; because the traditional relational database cannot meet the real-time system's requirements for real-time data in some occasions with strict time limits, and memory direct addressing is a high-speed data access method. The technical use of in-memory database is the solution The ideal solution to this problem.
The design of the entire real-time database system solution is divided into two parts: in-house and out-of-home. The in-house part is the in-memory database, which is the main body of the real-time database. The storage form can use sequential structure, B-tree structure or multi-directory search hash technology ( Hashing technology). The in-memory database regularly performs transaction processing, and data over a certain period of time is cleared from the memory and written to the external storage database. The external storage database is the disk database or the historical database, which is used for historical record analysis, report generation permission or related decision-making and so on. The historical database of this system uses Microsoft's database product SQLServer.
3 Research and implementation of key technologies
3.1 Real-time data collection
In industrial control systems, the real-time nature and stability of the data acquisition program play a vital role in the performance of the entire industrial control system. The timer TImer provided by Windos is far from the requirement and must be replaced by a timer with higher accuracy.
The multimedia timer API functions TImeSetevent and TImeKillEvent under the Windows system can well meet the real-time requirements. The multimedia timer works in its own thread, and its thread priority (threadprioritylevel) is set to THREAD_PRIORITY_TIME_CRITICAL, which is higher than most of the thread priority value, compared to the Timer timer working in the user interface thread In general, it is not affected by the message mechanism and can achieve high timing accuracy. Its highest timing accuracy can reach 1ms, which can meet the requirements of higher real-time.
3.2 Memory database technology
In-memory database refers to the database resident memory and transaction data access only involves memory. In-memory database is one of the best technologies to support real-time transactions. Its essential feature is that its "master copy" or "working version" resides in memory. Active transactions only interact with the memory copy of the real-time in-memory database. The amount of memory. The memory database can be abbreviated as MMDB. The "working version" of MMDB resides in memory, and there is no data I / O between internal and external memory during the execution of any transaction. This lays the foundation for the system to more accurately estimate and schedule the running time of transactions and achieve transaction timing constraints, thereby meeting the needs of external transaction applications for response time and transaction throughput.
3.2.1 Using memory mapped file shared memory
Shared memory is one of the core technologies of real-time databases. The so-called memory-mapped file is to apply for a memory space in the memory, associate a file with this space, and then perform memory mapping. In this way, operating the file has the same efficiency as operating the memory. Several processes can operate the mapping Files, to achieve high-speed data interaction between processes at the memory level. When using the memory-mapped file method, Windows does not create a new mapped file object but shares the previous memory-mapped object with the process of using the file again, and maps the object into two address spaces. This mechanism not only effectively uses The memory also achieves data sharing. The only way to achieve data communication efficiency of memory read and write under Windows 2000 is to use memory mapped files. The method of using memory mapped files is as follows:
(1) Create or open a file kernel object
Create or open a file kernel object, always call the CreateFileCreateFile function: HANDLECreateFile, dworddwdesirdaccess, dworddwshare-mode, psecurity_attributespsa, dworddwcreationdisposition, dworddwflagsandatributes, handlehtemplatefile), if the createfile function successfully creates or opens the specified file, it returns a file memory object Handle, otherwise return invalid_handle_value.
(2) Create a file mapping kernel object.
Right-angle prism is the most common type of prisms. It is used to re-direct a beam of light at 90 degrees from the the incident direction or used as a 180 beam retro-reflector. They are often coated with various optical coatings to form cubic beam splitters and color separation cubes used in various projection systems.
Right Angle Prism,Right Angled Prism,Right Angle Prisms,Optical Prism
Changchun Realpoo Photoelectric Co., Ltd. , https://www.optics-realpoo.com