Data acquisition method and device based on Internet of Things gateway, and computer equipment
By obtaining configuration information in the Internet of Things gateway, determining the communication connection of the PLC device, and collecting data in groups, the problem of low data acquisition and uploading of PLC devices is solved, and efficient and accurate PLC data transmission is achieved.
Patent Information
- Application Number
- CN202510486108.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-06-24
AI Technical Summary
In the prior art, PLC devices lack IoT functions, resulting in low efficiency in PLC data acquisition and uploading, and need to configure targeted IoT gateways, making it difficult to achieve efficient data transmission.
Provide a data acquisition method based on the IoT gateway. By obtaining configuration information of the configuration module, including PLC communication configuration parameters and variable data points, the communication connection between the IoT gateway and the PLC device is determined, and data is collected in groups and finally uploaded to the Internet of Things platform.
It realizes efficient acquisition and transmission of PLC data, improves data acquisition efficiency, reduces communication costs, and ensures the accuracy and efficiency of data transmission.
Smart Images

Figure CN120201058A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of industrial automation control technology, and particularly to a data acquisition method, device, and computer equipment based on an Internet of Things gateway. Background Art
[0002] In the field of industrial automation control technology, it involves collecting PLC data and uploading it to an Internet of Things platform.
[0003] In related PLC data acquisition methods, since PLC devices do not have Internet of Things functions, it is necessary to use an Internet of Things gateway to achieve the acquisition and upload of PLC data; however, the requirements for data acquisition vary, and it is necessary to configure the Internet of Things gateway specifically, making it difficult to efficiently achieve the acquisition and transmission of PLC data. Summary of the Invention
[0004] Based on this, in view of the above technical problems, it is necessary to provide a data acquisition method, device, computer equipment, and computer-readable storage medium based on an Internet of Things gateway, which are used to configure the Internet of Things gateway adaptively, so as to efficiently achieve the acquisition and transmission process of PLC data.
[0005] In a first aspect, this application provides a data acquisition method based on an Internet of Things gateway, including: Obtaining configuration information from a configuration module, where the configuration module includes at least one of configuration software and a configuration web page for inputting configuration information, and the configuration information includes PLC communication configuration parameters and variable data points; Determining the communication connection between the Internet of Things gateway and a target PLC device according to the PLC communication configuration parameters, taking the matching variable data points as a group of variable data points, and respectively collecting the PLC data of the target PLC device according to each group of variable data points to obtain PLC data sets corresponding to each group of variable data points; Determining target PLC data to be uploaded in the PLC data sets corresponding to each group of variable data points, and uploading the target PLC data to the target Internet of Things platform according to the communication connection between the Internet of Things gateway and the target Internet of Things platform.
[0006] In a second aspect, this application also provides a data acquisition device based on an Internet of Things gateway, including: An obtaining module, configured to obtain configuration information from a configuration module, where the configuration module includes at least one of configuration software and a configuration web page for inputting configuration information, and the configuration information includes PLC communication configuration parameters and variable data points; The acquisition module is used to determine the communication connection between the IoT gateway and the target PLC device according to the PLC communication configuration parameters, take the matching variable data points as the same group of variable data points, and collect the PLC data of the target PLC device according to each group of variable data points to obtain the PLC data sets corresponding to each group of variable data points respectively; The upload module is used to determine the target PLC data to be uploaded in the PLC data sets corresponding to each group of variable data points respectively, and upload the target PLC data to the target IoT platform according to the communication connection between the IoT gateway and the target IoT platform.
[0007] In a third aspect, the present application further provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the above steps are implemented.
[0008] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above steps are implemented.
[0009] In the above data acquisition method, device, computer device and computer-readable storage medium based on the IoT gateway, in the above data acquisition method based on the IoT gateway, first, according to the configuration information from the configuration module, the IoT gateway can accurately obtain the PLC communication configuration parameters and variable data points, thereby ensuring the accuracy of subsequent communication connections and data acquisitions. At the same time, different configuration methods of the configuration software and the configuration web page are supported, making the configuration method more flexible; furthermore, according to the PLC communication configuration parameters, the communication connection between the IoT gateway and the target PLC device is accurately determined, and then the matching variable data points are used as the same group of variable data points to group and collect the PLC data of the target PLC device, thereby optimizing the organization method of data acquisition, improving the acquisition efficiency and reducing the communication cost; furthermore, the target PLC data to be uploaded is screened from the PLC data sets corresponding to each group of variable data points respectively and uploaded to the target IoT platform, thereby ensuring the accuracy of data transmission, reducing redundant data and improving the upload efficiency; based on this, through the standardized and adaptable configuration of the IoT gateway at the data acquisition level and the data transmission level, an efficient and stable process of PLC data acquisition and transmission is realized. Description of the Drawings
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0011] Figure 1 It is a schematic flowchart of a data acquisition method based on an IoT gateway in an embodiment; Figure 2 It is a structural block diagram of a data acquisition device based on an IoT gateway in an embodiment. Detailed implementation manners
[0012] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0013] In one embodiment, as Figure 1 shown, a data acquisition method based on an IoT gateway is provided. In this embodiment, it is exemplified that the method is applied to a terminal. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method is applied to an IoT gateway and includes the following steps S101 to S103.
[0014] Step S101: Obtain configuration information from a configuration module. The configuration module includes at least one of a configuration software and a configuration web page for inputting configuration information. The configuration information includes PLC communication configuration parameters and variable data points.
[0015] Among them, the IoT gateway refers to a communication device used to connect a PLC device to an IoT platform, that is, to collect data of the PLC device and upload it to the IoT platform to realize the interconnection between industrial devices and the cloud; the PLC device (Programmable Logic Controller) refers to a digital industrial control device; the IoT platform refers to a server or cloud platform used to receive, store and manage the data uploaded by the IoT gateway.
[0016] Among them, the configuration information refers to a set of parameters used to guide the IoT gateway on how to perform data acquisition and communication. It includes PLC communication configuration parameters and variable data points; the PLC communication configuration parameters refer to the necessary parameters for establishing a communication connection between the IoT gateway and the PLC to ensure that the IoT gateway can correctly access the PLC device and read data according to the specified protocol, such as IP address, port number, device station number, communication protocol, baud rate, etc.; the variable data points refer to the specific variable addresses inside the PLC device that need to be collected, and are used to define the PLC registers or variable values that the IoT gateway needs to read. For example, a variable data point in the PLC device can represent a register (such as address 40001) for storing temperature sensor data.
[0017] Among them, the configuration module represents a configuration web page and / or configuration software for inputting configuration information; the configuration web page represents a remotely or locally accessible configuration interface developed based on Web technology, which is used to provide a user interaction interface in a browser, enabling users to input and manage the configuration information of the IoT gateway online without installing additional software; the configuration software represents an independent application specifically used to manage the configuration of the IoT gateway, which is used to provide richer configuration functions on a local computer, enabling users to input and manage the configuration information of the IoT gateway.
[0018] Exemplarily, the IoT gateway obtains configuration information from the configuration module. The configuration module includes a configuration web page and / or configuration software, and the functions of both are to provide necessary parameters to the IoT gateway, enabling the IoT gateway to accurately establish connections with the PLC device and the target IoT platform respectively, and collect and upload data as required. Among them, in the configuration mode based on the configuration web page, the specified Web configuration interface can be accessed through a browser to input configuration information, and then the configuration information is sent to the IoT gateway according to the data interaction between the Web configuration interface and the IoT gateway through the HTTP or HTTPS protocol; while in the configuration mode based on the configuration software, the configuration information can be input through a specified application installed on the computer, and then the configuration information is sent to the IoT gateway according to the data interaction between the computer and the IoT gateway through the local area network or wireless communication. After receiving the configuration information, the IoT gateway stores the configuration information in the local storage medium of the IoT gateway (such as Flash storage or database) to ensure that the configuration remains unchanged even after the device is powered off.
[0019] Optionally, after the IoT gateway receives the configuration information, it can parse and verify the configuration information. The verification process usually includes data format check and integrity verification. For example, it is confirmed whether the IP address conforms to the standard format, whether the port number is within the allowed range, whether the variable address conforms to the register rules of the PLC, etc.; if the configuration information passes the verification, the IoT gateway stores the configuration information in the local storage medium, and if the configuration information is incorrect or incomplete, the IoT gateway feeds back an error message to the user, prompting to re-enter or correct the configuration information.
[0020] Step S102, determine the communication connection between the IoT gateway and the target PLC device according to the PLC communication configuration parameters, regard the matching variable data points as the same set of variable data points, and collect the PLC data of the target PLC device according to each set of variable data points respectively, so as to obtain the PLC data set corresponding to each set of variable data points respectively.
[0021] Among them, the target PLC device represents a PLC device that has established a communication connection with the IoT gateway.
[0022] Among them, the PLC data represents the data read by the IoT gateway from the target PLC device and is used to record the current status of the internal variables of the target PLC device. For example, if the data of a certain temperature sensor is an integer value "2300", it can represent a temperature of 23.00 degrees Celsius.
[0023] Among them, the PLC data set represents a set of multiple PLC data obtained by grouping and collecting according to variable data points. For example, a certain PLC data set may contain PLC data read from multiple PLC registers of the same type.
[0024] Exemplarily, first, the IoT gateway determines the target PLC device to be connected based on the PLC communication configuration information, and then sends a handshake request to the target PLC device to confirm whether the target PLC device can respond normally; if the target PLC device correctly returns the response information, it means that the communication connection is successfully established, otherwise the IoT gateway will resend the handshake request until the connection is determined to be successful, or feedback the reason for the connection failure to the user. Exemplarily, since the variable data points of the target PLC device may be distributed in different storage areas, if read one by one without discrimination, it will cause excessive communication costs and affect the real-time performance of data collection; based on this, the method of grouping by the same type can be adopted, that is, the variable data points of adjacent or the same register type are grouped into one group, and the data collection is carried out in a batch reading manner; for example, if multiple variable data points are continuously stored in the same register block of the target PLC device, the IoT gateway can read the data of the entire register block at one time, and then parse the specific values of each variable data point locally, so as to reduce the interaction times with the target PLC device and improve the data collection efficiency.
[0025] Step S103, determine the target PLC data to be uploaded in the PLC data set corresponding to each group of variable data points, and upload the target PLC data to the target IoT platform according to the communication connection between the IoT gateway and the target IoT platform.
[0026] Among them, the target IoT platform represents the IoT platform that has established a communication connection with the IoT gateway.
[0027] Exemplarily, the IoT gateway screens out the target PLC data to be uploaded from the PLC data sets of each group of variable data points and uploads it to the target IoT platform, and the basis for data screening is usually defined by the configuration information. For example, all collected data can be selected for upload, or only the changed data can be uploaded; the communication protocol for data upload can adopt communication protocols such as MQTT, HTTP, WebSocket or CoAP, etc., to establish a communication connection between the IoT gateway and the target IoT platform based on the selected communication protocol, so as to push the target PLC data to the target IoT platform.
[0028] Optionally, after the data upload is completed, the IoT gateway can perform local storage or logging for data traceback or troubleshooting when needed; if the data upload fails due to network problems, the IoT gateway will adopt a data caching and retry mechanism to re-upload the data after the network is restored to ensure the integrity and reliability of the data.
[0029] In the above data acquisition method based on the IoT gateway, first, according to the configuration information from the configuration module, the IoT gateway can accurately obtain the PLC communication configuration parameters and variable data points, thus ensuring the accuracy of subsequent communication connections and data acquisition. At the same time, it supports different configuration methods of the configuration software and the configuration web page, making the configuration method more flexible; furthermore, according to the PLC communication configuration parameters, the communication connection between the IoT gateway and the target PLC device is accurately determined, and then the matching variable data points are used as a group of variable data points to group and collect the PLC data of the target PLC device, thereby optimizing the organization method of data acquisition, improving the acquisition efficiency and reducing the communication cost; furthermore, the target PLC data to be uploaded is screened from the PLC data sets corresponding to each group of variable data points and uploaded to the target IoT platform, thus ensuring the accuracy of data transmission, reducing redundant data and improving the upload efficiency; based on this, through the standardized and adaptable configuration of the IoT gateway at the data acquisition level and the data transmission level, an efficient and stable process of PLC data acquisition and transmission is realized.
[0030] In an exemplary embodiment, determining the communication connection between the IoT gateway and the target PLC device according to the PLC communication configuration parameters includes steps S201 to S203.
[0031] Step S201, parsing the PLC communication configuration parameters to obtain the communication address information and communication characteristic information of the target PLC device. The communication address information includes the IP address, port, and station number of the target PLC device, and the communication characteristic information includes the model, function category, and communication method of the target PLC device.
[0032] Among them, the communication address information represents the relevant parameters for uniquely identifying the target PLC device and establishing a communication connection, that is, for ensuring that the IoT gateway can correctly locate and access the target PLC device and perform data interaction in a set manner. For example, the IP address is used to identify the target PLC device located in the industrial network, enabling the IoT gateway to establish a connection with the target PLC device through communication protocols such as TCP and IP; the port is used to specify the communication interface of the target PLC device, and the IoT gateway needs to send and receive data through this port; the station number is used to distinguish different PLC devices on the same bus or serial network. In Modbus RTU or other serial communication protocols, the IoT gateway needs to correctly address the target PLC device through the station number. Among them, the communication feature information represents the relevant parameters for describing the communication attributes and interaction methods of the target PLC device during the communication process, that is, for assisting the IoT gateway in identifying the type of the target PLC device and selecting a suitable communication protocol for matching. For example, the model of the target PLC device represents the manufacturer-defined name or number for uniquely identifying the target PLC device, that is, for distinguishing PLC devices of different brands, series, or specifications; the function category of the target PLC device represents the classification information for describing the main application field or specific control function of the target PLC device, that is, for guiding the IoT gateway to understand the purpose of the target PLC device. For example, the general logic control category (for basic logic operations), the motion control category (for motor control), the process control category (for continuous production processes such as chemical industry and food), and the safety category (for emergency stop and fault protection), etc.; the communication methods supported by the target PLC device represent the communication mechanisms used by the target PLC device to interact with external devices, such as Ethernet communication (such as TCP, IP), serial communication (such as Modbus RTU), proprietary protocols (such as Siemens S7 protocol), or wireless communication (such as Wi-Fi, 4G / 5G), etc.
[0033] Exemplarily, during the parsing process of the communication address information, the communication address information and communication feature information of the target PLC device are extracted; among them, for the IP address, it is necessary to check whether it conforms to the IPv4 or IPv6 format and ensure that it does not conflict with the IP addresses of other devices in the network; for the port, it is necessary to confirm whether its numerical range is within the legal range and is not occupied by other devices or services; for the station number, it is necessary to ensure that the setting of the station number conforms to the site numbering rules of the target PLC device. During the parsing process of the communication feature information, it is necessary to identify the model of the target PLC device to further determine the function category and supported communication methods of the target PLC device, that is, based on the model of the target PLC device, perform a match in the pre-stored device information library to determine which function category the target PLC device belongs to and confirm its supported communication mode.
[0034] Step S202: Based on the communication characteristic information of the target PLC device, screen out the target communication protocol that matches the target PLC device from the supported communication protocols.
[0035] Among them, the target communication protocol refers to the communication protocol screened out from the multiple communication protocols supported by the IoT gateway and compatible with the target PLC device, which is used to guide the data interaction between the IoT gateway and the target PLC device to ensure correct instruction parsing and data transmission.
[0036] Exemplarily, based on the communication characteristic information of the target PLC device, screen out the target communication protocol that matches the target PLC device from the list of supported communication protocols; during the screening process, first, query the preset protocol adaptation table according to the model of the target PLC device. The protocol adaptation table stores the correspondence between the models of common PLC devices and the communication protocols they support, so as to obtain the list of communication protocols supported by the target PLC device in the protocol adaptation table, that is, initially screen out the communication protocols applicable to the target PLC device according to the model of the target PLC device to narrow the range of optional protocols; furthermore, combine the function category of the target PLC device with the supported communication protocols to further screen out the final target communication protocol from the initially screened communication protocols at the level of function category and communication protocol. Step S203: Obtain the target dynamic library corresponding to the target communication protocol, and based on the target dynamic library, combine the communication address information of the target PLC device to establish a communication connection between the IoT gateway and the target PLC device.
[0037] Among them, the target dynamic library refers to an executable code library for implementing the target communication protocol, that is, it is used to enable the IoT gateway to load the adapted communication logic and interact with the target PLC device based on this communication logic.
[0038] Exemplarily, since the implementation methods corresponding to different communication protocols are different, the IoT gateway needs to dynamically load the corresponding communication logic according to the screened target communication protocol so that the IoT gateway can correctly implement the communication behavior based on the target communication protocol; for example, for a target PLC device using the Modbus TCP protocol, the IoT gateway will load the target dynamic library of Modbus TCP, and this target dynamic library provides functions such as establishing a TCP connection, sending read instructions, and parsing the data returned by the PLC device.
[0039] Optionally, during the process of loading the dynamic library, first check whether the corresponding dynamic library already exists in the local storage. If not, it is necessary to download it from the remote server or read it from the pre-set storage medium. After the dynamic library is successfully loaded, initialize the communication connection according to the communication address information of the target PLC device, such as IP address, port, station number, etc., and attempt to establish an actual connection between the IoT gateway and the target PLC device. After the communication connection is successfully established, create a data transmission channel between the IoT gateway and the target PLC device, so that the IoT gateway can read data from the target PLC device according to the pre-defined acquisition-related configuration parameters.
[0040] In this embodiment, first, the communication address information and communication feature information are parsed according to the PLC communication configuration parameters. In the scenario where the communication protocol is determined, then according to the communication feature information of the target PLC device, the target communication protocol that matches is adaptively selected from the supported communication protocols to reduce manual intervention and improve communication compatibility and efficiency. Furthermore, in the scenario of building a communication connection, the corresponding target dynamic library is obtained according to the target communication protocol, and the communication connection is built in combination with the communication address information, so as to realize the dynamic communication logic loading process and ensure stable and efficient data interaction.
[0041] In an exemplary embodiment, the phase-matched variable data points are used as the same set of variable data points, including steps S301 to S302.
[0042] Step S301, obtain the data storage characteristics corresponding to each variable data point. By performing a continuity analysis on the point distribution interval of the variable data points with the same data storage characteristics, at least one continuous point distribution interval is obtained in the point distribution interval corresponding to the variable data points with the same data storage characteristics. The interval between adjacent variable data points in the same continuous point distribution interval satisfies the preset interval threshold condition.
[0043] Among them, the data storage feature represents relevant parameters used to describe the storage attributes of variable data points in the target PLC device, that is, it is used to distinguish different types of variable data points and guide the data reading and parsing process of the IoT gateway for the target PLC device. For example, the data storage feature can represent the storage area corresponding to the variable data point, such as different types of storage units like input registers and holding registers; the data storage feature can represent the data storage format corresponding to the variable data point, such as integers, floating-point numbers, boolean values, strings, etc.; the data storage feature can represent the data storage method corresponding to the variable data point, such as storage methods like Big-Endian or Little-Endian; the data storage feature can represent the data source and usage corresponding to the variable data point, such as data sources like built-in sensors, external I / O modules, communication interfaces, etc., and for example, functions such as monitoring, control, and alarm.
[0044] Among them, the point distribution interval of variable data points with the same data storage feature represents the address range of multiple variable data points with the same data storage feature in the target PLC device; the continuity analysis represents an analysis process used to determine whether the arrangement of variable data points with the same data storage feature in the corresponding point distribution interval is continuous.
[0045] Exemplarily, first, according to the data storage features respectively corresponding to each variable data point, each variable data point is preliminarily grouped to obtain variable data points with the same data storage feature; furthermore, among the variable data points with the same data storage feature, each variable data point is arranged according to the storage address of the variable data point. After the arrangement is completed, continuity analysis is performed on the variable data points with the same data storage feature, that is, according to the relative positions of these variable data points in the corresponding point distribution interval, continuous point distribution intervals are identified in the overall point distribution interval.
[0046] Among them, during the continuity analysis process, the storage address interval between adjacent variable data points is evaluated to determine whether these storage address intervals meet the preset interval threshold conditions. For example: if the storage address interval between two adjacent variable data points is less than or equal to the preset threshold set by the interval threshold conditions, it means that these two adjacent variable data points belong to the same continuous point distribution interval, and if the storage address interval is greater than the preset threshold, it means that these two adjacent variable data points belong to different continuous point distribution intervals.
[0047] Optionally, if the storage addresses of multiple variable data points are 40001, 40002, and 40003 respectively, and the preset threshold set by the interval threshold condition is "address interval ≤ 1", then these variable data points can be regarded as continuous, and "40001, 40002, 40003" are divided into the same continuous point distribution interval; if the storage address of the next variable data point is 40006, it is divided into another continuous point distribution interval because it is greater than the preset threshold.
[0048] Step S302, use the variable data points in the same continuous point distribution interval as the same group of variable data points.
[0049] Exemplarily, according to the divided continuous point distribution intervals, all variable data points belonging to the same continuous point distribution interval are grouped into the same group, and a unified batch reading strategy is assigned to the variable data points in the same group. For example, if a continuous point distribution interval contains ten variable data points, the IoT gateway can obtain the PLC data of these ten variable data points through a single batch reading operation, without having to perform independent reading operations on each variable data point separately.
[0050] In this embodiment, first, the variable data points are initially divided according to the data storage characteristics corresponding to the variable data points respectively, and the variable data points with the same data storage characteristics are obtained; furthermore, by performing continuity analysis on the point distribution intervals of the variable data points with the same data storage characteristics, continuous point distribution intervals are further divided in the point distribution intervals, so that the variable data points in the same continuous point distribution interval are used as the same group of variable data points, thereby ensuring that the organization of the variable data points is more reasonable, improving the predictability of data reading and the feasibility of batch reading; based on this, the data reading process is optimized according to a reasonable point grouping method, reducing the communication times between the IoT gateway and the target PLC device, improving the data acquisition efficiency and reducing resource consumption.
[0051] In an exemplary embodiment, the PLC data of the target PLC device is collected according to each group of variable data points, and the PLC data sets corresponding to each group of variable data points are obtained, including Step S401 to Step S403.
[0052] Step S401, determine the collection period of the IoT gateway based on the target PLC device according to the data update frequencies corresponding to each group of variable data points respectively.
[0053] Among them, the data update frequency represents the data change rate of a variable data point in the target PLC device. For example, if the variable data point corresponding to a temperature sensor data is updated once per second, its data update frequency is 1 Hz (i.e., 1 time / second). If the variable data point corresponding to a pressure sensor data is updated every 100 milliseconds, its data update frequency is 10 Hz.
[0054] Among them, the collection period represents the time interval for the IoT gateway to request data from the target PLC device. For example, if the collection period is set to 1 second, the IoT gateway requests data from the target PLC device every 1 second.
[0055] Exemplarily, based on the data update frequencies respectively corresponding to each group of variable data points, a data collection period suitable for the target PLC device is determined. That is, the update frequencies of different variable data points may vary. For example, some variables for real-time monitoring may require millisecond-level updates, while some environmental parameters may be updated at the second-level or even minute-level. Therefore, during the determination of the collection period, it is necessary to analyze the data update frequencies of each group of variable data points to ensure that the data collection period can match the actual data change rate of the target PLC device.
[0056] Exemplarily, during the analysis of the data update frequency, first, the data update frequency is extracted from the configuration parameters or historical data change situations of each group of variable data points, and then a suitable collection period is calculated based on the data update frequencies of each group of variable data points. For example: if the data change frequencies of each group are generally high, a shorter collection period is adopted to ensure the timeliness of the data, while if the data change frequencies of each group are generally low, a longer collection period is adopted to reduce the communication pressure.
[0057] Furthermore, the optimal collection period can also be comprehensively determined according to various factors such as data update requirements, device bearing capacity, network communication efficiency, etc. That is, a comprehensive balance is made according to factors such as the update frequencies of each group of variable data points, the maximum data access rate of the target PLC device, network bandwidth limitations or delays, etc., to dynamically adjust the collection period.
[0058] Step S402, collect the PLC data of the target PLC device according to each group of variable data points according to the collection period, and obtain the PLC data sets respectively corresponding to each group of variable data points in different collection periods.
[0059] Exemplarily, during the data acquisition process, the IoT gateway needs to read the data of each group of variable data points according to the set acquisition period, and maintain a consistent data acquisition logic in different acquisition periods. For example: at the beginning of the first acquisition period, the IoT gateway sends a data read request to the PLC device to acquire the data of each group of variable data points. If the groups of variable data points include the first group of variable data points, the second group of variable data points, and the third group of variable data points, then within the first acquisition period, the data of these three groups of variable data points are read in sequence and stored in the corresponding PLC data set; at the beginning of the second acquisition period, the data of these three groups of variable data points are read in sequence again, and the new data is stored in a new PLC data set, and so on, to ensure a consistent data acquisition logic and data storage structure in different acquisition periods.
[0060] Step S403: Determine the PLC data corresponding to different variable data points in each PLC data set, and associate and store each variable data point and the PLC data corresponding to each variable data point in the form of key-value pairs.
[0061] Exemplarily, a key-value pair storage structure is adopted, where the variable data point is used as the key (Key), and the corresponding PLC data is used as the value (Value), and a timestamp information is attached to effectively manage the PLC data in the time dimension. Furthermore, based on data storage characteristics such as the storage area corresponding to the variable data point, the data storage method, and the storage data format, the acquired PLC data can be hierarchically stored to more efficiently locate the required data during subsequent data query and analysis.
[0062] In this embodiment, first, according to the data update frequency corresponding to each group of variable data points, the acquisition period of the IoT gateway is comprehensively determined, so that the data acquisition period matches the actual update rate of the PLC data, ensuring the timeliness of the data and reducing the communication burden; furthermore, the PLC data of the target PLC device is acquired according to the acquisition period to obtain the PLC data sets corresponding to each group of variable data points, effectively ensuring a consistent data acquisition logic and data storage structure in different acquisition periods; furthermore, the PLC data is associated and stored in the form of key-value pairs, thereby effectively realizing the structured management of the PLC data.
[0063] In an exemplary embodiment, the configuration information is information represented in the JSON file format. After obtaining the configuration information from the configuration module, the method further includes step S501; according to the communication connection between the IoT gateway and the target IoT platform, the target PLC data is uploaded to the target IoT platform, including step S502.
[0064] Step S501, parse the configuration information based on the parsing library corresponding to the JSON file format to obtain the parsed configuration information. The PLC communication configuration parameters in the parsed configuration information are used to determine the communication connection between the IoT gateway and the target PLC device, and the variable data points in the parsed configuration information are used to collect the PLC data of the target PLC device.
[0065] Among them, the JSON file format represents a text format for structured storage and transmission of data in the form of JavaScript objects, and is used to represent data in a hierarchical and easily parsable manner.
[0066] Among them, the parsing library corresponding to the JSON file format represents a software tool for parsing, reading, and operating on data in the JSON file format, that is, used to convert the configuration information in the JSON file format into a data structure that can be processed by the program, and supports validating, querying, and storing it.
[0067] Exemplarily, parse the configuration information based on the parsing library corresponding to the JSON file format to obtain the parsed configuration information. The parsed configuration information includes PLC communication configuration parameters and variable data points, which can be directly used in subsequent processes such as data collection and communication connection. Among them, after receiving the configuration information in the JSON text format from the configuration module, the IoT gateway can directly call a common JSON parsing library to convert the configuration information into a data structure that can be directly called by the program logic. During the parsing process, it is necessary to verify the integrity of the JSON data to ensure that it conforms to the standard format, such as checking for format errors, missing necessary fields, or data type mismatches. After parsing, the parsed configuration information is stored in the local cache or database of the IoT gateway to ensure that even if the device is powered off or restarted, the same configuration can still be used for data collection and upload.
[0068] Step S502, according to the data format conditions in the configuration information, convert the target PLC data into target PLC data in the JSON file format, determine the communication connection channel between the IoT gateway and the target IoT platform based on the MQTT protocol, and upload the target PLC data in the JSON file format to the target IoT platform through the communication connection channel.
[0069] Among them, the data format conditions refer to the data organization and conversion rules set according to the configuration information when the IoT gateway processes the target PLC data, and are used to ensure that the uploaded target PLC data meets the format requirements of the target IoT platform to improve the readability, compatibility, and consistency of the data. For example, the value of a certain variable data point needs to be converted into a floating-point number format, or the boolean variable 1 may be converted into "ON", etc.
[0070] Among them, the MQTT protocol represents a lightweight Internet of Things (IoT) communication protocol based on the publish-subscribe model, which is used to establish an efficient and low-bandwidth data transmission channel between the IoT gateway and the target IoT platform, and ensure the real-time and reliability of data. For example, the IoT gateway can use the MQTT protocol to publish the target PLC data in JSON file format to a specific topic, and the target IoT platform receives the target PLC data by subscribing to this topic.
[0071] Exemplarily, the IoT gateway performs standardization processing on the determined target PLC data according to preset data format conditions. For example, for the original target PLC data, the data unit is converted into a predetermined standard unit, the integer-type data is converted into a floating-point format to improve accuracy, or the boolean-type data is marked with status, etc., to ensure the readability and consistency of the data. After the standardization processing of the target PLC data is completed, in the standardized target PLC data, the information such as the name, value, and timestamp of each variable data point is encapsulated in JSON file format to obtain the target PLC data in JSON file format, so that it can be correctly parsed by the target IoT platform.
[0072] Exemplarily, after determining the target PLC data in JSON file format, the IoT gateway establishes a communication connection with the target IoT platform through the MQTT protocol and selects a suitable communication connection channel. Among them, when establishing the communication connection, the IoT gateway needs to send a connection request to the MQTT server and perform identity authentication to ensure the security of data transmission. After the communication connection is established, the IoT gateway publishes the target PLC data in JSON file format to the specified MQTT topic, and the target IoT platform receives the target PLC data by subscribing to this MQTT topic and performs subsequent storage and processing.
[0073] In this embodiment, first, the configuration information in JSON file format is parsed according to the corresponding parsing library of the JSON file format, thereby reducing the parsing difficulty of the configuration information and efficiently obtaining the PLC communication configuration parameters and variable data points in the parsed configuration information. Furthermore, the target PLC data is converted into JSON file format according to the data format conditions in the configuration information, and a communication connection channel is established based on the MQTT protocol to upload the target PLC data in JSON file format to the target IoT platform, thereby ensuring the standardization, low latency, and efficiency of data transmission.
[0074] In an exemplary embodiment, determining the target PLC data to be uploaded in the PLC data sets respectively corresponding to each group of variable data points includes steps S601 to S602.
[0075] Step S601, according to the data triggering method in the preset data upload policy, filter the first target PLC data from the PLC data sets corresponding to each group of variable data points. The data triggering method includes one of the periodic triggering method and the variable triggering method.
[0076] Among them, the data upload policy represents a set of rules for determining the target PLC data to be uploaded, that is, for ensuring that the content of the data upload meets the business requirements; the data triggering method represents a rule for realizing data screening according to the timing of triggering data upload, including the periodic triggering method and the variable triggering method.
[0077] Among them, the periodic triggering method means triggering data upload according to a preset time interval. For example, all data is uploaded every 10 seconds to ensure the continuity and integrity of the data, which is applicable to scenarios such as real-time monitoring; the variable triggering method means triggering data upload for specific types of variable data points. For example, only temperature data is uploaded, and pressure or humidity data is not uploaded, which is applicable to scenarios such as classified data management.
[0078] Exemplarily, according to the data triggering method in the preset data upload policy, initially filter the first target PLC data from the PLC data sets corresponding to each group of variable data points to ensure that the triggering timing of the data upload meets the business requirements; among them, in the periodic triggering method, the IoT gateway selects the data within the current collection cycle as the first target PLC data according to the set time interval; in the variable triggering method, the IoT gateway only selects the data corresponding to a certain specified type of variable data point as the first target PLC data.
[0079] Step S602, according to the data selection method in the preset data upload policy, filter the second target PLC data from the first target PLC data, and use the second target PLC data as the target PLC data to be uploaded. The data selection method includes one of the full-volume selection method and the incremental selection method.
[0080] Among them, the data selection method represents a rule for realizing data screening according to the integrity of the data upload, including the full-volume selection method and the incremental selection method.
[0081] Among them, the full-volume selection method means that each time data is uploaded, the latest values of all variable data points are uploaded, which is applicable to scenarios that require complete recording of data changes, such as environmental monitoring and trend analysis; the incremental selection method means that each time data is uploaded, only the data that has changed since the last upload is uploaded, which is applicable to scenarios that reduce data transmission volume and optimize bandwidth utilization.
[0082] Exemplarily, according to the data selection method in the preset data upload policy, the second target PLC data is further screened out from the first target PLC data and used as the target PLC data to be finally uploaded, so as to ensure that the integrity of data upload meets the business requirements. Among them, in the full-volume selection method, the IoT gateway will use the data corresponding to all variable data points in the first target PLC data as the second target PLC data. In the incremental selection method, the IoT gateway compares the current data with the data uploaded last time in the first target PLC data, screens out the first target PLC data that has changed, and uses the changed first target PLC data as the second target PLC data.
[0083] In this embodiment, first, according to the data trigger method in the preset data upload policy, the first target PLC data is preliminarily screened out from the PLC data sets corresponding to each group of variable data points, so as to ensure that the trigger timing of data upload can meet the requirements of different application scenarios. Furthermore, according to the data selection method in the preset data upload policy, the second target PLC data is further screened out from the first target PLC data and used as the target PLC data to be uploaded, so as to ensure that the integrity of data upload can meet the requirements of different application scenarios. Based on this, through flexible data trigger methods and data selection methods, the screening process of the data to be uploaded accurately and efficiently is hierarchically realized.
[0084] In an exemplary embodiment, after determining the communication connection between the IoT gateway and the target PLC device according to the PLC communication configuration parameters, the method further includes steps S701 to S702.
[0085] Step S701, obtain an operation instruction, and parse the operation instruction to obtain the instruction type corresponding to the operation instruction. The operation instruction is used to indicate the read / write state or running state of the target PLC device.
[0086] Among them, the operation instruction represents an instruction received by the IoT gateway and used to control the target PLC device. For example, it is used to remotely read or modify the data of the target PLC device, or adjust the running state of the target PLC device. The instruction type represents the specific category determined after parsing the operation instruction, and is used to distinguish different operation targets and guide the IoT gateway to execute corresponding operations. For example, the operation instruction of the read type is used to read PLC data, the operation instruction of the write type is used to modify the PLC variable value, and the operation instruction of the control type is used to adjust the running state of the PLC (such as start, stop or reset).
[0087] Among them, the read / write status indicates the occupancy of the access rights to the internal data of the target PLC device, that is, whether reading or writing is allowed. For example, the read / write status of a certain PLC data may be "read-only", which means it can only be read but not modified, or "readable and writable", which means it can be both read and modified.
[0088] Among them, the running status indicates the current working mode of the target PLC device, and is used to indicate whether the target PLC device is in different states such as running, stopped, faulty, standby, etc. For example, if the running status of a certain PLC device is "running", it means that a certain operation is being executed, or "stopped", which means that no operation is being executed, or "error", which means that an abnormality has occurred in the PLC device.
[0089] Exemplarily, the IoT gateway can receive operation instructions from the target IoT platform, user terminal, or other control systems (such as single-chip microcontrollers). These operation instructions may adopt standardized protocol formats such as JSON, XML, or binary protocols; after receiving the operation instructions, first, it is necessary to verify the integrity of the operation instructions to ensure that the instruction format of the operation instructions conforms to expectations and verify whether the instruction content contains necessary parameters, such as the address of the target PLC device, operation data, instruction type, etc.; among them, if the operation instruction contains a request to read the PLC register, the instruction type of the operation instruction is parsed as an operation instruction of the read type; if the operation instruction contains a request to write a specific variable to the PLC, the instruction type of the operation instruction is parsed as an operation instruction of the write type; if the operation instruction involves controlling the running status of the target PLC device, such as starting, pausing, or resetting, the instruction type of the operation instruction is parsed as an operation instruction of the control type.
[0090] Step S702, based on the instruction type of the operation instruction, obtain the operation permission of the target PLC device based on the instruction type, and based on the operation permission, execute the operation behavior corresponding to the operation instruction on the target PLC device and record the operation result based on the operation behavior.
[0091] Among them, the operation permission indicates the access level or authorization conditions required to execute a specific operation instruction, and is used to restrict unauthorized operations and prevent illegal modification of the data or running status of the target PLC device.
[0092] Among them, the operation behavior indicates the specific actions executed by the IoT gateway on the target PLC device according to the operation instruction, and is used to complete the modification of the specified data or running status of the target PLC device. For example, the operation behavior can represent reading the data at address 40001 of the target PLC device, writing a new variable value to address 40002 of the target PLC device, starting the target PLC device, etc.
[0093] Among them, the operation result represents the actual execution situation and feedback information after the operation behavior is executed, and is used to record the success or failure status of the operation, as well as record the specific data involved in the execution process, so as to conduct monitoring or troubleshooting.
[0094] Exemplarily, to ensure the security of the operation, the IoT gateway will first query the permission configuration of the target PLC device and verify whether the instruction type corresponding to the current operation instruction has the corresponding operation permission. If the corresponding operation permission is obtained based on the instruction type, the IoT gateway will execute the corresponding operation behavior according to the operation instruction. For example, when executing a read-type operation instruction, the IoT gateway first obtains the operation permission corresponding to the read-type operation instruction, then sends a data read request to the target PLC device, and waits for the specified data returned by the target PLC device; when executing a write-type operation instruction, the IoT gateway first obtains the operation permission corresponding to the write-type operation instruction, then sends a write request to the target PLC device to write new data at the specified address and check whether the write is successful; when executing a control-type operation instruction, the IoT gateway first obtains the operation permission corresponding to the control-type operation instruction, then sends a status control request to the target PLC device to make the target PLC device in a running state such as start, stop or reset, and confirm whether the current running state of the target PLC device meets the expectation.
[0095] Exemplarily, all operation behaviors will be recorded in real time, including operation time, operation result, return value, etc., for subsequent system log analysis or fault tracking; if the operation fails, the IoT gateway also needs to record the specific reason for the failure and feedback error information to the sender of the operation instruction (such as the target IoT platform, user terminal or other control systems) so as to take remedial measures.
[0096] In this embodiment, the operation instruction is parsed according to the obtained operation instruction to determine the instruction type, so as to effectively and accurately determine the operation requirement; furthermore, the operation permission of the target PLC device based on the instruction type is obtained, and then the corresponding operation behavior is executed based on the operation permission and the operation result is recorded, so as to ensure that the execution of the operation instruction meets the permission management requirements, and improve the security and traceability of data processing; based on this, through the combination of instruction parsing, permission verification and operation record, the efficient and secure remote operation of the PLC device is realized, and the accurate execution of the operation instruction is ensured.
[0097] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the indications of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless specifically stated herein, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least some of the steps or stages in other steps or other steps.
[0098] Based on the same inventive concept, an embodiment of the present application further provides a data acquisition device based on an IoT gateway for implementing the data acquisition method based on an IoT gateway described above. The implementation solution provided by this device to solve the problem is similar to the implementation solution described in the above method. Therefore, the specific limitations in one or more embodiments of the data acquisition device based on an IoT gateway provided below can refer to the limitations on the data acquisition method based on an IoT gateway in the foregoing, and will not be elaborated herein.
[0099] In an exemplary embodiment, as Figure 2 shown, a data acquisition device based on an IoT gateway is provided, which is applied to an IoT gateway and includes: an acquisition module 201, a collection module 202, and an upload module 203, where: The acquisition module 201 is configured to acquire configuration information from a configuration module. The configuration module includes at least one of a configuration software and a configuration web page for inputting configuration information. The configuration information includes PLC communication configuration parameters and variable data points. The collection module 202 is configured to determine a communication connection between the IoT gateway and a target PLC device according to the PLC communication configuration parameters, use the matching variable data points as a set of variable data points, and collect the PLC data of the target PLC device according to each set of variable data points to obtain a PLC data set corresponding to each set of variable data points. The upload module 203 is configured to determine the target PLC data to be uploaded in the PLC data sets corresponding to each set of variable data points, and upload the target PLC data to the target IoT platform according to the communication connection between the IoT gateway and the target IoT platform.
[0100] In an exemplary embodiment, the acquisition module 202 is further configured to: parse the PLC communication configuration parameters to obtain the communication address information and communication feature information of the target PLC device, where the communication address information includes the IP address, port, and station number of the target PLC device, and the communication feature information includes the model, function category, and communication method of the target PLC device; based on the communication feature information of the target PLC device, filter out the target communication protocol matching the target PLC device from the supported communication protocols; obtain the target dynamic library corresponding to the target communication protocol, and based on the target dynamic library, combine the communication address information of the target PLC device to establish a communication connection between the Internet of Things gateway and the target PLC device.
[0101] In an exemplary embodiment, the acquisition module 202 is further configured to: obtain the data storage characteristics corresponding to each variable data point position, perform continuity analysis on the point position distribution intervals of the variable data point positions with the same data storage characteristics, and divide at least one continuous point position distribution interval from the point position distribution intervals corresponding to the variable data point positions with the same data storage characteristics, where the interval between adjacent variable data point positions in the same continuous point position distribution interval satisfies the preset interval threshold condition; use the variable data point positions in the same continuous point position distribution interval as the same group of variable data point positions.
[0102] In an exemplary embodiment, the acquisition module 202 is further configured to: determine the acquisition period of the Internet of Things gateway based on the target PLC device according to the data update frequency corresponding to each group of variable data point positions; collect the PLC data of the target PLC device by each group of variable data point positions according to the acquisition period to obtain the PLC data sets corresponding to each group of variable data point positions in different acquisition periods; determine the PLC data corresponding to different variable data point positions in each PLC data set, and associate and store each variable data point position and the PLC data corresponding to each variable data point position in the form of key-value pairs.
[0103] In an exemplary embodiment, the acquisition module 201 is further configured to: parse the configuration information based on the parsing library corresponding to the JSON file format to obtain the parsed configuration information, where the PLC communication configuration parameters in the parsed configuration information are used to determine the communication connection between the Internet of Things gateway and the target PLC device, and the variable data point positions in the parsed configuration information are used to collect the PLC data of the target PLC device; the upload module 203 is further configured to: convert the target PLC data into the target PLC data in JSON file format according to the data format condition in the configuration information, determine the communication connection channel between the Internet of Things gateway and the target Internet of Things platform based on the MQTT protocol, and upload the target PLC data in JSON file format to the target Internet of Things platform through the communication connection channel.
[0104] In an exemplary embodiment, the upload module 203 is further configured to: screen out first target PLC data from the PLC data sets respectively corresponding to each group of variable data points according to the data triggering method in the preset data upload policy, where the data triggering method includes one of a periodic triggering method and a variable triggering method; screen out second target PLC data from the first target PLC data according to the data selection method in the preset data upload policy, and use the second target PLC data as the target PLC data to be uploaded, where the data selection method includes one of a full - volume selection method and an incremental selection method.
[0105] In an exemplary embodiment, the device further includes an instruction operation module, and the instruction operation module is further configured to: obtain an operation instruction, parse the operation instruction to obtain the instruction type corresponding to the operation instruction, where the operation instruction is used to indicate the read - write state or the running state of the target PLC device; based on the instruction type of the operation instruction, obtain the operation permission of the target PLC device based on the instruction type, and based on the operation permission, execute the operation behavior corresponding to the operation instruction on the target PLC device and record the operation result based on the operation behavior.
[0106] Each module in the above - mentioned data acquisition device based on the Internet of Things gateway can be implemented in whole or in part by software, hardware, and their combination. The above - mentioned modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above - mentioned modules.
[0107] In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in any of the above - mentioned embodiments are implemented.
[0108] In an embodiment, a computer - readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, the steps in any of the above - mentioned embodiments are implemented.
[0109] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memories can include read-only memory (ROM), magnetic tapes, floppy disks, flash memories, optical memories, high-density embedded non-volatile memories, resistive random access memories (ReRAM), magnetoresistive random access memories (MRAM), ferroelectric random access memories (FRAM), phase change memories (PCM), graphene memories, etc. Volatile memories can include random access memory (RAM) or external cache memories, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logics, data processing logics based on quantum computing, etc., without limitation.
[0110] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0111] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A data collection method based on the Internet of Things gateway, characterized in that: Applied to an Internet of Things gateway, the method comprises: Acquire configuration information from a configuration module, the configuration module comprising at least one of configuration software and a configuration webpage for inputting configuration information, the configuration information comprising PLC communication configuration parameters and variable data points; Determine the communication connection between the IoT gateway and the target PLC device according to the PLC communication configuration parameters, take the matched variable data points as the same group of variable data points, collect the PLC data of the target PLC device according to each group of variable data points, and obtain the PLC data sets corresponding to each group of variable data points; The target PLC data to be uploaded is determined in the PLC data sets corresponding to the respective groups of variable data points, and the target PLC data is uploaded to the target Internet of Things platform according to the communication connection between the Internet of Things gateway and the target Internet of Things platform.
2. The method according to claim 1, characterized in that Determining the communication connection between the Internet of Things gateway and the target PLC device according to the PLC communication configuration parameters includes: Parsing the PLC communication configuration parameters to obtain communication address information and communication feature information of the target PLC device, wherein the communication address information includes the IP address, port and station number of the target PLC device, and the communication feature information includes the model, function category and communication mode of the target PLC device; Based on the communication characteristic information of the target PLC device, a target communication protocol matching the target PLC device is obtained by screening supported communication protocols; Obtain a target dynamic library corresponding to the target communication protocol, and build a communication connection between the Internet of Things gateway and the target PLC device based on the target dynamic library and the communication address information of the target PLC device.
3. The method according to claim 1, characterized in that The method of treating the matched variable data points as the same group of variable data points includes: Obtaining data storage features corresponding to each variable data point, respectively, by performing continuity analysis on the point distribution interval of the variable data points of the same data storage feature, dividing the point distribution interval corresponding to the variable data points of the same data storage feature to obtain at least one continuous point distribution interval, wherein the intervals between adjacent variable data points in the same continuous point distribution interval meet a preset interval threshold condition; The variable data points in the same continuous point distribution interval are regarded as the same group of variable data points.
4. The method according to claim 1, characterized in that: The PLC data of the target PLC device is collected according to each group of variable data points to obtain a PLC data set corresponding to each group of variable data points, including: Determine the collection period of the IoT gateway based on the target PLC device based on the data update frequency corresponding to each group of variable data points; According to each group of variable data points, the PLC data of the target PLC device is collected according to the collection period to obtain the PLC data sets corresponding to each group of variable data points in different collection periods; Determine the PLC data corresponding to different variable data points in each PLC data set, and associate and store each variable data point and the PLC data corresponding to each variable data point in the form of a key-value pair.
5. The method according to claim 1, characterized in that The configuration information is information represented in a JSON file format. After acquiring the configuration information from the configuration module, the following steps are further included: Parsing the configuration information based on a parsing library corresponding to the JSON file format to obtain parsed configuration information, wherein the PLC communication configuration parameters in the parsed configuration information are used to determine the communication connection between the IoT gateway and the target PLC device, and the variable data points in the parsed configuration information are used to collect and obtain PLC data of the target PLC device; The method of uploading the target PLC data to the target Internet of Things platform according to the communication connection between the Internet of Things gateway and the target Internet of Things platform comprises: According to the data format conditions in the configuration information, the target PLC data is converted into target PLC data in JSON file format, the communication connection channel between the IoT gateway and the target IoT platform is determined based on the MQTT protocol, and the target PLC data in JSON file format is uploaded to the target IoT platform through the communication connection channel.
6. The method according to claim 1, characterized in that The step of determining the target PLC data to be uploaded in the PLC data sets corresponding to the respective groups of variable data points comprises: According to a data triggering method in a preset data uploading strategy, first target PLC data is obtained by screening out the PLC data sets corresponding to the respective groups of variable data points, wherein the data triggering method includes one of a periodic triggering method and a variable triggering method; According to the data selection method in the preset data upload strategy, the second target PLC data is screened from the first target PLC data, and the second target PLC data is used as the target PLC data to be uploaded. The data selection method includes one of a full selection method and an incremental selection method.
7. The method according to claim 1, characterized in that After determining the communication connection between the IoT gateway and the target PLC device according to the PLC communication configuration parameters, the method further includes: Acquire an operation instruction, and parse the operation instruction to obtain an instruction type corresponding to the operation instruction, wherein the operation instruction is used to indicate a read / write state or an operation state of the target PLC device; Based on the instruction type of the operation instruction, the operation authority of the target PLC device based on the instruction type is obtained; based on the operation authority, the operation behavior corresponding to the operation instruction is executed on the target PLC device and the operation result based on the operation behavior is recorded.
8. A data collection device based on the Internet of Things, characterized in that: Applied to the Internet of Things gateway, the device comprises: An acquisition module, used to acquire configuration information from a configuration module, wherein the configuration module includes at least one of configuration software and a configuration webpage for inputting configuration information, wherein the configuration information includes PLC communication configuration parameters and variable data points; A collection module is used to determine the communication connection between the IoT gateway and the target PLC device according to the PLC communication configuration parameters, take the matched variable data points as the same group of variable data points, collect the PLC data of the target PLC device according to each group of variable data points, and obtain the PLC data sets corresponding to each group of variable data points; The uploading module is used to determine the target PLC data to be uploaded in the PLC data sets corresponding to the respective groups of variable data points, and upload the target PLC data to the target Internet of Things platform according to the communication connection between the Internet of Things gateway and the target Internet of Things platform.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Method for automatically generating instruction conforming to Modbus protocol
CN120499164A
A method for automatically generating instructions that comply with the Modbus protocol
CN120499164B
Internet of Things data acquisition method and device, storage medium and electronic equipment
CN120956771A
Internet of Things (IoT) data acquisition methods, devices, storage media, and electronic devices
CN120956771B
Data interaction method and related device
CN121635042A