Intelligent gateway data acquisition system and method based on Json data sheet
Technical Field
The invention relates to the technical field of data information acquisition, in particular to an intelligent gateway data acquisition system and method based on a Json data sheet.
Background
In the construction of urban major projects, sensor monitoring technology based on the internet of things is increasingly widely used. Such as: various micro-miniature pull crack sensors, vibrating wire sensors, etc. In current engineering practice, when data acquisition is performed by using a sensor monitoring technology, data acquisition and preprocessing are required to be performed by means of specially customized professional acquisition equipment and a customized system. In the mode, when large-scale real-time intelligent monitoring work is carried out on a super large project, the number of input acquisition equipment and professional systems is huge; and the systems of various sensor manufacturers are incompatible, the instruction protocol is not universal, the setting and changing mode is complex when the network is accessed again after the sensors are replaced, the acquisition mode is single, and the efficiency is low.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides an intelligent gateway data acquisition system and method based on a Json data sheet, and aims to solve the technical problems that when an internet of things sensor is used for data acquisition, the set change mode is complex, the acquisition mode is single, and the efficiency is low when the sensor is replaced and the network is accessed again in the prior art.
The technical scheme adopted by the invention is as follows:
in a first aspect, the invention provides an intelligent gateway data acquisition system based on a Json data sheet, which comprises a task control module, an instruction control module, a data acquisition module, a data calculation module, a data storage module and a data transmission module;
the task control module is used for constructing an independent data acquisition task according to the equipment communication channel of the intelligent gateway and configuring and managing task execution on each data communication channel;
the command control module is used for carrying out standardized encapsulation on a control command of the sensor according to a sensor command rule set configured by design and then coding and sending the control command; the device is also used for carrying out self-adaptive decoding on the data collected and returned by the sensor and extracting corresponding data information;
the data acquisition module comprises a data initial learning module and a periodic acquisition module; the data initial learning module is used for acquiring initial configuration data of the sensor, and the periodic acquisition module is used for periodically acquiring data of the data acquisition channel according to data acquisition rule configuration;
the data calculation module performs parametric calculation and data quality calibration on the acquired sensor data according to the data calculation rule set;
the data storage module is used for converting the acquired sensor data into a Json data sequence according to a data storage rule set and then storing the Json data sequence in a local database;
and the data transmission module converts the Json data sequence stored in the data storage module into a Json data packet and an XML file packet respectively according to the data storage rule set and uploads the Json data packet and the XML file packet to the big data platform.
In a second aspect, the present invention further provides a data acquisition method for an intelligent gateway data acquisition system based on a Json data slice, which is characterized by comprising the following steps:
s1, establishing a data acquisition task through a task control module, and configuring and scheduling task parameters of accessed multi-type sensing equipment according to a communication channel;
s2, carrying out standardized packaging on a sensor control instruction according to a designed and configured sensor instruction rule set through an instruction control module, then coding and sending the sensor control instruction, and acquiring initial data of a sensor;
s3, using a periodic acquisition module in the data acquisition module to perform periodic data acquisition on the data acquisition channel;
s4, carrying out self-adaptive decoding on the data acquired and returned by the sensor through the instruction control module;
s5, carrying out data parameterization calculation and data quality calibration through a data calculation module;
and S6, converting the data subjected to quality calibration into a Json data sequence through a data storage module according to a data storage rule set, storing the Json data sequence in a local database, and uploading the Json data sequence to a big data platform through a data transmission module.
Further, the task control module specifically works according to the following steps:
managing a data acquisition task according to an equipment communication channel of the intelligent gateway;
configuring task parameters of data acquisition of a current communication channel, wherein the parameters comprise an acquisition method, initial time, sampling interval, a cooperative channel and a cooperative mode;
configuring a sensor of a current communication channel, and setting a sampling limit difference of the sensor;
and maintaining the data acquisition channel according to the acquisition task configuration, wherein the maintenance comprises starting, stopping and resetting.
Further, the instruction control module specifically works according to the following steps:
preloading a sensor instruction rule set file, and organizing the rule set file in a Json format;
searching matched sensor types and loading corresponding instruction sets according to task scheduling parameters of the data acquisition module;
capturing corresponding standard instruction set configuration according to the currently executed instruction name;
extracting coding information according to the currently matched instruction configuration, carrying out instruction encapsulation, and sending the coding information to a sensor under a corresponding communication channel;
monitoring data return information of a current communication channel, and stopping data reception when a data string meeting a stop identifier is received;
according to the decoding and data extraction rule configured by the current instruction, self-decoding of the data string is carried out; loading corresponding calculation rules and calculation models according to the matched sensor types, and performing regularized calculation on data by using a data calculation module;
and matching the storage identifiers of the data blocks by combining the data storage rule set according to the data identifier information configured by the current instruction, and packaging into a Json data sheet.
Further, the set of sensor instruction rules is formed as follows:
the single equipment control instruction comprises an instruction name, a start character, an instruction code, an instruction decode, an instruction sort, an equipment address, an instruction state, a data extraction, a data bit identification and a calculation model;
the control and access of the sensor are formed by one to a plurality of standard instructions, and the drive control and data acquisition of the sensor are realized.
Further, the data initial learning module specifically works according to the following steps:
under the selected communication channel, adding a new sensor node, and loading a sensor instruction rule set corresponding to the node;
calling a control instruction to check the working state of the sensing equipment, and calling a measurement instruction to acquire initial configuration data and initial observation data of the sensor;
storing the obtained initial configuration and observation data in a local database;
further, the periodic acquisition module specifically works according to the following steps:
starting a task timer, loading parameter configuration, sensor configuration and acquisition rule configuration of a matching channel, and executing data acquisition work of a current period; the data acquisition working mode comprises polling data acquisition and grouped data acquisition;
and after the data acquisition of the current period is finished, the data quality is checked and corrected by the data calculation module, and after the data is qualified, the local data is stored and uploaded to the big data platform.
Furthermore, the periodic acquisition module arranges the acquisition rules of the sensors and cooperatively controls data acquisition; the cooperative control data acquisition comprises the cooperative control of the sensors across the channels and the cooperative monitoring of the multi-type sensing equipment under the same channel.
Further, the data storage rule set comprises a data name, a data tag, a data type, a data index and a data association; the data storage rule set is used for changing configuration of different types of sensors during data storage.
According to the technical scheme, the beneficial technical effects of the invention are as follows:
1. the method comprises the steps of designing standard instruction rule sets of different types of sensors, realizing flow processing of instructions in the processes of packaging, sending, encoding, decoding and storing, realizing customized data acquisition and analysis work of a single sensing device through serial configuration of an instruction execution process, and finally realizing simultaneous online data acquisition of the different types of sensors by taking a gateway channel as a working unit, thereby effectively improving the data acquisition efficiency.
2. The method comprises the steps of designing a sensor instruction rule set, wherein different types of sensors correspond to a plurality of instruction sequence sets, the sets corresponding to each type of sensor are different, and the customized design of an instruction system is carried out on different engineering projects, so that the situation that the existing working parameters are not changed is ensured, the situation that the different types of sensors are accessed in a dynamic capacity expansion mode under the situation that the intelligent gateway setting is not adjusted is realized by changing the sets corresponding to the plurality of instruction sequences of the sensors.
3. By polling data acquisition, grouping data acquisition and regularized acquisition configuration, the data acquisition mode is diversified.
4. Through the arrangement of the acquisition rules of a plurality of sensing devices, the cooperative control data acquisition is realized, the data acquisition time can be saved, errors are reduced, and the data acquisition efficiency is further improved.
5. The data storage rule set is used for changing configuration of different types of sensors during data storage. The sensor instruction rule set, the data storage rule set and the data calculation rule are matched for use, so that the sensor access capability of the intelligent gateway is greatly expanded. The processes of data acquisition, storage, calculation, transmission and the like are decoupled through the design of a rule set, dynamic matching loading is carried out when needed, and the compatibility of gateway equipment is improved.
Drawings
In order to more clearly illustrate the detailed description of the invention or the technical solutions in the prior art, the drawings that are needed in the detailed description of the invention or the prior art will be briefly described below. Throughout the drawings, like elements or portions are generally identified by like reference numerals. In the drawings, elements or portions are not necessarily drawn to scale.
FIG. 1 is a flow chart of the system operation of the present invention.
FIG. 2 is a system architecture diagram of the present invention.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings. The following examples are only for illustrating the technical solutions of the present invention more clearly, and therefore are only examples, and the protection scope of the present invention is not limited thereby.
It is to be noted that, unless otherwise specified, technical or scientific terms used herein shall have the ordinary meaning as understood by those skilled in the art to which the invention pertains.
Example 1
As shown in fig. 1, the invention provides an intelligent gateway data acquisition system based on a Json data sheet, which comprises a task control module, an instruction control module, a data acquisition module, a data calculation module, a data storage module and a data transmission module;
the task control module is used for constructing an independent data acquisition task according to the equipment communication channel of the intelligent gateway and configuring and managing task execution on each data communication channel;
the command control module is used for carrying out standardized encapsulation on a control command of the sensor according to a sensor command rule set configured by design and then coding and sending the control command; the device is also used for carrying out self-adaptive decoding on the data collected and returned by the sensor and extracting corresponding data information;
the data acquisition module comprises a data initial learning module and a periodic acquisition module; the data initial learning module is used for acquiring initial configuration data of the sensor, and the periodic acquisition module is used for periodically acquiring data of the data acquisition channel according to data acquisition rule configuration;
the data calculation module performs parametric calculation and data quality calibration on the acquired sensor data according to the data calculation rule set;
the data storage module is used for converting the acquired sensor data into a Json data sequence according to a data storage rule set and then storing the Json data sequence in a local database;
and the data transmission module converts the Json data sequence stored in the data storage module into a Json data packet and an XML file packet respectively according to the data storage rule set and uploads the Json data packet and the XML file packet to the big data platform.
The working principle of example 1 is explained in detail below:
the technical scheme of the embodiment is a software system loaded and operated on an intelligent gateway. In this embodiment, the data acquisition of the sensor of the internet of things is implemented by the intelligent gateway. The intelligent gateway carries out networking connection on various types of sensors and the remote server in a wired or wireless mode; and then according to the communication protocols of different sensors, software connection is carried out by using interfaces allowed by the protocols, so that control, data acquisition and data transmission of various sensors are realized.
For controlling the sensor to perform data acquisition, the following steps are performed in this embodiment:
1. the task control module establishes a data acquisition task, and performs task execution configuration and task scheduling on the data acquisition task
After the software system of this embodiment is loaded on the intelligent gateway, the task control module starts to work first. The task control module is used for newly adding a data acquisition task according to an equipment communication channel of the intelligent gateway; then configuring data acquisition task parameters, wherein the parameters comprise an acquisition method, initial time, sampling interval, a cooperative channel and a cooperative mode; and then configuring the sensor of the current communication channel, and setting the sampling limit difference of the sensor.
In this embodiment, the gateway communication channel types include RS232, RS485, Wifi, bluetooth, LoRa, network cable, optical fiber, and the like. And in the process of controlling the sensor to collect data, the task control module also carries out maintenance according to the collection task parameters, and the maintenance comprises starting, stopping and resetting of the data collection task.
2. Through the instruction control module, the sensor measurement control instruction is subjected to standardized packaging according to the sensor instruction rule set of design configuration and then is coded and sent, and initial configuration data of the sensor is acquired
Firstly, a sensor instruction rule set file is preloaded through a sensor instruction control module; under the condition of selecting a gateway communication channel, searching matched sensor types according to task scheduling parameters of a data acquisition module, adding sensor nodes, and loading a sensor instruction rule set of the nodes. The sensor instruction rule set includes a plurality of instruction sequences including instruction names, starters, instruction encodings, instruction decodings, instruction classifications, device addresses, instruction states, data extractions, data bit identifications, computational models, and the like. The same type of sensor corresponds to one or more of a plurality of instruction sequences and executes dynamic instruction logic, including feedback instructions and non-feedback instructions. Different types of sensors correspond to a plurality of sets of command sequences, and the sets corresponding to each type of sensor are different. Under the condition that other working parameters are not changed, the dynamic switching of the sensors can be realized by changing the set of a plurality of instruction sequences corresponding to the sensors without adjusting the setting of the intelligent gateway system. In this way, by changing the set of the plurality of instruction sequences, dynamic access to different types of sensors can be realized without adjusting the setting of the intelligent gateway. The integrated application of the instruction rule set comprises ASCII, hexadecimal and other different types of instruction encoding and decoding, and the adaptability is stronger. The acquisition control of different types of sensors can be realized by changing the sensor instruction rule set.
Capturing corresponding standard instruction set configuration according to the currently executed instruction name; and then, carrying out instruction encapsulation according to the instruction coding information and sending the instruction to the sensor under the corresponding gateway communication channel. According to the rules, when the novel sensing equipment is accessed to the gateway, data acquisition can be carried out by editing and configuring the instruction rule set file under the condition that the working parameters of the existing intelligent gateway are not changed.
And then, calling a measurement instruction below the instruction set by using a data initial learning module in the data acquisition module to acquire initial data of the sensor, and storing the acquired initial configuration data in a local database. And simultaneously, testing other instructions of the current type of sensor, and checking the working state of the sensor.
In this embodiment, the acquired initial data includes initial angle data, initial coordinate data, initial frequency data, initial deformation data, initial environment data, and the like.
3. Using a periodic acquisition module in the data acquisition module to perform periodic data acquisition on the data acquisition channel
Firstly, according to a data acquisition task, starting a task timer and executing periodic data acquisition; then loading the parameter configuration, the sensor configuration and the acquisition rule configuration of the gateway communication channel; and performing current regularized data acquisition work, including polling data acquisition and grouping data acquisition. After the sensor is initially configured, the data acquisition module can alternately perform initial configuration data acquisition work and periodic acquisition work.
For polling data acquisition, the acquisition sequence numbers of all sensors under a channel are taken as the basis to carry out sequential acquisition. And calling a sensor instruction rule module in the acquisition process to drive the sensor to acquire data.
For grouped data acquisition, a group is a batch by taking monitoring point groups as reference. And the current intra-group acquisition carries out data acquisition by taking the serial number of the monitoring point as a basis.
And for the configured data acquisition, dynamically observing the sensor according to the acquisition sequence of the configuration file.
In the process of data acquisition, the periodic acquisition module monitors data return information of a gateway communication channel, and stops data reception when receiving a data string meeting the stop identifier.
In this embodiment, the collected data includes angle data, coordinate data, frequency data, deformation data, environment data, and the like.
4. Self-adaptive decoding is carried out on data collected and returned by a sensor through an instruction control module
And using a sensor instruction control module to perform self-adaptive decoding on the data acquired and returned by the sensor according to the decoding configuration of the instruction.
5. Data parameterization calculation and data quality calibration through data calculation module
And (4) performing data quality checking after the acquisition is finished, storing the data into a database after the data is qualified, and performing data repairing and testing if the data is not qualified. And performing parametric calculation of data according to a pre-configuration data calculation rule of the matched sensor by using a regular expression and a formula expression through a data calculation module. Data quality checks include duplicate value checks, missing value checks, outlier checks, etc. on the data.
6. Converting the data subjected to quality calibration into a Json data sequence through a data storage module according to a data storage rule set, storing the Json data sequence in a local database, and uploading the Json data sequence to a big data platform through a data transmission module
Firstly, matching a storage identifier of a data string with a rule set through a data storage module according to the storage rule configuration of an instruction; preloading a data model rule set, and creating and updating a Sqlite database table; matching a corresponding data column set according to the name of the data model; carrying out fusion matching on the shared and exchanged Json data source and the data column to generate an SQL operation statement of the Sqlite database; then, inquiring, editing, deleting and the like are carried out to obtain a Json data sheet; and finally storing the Json data sheet in a local database. In this embodiment, the local database is loaded in the intelligent gateway.
The storage definition of one data item comprises a data name, a data identifier, a data type, a data index, a data association and the like, one type of sensing data comprises one or more data items, and the storage rule set of one intelligent gateway acquisition system comprises one or more storage definitions of the sensing data. After the data acquisition module receives the original data of the sensor, transcoding the data sequence through the data storage module, and storing the data sequence to a local database system in real time. After the network online interface is configured, the data transmission module can perform data packaging and encapsulation through a data sequence, and then upload the data to a big data platform, and can also serve as a standardized data sharing exchange interface to provide services. Data storage for different types of sensors is achieved by storing changes to the rule set.
Json is a data exchange format. The data is stored and represented by adopting a text format completely independent of a programming language, the hierarchy is simple and clear, the reading and the writing of programmers are easy, the machine analysis and the generation are easy, and the network transmission efficiency can be effectively improved. In this embodiment, the sensor instruction rule set, the data acquisition rule set, the data calculation rule set, and the data storage rule set are all organized in the form of a Json data sheet.
Similarly, when the Json data sheet is uploaded to a big data platform, a data model rule file is loaded through a data transmission module; and then, a database storage module is utilized to inquire corresponding database table results, the database table results are respectively converted into a Json data packet and an XML file packet according to a data model, and the Json data packet and the XML file packet are reported to a big data platform.
According to the technical scheme in the embodiment 1, the steps of packaging, sending, coding, decoding and storing the instructions are standardized by designing rule sets such as instructions, calculation and storage of different sensors, customized data acquisition and analysis work of a single sensing device is realized by executing sequential coding of the instructions, and finally, the simultaneous online data acquisition of different sensors is realized by taking a gateway channel as a working unit; by polling data acquisition, multi-test-loop data acquisition and configuration data acquisition, the data acquisition mode is diversified, and the data acquisition efficiency is effectively improved. Through the matching use of the rule sets, the sensor access capability of the intelligent gateway is greatly expanded.
Example 2
The invention also provides a data acquisition method of the intelligent gateway data acquisition system based on the Json data sheet, which is characterized by comprising the following steps:
s1, establishing a data acquisition task through a task control module, and configuring and scheduling task parameters of accessed multi-type sensing equipment according to a communication channel;
s2, carrying out standardized packaging on the sensor control instruction through an instruction module, then coding and sending the sensor control instruction, and acquiring initial data of the sensor;
s3, using a periodic acquisition module in the data acquisition module to perform periodic data acquisition on the data acquisition channel;
s4, carrying out self-adaptive decoding on data acquired and returned by the sensor through a sensor instruction module;
s5, carrying out data parameterization calculation and data quality calibration through a data calculation module;
and S6, converting the data subjected to quality calibration into a Json data sequence through a data storage module according to a data storage rule set, storing the Json data sequence in a local database, and uploading the Json data sequence to a big data platform through a data transmission module.
Example 3
In the actual process of data acquisition, according to the needs of actual conditions, the situation that a plurality of sensors are required to acquire data simultaneously sometimes occurs. In order to solve the technical problem, the following technical scheme is adopted for further optimization on the basis of the embodiment 1:
arranging the acquisition rules of a plurality of sensors through a periodic acquisition module to realize cooperative control data acquisition; the cooperative control data acquisition comprises the cooperative control of the sensors across the channels and the cooperative monitoring of the multi-type sensing equipment under the same channel.
The working principle of example 3 is explained in detail below:
1. sensor coordinated control across channels
For example, in the working process of the measurement robot, a protection door switch and an environmental sensor of the protection device need to be controlled to acquire environmental parameters, in this mode, a measurement robot channel needs to be used as a main channel, a protection door device needs to be used as a second channel, and an environmental sensor needs to be used as a third channel.
2. Multi-type sensing device cooperative monitoring
And in the acquisition process, when the data of a certain sensing device is found to be abnormal and is out of the range of the early warning control value, immediately triggering the cooperative encrypted data observation of other sensing devices in the same group, carrying out quality analysis and result study and judgment on the data of the current encrypted observation group, and evaluating the accuracy of the current sensing data exceeding the early warning threshold value.
Through the arrangement of the acquisition rules of a plurality of sensing devices, the cooperative control data acquisition is realized, the data acquisition time can be saved, errors are reduced, and the data acquisition efficiency is further improved.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the present invention, and they should be construed as being included in the following claims and description.