Design of embedded database mine safety system

Publisher:心满愿望Latest update time:2010-08-21 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract: This paper designs a safety system that can work normally in harsh environments in response to the frequent accidents in the mining industry. First, the related concepts and software and hardware environment of embedded systems are introduced, and the embedded system requirements and Windows CE embedded operating system selection of coal mine monitoring terminals are explained; then, the related concepts and software and hardware environment of embedded databases are introduced.

Based on the embedded database requirements and characteristics of monitoring terminals, this paper studies in detail the key technical characteristics of Berkeley DB database and its applicability in coal mine monitoring systems, and introduces the basic concepts and basic API function operations of Berkeley DB database.

introduction

Embedded databases are not only very different from traditional databases in terms of functional concepts and system characteristics, but also in their application methods. Embedded databases are not sold directly to users, but are provided to device manufacturers or application developers so that they can be directly generated in embedded systems and applications. Embedded databases have broad application prospects in many fields, such as handheld computing and mobile computing, smart devices, and this article provides a good application.

1 System Requirements Analysis

Embedded system software development work such as front-end data collection, monitoring, and transmission. In order to meet the large amount of processing requirements of the front-end embedded monitoring system for storage, query, and display of real-time underground data, a database management system must be installed. However, the traditional database management system is obviously not suitable for embedded mine monitoring systems due to its large resource usage and low data management efficiency. Therefore, exploring a database system suitable for embedded monitoring terminals in the harsh environment of mines has become the key to the progress of this article.

Embedded database management system is a type of embedded application software that has emerged with the development of embedded applications. It has become an important branch of database technology research and is widely used in mobile computing platforms (such as HPC, PDA), home information environments (such as set-top boxes and digital TVs), communication computing platforms, automotive electronics platforms, e-commerce platforms (such as smart card applications) and other fields.

In order to solve these problems, the application of embedded system in coal mine monitoring system is proposed. The small size, high reliability, low power consumption and low cost of embedded system technology meet the strict requirements of the equipment of the mine monitoring system and the adaptability to the harsh production environment on site. The monitoring terminal transplants the embedded database management system to meet the main functional requirements of the traditional coal mine safety monitoring system:

1. Data communication function requirements.

2. Real-time query and display requirements.

3. User login management requirements.

2 Overall system design

The core of the embedded mine safety system is data processing. The monitoring terminal collects analog signals from various sensors in the mine (such as gas concentration, carbon monoxide concentration, wind speed, temperature, humidity, dust, pressure, etc.) and switch signals from field equipment control equipment (such as fan start and stop status, etc.) in real time to achieve real-time data display, real-time/historical curve display, query and report printing, sound and light alarm, manual/automatic control, and network communication. The realization of all these functions is based on data management. The embedded database system can effectively organize and manage various types of data in the coal mine, so as to achieve the design requirements of real-time query and control functions of the mine monitoring system. Figure 1 is a typical structure diagram of a mine safety system using an embedded database:


The system uses Windows CE embedded operating system and Berkeley DB embedded database as the development platform for the terminal application of the mine well monitoring system; it uses the existing mine safety monitoring system as the data source, collects on-site safety production data in real time through file sharing, and processes and sends the data.

3. Implementation of main functional modules of the system

3.1 Data Acquisition Module

The data acquisition module realizes the reading of real-time data from the coal mine data source sensor and is designed into a certain format of data structure for database and application operation. This system uses the existing mine safety system (MSUS) as the data source. The safety system organizes the sensor data according to the file format specified by the protocol and stores it in the specified local disk path.

1. Device installation information file (dev.xml)

The sensor device file is divided into a data header and a data body. The data header format is as follows:

2. Real-time data file (rtdata.xml)

The real-time data file is divided into a data header and a data body. The data header format is as follows:

The data body format is specified as follows:

The data status is represented by bits to indicate the data status (defined in binary and converted to integers when used), and its text correspondence is as follows:

[page]

Data acquisition program design

