CN117997927A - Internet of things analysis method and system for ecological environment monitoring - Google Patents

Internet of things analysis method and system for ecological environment monitoring Download PDF

Info

Publication number
CN117997927A
CN117997927A CN202410398479.2A CN202410398479A CN117997927A CN 117997927 A CN117997927 A CN 117997927A CN 202410398479 A CN202410398479 A CN 202410398479A CN 117997927 A CN117997927 A CN 117997927A
Authority
CN
China
Prior art keywords
data
monitoring
server
setting
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202410398479.2A
Other languages
Chinese (zh)
Other versions
CN117997927B (en
Inventor
徐承
张宇
宗蔷雯
廖阳
马昊
潘峰
刘阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Three Gorges High Technology Information Technology Co ltd
Original Assignee
Three Gorges High Technology Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Three Gorges High Technology Information Technology Co ltd filed Critical Three Gorges High Technology Information Technology Co ltd
Priority to CN202410398479.2A priority Critical patent/CN117997927B/en
Publication of CN117997927A publication Critical patent/CN117997927A/en
Application granted granted Critical
Publication of CN117997927B publication Critical patent/CN117997927B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides an analysis method and system of the Internet of things for ecological environment monitoring, wherein the method comprises the following steps: setting a data reporting address of the hardware equipment as an address of a reachable server; analyzing protocol data of the HJ212 based on the TCP protocol into readable character strings, and converting the analyzed readable character strings into json for convenient program identification; finally, the data is stored in a database; the system comprises: the system comprises a hardware device configuration module, a data analysis module and a data storage module. The invention reports the data of the hardware equipment to the data storage, thereby realizing reliable management and effective utilization of the equipment data; through reporting, analyzing and storing the data, the real-time monitoring, analyzing and reporting of the equipment data can be realized, and reliable data support is provided for environmental monitoring, equipment management, decision making and the like. Meanwhile, a foundation is provided for subsequent data processing and application, such as data analysis, visual display, alarm notification and the like.

Description

Internet of things analysis method and system for ecological environment monitoring
Technical Field
The invention relates to the technical field of data processing, in particular to an Internet of things analysis method and system for ecological environment monitoring.
Background
Ecological environment monitoring refers to monitoring and assessing the health and environmental quality of an ecosystem by collecting, analyzing and assessing data of environmental elements. In ecological environment monitoring, technology plays a key role. Existing technology related to ecological environment monitoring: sensor technology: the sensor is used for monitoring environmental elements such as temperature, humidity, gas concentration, illumination and the like in real time; the sensor can transmit data to the monitoring system through a wireless network, so that remote monitoring and data acquisition are realized. Remote sensing technology: the remote sensing technology acquires the image data of the earth surface and the atmosphere through satellites, airplanes or other remote sensor devices, and the data can be used for monitoring land utilization changes, vegetation conditions, water quality and the like. Data analysis and modeling: useful information and trends can be extracted from a large amount of monitored data using data analysis and modeling techniques; for example, using machine learning algorithms, the likelihood of natural disasters occurring can be predicted, or the diffusion path and extent of impact of contaminants can be assessed. Air quality monitoring technology: the air quality monitoring technology is used for monitoring the concentration of pollutants in the atmosphere, such as sulfur dioxide, nitrogen oxides, ozone and the like; common monitoring devices include weather stations, air quality sensors, and weather radars. The water quality monitoring technology comprises the following steps: the water quality monitoring technology is used for evaluating the chemical, physical and biological characteristics of the water body; common monitoring equipment comprises a water quality sensor, a water quality automatic monitoring station, a hydrological measuring station and the like. Biological monitoring technology: biological monitoring techniques are used to assess the biodiversity and ecological health of the ecosystem; for example, by monitoring the number and distribution of organisms such as birds, insects, and fish, changes in the ecosystem and environmental quality can be understood. Data visualization techniques: the data visualization technology is used for displaying the monitoring data in a chart, map or other visual forms, so that people can more intuitively understand and analyze the data; helping decision makers and the public to better understand the condition and trend of the ecological environment. In summary, the technical background of ecological environment monitoring relates to multiple aspects of sensor technology, remote sensing technology, data analysis and model, air quality monitoring technology, water quality monitoring technology, biological monitoring technology, data visualization technology and the like; the continuous development and application of these technologies provides a more accurate, efficient and comprehensive means for environmental monitoring. However, the current ecological environment monitoring equipment is incompatible in data due to non-uniform production standards, so that difficulty in data sharing and analysis is increased, and accuracy of an ecological environment monitoring effect is affected to a certain extent.
First, chinese patent, application number: CN202210130355.7 discloses an ecological environment monitoring quality management system, through a laboratory information management core platform, an environment monitoring standard service platform and a data quality supervision platform, the supervision and management of a regional ecological environment monitoring organization are enhanced through the ecological environment monitoring quality management system, and the information platform is used as a support to enhance the overall process quality management of the ecological monitoring organization, personnel and monitoring activities, standardize the ecological environment monitoring service behavior, and realize effective quality control of monitoring data; but lack of data format processing for different ecological environment monitoring devices results in less efficient data processing.
In the second prior art, chinese patent, application number: CN202310365064.0 discloses an ecological environment monitoring system based on internet of things, which comprises a cloud control module and an ecological environment monitoring module; each ecological environment monitoring module is provided with a wireless communication unit, and the wireless communication unit is used for acquiring the relative position between every two ecological environment monitoring modules and transmitting the relative position to the cloud control module; a positioning unit is further arranged on one of the ecological environment monitoring modules, and the absolute position of one of the ecological environment monitoring modules is obtained by the positioning unit and is transmitted to the cloud control module; and the cloud control module calculates the absolute position of each remaining ecological environment monitoring module according to the relative position and one absolute position between every two ecological environment monitoring modules. The environmental data and the position data acquired by the on-site ecological environment monitoring modules are directly acquired at the cloud end so as to know the positions and arrangement conditions among the monitoring modules, and the on-site ecological environment monitoring module has the effect of being convenient to monitor; however, the scheme of the same data format of different ecological monitoring devices is not provided, so that some data may have an incompatible problem, and the accuracy of ecological monitoring results is affected.
Three in the prior art, chinese patent, application number: CN202310999450.5 discloses an ecological environment monitoring data processing method and system applied to cloud computing, which respectively analyzes first template image semantic vectors corresponding to each template ecological environment monitoring image in a template ecological environment monitoring image sequence through an environment feature label prediction network for completing model convergence optimization, respectively analyzes second template image semantic vectors corresponding to each template ecological environment monitoring image according to an initialized environment feature label prediction network, predicts according to each second template image semantic vector, combines a first output error value determined by the first template image semantic vector and the second template image semantic vector of the same template ecological environment monitoring image and a second output error value determined by the second template image semantic vector corresponding to two template ecological environment monitoring images belonging to different environment feature labels to obtain a target environment feature label prediction network, although the accuracy of the subsequent environment feature label prediction is improved; but do not involve the problem of format conversion of different physiological monitor devices, resulting in poor accuracy of predictions.
The invention provides an analysis method and a system of the Internet of things for ecological environment monitoring, which only need to set a reporting address on a sensor device, so that the sensor device data can be transmitted into a service system, and the service system only needs to utilize data according to own service; the problem that standards of various factories of current ecological environment monitoring equipment are not uniform is solved, the HJ 212-2017 protocol is uniformly adopted as an access standard to construct an Internet of things system according to the technical requirement of the communication protocol of the automatic monitoring system for the surface water of the country, and the data acquisition system can be quickly built by using the platform in relation to environment monitoring.
Disclosure of Invention
In order to solve the technical problems, the invention provides an analysis method of the Internet of things for ecological environment monitoring, which comprises the following steps:
setting a data reporting address of the hardware equipment as an address of a reachable server;
analyzing the protocol data of the HJ212 based on the TCP protocol into readable character strings, and converting the analyzed readable character strings into json identification;
The data is stored in a database.
Optionally, the process of parsing the protocol data of the HJ212 based on the TCP protocol into readable character strings includes the following steps:
Creating a TCP protocol receiving server by using the network shortcut network frame instantiation server, setting a port to 8000, and setting a processor word processing program, wherein the processor instantiates and rewrites an initialization channel of the processor to a socket channel of the processor through a channel initializer;
And acquiring a channel processing program chain and setting a parser to convert the original message data into a character string in the UTF-8 format.
Optionally, the encoder is set to convert the message data into a character string in UTF-8 format, the network data frame size is set to limit the size of the frame aggregator data packet not to exceed 10M, the timeout off time is set to 60 minutes, and the custom data processor HJ212Handler is set.
Optionally, the construction process of the parser comprises the following steps:
Defining a common data reception class;
Dividing each group of data by a division number, dividing the data into character string arrays according to the division number, and carrying out cyclic analysis on the divided character string arrays; dividing the character string of the current cycle according to the comma, and dividing the divided character string according to the "=" equal sign to obtain a group of data;
Judging the attribute codes of the group of data, -Avg being average, -Max being maximum, -Min being minimum, -fixing the end of Flag to a data state; and setting the data into monitoring item data classes according to rules, wherein each group of monitoring item data classes contains one circulation item of comma, namely one monitoring item data class instance, and converting the received primary message to obtain a father-son structure containing a plurality of monitoring data classes under the common data class.
Optionally, the defined public data receiving class includes an attribute request code QN, a system code ST, a command code CN, an access password PW, a site identifier MN, a reply identifier Flag, a collection time DataTime, and an instruction parameter CP.
Optionally, the definition of the common data receiving class includes the following steps:
the common data receiving attribute is consistent with the common part of the received data, and the end of the data is a fixed & +.4-bit check code;
Cutting off the 6-bit character string at the end, and ending the process of adding the instruction parameter with the & &; ".
Optionally, the process of performing cyclic analysis on the segmented string array includes the following steps:
In the circulation, whether the inside contains a comma or not is judged, and for the comma which does not contain the comma, the comma is directly divided according to an 'equal sign', wherein the front of the equal sign is an attribute code, and the rear of the equal sign is an attribute value;
Firstly, matching attribute codes according to public attributes, and setting values into public data receiving classes if the attribute codes are matched;
a monitoring item data class is defined.
Optionally, attribute codes are first matched according to common attributes, and for comma-containing analysis data are found to be specific monitoring items by cross-line linking attribute types and data values thereof and using equal sign separation.
Optionally, a monitoring item data class is defined, including a monitoring item code, a monitoring value, a monitoring value type, and a monitoring item status.
The invention provides an analytic system of the Internet of things for ecological environment monitoring, which comprises the following components:
the hardware device configuration module is responsible for setting the data reporting address of the hardware device as the address of the reachable server;
the data analysis module is in charge of analyzing the protocol data of the HJ212 based on the TCP protocol into readable character strings and converting the analyzed readable character strings into json identification;
And the data storage module is responsible for storing the data into the database.
Firstly, determining an IP address or a domain name of a server, entering a configuration interface of hardware equipment, finding out network configuration options, and setting network parameters of the hardware equipment according to a network connection mode of the hardware equipment; finding a setting option of a data reporting address, and filling the address of the server into a designated field; confirming the storage configuration, and enabling the data reporting address of the hardware equipment to take effect; secondly, based on a TCP protocol, using an HJ212 protocol to transmit data of hardware equipment, using netty network frames, writing a corresponding protocol decoder, analyzing the protocol data of the HJ212 based on the TCP protocol into readable character strings, and converting the data format of the analyzed readable character strings into json for program identification; finally, a relational database adopting aggregate storage data is established, the connection information of the database is provided through a driver, and the connection between the hardware equipment and the database is established; when the data is reported, analyzing json format data of the hardware equipment; using the database's API, performing an insert operation stores the parsed json-format data into a collection of databases (the principles of which refer to FIG. 2). When the server address is determined, the scheme can select the IP address or the domain name to be used, and corresponding fields are filled in according to actual conditions; finding out network configuration options by entering a configuration interface of hardware equipment so as to set network parameters; the network configuration options generally comprise parameters such as an IP address, a subnet mask, a gateway and the like, and corresponding configuration is carried out according to the network connection mode of the hardware equipment; ensuring that the hardware equipment can be correctly connected to the network and communicate with the server; the hardware equipment can accurately report the acquired data to a designated server; ensuring that the configuration information of the hardware equipment is correctly stored, enabling the hardware equipment to be normally connected to a server and reporting data to a designated address; through the steps, the specific operation required when setting the network parameters and the data reporting address of the hardware equipment can be more clearly understood.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings.
The technical scheme of the invention is further described in detail through the drawings and the embodiments.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate the invention and together with the embodiments of the invention, serve to explain the invention. In the drawings:
Fig. 1 is a flow chart of an analytic method of the internet of things for ecological environment monitoring in embodiment 1 of the present invention;
fig. 2 is a schematic diagram of an analytic method of the internet of things for ecological environment monitoring in embodiment 1 of the present invention;
FIG. 3 is a process diagram of filling the address of the server into the designated field in embodiment 2 of the present invention;
FIG. 4 is a process diagram of parsing the protocol data of the HJ212 based on the TCP protocol into readable character strings in embodiment 3 of the present invention;
FIG. 5 is a diagram showing the construction process of the resolver according to embodiment 4 of the present invention;
FIG. 6 is a diagram showing the definition of a common data reception class in embodiment 5 of the present invention;
FIG. 7 is a schematic diagram of a data processor of the present invention after decoding the original message data and then inputting the decoded data into the custom data processor;
FIG. 8 is a diagram illustrating the message processing in embodiment 5 of the present invention;
FIG. 9 is a process diagram of performing cyclic analysis on a segmented string array according to embodiment 6 of the present invention;
FIG. 10 is a process diagram of establishing a connection between a hardware device and a database in accordance with embodiment 7 of the present invention;
FIG. 11 is a diagram showing the process of designing and creating a corresponding table structure in embodiment 8 of the present invention;
Fig. 12 is a block diagram of an analytic system of internet of things for ecological environment monitoring in embodiment 11 of the present invention.
Detailed Description
The preferred embodiments of the present invention will be described below with reference to the accompanying drawings, it being understood that the preferred embodiments described herein are for illustration and explanation of the present invention only, and are not intended to limit the present invention.
The terminology used in the embodiments of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of embodiments of the application. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the application as detailed in the accompanying claims. In the description of the present application, it should be understood that the terms "first," "second," "third," and the like are used merely to distinguish between similar objects and are not necessarily used to describe a particular order or sequence, nor should they be construed to indicate or imply relative importance. The specific meaning of the above terms in the present application can be understood by those of ordinary skill in the art according to the specific circumstances.
Example 1: as shown in fig. 1, the embodiment of the invention provides an analysis method of the internet of things for ecological environment monitoring, which comprises the following steps:
S100: determining an IP address or a domain name of a server, entering a configuration interface of hardware equipment, finding a network configuration option, and setting network parameters of the hardware equipment according to a network connection mode of the hardware equipment; finding a setting option of a data reporting address, and filling the address of the server into a designated field; confirming the storage configuration, and enabling the data reporting address of the hardware equipment to take effect;
S200: based on the TCP protocol, using the HJ212 protocol to transmit data of hardware equipment, using netty network frames, writing a corresponding protocol decoder, analyzing the protocol data of the HJ212 based on the TCP protocol into readable character strings, and converting the data format of the analyzed readable character strings into json for program identification;
S300: creating a relational database adopting aggregate storage data, providing connection information of the database through a driver, and establishing connection between hardware equipment and the database; when the data is reported, analyzing json format data of the hardware equipment; and executing an inserting operation by using an API of the database, and storing the parsed json format data into a set of the database.
The working principle and beneficial effects of the technical scheme are as follows: firstly, determining an IP address or a domain name of a server, entering a configuration interface of hardware equipment, finding out a network configuration option, and setting network parameters of the hardware equipment according to a network connection mode of the hardware equipment; finding a setting option of a data reporting address, and filling the address of the server into a designated field; confirming the storage configuration, and enabling the data reporting address of the hardware equipment to take effect; secondly, based on a TCP protocol, using an HJ212 protocol to transmit data of hardware equipment, using netty network frames, writing a corresponding protocol decoder, analyzing the protocol data of the HJ212 based on the TCP protocol into readable character strings, and converting the data format of the analyzed readable character strings into json for program identification; finally, a relational database adopting aggregate storage data is established, the connection information of the database is provided through a driver, and the connection between the hardware equipment and the database is established; when the data is reported, analyzing json format data of the hardware equipment; using the database's API, performing an insert operation stores the parsed json-format data into a collection of databases (the principles of which refer to FIG. 2). When the server address is determined, the scheme can select the IP address or the domain name to be used, and corresponding fields are filled in according to actual conditions; finding out network configuration options by entering a configuration interface of hardware equipment so as to set network parameters; the network configuration options generally comprise parameters such as an IP address, a subnet mask, a gateway and the like, and corresponding configuration is carried out according to the network connection mode of the hardware equipment; ensuring that the hardware equipment can be correctly connected to the network and communicate with the server; the hardware equipment can accurately report the acquired data to a designated server; ensuring that the configuration information of the hardware equipment is correctly stored, enabling the hardware equipment to be normally connected to a server and reporting data to a designated address; through the steps, the specific operation required when setting the network parameters and the data reporting address of the hardware equipment can be more clearly understood.
The following effects can be achieved by setting the data reporting address to be the address of the reachable server: stability of data transmission: the device directly transmits the data to the address of the server, so that instability and delay of the data passing through an intermediate node or a third party platform are avoided; the stability and the instantaneity of data transmission can be improved, and the data can be timely transmitted to the server. Data security: setting the data reporting address as an address of a reachable server, and protecting the safety of the data through proper safety measures; the server can adopt a security protocol and an encryption algorithm to protect the transmitted data and prevent the data from being tampered or leaked in the transmission process. Simplifying the data processing flow: the data is directly transmitted to the address of the server, so that the data processing flow can be simplified; the server can directly receive the data reported by the equipment, process, store and analyze the data in real time, reduce the complexity of data transmission and processing, and improve the efficiency and response speed of the system. Remote management and monitoring: by setting the data reporting address as the address of the reachable server, the device can establish remote connection with the server, so as to realize the management and monitoring of the device; the server can remotely acquire the state and data of the equipment, perform remote configuration and control, and improve the manageability and maintainability of the equipment.
In summary, the embodiment realizes the reporting, analysis and storage of the hardware device data, thereby realizing the effective management and utilization of the device data. Reporting hardware equipment data: the data reporting address of the hardware equipment is set, so that the equipment can transmit the data to a designated server; real-time data reporting can be realized, and monitoring data of the equipment can be timely obtained. Data parsing and format conversion: analyzing the HJ212 protocol data based on the TCP protocol into a readable character string by using netty network frames and a custom protocol decoder, and converting the analyzed data format into json format; the analysis and the identification of the equipment data can be realized, and the subsequent data processing and analysis are convenient. Data storage and management: the method comprises the steps of storing parsed json format device data into a relational database by creating a set of the database; the method can realize the persistent storage of the equipment data and is convenient for subsequent data inquiry, analysis and management.
The embodiment provides a complete data processing flow, and the data of the hardware equipment is reported to the data storage, so that the reliable management and effective utilization of the equipment data are realized; through reporting, analyzing and storing the data, the real-time monitoring, analyzing and reporting of the equipment data can be realized, and reliable data support is provided for environmental monitoring, equipment management, decision making and the like. Meanwhile, a foundation is provided for subsequent data processing and application, such as data analysis, visual display, alarm notification and the like.
Example 2: as shown in fig. 3, on the basis of embodiment 1, the process of filling the address of the server into the specified field provided in the embodiment of the present invention includes the following steps:
s101: receiving a connection request of a hardware device, acquiring an authentication method selection request from the hardware device, feeding back the authentication method selection request to the hardware device, and acquiring connection request information from the hardware device if authentication is passed, wherein the connection request information comprises a data reporting address, an address of a server and a port number; establishing connection with the server by using a data reporting address according to the address and the port number of the server;
S102: acquiring specified field data in a specified table of a server, determining a logic relation between the specified table and the specified field data, and storing the specified field data under a directory;
S103: and receiving a data request of the server, acquiring address information of the server, sending specified field data in the catalogue and a logic relation between the specified field data and the catalogue to the server according to the address information, and filling the address of the server into the specified field.
The working principle and beneficial effects of the technical scheme are as follows: step S101 in this embodiment: and receiving a connection request of the hardware equipment, and acquiring an authentication method selection request from the hardware equipment. After passing the authentication, obtaining connection request information of the hardware equipment, wherein the connection request information comprises a data reporting address, an address of a server and a port number; establishing connection with a server according to the address and the port number of the server; the hardware equipment can be ensured to establish effective communication connection with the server so as to report and interact data; ensuring that the device can successfully communicate with the server, and providing a basis for subsequent data transmission and interaction. Step S102: acquiring specified field data in a specified table of a server, and determining a logic relationship between the specified table and the specified field data; storing the specified field data under the catalog; acquiring specific data from a server and storing the specific data in a local directory; and acquiring required data, and providing an accurate data basis for subsequent data processing and use. Step S103: and receiving a data request of the server and acquiring address information of the server. And sending the specified field data in the catalogue and the logic relation between the specified field data and the catalogue to the server according to the address information. Filling the address of the server into a designated field; transmitting the local specified field data and the logic relationship thereof to a server, and filling the address of the server into the specified field; the bidirectional transmission and interaction of the data are realized, the server can acquire the required data, and the server can effectively communicate and control with the equipment.
In summary, the embodiment includes establishing an effective connection with a server, acquiring required server data, implementing bidirectional transmission and interaction of the data, and the like, and provides an accurate and reliable basis for communication and data processing between hardware equipment and the server; the hardware equipment can be ensured to normally communicate and exchange data with the server, and accurate transmission and effective utilization of data are realized.
Example 3: as shown in fig. 4, based on embodiment 1, the process of parsing the protocol data of the HJ212 based on the TCP protocol into readable character strings provided in the embodiment of the present invention includes the following steps:
S201: creating a TCP protocol reception server using the network shortcut netty network frame instantiation server boot ServerBootstrap, provisioning the port to 8000 setup the processor word processor CHILDHANDLER, wherein the processor instantiates and rewrites its initialization channel INITCHANNEL to its socket channel SocketChannel through channel initializer ChannelInitializer;
S202: obtaining a channel processing program chain pipeline and setting a parser serverDecoder to convert the original message data into a character string in UTF-8 format;
s203: the encoder serverEncoder is set to convert the message data into character strings in UTF-8 format, the network data frame size is set to limit the size of the frame aggregation device frame-aggregator data packet not to exceed 10M, the overtime disconnection time is set to 60 minutes, and the custom data processor HJ212Handler is set.
The working principle and beneficial effects of the technical scheme are as follows: the TCP protocol of the embodiment is converted into readable character strings, and the specific processing is decoding the data stream in UTF-8 format to obtain readable HJ212 protocol data; firstly, creating a TCP protocol receiving server by utilizing a network shortcut netty network frame instantiation server guide ServerBootstrap, setting a port to 8000 and setting a processor word processing program CHILDHANDLER, wherein a processor instantiates and rewrites an initialization channel INITCHANNEL of the processor to a socket channel SocketChannel of the processor through a channel initializer ChannelInitializer; secondly, obtaining a channel processing program chain pipeline and setting a parser serverDecoder to convert the original message data into a character string in a UTF-8 format; finally, an encoder serverEncoder is arranged to convert the message data into character strings in UTF-8 format, the size of the network data frame is set to limit the size of the frame aggregation device frame-aggregator data packet not to exceed 10M, the timeout disconnection time is set to 60 minutes, and a custom data processor HJ212Handler is set. The scheme realizes a receiving server based on the TCP protocol and converts the received original data stream into readable HJ212 protocol data. The specific meaning is as follows: implementing a TCP protocol receiving server: by using ServerBootstrap of the Netty framework, a receiving server of a TCP protocol can be rapidly realized; the server may monitor the designated port, receive a connection request from the client, and process the received data. Decoder and encoder settings: by arranging a decoder (serverDecoder) and an encoder (serverEncoder), the original TCP data stream can be converted into a readable character string in UTF-8 format, and the character string can be converted into the TCP data stream; the decoder and encoder function as data format conversions so that the server can parse and process the received data. Setting of a frame aggregator: by setting a frame aggregator (frame-aggregator), the size of the data packet can be limited, and memory overflow or performance problem caused by oversized data packet can be prevented; the frame aggregator aggregates the data frames transmitted in segments into complete messages, which is convenient for subsequent processing and analysis. Timeout off time setting: by setting the overtime disconnection time, the connection can be automatically disconnected when no data is transmitted in a certain time, so that resources are released and the reliability and stability of the system are improved. Custom data processor: by setting a custom data processor (HJ 212 Handler), specific business logic processing can be performed on the received data. The received data can be analyzed and processed according to the specification of the HJ212 protocol to perform corresponding business logic operation.
In summary, the embodiment realizes a readable receiving server of HJ212 protocol data, and by reasonably setting components such as a decoder, an encoder, a frame aggregator, etc., analysis, conversion and processing of TCP data streams can be realized, so as to improve reliability, stability and readability of the system.
Example 4: as shown in fig. 5, on the basis of embodiment 3, the construction process of the parser provided in the embodiment of the present invention includes the following steps:
S2021: defining a public data receiving class, wherein the public data receiving class comprises an attribute request code QN, a system code ST, a command code CN, an access password PW, a site identifier MN, a response identifier Flag, acquisition time DataTime and an instruction parameter CP;
S2022: dividing each group of data by a division number, dividing the data into character string arrays according to the division number, and carrying out cyclic analysis on the divided character string arrays; dividing the character string of the current cycle according to the comma, and dividing the divided character string according to the "=" equal sign to obtain a group of data;
S2023: judging the attribute codes of the group of data, -Avg being average, -Max being maximum, -Min being minimum, -fixing the end of Flag to a data state; and setting the data into monitoring item data classes according to rules, wherein each group of monitoring item data classes contains one circulation item of comma, namely one monitoring item data class instance, and converting the received primary message to obtain a father-son structure containing a plurality of monitoring data classes under the common data class.
The working principle and beneficial effects of the technical scheme are as follows: firstly, defining a public data receiving class, wherein the public data receiving class comprises an attribute request code QN, a system code ST, a command code CN, an access password PW, a site identifier MN, a response identifier Flag, acquisition time DataTime and an instruction parameter CP; secondly, dividing each group of data by a division number, dividing the data into character string arrays according to the division number, and carrying out cyclic analysis on the divided character string arrays; dividing the character string of the current cycle according to the comma, and dividing the divided character string according to the "=" equal sign to obtain a group of data; finally judging attribute codes of the group of data, wherein-Avg is an average value, -Max is a maximum value, -Min is a minimum value, and the data state is fixed at the end of-Flag; and setting the data into monitoring item data classes according to rules, wherein each group of monitoring item data classes contains one circulation item of comma, namely one monitoring item data class instance, so that the received primary message is converted into a father-son structure containing a plurality of monitoring data classes under the public data class. The scheme realizes the analysis and conversion of the received data message, and saves the data into the father-son structure of the public data class and the monitoring item data class according to the specified format, thereby facilitating the subsequent processing and use. The specific meaning is as follows: defining a common data reception class: by defining a public data receiving class, each field of the received data message is encapsulated, so that unified management and processing of data are facilitated; the public data receiving class comprises the attributes such as request codes, system codes, command codes, access passwords, site identifiers, response identifiers, acquisition time, instruction parameters and the like, and the attributes can be operated and used according to the needs. Data analysis and conversion: dividing and analyzing the received data message, dividing each group of data according to the semicolons, and further dividing according to commas and equal signs to obtain the attribute and value of each group of data; the type of data (average value, maximum value, minimum value, data state, etc.) is judged according to the rule of the attribute code, and the data is set into the monitoring item data class. Monitoring usage of item data classes: each set of data can be converted into an instance of a monitoring item data class through the definition and use of the monitoring item data class; the monitoring item data class comprises a plurality of attributes and values, and is used for representing the data of one monitoring item; thus, through the monitoring item data class under the common data class, unified management and processing of a plurality of received monitoring data can be realized. The subsequent treatment and use are convenient: the received data are converted into the father-son structures of the public data class and the monitoring item data class, so that the subsequent data processing and use can be facilitated; the public data class and the monitoring item data class can be subjected to operations such as inquiring, calculating and storing according to the requirements, so that further analysis and application of the monitoring data are realized.
In summary, the embodiment achieves analysis and conversion of the received data message, and saves the data as the father-son structure of the public data class and the monitoring item data class according to the specified format; the method can conveniently manage, process and use the data, improves the readability and operability of the data, and provides a basis for subsequent business logic processing.
Example 5: as shown in fig. 6, on the basis of embodiment 4, the definition of the common data receiving class provided in the embodiment of the present invention includes the following steps:
s20211: the common data receiving attribute is consistent with the common part of the received data, and the end of the data is a fixed & +.4-bit check code;
s20212: cutting off the 6-bit character string at the end, and ending the process of adding the instruction parameter with the & &; "; the message is processed as shown in fig. 8:
After the original message data is decoded and then is transmitted into a self-defined data processor, the data can be obtained as shown in figure 7; the data analysis can obtain that the frame is framed, the structure is highly similar, w01001 is PH value, -AVG is average value of current monitoring, -Flag is current value state, and each comma is a group of monitoring data. "##0630QN=20230901131411218;ST=21;CN=2061;PW=123456;MN=5100000003;Flag=9;CP=&&DataTime=20230901120000;" above the box is reported public data, which is transmitted regardless of the specific monitored value and the variation of the detected item.
The working principle and beneficial effects of the technical scheme are as follows: in the embodiment, firstly, the common data receiving attribute is consistent with the common part of the received data, and the end of the data is a fixed & +.4-bit check code; then, cutting off the 6-bit character string at the end, and simultaneously ending the' CP= = &; ". The scheme is that the received data message is processed and converted to conform to the attribute definition of the public data receiving class, and the ending symbol of the instruction parameter is replaced by "& gt and & gt by a semicolon"; ". The specific meaning is as follows: common data reception class attribute definition: by defining a public data receiving class, the public part of the received data message corresponds to the attribute of the public data receiving class, so that the received data can be packaged and managed according to the specified attribute; the subsequent operation and use of the data can be facilitated. Intercepting the ending character string and processing instruction parameters: according to a given data format, the check code part can be removed by intercepting the 6-bit character string at the end, and effective data is reserved; meanwhile, "cp= and =" are replaced with "cp=; ", to meet the ending character requirements of the instruction parameters. Data format normalization: the data is enabled to accord with the attribute definition of the public data receiving class and the format requirement of the instruction parameter through the processing and the conversion of the data; the consistency and normalization of the data can be ensured, and the subsequent processing and use are convenient. The subsequent treatment and use are convenient: the received data can be converted into a format conforming to the attribute definition of the public data receiving class through processing and converting the data, so that the subsequent operation and use of the data are convenient; the public data class can be subjected to operations such as inquiring, calculating and storing according to the requirement, and the readability and operability of the data are improved.
In summary, the embodiment processes and converts the received data message to conform to the attribute definition of the public data receiving class, and replaces the ending symbol of the instruction parameter with "& +" by a semicolon "; "; the consistency and normalization of the data can be ensured, the subsequent data processing and use are convenient, and the readability and operability of the data are improved.
Example 6: as shown in fig. 9, on the basis of embodiment 4, the process for performing cyclic analysis on the segmented string array provided by the embodiment of the present invention includes the following steps:
S20221: in the circulation, whether the inside contains a comma or not is judged, and for the comma which does not contain the comma, the comma is directly divided according to an 'equal sign', wherein the front of the equal sign is an attribute code, and the rear of the equal sign is an attribute value;
S20222: firstly, matching attribute codes according to public attributes, and setting values into public data receiving classes if the attribute codes are matched; for comma-containing analysis data find that a specific monitoring item is linked with the attribute type and the data value thereof by a middle cross line and separated by an equal sign;
s20223: a monitoring item data class is defined, and the monitoring item data class comprises a monitoring item code, a monitoring value, a monitoring value type and a monitoring item state status.
The working principle and beneficial effects of the technical scheme are as follows: in the embodiment, firstly, in the circulation, whether the inside contains a comma or not is judged, and for the comma which does not contain the comma, the comma is directly divided according to an 'equal sign', the front of the equal sign is an attribute code, and the back of the equal sign is an attribute value; secondly, the attribute codes are matched according to the public attribute, and if the public attribute codes are matched, the value is set into a public data receiving class; for comma-containing analysis data find that a specific monitoring item is linked with the attribute type and the data value thereof by a middle cross line and separated by an equal sign; and finally defining a monitoring item data class which comprises a monitoring item code, a monitoring value, a monitoring value type and a monitoring item state status as attributes. The scheme realizes further analysis and conversion of the received data message, matches and processes the data according to the rules of the attribute codes and the attribute values, and stores the specific monitoring item data as an example of the monitoring item data class. The specific meaning is as follows: matching and processing of attribute codes and attribute values: and judging whether commas are included in the data, and dividing and processing the data. For data which does not contain commas, dividing the data directly according to an equal sign, wherein attribute codes are arranged in front of the equal sign, and attribute values are arranged behind the equal sign; and matching the attribute codes with the public attributes, and if the matching is successful, setting the attribute values into the public data receiving class. Analysis and preservation of monitoring item data: for comma-containing data, the analytical data structure finds specific monitoring item data; the attribute code and attribute value of the monitoring item can be obtained by linking the attribute type and data value with a middle horizontal line and using equal sign separation. These data are saved as instances of the monitoring item data class according to rules of the attribute codes and values. Definition of the monitoring item data class: by defining the monitoring item data class, the monitoring item data class comprises the attributes such as codes, values, types, states and the like of the monitoring items; specific monitoring item data can be packaged and managed, and subsequent processing and use are convenient. The subsequent treatment and use are convenient: the data can be conveniently operated and used by matching and processing the data according to the rules of the attribute codes and the attribute values and storing the specific monitoring item data as an example of the monitoring item data class; the public data receiving class and the monitoring item data class can be subjected to operations such as inquiring, calculating and storing according to the requirements, so that further analysis and application of the monitoring data are realized.
In summary, the embodiment realizes further analysis and conversion of the received data message, matches and processes the data according to the rule of the attribute codes and the attribute values, and stores the specific monitoring item data as an instance of the monitoring item data class; the method can conveniently manage, process and use the data, improves the readability and operability of the data, and provides a basis for subsequent business logic processing.
Example 7: as shown in fig. 10, on the basis of embodiment 1, the process for establishing connection between a hardware device and a database provided in the embodiment of the present invention includes the following steps:
S301: selecting a structured query language SQL SERVER relational database system and configuring the database system; connecting to a database system using a database management tool or command line tool and creating a new database; designing and creating a corresponding table structure according to data requirements, and defining fields and relations;
S302: downloading and installing a corresponding database driver according to the selected programming language, wherein the database driver comprises an API (application program interface) for connecting a database, executing SQL (structured query language) sentences and other functions; creating a database connection object by using an API provided by a driver, and establishing connection with the database according to the connection information of the database;
S303: after the database connection is established, executing SQL sentences by using an API provided by a driver, and storing data into the database or retrieving data from the database; storing data using the collection and mapping it to fields in a table structure of the database; the collection contains a list or dictionary.
The working principle and beneficial effects of the technical scheme are as follows: firstly, selecting a structural query language SQL SERVER relational database system and configuring the database system; connecting to a database system using a database management tool or command line tool and creating a new database; designing and creating a corresponding table structure according to data requirements, and defining fields and relations; secondly, according to the selected programming language, downloading and installing a corresponding database driver, wherein the database driver comprises an API (application program interface) for connecting a database, executing SQL (structured query language) sentences and other functions; creating a database connection object by using an API provided by a driver, and establishing connection with the database according to the connection information of the database; finally, after the database connection is established, executing SQL sentences by using an API provided by a driver, and storing the data into the database or retrieving the data from the database; storing data using the collection and mapping it to fields in a table structure of the database; the collection contains a list or dictionary. The scheme establishes a complete database system, realizes the connection with hardware equipment by using SQL SERVER relational database system and corresponding driver, and manages the database by database management tool or command line tool. Specifically, data storage and management: by configuring and using SQL SERVER database systems, large amounts of structured data can be efficiently stored and managed; the table structure and field definitions of the database may be designed according to data requirements to meet the organization and storage requirements of the data. Data access and operation: by using the APIs provided by the database driver, a connection with the database can be established and SQL statements can be executed to store and retrieve data; the application program can conveniently access and operate the data in the database, and the operations of adding, deleting, modifying, checking and the like on the data are realized. Data consistency and security: the relational database system provides a mechanism for transaction processing and data integrity, and ensures consistency and reliability of data; in addition, SQL SERVER provide security functions, such as user authentication and rights management, to protect the data in the database from unauthorized access and modification. Data analysis and reporting: SQL SERVER provide functions for analysis services and reporting services, which enable data analysis and report generation; through the functions, the user can extract data from the database, perform operations such as data analysis and visual report generation, and the like, and help to make better decisions.
In summary, the embodiment establishes a reliable and efficient database system, realizes data storage, access, management and analysis, and provides powerful data support and decision basis for application programs and services.
Example 8: as shown in fig. 11, on the basis of embodiment 7, the process of designing and creating a corresponding table structure provided in the embodiment of the present invention includes the following steps:
s3011: creating a table named public data reception for storing attributes of the public data reception class;
S3012: the following fields and corresponding data types are created in the table:
request encoding: setting the field length according to actual requirements by using varchar or nvarchar data types;
and (3) system coding: setting the field length according to actual requirements by using varchar or nvarchar data types;
command encoding: setting the field length according to actual requirements by using varchar or nvarchar data types;
access password: setting the field length according to actual requirements by using varchar or nvarchar data types;
station identification: setting the field length according to actual requirements by using varchar or nvarchar data types;
And (3) response identification: using bit or int data types to indicate whether there is a response; bit type stores 0 or 1, int type stores more complex response states;
acquisition time: using datetime or datetime data types to represent the acquisition time of the data;
Instruction parameters: setting the field length according to actual requirements by using varchar or nvarchar data types;
S3013: corresponding table structures are created in the database according to the fields and data types through the T-SQL command.
The working principle and beneficial effects of the technical scheme are as follows: firstly, creating a table named as public data receiving, and storing the attribute of the public data receiving class; secondly, the following fields and corresponding data types are created in the table: request encoding: setting the field length according to actual requirements by using varchar or nvarchar data types; and (3) system coding: setting the field length according to actual requirements by using varchar or nvarchar data types; command encoding: setting the field length according to actual requirements by using varchar or nvarchar data types; access password: setting the field length according to actual requirements by using varchar or nvarchar data types; station identification: setting the field length according to actual requirements by using varchar or nvarchar data types; and (3) response identification: using bit or int data types to indicate whether there is a response; bit type stores 0 or 1, int type stores more complex response states; acquisition time: using datetime or datetime data types to represent the acquisition time of the data; instruction parameters: setting the field length according to actual requirements by using varchar or nvarchar data types; and finally, creating a corresponding table structure in the database according to the fields and the data types through the T-SQL command. The above scheme creates a table named "common data reception" for storing attributes of the common data reception class. By defining different fields and corresponding data types, it is ensured that the structure of the table matches the actual requirements and that the data can be stored and retrieved correctly. The specific meaning is as follows: and (3) data storage: by creating tables and definition fields, relevant data may be stored in a database for subsequent data management and query operations. Data type definition: selecting the appropriate data type to define the field can ensure the accuracy and integrity of the data. Different data types may be adapted to different data requirements, for example using varchar or nvarchar to store text data, bit or int to store boolean or integer data, datetime or datetime2 to store date and time data. Data structure consistency: by creating a corresponding table structure in the database, the consistency of the data can be ensured; all relevant data will be stored according to predefined fields and data types, avoiding the problems of data confusion and inconsistency. Data query and analysis: after the correct table structure is defined, the data in the table can be queried, filtered and analyzed by using the T-SQL command, the required data can be conveniently retrieved and analyzed, and the operations such as business decision and report generation are supported.
In summary, the present embodiment creates a suitable table structure, so that the properties of the common data reception can be stored and managed correctly, to meet the actual requirements and support the subsequent data operation and analysis.
Example 9: as shown in fig. 12, on the basis of embodiments 1 to 8, the system for analyzing the internet of things for monitoring the ecological environment provided by the embodiment of the invention includes:
The hardware equipment configuration module is responsible for determining the IP address or domain name of the server, entering a configuration interface of the hardware equipment, finding out network configuration options, and setting network parameters of the hardware equipment according to the network connection mode of the hardware equipment; finding a setting option of a data reporting address, and filling the address of the server into a designated field; confirming the storage configuration, and enabling the data reporting address of the hardware equipment to take effect;
The data analysis module is responsible for transmitting data of hardware equipment by using an HJ212 protocol based on a TCP protocol, writing a corresponding protocol decoder by using a netty network frame, analyzing the protocol data of the HJ212 based on the TCP protocol into readable character strings, and converting the data format of the analyzed readable character strings into json for program identification;
The data storage module is responsible for creating a relational database for storing data in a collection mode, providing connection information of the database through a driver and establishing connection between hardware equipment and the database; when the data is reported, analyzing json format data of the hardware equipment; and executing an inserting operation by using an API of the database, and storing the parsed json format data into a set of the database.
The working principle and beneficial effects of the technical scheme are as follows: the hardware equipment configuration module of the embodiment determines the IP address or domain name of the server, enters a configuration interface of the hardware equipment, finds out a network configuration option, and sets network parameters of the hardware equipment according to the network connection mode of the hardware equipment; finding a setting option of a data reporting address, and filling the address of the server into a designated field; confirming the storage configuration, and enabling the data reporting address of the hardware equipment to take effect; the data analysis module uses the HJ212 protocol to transmit the data of the hardware device based on the TCP protocol, uses netty network frames to write a corresponding protocol decoder, analyzes the protocol data of the HJ212 based on the TCP protocol into readable character strings, and then converts the data format of the analyzed readable character strings into json for program identification; the data storage module creates a relational database for storing data in a collection mode, provides connection information of the database through a driver program, and establishes connection between hardware equipment and the database; when the data is reported, analyzing json format data of the hardware equipment; and executing an inserting operation by using an API of the database, and storing the parsed json format data into a set of the database. When the server address is determined, the scheme can select the IP address or the domain name to be used, and corresponding fields are filled in according to actual conditions; finding out network configuration options by entering a configuration interface of hardware equipment so as to set network parameters; the network configuration options generally comprise parameters such as an IP address, a subnet mask, a gateway and the like, and corresponding configuration is carried out according to the network connection mode of the hardware equipment; ensuring that the hardware equipment can be correctly connected to the network and communicate with the server; the hardware equipment can accurately report the acquired data to a designated server; ensuring that the configuration information of the hardware equipment is correctly stored, enabling the hardware equipment to be normally connected to a server and reporting data to a designated address; through the steps, the specific operation required when setting the network parameters and the data reporting address of the hardware equipment can be more clearly understood.
The following effects can be achieved by setting the data reporting address to be the address of the reachable server: stability of data transmission: the device directly transmits the data to the address of the server, so that instability and delay of the data passing through an intermediate node or a third party platform are avoided; the stability and the instantaneity of data transmission can be improved, and the data can be timely transmitted to the server. Data security: setting the data reporting address as an address of a reachable server, and protecting the safety of the data through proper safety measures; the server can adopt a security protocol and an encryption algorithm to protect the transmitted data and prevent the data from being tampered or leaked in the transmission process. Simplifying the data processing flow: the data is directly transmitted to the address of the server, so that the data processing flow can be simplified; the server can directly receive the data reported by the equipment, process, store and analyze the data in real time, reduce the complexity of data transmission and processing, and improve the efficiency and response speed of the system. Remote management and monitoring: by setting the data reporting address as the address of the reachable server, the device can establish remote connection with the server, so as to realize the management and monitoring of the device; the server can remotely acquire the state and data of the equipment, perform remote configuration and control, and improve the manageability and maintainability of the equipment.
In summary, the embodiment realizes the reporting, analysis and storage of the hardware device data, thereby realizing the effective management and utilization of the device data. Reporting hardware equipment data: the data reporting address of the hardware equipment is set, so that the equipment can transmit the data to a designated server; real-time data reporting can be realized, and monitoring data of the equipment can be timely obtained. Data parsing and format conversion: analyzing the HJ212 protocol data based on the TCP protocol into a readable character string by using netty network frames and a custom protocol decoder, and converting the analyzed data format into json format; the analysis and the identification of the equipment data can be realized, and the subsequent data processing and analysis are convenient. Data storage and management: the method comprises the steps of storing parsed json format device data into a relational database by creating a set of the database; the method can realize the persistent storage of the equipment data and is convenient for subsequent data inquiry, analysis and management.
The embodiment provides a complete data processing flow, and the data of the hardware equipment is reported to the data storage, so that the reliable management and effective utilization of the equipment data are realized; through reporting, analyzing and storing the data, the real-time monitoring, analyzing and reporting of the equipment data can be realized, and reliable data support is provided for environmental monitoring, equipment management, decision making and the like. Meanwhile, a foundation is provided for subsequent data processing and application, such as data analysis, visual display, alarm notification and the like.
Example 10: on the basis of embodiment 9, the hardware device configuration module provided by the embodiment of the present invention includes:
The request processing sub-module is in charge of receiving a connection request of the hardware equipment, acquiring an authentication method selection request from the hardware equipment, feeding back the authentication method selection request to the hardware equipment, and acquiring connection request information from the hardware equipment if the authentication is passed, wherein the connection request information comprises a data reporting address, an address of a server and a port number; establishing connection with the server by using a data reporting address according to the address and the port number of the server;
The relationship confirmation sub-module is responsible for acquiring the appointed field data in the appointed table of the server, determining the logic relationship between the appointed table and the appointed field data, and storing the appointed field data under the catalogue;
The information acquisition sub-module is in charge of receiving the data request of the server, acquiring the address information of the server, sending the specified field data in the catalogue and the logic relation between the specified field data and the catalogue to the server according to the address information, and filling the address of the server into the specified field.
The working principle and beneficial effects of the technical scheme are as follows: the request processing submodule of the embodiment receives a connection request of a hardware device, acquires an authentication method selection request from the hardware device, feeds back the authentication method selection request to the hardware device, and acquires connection request information from the hardware device if authentication is passed, wherein the connection request information comprises a data report address, an address of a server and a port number; establishing connection with the server by using a data reporting address according to the address and the port number of the server; the relation confirmation submodule acquires the appointed field data in the appointed table of the server, determines the logic relation between the appointed table and the appointed field data, and stores the appointed field data under the catalogue; the information acquisition submodule receives the data request of the server, acquires the address information of the server, sends the specified field data in the catalogue and the logic relation between the specified field data and the catalogue to the server according to the address information, and fills the address of the server into the specified field.
In summary, the embodiment includes establishing an effective connection with a server, acquiring required server data, implementing bidirectional transmission and interaction of the data, and the like, and provides an accurate and reliable basis for communication and data processing between hardware equipment and the server; the hardware equipment can be ensured to normally communicate and exchange data with the server, and accurate transmission and effective utilization of data are realized.
Example 11: on the basis of embodiment 9, the data parsing module provided in the embodiment of the present invention includes:
A server creation sub-module responsible for creating a TCP protocol receiving server using the web shortcut netty network frame instantiation server guide ServerBootstrap, setting up a port to 8000 a processor word processor CHILDHANDLER, wherein the processor instantiates and rewrites its initialization channel INITCHANNEL to its socket channel SocketChannel through channel initializer ChannelInitializer;
The parser setting submodule is responsible for acquiring a channel processing program chain pipeline and setting a parser serverDecoder to convert the original message data into a character string in a UTF-8 format;
The data conversion sub-module is responsible for setting an encoder serverEncoder to convert message data into character strings in UTF-8 format, setting a network data frame size to limit the size of a frame aggregator frame-aggregator data packet not to exceed 10M, setting a timeout disconnection time of 60 minutes, and setting a custom data processor HJ212Handler.
The working principle and beneficial effects of the technical scheme are as follows: the server creation sub-module of this embodiment creates a TCP protocol receiving server using the web shortcut netty network frame instantiation server guide ServerBootstrap, sets up a processor word processor CHILDHANDLER for 8000, wherein the processor instantiates and rewrites its initialization channel INITCHANNEL for its socket channel SocketChannel through channel initializer ChannelInitializer; the parser setting sub-module obtains a channel processing program chain pipeline and sets a parser serverDecoder to convert the original message data into a character string in UTF-8 format; the data conversion submodule sets an encoder serverEncoder to convert the message data into character strings in UTF-8 format, sets a network data frame size to limit the size of a frame aggregator frame-aggregator data packet not to exceed 10M, sets a timeout disconnection time of 60 minutes, and sets a custom data processor HJ212Handler. The scheme realizes a receiving server based on the TCP protocol and converts the received original data stream into readable HJ212 protocol data. The specific meaning is as follows: implementing a TCP protocol receiving server: by using ServerBootstrap of the Netty framework, a receiving server of a TCP protocol can be rapidly realized; the server may monitor the designated port, receive a connection request from the client, and process the received data. Decoder and encoder settings: by arranging a decoder (serverDecoder) and an encoder (serverEncoder), the original TCP data stream can be converted into a readable character string in UTF-8 format, and the character string can be converted into the TCP data stream; the decoder and encoder function as data format conversions so that the server can parse and process the received data. Setting of a frame aggregator: by setting a frame aggregator (frame-aggregator), the size of the data packet can be limited, and memory overflow or performance problem caused by oversized data packet can be prevented; the frame aggregator aggregates the data frames transmitted in segments into complete messages, which is convenient for subsequent processing and analysis. Timeout off time setting: by setting the overtime disconnection time, the connection can be automatically disconnected when no data is transmitted in a certain time, so that resources are released and the reliability and stability of the system are improved. Custom data processor: by setting a custom data processor (HJ 212 Handler), specific business logic processing can be performed on the received data. The received data can be analyzed and processed according to the specification of the HJ212 protocol to perform corresponding business logic operation.
In summary, the embodiment realizes a readable receiving server of HJ212 protocol data, and by reasonably setting components such as a decoder, an encoder, a frame aggregator, etc., analysis, conversion and processing of TCP data streams can be realized, so as to improve reliability, stability and readability of the system.
Example 12: on the basis of embodiment 9, the data storage module provided in the embodiment of the present invention includes:
The table structure creation sub-module is responsible for selecting a structural query language SQL SERVER relational database system and configuring the database system; connecting to a database system using a database management tool or command line tool and creating a new database; designing and creating a corresponding table structure according to data requirements, and defining fields and relations;
the connection object sub-module is responsible for downloading and installing a corresponding database driver according to the selected programming language, wherein the database driver comprises an API (application program interface) for connecting a database, executing SQL (structured query language) sentences and other functions; creating a database connection object by using an API provided by a driver, and establishing connection with the database according to the connection information of the database;
The storage execution sub-module is responsible for executing SQL sentences by using an API provided by a driver after establishing database connection, and storing data into a database or retrieving data from the database; storing data using the collection and mapping it to fields in a table structure of the database; the collection contains a list or dictionary.
The working principle and beneficial effects of the technical scheme are as follows: the table structure creation submodule of the embodiment selects a structural query language SQL SERVER relational database system and configures the database system; connecting to a database system using a database management tool or command line tool and creating a new database; designing and creating a corresponding table structure according to data requirements, and defining fields and relations; the connection object submodule downloads and installs a corresponding database driver according to the selected programming language, wherein the database driver comprises an API (application program interface) for connecting a database and executing SQL (structured query language) sentences and other functions; creating a database connection object by using an API provided by a driver, and establishing connection with the database according to the connection information of the database; after the database connection is established, the storage execution submodule executes SQL sentences by using an API provided by a driver, and stores data into the database or retrieves data from the database; storing data using the collection and mapping it to fields in a table structure of the database; the collection contains a list or dictionary. The scheme establishes a complete database system, realizes the connection with hardware equipment by using SQL SERVER relational database system and corresponding driver, and manages the database by database management tool or command line tool. Specifically, data storage and management: by configuring and using SQL SERVER database systems, large amounts of structured data can be efficiently stored and managed; the table structure and field definitions of the database may be designed according to data requirements to meet the organization and storage requirements of the data. Data access and operation: by using the APIs provided by the database driver, a connection with the database can be established and SQL statements can be executed to store and retrieve data; the application program can conveniently access and operate the data in the database, and the operations of adding, deleting, modifying, checking and the like on the data are realized. Data consistency and security: the relational database system provides a mechanism for transaction processing and data integrity, and ensures consistency and reliability of data; in addition, SQL SERVER provide security functions, such as user authentication and rights management, to protect the data in the database from unauthorized access and modification. Data analysis and reporting: SQL SERVER provide functions for analysis services and reporting services, which enable data analysis and report generation; through the functions, the user can extract data from the database, perform operations such as data analysis and visual report generation, and the like, and help to make better decisions.
In summary, the embodiment establishes a reliable and efficient database system, realizes data storage, access, management and analysis, and provides powerful data support and decision basis for application programs and services.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (9)

1. The analytic method of the Internet of things for ecological environment monitoring is characterized by comprising the following steps of:
setting a data reporting address of the hardware equipment as an address of a reachable server;
analyzing the protocol data of the HJ212 based on the TCP protocol into readable character strings, and converting the analyzed readable character strings into json identification;
storing the data in a database;
A process for parsing protocol data of the HJ212 based on the TCP protocol into readable strings, comprising the steps of:
Creating a TCP protocol receiving server by using the network shortcut network frame instantiation server, setting a port to 8000, and setting a processor word processing program, wherein the processor instantiates and rewrites an initialization channel of the processor to a socket channel of the processor through a channel initializer;
And acquiring a channel processing program chain and setting a parser to convert the original message data into a character string in the UTF-8 format.
2. The method for analyzing the internet of things for ecological environment monitoring according to claim 1, wherein an encoder is arranged to convert message data into character strings in UTF-8 format, the size of a network data frame is set to limit the size of a frame aggregator data packet not to exceed 10M, a timeout disconnection time is set to 60 minutes, and a custom data processor HJ212Handler is set.
3. The method for resolving an internet of things for ecological environment monitoring according to claim 1, wherein the construction process of the resolver comprises the following steps:
Defining a common data reception class;
Dividing each group of data by a division number, dividing the data into character string arrays according to the division number, and carrying out cyclic analysis on the divided character string arrays; dividing the character string of the current cycle according to the comma, and dividing the divided character string according to the "=" equal sign to obtain a group of data;
Judging the attribute codes of the group of data, -Avg being average, -Max being maximum, -Min being minimum, -fixing the end of Flag to a data state; and setting the data into monitoring item data classes according to rules, wherein each group of monitoring item data classes contains one circulation item of comma, namely one monitoring item data class instance, and converting the received primary message to obtain a father-son structure containing a plurality of monitoring data classes under the common data class.
4. The method for analyzing the internet of things for monitoring the ecological environment according to claim 3, wherein the definition of the public data receiving class comprises attribute request codes QN, system codes ST, command codes CN, access passwords PW, site identifiers MN, response identifiers Flag, acquisition time DataTime and instruction parameters CP.
5. The method for resolving an internet of things for ecological environment monitoring according to claim 3, wherein the definition of the common data receiving class comprises the steps of:
the common data receiving attribute is consistent with the common part of the received data, and the end of the data is a fixed & +.4-bit check code;
Cutting off the 6-bit character string at the end, and ending the process of adding the instruction parameter with the & &; ".
6. The method for analyzing the internet of things for ecological environment monitoring according to claim 2, wherein the process of circularly analyzing the segmented character string array comprises the following steps:
In the circulation, whether the inside contains a comma or not is judged, and for the comma which does not contain the comma, the comma is directly divided according to an 'equal sign', wherein the front of the equal sign is an attribute code, and the rear of the equal sign is an attribute value;
Firstly, matching attribute codes according to public attributes, and setting values into public data receiving classes if the attribute codes are matched;
a monitoring item data class is defined.
7. The method for analyzing the internet of things for monitoring the ecological environment according to claim 6, wherein attribute codes are matched according to common attributes, and for comma-containing analysis data, specific monitoring items are found by using middle-transversal line to link attribute types and data values thereof and are separated by using equal signs.
8. The method for analyzing the internet of things for monitoring the ecological environment according to claim 6, wherein the monitoring item data class is defined and comprises a monitoring item code, a monitoring value, a monitoring value type and a monitoring item status.
9. An analytic system of thing networking of ecological environment monitoring, characterized by comprising:
the hardware device configuration module is responsible for setting the data reporting address of the hardware device as the address of the reachable server;
the data analysis module is in charge of analyzing the protocol data of the HJ212 based on the TCP protocol into readable character strings and converting the analyzed readable character strings into json identification;
The data storage module is in charge of storing data into the database;
A data parsing module comprising:
The server creation submodule is responsible for guiding and creating a TCP protocol receiving server by utilizing the network shortcut network frame instantiation server, setting a port to 8000 and setting a processor word processing program, wherein the processor instantiates and rewrites an initialization channel of the processor to a socket channel of the processor through the channel initializer;
The parser setting submodule is responsible for acquiring a channel processing program chain and setting the parser to convert the original message data into a character string in a UTF-8 format;
The data conversion sub-module is responsible for setting an encoder to convert message data into character strings in UTF-8 format, setting the size of a network data frame to limit the size of a data packet of a frame aggregator to be not more than 10M, setting timeout disconnection time to be 60 minutes, and setting a custom data processor.
CN202410398479.2A 2024-04-03 2024-04-03 Internet of things analysis method and system for ecological environment monitoring Active CN117997927B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410398479.2A CN117997927B (en) 2024-04-03 2024-04-03 Internet of things analysis method and system for ecological environment monitoring

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410398479.2A CN117997927B (en) 2024-04-03 2024-04-03 Internet of things analysis method and system for ecological environment monitoring

Publications (2)

Publication Number Publication Date
CN117997927A true CN117997927A (en) 2024-05-07
CN117997927B CN117997927B (en) 2024-07-05

Family

ID=90891413

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410398479.2A Active CN117997927B (en) 2024-04-03 2024-04-03 Internet of things analysis method and system for ecological environment monitoring

Country Status (1)

Country Link
CN (1) CN117997927B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016054992A1 (en) * 2014-10-10 2016-04-14 中兴通讯股份有限公司 Network data collection system and method
US20170099353A1 (en) * 2015-10-05 2017-04-06 Microsoft Technology Licensing, Llc Design and Systems Architecture for Internet of Things
CN110445762A (en) * 2019-07-10 2019-11-12 湖北省协诚交通环保有限公司 Intelligent environment protection monitoring management system in highway network based on Internet of Things
CN111887806A (en) * 2019-05-06 2020-11-06 上海交通大学 Guarding monitoring system based on intelligent bracelet and Internet of things
US11036497B1 (en) * 2018-10-24 2021-06-15 Cerner Innovation, Inc. Code assessment for quality control of an object relational mapper and correction of problematic cast functions
CN114143171A (en) * 2021-11-30 2022-03-04 中国电信集团系统集成有限责任公司 Alarm root cause positioning method and system based on TR069 protocol
CN117761255A (en) * 2023-12-21 2024-03-26 杭州老板电器股份有限公司 Pollution monitoring method, system, device and program product

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016054992A1 (en) * 2014-10-10 2016-04-14 中兴通讯股份有限公司 Network data collection system and method
US20170099353A1 (en) * 2015-10-05 2017-04-06 Microsoft Technology Licensing, Llc Design and Systems Architecture for Internet of Things
US11036497B1 (en) * 2018-10-24 2021-06-15 Cerner Innovation, Inc. Code assessment for quality control of an object relational mapper and correction of problematic cast functions
CN111887806A (en) * 2019-05-06 2020-11-06 上海交通大学 Guarding monitoring system based on intelligent bracelet and Internet of things
CN110445762A (en) * 2019-07-10 2019-11-12 湖北省协诚交通环保有限公司 Intelligent environment protection monitoring management system in highway network based on Internet of Things
CN114143171A (en) * 2021-11-30 2022-03-04 中国电信集团系统集成有限责任公司 Alarm root cause positioning method and system based on TR069 protocol
CN117761255A (en) * 2023-12-21 2024-03-26 杭州老板电器股份有限公司 Pollution monitoring method, system, device and program product

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
事情判断忘记: "spring boot结合Netty对接环保协议HJ212-2017数据接收_netty hj212-CSDN博客", CSDN, 21 June 2023 (2023-06-21), pages 1 - 13 *
刘祥宏等: "基于Netty+ActiveMQ 的农村生活污水处理设施监测数据通信管理平台设计", 数字通信世界, 31 July 2019 (2019-07-31), pages 1 - 4 *
宋凯: "面向环境保护的智慧物联网关及平台设计与实现_宋凯", 中国优秀硕士学位论文全文数据库(电子期刊), 15 May 2019 (2019-05-15), pages 2 - 6 *
工控马哝: "Python 解析HJ212-2017并输出Modbus-TCP_hj212协议转换modbus", CSDN, 19 April 2023 (2023-04-19), pages 1 - 17 *

Also Published As

Publication number Publication date
CN117997927B (en) 2024-07-05

Similar Documents

Publication Publication Date Title
CN111930635B (en) Swagger-based rapid automatic testing method and system
Ahmad et al. Model-based testing as a service for iot platforms
US20180012145A1 (en) Machine learning based analytics platform
CN108667807A (en) A kind of protocol self-adapting method and system based on monitoring cloud platform and gateway
CN106355319A (en) Safety risk assessment system and method
CN106597947A (en) Substation equipment test method and system, server and tester
CN107957940B (en) Test log processing method, system and terminal
CN110502538B (en) Method, system, equipment and storage medium for portrait tag generation logic mapping
CN115034638A (en) Digital twinning processing method and digital twinning system
Graciano Neto et al. ASAS: an approach to support simulation of smart systems
CN110381101A (en) API gateway control system, control method, equipment and medium
CN112306884A (en) Program test control and execution method and corresponding device, equipment and medium
CN114281903A (en) Digital twin construction method, device, equipment and storage medium
CN110825412A (en) Controller program flashing system and method based on LabVIEW
CN115794106A (en) Method and system for analyzing configuration of binary protocol data of rail transit
CN112019403B (en) Cross-platform automatic mining method and system for message protocol state machine of Internet of things
CN117997927B (en) Internet of things analysis method and system for ecological environment monitoring
CN116346660A (en) Data processing method, device, equipment and medium based on dependent replacement service
Jones et al. UncertWeb processing service: making models easier to access on the web
CN111711695A (en) Distributed equipment management system based on cloud platform
Figura et al. Iris: Efficient visualization, data analysis and experiment management for wireless sensor networks
CN113315769A (en) Industrial control asset information collection method and device
CN113949438B (en) Unmanned aerial vehicle communication method, device, equipment and storage medium
CN117573480B (en) Data security monitoring method and device based on artificial intelligence
KR20200081657A (en) Platform of Smart Factory

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant