Xiaoli Wang* , Feifei Wang** , Yuhou Song* , Guirong Zhang* and Shaohui Wang*
Design of Intelligent Management and Service System for Gas Valve
Abstract: This paper introduces a design scheme of intelligent gas valve management and service system based on Internet. This scheme adds sensor and general packet radio service (GPRS) modules to the traditional gas valve and establishes communication connection between gas valve and the server through wireless packet communication technology, which makes the traditional gas valve have the networking ability. Compared with the traditional gas valve management and service business, the method proposed in this paper is more convenient and efficient.
Keywords: Gas Valve , Intelligent Management and Service System , Server
At present, the research on the gas pipeline network infrastructure has made a lot of achievements, and the effectiveness has been verified in practice . With the construction of smart city, automatic meter reading technology gradually replaced the traditional meter reading technology, especially electric meter reading technology has been popularized and promoted . In recent years, gas appliance manufacturers use general packet radio service (GPRS), Bluetooth, Wi-Fi, non-contact radio frequency identification (RFID) and other technologies to transfer the sensor data from the gas valve to the host computer or the server. It has gradually become a trend to process, analyze, share and display the data with the Internet [3-5]. In recent years, the development of Internet of things and cloud computing technology provides a more convenient and efficient way for remote control and real-time processing of a large number of natural gas data. In addition, the safe and stable cloud technology reduces the labor cost of traditional gas management mode, which meets the rapid development of production and living demand . On the other hand, as the center of system data storage and processing, the reliability of database directly determines the performance of the whole system .
Traditional gas valves use mechanical or electronic devices to close, open and regulate the gas flow in the pipeline, so there are risks such as gas leakage and abnormal operation of appliances. At present, some manufacturers have installed gas detection and alarm devices on gas valves. These detection devices detect the concentration of combustible gas in the surrounding environment through gas sensors. When the set value is reached, the alarm device will send out to remind the user [8,9]. However, when the gas detection alarm device alarms, but no one at home to deal with it in time, there will still be security risks. This paper will combine the Internet technology and provide a set of intelligent gas valve management and service system design scheme to solve problems on gas security and convenience.
The research of intelligent instrument and remote meter reading has made a lot of progress. With the development of American economy and the improvement of urbanization rate, the concept of automatic meter reading was put forward in 1980s . Biranjeav and Lokhande  proposed a smart meter used by a 32-bit low-power ARM chip. It automatically collects data and uploads to a data center server. Compared with the conventional meter, this program obtains more accurate data. The entire system provides many functions: billing management, power parameter monitoring and remote-control valve. At the same time, the program can also be extended to the water meter, gas meter and thermometer meter system. Ladarat and Naetiladdanon  use the advanced metering infrastructure (AMI) system to realize the intelligent meter reading and efficient management of the power authority of Thailand, which has contributed to the implementation of the National Smart Grid. Gallo et al.  proposed both region-based and maximally stable extremal regions techniques, during the phase involving the localization of the meter area and to detect the meter counter digits in the detection step, respectively. It is of great significance to change traditional gas meter to intelligent gas meter.
This paper will combine the Internet technology and provide a set of intelligent gas valve management and service system design scheme to solve problems on gas security and convenience. The rest of this paper is organized as follows. Section 2 gives the hardware architecture scheme of the system. Section 3 starts with a design scheme of database server. Real-time server is designed in Section 4. Sections 5 and 6 describe the design of web server and mobile terminal server, respectively. Conclusions and remarks on possible further work are given finally in Section 7.
2. Hardware Architecture
In order to build the intelligent gas system, it is necessary to refit the traditional gas valve, including installing GPRS module and gas data acquisition module composed of multiple sensors on the gas valve. These modules are used to collect the pressure and temperature data of the valve, and transmit the data to the real-time server through wireless packet communication technology. The real-time server analyzes the data according to the predetermined communication protocol, and then transmits the data to the database server for storage, or transmits the gas valve flow regulation command back to the gas valve through wireless packet communication technology to operate the gas valve. When installing or repairing the gas valve, engineers can record the installation and maintenance data through app and upload it to the mobile terminal server. The equipment installation and maintenance data will be processed on the mobile terminal server, and then transmitted to the database server for storage. Users and staff can access the web server through the web browser to query, analyze or process the gas data. The hardware architecture of the whole system is shown in Fig. 1.
3. Design of Database Server
This system’s database server is consisted of the Swedish MySQL AB company’s free product MySQL 5.6 and Hong Kong PremiumSoft’s paid product Navicat for MySQL. There are two reasons for choosing MySQL software as database management system. On one hand, it is that the combination of these two products can reduce the economic cost of the system operation. On the other hand, there are many mature reference cases about the combination of these two products which brings convenience for early development and post-maintenance [14,15].
3.1 Dual Server Hot Backup
To ensure that the database server is still able to quickly recover and continue to provide data exchange services in case of emergency such as the power cut-out, being hacked by hackers, hardware and software failures and other unforeseen circumstances, the system uses dual server hot backup program on the database servers configuration. The biggest advantage of this strategy is that the switch between the two database servers is automatic and does not need too much manual intervention.
The principle of dual server hot backup is that a database server plays as an active role, and another database server plays as a standby role. In the normal working state, the primary server is in the working state, and the standby server is in the ready state. At this time, the data received by the system is auto¬matically synchronized to the standby server when it is written to the active server. The communication between the two servers is established through TCP/IP heartbeat mechanism. When the primary server is unexpected, the system can automatically switch the data server to make the standby server work.
In order to ensure that the data on the two servers are consistent before automatic synchronization, it is necessary to synchronize the existing data from the primary server to the standby server. First, the server ID in the MySQL configuration file is set to the IP address of the corresponding server, and then restart the two servers. Finally, add a backup server to the active server that is the standby server, and set the standby server mode to Slave.
In order to realize the automatic switch between the two database servers, it is necessary to establish a heartbeat signal between the primary server and the standby server. When the heartbeat between two database servers is periodic and stable, it indicates that both servers are running normally. When the heartbeat signal stops, it indicates that the master server has encountered an unexpected situation. When the system is working, it judges the status of the current master database server by monitoring the heartbeat signal status between the two data servers. When the primary data server is abnormal, the system will replace the original primary server with the standby data server as the active server, and then switch the two servers back to the initial state after the operation and maintenance personnel eliminate the fault of the active server and recover the heartbeat signal.
3.2 Design of Database Forms
To obtain better retrieval performance, the database uses MyISAM engine because the frequency of queries and reads is higher than the frequency of writes and updates. Compared to the transaction system using InnoDB engine, the system using MyISAM engine to implement numerous SELECT query opera¬tions is able to effectively improve the retrieval speed.
In order to reduce the duplication of data in the form and the coupling between forms, the database form is divided into account information, equipment information, address information, billing informa¬tion, log information, and so on. At the same time, each part is subdivided into various forms according to the business needs.
The account information part includes five forms such as administrator information, business personnel information, engineering personnel information, user information and account authority information. The appliance information part includes seven forms which are gas valve information, maintenance and replacement information, operation information, fault information, GPRS module information, user re¬pair information and appliance life information. The address information part includes four forms: city information, regional information, cell information, and area coding information. The billing information part includes two forms: payment record information and charging rules information. The log information part includes login log information and sensitive operation log information.
This paper takes two methods to further improve the query speed of the form. First, set different fields as indexes under different constraints. Specifically, according to the specific business, the system sets the account field in the account information part, the gas valve ID field in the home appliance information part, the address code field in the address information part, the payment bill number field in the billing information part, and the time field in the log information part as the index. In order to compare the impact of adding index and not adding index on query speed, this paper designs a query test experiment, and the results are shown in Table 1.
Secondly, in order to solve the problem of slow query speed caused by too much data in the form, this paper adopts the strategy of setting different sub tables. Since GPRS module will regularly update the gas valve information, it can calculate and predict the amount of data to be generated in the related form, and then dynamically create a related form every month to solve the problem.
In this way, on the one hand, it can limit the amount of data in a single table to a certain extent; on the In this way, on the one hand, it can limit the amount of data in a single table to a certain extent; on the other hand, it is convenient to query historical information by month. In addition, it is difficult to accurately predict the amount of dynamic information such as account information and log information, so it is not feasible to use the time-based dynamic table building strategy. For this kind of dynamic data with strong randomness, if the amount of data exceeds the current upper limit, the system will create a new form for the data as a sub table.
4. Design of Real-Time Server
4.1 Load Balancing and Concurrent Communication
Under the real conditions, the maximum communication concurrency on the real-time server is deter¬mined by both hardware and software of the system. To ensure that a large number of concurrent com¬munications between GPRS modules and real-time server can be carried out reliably and stably, this paper proposed three methods according to the method of grouping in the field of image processing [16,17]. Firstly, it can limit the maximum load per real-time server. In this system, each real-time server limits up to 100,000 GPRS modules to communicate. In other words, a fixed IP address of a real-time server is used for every 100,000 gas valves. Secondly, it can improve the maximum communication concurrency on the real-time server from the business. 100,000 GPRS modules are divided into 200 groups, and each group are set a different upload time. There are two advantages: first, it can make full use of the server without wasting computing resources; second, it can achieve load balancing because centralized communication is distributed to different times of the day. Finally, in order to solve the problem of each real-time server at the same time up to 500 TCP/IP socket links, this paper use Java non-blocking IO (NIO) technology which is an API provided by jdk1.4 and above. Compared with the conventional blocking IO (BIO) technology, NIO technology can effectively solve the multi-link concurrency problems. Table 2 lists the test results which is obtained by writing client code to simulate the upload data in multiple GPRS modules. It can be seen that using the NIO technology can greatly improve the number of concurrent communication and reach the 500 TCP/IP socket links expected.
4.2 Design of Communication Protocol
In order to establish the communication between the GPRS module and the real-time server, it is necessary to analyze the data uploaded and transmitted according to the communication protocol. The data frame format of the communication protocol designed in this paper is shown in Table 3.
Where SOF represents the start of the data frame, and the fixed value is 0x85. EOF represents the end of the data frame, and the fixed value is 0x8A. ADDR is a 5-bytes binary-coded decimal (BCD) representing the address ID. The high bit is in the former and the low bit is in the post when an address ID is transmitted. CMD represents the command of the data, and different commands achieve different functions. LEN represents the length of data. CS verifies whether the error occurred during the current data frame transmission. The verification method is used by accumulating all bytes from SOF to CS without counting an overflow value of more than 0xFF, and it compares all these bytes with the CS to determine whether these two values are consistent.
When the operation information of gas valve is uploaded, CMD is 0x80; LEN is 0x13; and DATA is shown in Table 4.
When the abnormal information of gas valve is uploaded: CMD is 0x81; LEN is 0x01; and DATA indicates abnormal states information. Each bit of DATA represents the abnormal state shown in Table 5, where 0 is set as normal state, and 1 is set as exception state. When the abnormal state of gas valve is released, the corresponding data will be uploaded. At this time, CMD is 0x82 and the remaining fields are the same as the uploaded information when the exception occurs.
The real-time server is able to send command to set gas valve standard time. At this time, CMD is 0x01; LEN is 0x07; and DATA represents the server standard time. The server can also send a self-check command to gas valve. After the gas valve receives this command, it will upload the operation information. If the gas valve is in an abnormal state, the fault message will be uploaded simultaneously. At this time, CMD is 0x02, LEN is 0x00 which means that there is no need to include any data.
4.3 Design of Heartbeat Mechanism
The purpose of establish heartbeat mechanism between the real-time server and the gas valve GPRS module is the same as what have done between two database servers. It is a prerequisite to ensure the normal communication between them. If no heartbeat signal is received between the two ends, it indicates that there is a problem in the communication line or one of the servers. At this point, it is necessary to remind the operation and maintenance personnel to carry out the investigation. The design of heartbeat signal format follows Section 4.2. The start and end flags of the heartbeat signal are 0x85 and 0x8A. The CMD and 0x83 is the identification mark of heartbeat signal. Since the data has only one byte, the LEN is 0x01. In the process of communication between the gas valve GPRS module and the real-time server, the real-time server is used as a master device while the GPRS module is used as a slave device. In the process of dual server hot backup between two database servers, the active server is used as a master device while the standby server is used as a slave device. The DATA is 0x55 when the master device sends a heartbeat signal to the slave one, and the DATA is 0x5A when the slave one responds to the heartbeat signal. The ADDR is not changed during whole heartbeat process.
5. Design of Web Server and Mobile Terminal Server
5.1 Struts, Spring and Hibernate Framework
The Web server is built by Struts, Spring, and Hibernate (SSH) framework. The mature framework draws on the classic Model+View+Controller (MVC) design pattern which is a kind of three-tier archi¬tecture. MVC can be used for data exchange, content display and business logic of web server. It can increase the reusability of code and the flexibility of combination among functional modules. However, in the process of actual development and maintenance, the workload is still heavy. Therefore, this paper uses SSH framework to build web server, which can retain the above advantages and reduce the code complexity.
By predicting the maximum flow of the system, a suitable hardware server is selected as the Web server carrier. The hardware of web server is consisted of an Intel Xeon E5-2609 processor, a 32-GB memory and a 1-TB 7200 RPM mechanical hard disk. The software of web server is consisted of Windows Server 2008 as operating system, MyEclipse 2014 and Tomcat7 as development and running environment.
5.2 Multi-level Operation Authority
In order to meet the different needs of different roles, the system is divided into four levels: administrator, business personnel, engineering personnel, and user. Different roles use different types of accounts to log into the system website. The website can provide different services and functions according to different roles. The operation authority division and the corresponding functions are shown in Fig. 2.
After users login the website, they can query and modify some of their account information and pay for GPRS data traffic. They can also report the situation of gas valve which is in the fault state or exists security risks, and query gas valve fault records and switch records by time. In addition, the system can also detect valve temperature, air pressure, battery voltage and other current status. Engineering personnel can not only query the identity information and electrical information of some users within their juris¬diction through the website, but also view the installation and maintenance records and various report statistics. After logging in to the website, business personnel can complete all operations of engineering personnel, and can also make charging rules, query fault alarm records, remote operation of gas valve and other operations. Administrators can use all the above functions, but also can manage the operation rights.
6. Design of Mobile Terminal Server
The mobile terminal server of this system is only used in the installation and maintenance by engineering personals. The Servlet is used to communicate with application (app), which can not only shorten the development time to reduce economic cost, but also can reliably ensure the realization of data entry function. App and database server interaction principle is shown in Fig. 3. Engineering personals send data from Android client to mobile terminal server by mobile communications network. Then the mobile terminal server receives and processes data by Servlet, and insert data into database server by Java database connectivity (JDBC) technology to prepare for web server.
This system uses eclipse software to develop an app on the client side to provide services for engineers. When the engineering personals install new valve, repair and replace bad valve, they can use the app to record and upload relevant information immediately, and write to database server from mobile terminal server for storage. Compared with the conventional paper registration and manually information input, this method is more convenient to operate and more conducive for information management.
The intelligent gas valve management and service system includes two parts: client and server. The client can be divided into web browser and Android app. Web browser is the primary provider of system functions and services. Administrators, business personals, engineering personals and users can login and use the system by web browser on the local computer. Android app which is used by engineering personals can input user information, installation information, maintenance information and replacement information. The gas valve adopts GPRS module to transmit the data collected by temperature sensor, pressure sensor and other sensors to the real-time server. The gas data is processed on the real-time server and then stored in the database server. Web server establishes a connection with database server and provides services to administrators, business personals, engineering personals and users. Mobile terminal server receives data from Android app. This design scheme integrates the use of gas valve, the safety of gas the analysis of appliance data and the payment of users into a system based on the Internet of Things. Compared with conventional business processes, this system is more convenient, economical and efficient. However, there are some deficiencies in this system. For instance, when the system is used for larger customer groups or wider geographical areas, it needs to use other load balancing and concurrent processing methods such as adding a content delivery network (CDN) server and a reverse proxy server in front of the real-time server, adding a cache server in front of the database server, separating data reading and writing to different database servers, and so on. These problems will be studied and solved in the future.
He received his B.S. degree in electronic information science and technology and his M.E. degree in circuits and systems from Shandong University, Weihai, China, in 2002 and 2008, respectively. He is currently a senior experimentalist in the School of Mechanical, Electrical and Information Engineering, Shandong University, Weihai, China. His current research interests include micro-grid and embedded system development.
She received his B.S. degree in electronic information science and technology and his M.E. degree in circuits and systems from Shandong University, Weihai, China, in 2009 and 2012, respectively. She is currently a software engineer in Jinan Glory & Co-creative Power Tech Co. Ltd. Her current research interests include power system automation.
He received his B.S. degree in radio electronics from Shandong University, China, in 2003, and his M.E. degree in communication and electronic systems from Shandong University, China, in 2007. He is currently the deputy director of the asset and laboratory management office of Weihai Campus of Shandong University. His current research interests include smart grid technology.
He received his bachelor of engineering degree from Harbin University of Technology, China, in 2015, and his M.E. degree in communication and electronic systems from Shandong University, Weihai, China, in 2018. He currently works in Hangzhou Hikvision Digital Technology Co. Ltd. His current research interests include ETC receivable no leakage technology, micro service component security technology, etc.
He received his B.S. degree from Shanxi Agricultural University, China, in 2015, and his M.E. degree in communication and electronic systems from Shandong University, Weihai, China, in 2018. He currently works in the network management software development post of Nanjing Zhongxing New Software Co. Ltd. His current research interests include signal and information processing, network management software development.