The data acquisition module program uses the ReadFile.h and ReadFile.cpp files, so this article designs the CReadFile class, which encapsulates all data acquisition operations for the dev.xml and rtdata.xml exchange files. According to the structure of the dev.xml and rtdata.xml exchange files, as well as the considerations of database storage operations, the program designs the DEVDATA and REALDATA structures for each sensor, which are used to save the data information of the dev.xml and rtdata.xml files respectively. The DEVDATA structure is shown below:

typedef struct devdata

{ TCHAR m_str_devSubstation[MAXLENGTH]; //Substation

TCHAR m_str_devID[MAXID]; //Sensor number

TCHAR m_str_devPlace[MAXLENGTH]; //Installation location

TCHAR m str_devName[MAX]; //Detection category

TCHAR m str_devType[MAX]; //Sensor type

TCHAR m str_devUnit[MAX]; //unit

float m_data_up; //Upper limit of range

float mes_data_down; //lower limit of range

float m_alarrn_up; //Alarm upper limit

float m_alarm_down; //Alarm lower limit

float m_power_off; //power-off value

float m_power_on; //power-on value

}DEVDATA;

The REALDATA structure is as follows:

typedef struct realdata

{TCHAR m_str_devID[MAXID]; //Sensor number

float m_data; //sensor value

TCHAR m_str_dataStatus[MAXSTATUS]; //Data status

}REALDATA;

The CReadFile class uses the CPtrList linked list data structure to manage all sensor information of the exchange file. The data nodes are DEVDATA and REALDATA structures.

3.2 Data Storage Module

The sensor device upload time is used as the key, and the device installation information encapsulated in the DEVDATA structure and the real-time data information encapsulated in the REALDATA structure constitute the data of the database, thus forming two sets of Key to Data pairs. Therefore, this solution will form two tables, which are stored in two database files. The sensor device installation information and real-time data information are stored in two database files separately. The device file storage operation is performed only when the device installation information changes, which greatly reduces the disk space occupied by the database file.

Berkeley DB uses Key/Data to distinguish data in the database. Key/Data pairs are the basis for BerkeleyDB to manage the database. The Key/Data pairs composed of these two constitute a basic structural unit in the database, and the entire database is actually composed of many such structural units. In other words, calling the database interface is actually providing the corresponding keyword, and using the keyword to find the data to be operated.

If a group of related Key/Data pairs is also regarded as a table, then each database is only allowed to store one table. Therefore, generally one type of Key/Data pair constitutes a database file. The database storage code design is mainly divided into the device installation information (key/data pair is the device upload time/DEVDATA structure) storage code design and real-time data information (key/data pair is the device upload time/REALDATA structure) storage code design. Berkeley DB manages the database in files. Since the device installation information is only stored in the database when the data changes, and the interval period is long, the author designed the dev.db file to implement the storage management of the installation information; since the update cycle of real-time data information is short, the database storage operation is frequent, and data is collected and updated every day, the author designed the real-time database file in units of daily dates. The system will obtain the date of the day and use it as the file name to form a database file for database operations. For example, if the date of the day is February 8, 2007, then the database file name is 2007-02-08.db.

[page]

The storage codes of equipment installation information and real-time data information have certain similarities. The author takes the storage code of real-time data information as an example to illustrate the design process. The program flow is as follows:


Figure 2 Equipment installation information database storage program flow

3.3 Data Query Module

The design of the real-time/historical data query module mainly involves the design of GetDevKey, DataQueryByRealTime and DataQuery functions.

1. DataQueryByRealTime function design

If the device installation information has not changed during the query time period entered by the user, the GetDevKey function will directly return FALSE. The program will then call the DataQueryByRealTime function to query the real-time database file. The device installation information is directly obtained from the m-devList structure list. The function design includes the following:

① Based on the query date input by the user, a real-time database file such as 2007-02-09.db is generated and the real-time database is opened.

② Build a cursor, use the get method, use the query time as the key, and the flag label as DB_ SET_ RANGE to locate the first record of multiple records in the database file.

③ Traverse the database file with multiple records of the same kev, and display the REALDATA structure whose sensor ID number in data is equal to the user input ID number and the corresponding m devList linked list node DEVDATA structure in the list box control (CC1istCtrl).

2. DataQuery function design

