The article introduces the design of real-time database system in the construction of real-time monitoring system for industrial automation process. According to the characteristics of real-time database system, the key technologies such as functional modules, storage structure, transaction scheduling and concurrency control of real-time database are analyzed and the specific implementation methods are given. In the implementation process, multimedia timer, memory mapping file, multi-threading, synchronization object and other technologies are adopted 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, the use of distributed control systems (DCS) and relational database technology alone cannot solve the problem completely. DCS data storage capacity is limited, and heterogeneous DCS in the enterprise cannot perform effective data sharing. The relational database data processing speed is low, and the production process data cannot be stored in a timely and efficient manner.
In order to solve the above problems, the real-time database is introduced into the industrial control system as a key supporting technology. In the process of production equipment operation, the real-time database system collects the operation data of the equipment in real time, keeps track of the operation of the device at any time, and timely processes the problems that occur through the real-time monitoring and analysis of the key data of the production process to make the production operation status. keep stable. The real-time database is also a bridge connecting the industrial production control system with the enterprise upper management system. The enterprise can provide the same data platform for the 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 features
A real-time database system (RTDBS) is a database system in which both transactions and data can have timing characteristics or explicit timing constraints. The correctness of the system depends not only on the logical outcome, but also on the time that the logical result is generated. For real-time database systems, data consistency and periodicity of execution are important goals. Since real-time data of controlled systems is often collected in a real-time system for a fixed period of time, the corresponding control system must also process data and periodically. Responding; because the traditional relational database can not meet the real-time system requirements for real-time data in some time-critical situations, the direct memory addressing is a high-speed data access method, and the technical use of the in-memory database is solved. The ideal solution to this problem.
The design of the whole real-time database system scheme is divided into two parts: the in-house and the outside, and the in-house part is the in-memory database, which is the main body of the real-time database. The storage form can adopt the sequential structure, the B-tree structure or the multi-directory search hash technology ( Hash technology). The in-memory database performs transaction processing at regular intervals, and data for more than a certain period of time is cleared from the memory and written into the external storage database. An external database is a disk database or a historical database for historical analysis, report generation or related decisions, and so on. The system history database uses Microsoft Corporation's database product SQLServer.
3 Key technology research and implementation
3.1 Real-time data collection
In industrial control systems, the real-time and stability of the data acquisition program plays a crucial role in the performance of the entire industrial control system. The timer TImer provided by Windos is far from satisfactory and must be replaced by a more accurate timer.
The multimedia timer API functions TImeSetevent and TImeKillEvent under Windows system can meet the requirements of real-time. The multimedia timer works in its own thread, and its thread priority level (threadprioritylevel) is set to THREAD_PRIORITY_TIME_CRITICAL, which is higher than most thread priority values, compared to the Timer timer working in the user interface thread. In other words, 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 In-memory database technology
In-memory database refers to database resident memory and transaction data access only involves memory. An in-memory database is an optimal technique for supporting real-time transactions. Its essential feature is that its "master copy" or "work version" resides in memory. Active transactions only interact with memory copies of real-time in-memory databases. Obviously, it requires a large The amount of memory. The in-memory database can be abbreviated as MMDB. The "working version" of MMDB resides in memory, and there is no internal and external data I/O during any transaction execution. This lays the foundation for the system to accurately estimate and schedule the running time of the transaction and realize the timing limit of the transaction, so as to meet the response time and transaction throughput requirements of the external transaction application.
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 mapping file, that is, apply for a memory space in memory, associate a file with this space, and then perform memory mapping, so that the operation file has the same efficiency as the operation memory, and several processes can operate the mapping. Files that enable high-speed data interaction between processes at the memory level. When using the memory mapped file method, Windows does not use the file to re-create the new memory file object and create the new memory file object, and map the object into two address spaces. This mechanism not only effectively utilizes the mechanism. Memory, but also the sharing of data. To achieve memory read and write level 1 data communication efficiency under Windows2000, the only way is to use memory mapped files. The memory mapping file is used as follows:
(1) create or open a file kernel object
Create or open a file kernel object, always call CreateFileCreateFile function: HANDLECreateFile, dworddwdesirdaccess, dworddwshare-mode, psecurity_attributespsa, dworddwcreationdisposition, dworddwflagsandatributes, handlehtemplatefile), if createfile function successfully create or open the specified file, it returns a file memory object to Handle, otherwise return invalid_handle_value.
(2) create a file-mapping kernel object.
Cylindrical lens are offered in both plano-concave and plano-convex configurations, they are typically used to focus incoming light to a line, or to change the aspect ratio of an image. Cylinder Lenses are available with positive or negative focal lengths, they are used for the optics, lasers, medical science, electronics, tele-communication and others.
Cylindrical lenses,Positive cylindrical lenses, Line Light,Laser Focusing Lenses,Negtive cylindrical lenses
Changchun Realpoo Photoelectric Co., Ltd. , https://www.optics-realpoo.com