If the installation information corresponding to the device query time has changed relative to the current time period, the GetDevKey function will return the correct device installation information query time devKey, which may be different from the sensor query time entered by the user; the program will then call the DataQuery function and pass the correct device query time devKey, the sensor real-time data query time realKey entered by the user, the sensor ID number strDevID, and the real-time database file name strRealDbName to the DataQuery function as formal parameters. The function design includes the following:

①Open the device database dev.db file and open the real-time database file according to the parameter strRealDbName.

② Build a cursor, use the get method, use devKey and realKey as the database key, and the flag tag is DB_ SET_ RANGE. The cursor is positioned to the first record of the device database file and the real-time database file.

③ Traverse multiple records with the same key in the database file. If the sensor ID number in the data recorded in the device database file (DEVDATA structure) is equal to the sensor ID number in the data recorded in the real-time database file (REALDATA structure), the two data information will be displayed in the list box control (CC1istCtrl).

4. Conclusion

The innovation of this paper: Analyze the functional requirements of the embedded coal mine monitoring system, develop and design a mine safety system based on Berkeley DB database and Windows CE, realize window login, data acquisition, system interface, database storage, real-time/historical data query, real-time curve display and other functional modules, and deeply discuss and study the system's data acquisition method, database KEY/DATA pair storage scheme and real-time/historical sensor data database query strategy. In actual production, it works stably and has fast query speed, achieving the expected design goals.

Reference address:Design of embedded database mine safety system

Previous article:Application of ZigBee Technology in Gun Positioning System
Next article:Design of security system for unattended substation

Recommended ReadingLatest update time:2024-11-16 22:35

Analysis of ModbusRTU communication example of Siemens S7 1214C PLC
PLC programmer Modbus is a commonly used communication method in PLC applications. Polling is a commonly used programming method when a controller is connected to multiple slaves. Due to the advantages of ST language in data processing, this method becomes simpler. The following takes the ModbusRTU communication of
[Embedded]
Analysis of ModbusRTU communication example of Siemens S7 1214C PLC
How to implement Ethernet communication and ModbusTCP configuration through CHNet-Q
Mitsubishi Q series PLC connected to CHNet-Q to achieve Ethernet communication configuration method CHNet-Q is an economical Ethernet communication processor developed by Xingda Easy Control. It is designed to meet the increasing needs of factory equipment informatization (equipment network monitoring and
[Embedded]
How to implement Ethernet communication and ModbusTCP configuration through CHNet-Q
Siemens SMARTP implements one master and multiple slaves via MODBUS RTU
When programming with SMART PLC, you will often encounter the need to transmit data from multiple RTU slaves. The master station of SMART PLC receives data transmitted from multiple slaves and displays it synchronously. In this case, the first thing to consider is the device address of the slave device. N
[Embedded]
Siemens SMARTP implements one master and multiple slaves via MODBUS RTU
Eisu and Huawei jointly release GaussDB database backup solution
During HUAWEI CONNECT 2019, Shanghai Aisu Information Technology Co., Ltd. (hereinafter referred to as "Aisu") and Huawei jointly released a backup solution based on Huawei's GaussDB database, jointly promoting the development of the Kunpeng computing industry ecosystem. (Eisu and Huawei jointly released the GaussDB
[Embedded]
Eisu and Huawei jointly release GaussDB database backup solution
What is ISDB-T? What does ISDB-T mean?
1. General Situation The terrestrial transmission system adopted by Japan is not limited to the transmission of digital television (image and audio) alone, but also includes independent sound and data broadcasting, which can exist alone or be combined arbitrarily to form one or more programs within a bandwidth
[Analog Electronics]
What is ISDB-T? What does ISDB-T mean?
Debug automotive designs faster with oscilloscope CAN-dbc character triggering and decoding
The differential Controller Area Network (CAN) bus is widely used in the powertrain and body control of today's automobiles. The CAN bus is a communication protocol developed by Bosch over 30 years ago and has long been considered the "workhorse" serial control bus for automobiles. The CAN bus is also widely used in i
[Test Measurement]
Debug automotive designs faster with oscilloscope CAN-dbc character triggering and decoding
Latest Security Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号