An intelligent gateway data storage deployment method, device, equipment and medium

The intelligent gateway data storage deployment method solves the problem of low data storage efficiency in existing technologies, and achieves efficient data query and secure storage, which is applicable to intelligent gateway data storage devices.

CN116126915BActive Publication Date: 2026-05-01XIAMEN FOUR FAITH COMM TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAMEN FOUR FAITH COMM TECH
Filing Date
2023-01-17
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

In existing technologies, data processing solutions can only store data by appending to the end. When the file size reaches a certain threshold, it needs to be split, resulting in low query efficiency and a problem of insufficient handle allocation when the number of files increases.

Method used

The smart gateway data storage deployment method is adopted. When the gateway process starts, the main thread and three sub-threads are started to obtain the data table of the day in the database, configure the collection protocol, parse and insert data, generate message packets, and send them to the docking platform when communication is normal, and cache them in the database cache table when communication is abnormal.

Benefits of technology

It improves data query efficiency, avoids insufficient handle allocation, ensures data integrity and security, and supports flexible storage and query operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116126915B_ABST
    Figure CN116126915B_ABST
Patent Text Reader

Abstract

The application provides a smart gateway data storage deployment method and device, equipment and medium, comprising: when the gateway process starts, starting the main thread and three sub-threads, obtaining the data table of the day in the database DB, configuring the collection protocol, triggering the gateway to collect the task; the collected data is parsed through the interface to generate parsed data, and the parsed data is inserted into the data table of the day; when it is judged that the reporting thread callback trigger period time reaches, the message packet is found and reported, and the message packet is composed of recent data records in the preset period in the database DB; when it is judged that the message packet is valid and the communication with the docking platform is not normal, the message packet is stored in the cache table in the database DB; when it is judged that the message packet is valid and the communication with the docking platform is normal, the message packet is sent to the docking platform. In addition, the existing data processing scheme stores the problems of needing to split files and being easy to trigger insufficient number of handle allocation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of smart gateway data storage technology, and specifically to a smart gateway data storage deployment method, apparatus, device, and medium. Background Technology

[0002] With the advent of the big data era, protocol platforms such as MQTT, HTTP, and CoAP need to collect, parse, and transform data from terminal devices across multiple geographical locations before presenting it to users for efficient monitoring. Throughout this process, it's crucial to ensure that important data is not lost. In areas with poor network connectivity, features like resumeable downloads and historical data reporting are essential. To meet the demands of efficient big data processing, existing solutions periodically and quantitatively save the acquired underlying data to disk files, then retrieve the data from the text file as needed. However, this approach suffers from a limited text storage method, low fault tolerance, and the lack of chained storage for data insertion, leading to inefficient queries of large file sizes. Simply put, current data processing solutions rely solely on appending to the end of the file, requiring file splitting once a certain size threshold is reached to prevent inefficient data retrieval. Furthermore, the large number of files can trigger issues such as insufficient handle allocation.

[0003] In view of the above, this application is hereby submitted. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a smart gateway data storage deployment method, apparatus, device and medium, which can effectively solve the problems in the existing data processing schemes that can only store data by appending to the end, and that the data needs to be split when the file size reaches a certain threshold to avoid low data query efficiency, and that the number of handles is easily insufficient when the number of files increases to a certain extent.

[0005] This invention discloses a smart gateway data storage deployment method, comprising:

[0006] When the gateway process starts, the main thread and three sub-threads are started to retrieve the data table for the current day from the database DB, configure the collection protocol, and trigger the gateway to perform the collection task.

[0007] The collected data is parsed through an interface to generate parsed data, and the parsed data is then inserted into the data table for that day.

[0008] When it is determined that the reporting thread callback trigger period has been reached, the message packet is searched and reported. The message packet consists of recent data records in the database DB within a preset period.

[0009] When it is determined that the message packet is valid but the communication with the docking platform is abnormal, the message packet is stored in the cache table in the database DB.

[0010] When it is determined that the message packet is valid and the communication with the docking platform is normal, the message packet is sent to the docking platform.

[0011] Preferably, the three sub-threads are a configuration thread, a data acquisition thread, and a display thread, wherein the main thread is used for reporting operations to the platform, the configuration thread is used for automated operations, and the data acquisition thread and the display thread are used for database read and write operations.

[0012] Preferably, the data table for the current day is retrieved from the database DB, and the data collection protocol is configured to trigger the gateway to perform the data collection task, specifically as follows:

[0013] If the database DB does not exist in the storage device, then the database DB will be created.

[0014] If the database DB exists in the storage device, check if the data table for the current day exists.

[0015] If not, create a data table for the current day and set a timer inside the infinite loop of the display thread. When the timer expires, a new data table for the current day is automatically created, and when the number of data tables reaches a preset value, the data table with the earliest date is deleted.

[0016] Configure the data acquisition protocol to trigger the gateway to perform the data acquisition task, where the data ID of the register data is used as a unique identifier.

[0017] Preferably, the collected data is parsed through an interface to generate parsed data, and the parsed data is inserted into the data table for that day, specifically as follows:

[0018] The PLC protocol is mapped by defining the first interface body;

[0019] The collected data is parsed through the second interface to generate parsed data;

[0020] Display the show_stat thread corresponding to the parsed data on the web status page;

[0021] The third interface is called to query the corresponding data table for the current day from the database DB, and the parsed data is inserted into the data table for the current day.

[0022] Preferably, the message packet consists of recent data records within a preset period in the database DB, specifically:

[0023] A data linked list is created through the fourth interface, and all data IDs that need to be reported are extracted from the linked list nodes of the data linked list;

[0024] The data ID and the current absolute timestamp are used as key-value pairs to match the data in the data table for that day. The filtered data is fed back into a complete record and then packaged to generate a message packet.

[0025] Preferably, after storing the message packet in the cache table of the database DB when it is determined that the message packet is valid and the communication with the docking platform is abnormal, the method further includes:

[0026] When it is determined that communication with the docking platform has been re-established, the third interface is invoked to search for all unreported data in the cache table during the disconnection period, and each data item is reported to the docking platform.

[0027] Preferably, after sending the message packet to the interfacing platform when it is determined that the message packet is valid and communication with the interfacing platform is normal, the method further includes:

[0028] When it is determined that there is a problem in sending the message group packet, the failed message is stored in the cache table in the database DB;

[0029] When communication with the docking platform is re-established, the third interface is invoked to find all unreported data in the cache table during the disconnection period, and each data item is reported to the docking platform.

[0030] The present invention also discloses a smart gateway data storage deployment device, comprising:

[0031] The data acquisition unit is used to start the main thread and three sub-threads when the gateway process starts, to obtain the data table of the day in the database DB, configure the acquisition protocol, and trigger the gateway to perform the acquisition task.

[0032] The data insertion unit is used to parse the collected data through an interface, generate parsed data, and insert the parsed data into the data table for the current day.

[0033] The message generation unit is used to search for and report a message packet when it is determined that the reporting thread callback trigger period has been reached. The message packet consists of recent data records in the database DB within a preset period.

[0034] The message caching unit is used to store the message packet in the cache table of the database DB when it is determined that the message packet is valid and the communication with the docking platform is abnormal.

[0035] The message sending unit is used to send the message packet to the docking platform when it is determined that the message packet is valid and the communication with the docking platform is normal.

[0036] The present invention also discloses a smart gateway data storage deployment device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a smart gateway data storage deployment method as described above.

[0037] The present invention also discloses a readable storage medium storing a computer program, which can be executed by the processor of the device where the storage medium is located to implement a smart gateway data storage deployment method as described in any of the above claims.

[0038] In summary, this embodiment provides a smart gateway data storage deployment method, apparatus, device, and medium. The smart gateway data storage deployment method primarily addresses the data issues arising during communication between different protocol platforms and terminal devices. It achieves this by continuously acquiring historical data at various time points from the local terminal. This technology combines memory linked lists for variable storage, real-time storage in an SQLite database, periodic traversal of data tables to update key values, and clearing early data when different devices reach their storage capacity limits. The original data is mainly collected from lower-level PLC devices using different protocols, and each data point is uniquely identified. Then, based on the absolute and relative timestamps of the collection time, a record is created and stored in SQLite, with one table created every 24 hours. This allows for the deletion of the entire table of old data after a period of time, such as a week, to ensure sufficient storage capacity. Flexible storage is also possible by adding, deleting, and modifying single data points using a combination of time and identifier. This solves the problems of existing data processing solutions where data can only be appended to the end, and where file size needs to be split to avoid inefficient data retrieval when it reaches a certain threshold. Furthermore, it addresses the issue of insufficient handle allocation when the number of files increases significantly. Attached Figure Description

[0039] Figure 1 This is a flowchart illustrating a smart gateway data storage deployment method provided in an embodiment of the present invention.

[0040] Figure 2 This is a schematic diagram of the database processing flow provided in an embodiment of the present invention.

[0041] Figure 3 This is a gateway software framework diagram provided in an embodiment of the present invention.

[0042] Figure 4 This is a schematic diagram of a smart gateway data storage deployment device provided in an embodiment of the present invention. Detailed Implementation

[0043] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to represent selected embodiments of the invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0044] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0045] This invention discloses a smart gateway data storage deployment method, apparatus, device, and medium, which at least partially solves the shortcomings of the prior art.

[0046] Please see Figures 1 to 3 The first embodiment of the present invention provides a smart gateway data storage deployment method, which can be executed by a storage deployment device (hereinafter referred to as the deployment device), and in particular by one or more processors within the deployment device, to achieve the following steps:

[0047] It should be noted that the deployment device can be a terminal device that can communicate with different protocol platforms via wired or wireless means. The terminal device can be a smartphone, a smart computer, or other smart device.

[0048] S101: When the gateway process starts, it starts the main thread and three sub-threads, retrieves the data table for the current day from the database DB, configures the collection protocol, and triggers the gateway to perform the collection task.

[0049] Specifically, step S101 includes: when it is determined that the database DB does not exist in the storage device, creating the database DB;

[0050] If the database DB exists in the storage device, check if the data table for the current day exists.

[0051] If not, create a data table for the current day and set a timer inside the infinite loop of the display thread. When the timer expires, a new data table for the current day is automatically created, and when the number of data tables reaches a preset value, the data table with the earliest date is deleted.

[0052] Configure the data acquisition protocol to trigger the gateway to perform the data acquisition task, where the data ID of the register data is used as a unique identifier.

[0053] Specifically, in this embodiment, the three sub-threads are a configuration thread, a data acquisition thread, and a display thread. The main thread is used for reporting to the platform, the configuration thread is used for automation, and the data acquisition thread and the display thread are used for database read and write operations.

[0054] Existing data processing solutions involve periodically and quantitatively saving the acquired underlying data to disk files, and then retrieving the data from the file for use based on different situations. However, this approach suffers from a limited text storage method, low fault tolerance, and the lack of chained storage for data insertion, leading to inefficient queries of large file sizes. In short, current data processing solutions rely solely on appending data to the end of the file, requiring file splitting once a certain size threshold is reached to prevent inefficient data retrieval. Furthermore, as the number of files grows, issues such as insufficient handle allocation can easily arise.

[0055] In this embodiment, when the gateway process starts, it launches three sub-threads: a configuration thread, a data acquisition thread, and a display thread. The main thread handles reporting to the platform, while automated operations such as database creation and destruction are performed in the configuration thread. Database read and write operations are performed in other threads. Then, the `create_history_data_sqlite` interface checks if the database `DB` exists in the storage device's TF card or flash memory. If the database `DB` does not exist, it is created. If the database `DB` exists, the `create_history_data_table` interface is called to check if the data table for the current day exists. If the data table for the current day does not exist, it is created. Simultaneously, a timer is set within the infinite loop of the display thread at midnight. If a new day is reached, a new date form is automatically created. When the preset timeout configured on the web is reached, such as a 7-day limit, the earliest date form is automatically deleted. The database destruction interface can be invoked via a web trigger button. Next, the data acquisition protocol is configured on the gateway's web page, and the data ID of the register data is used as a unique identifier, along with other flash parameters, to trigger the gateway to perform the data acquisition task.

[0056] S102, the collected data is parsed through the interface to generate parsed data, and the parsed data is inserted into the data table for the day;

[0057] Specifically, step S102 includes: defining the corresponding PLC protocol by mapping the first interface body;

[0058] The collected data is parsed through the second interface to generate parsed data;

[0059] Display the show_stat thread corresponding to the parsed data on the web status page;

[0060] The third interface is called to query the corresponding data table for the current day from the database DB, and the parsed data is inserted into the data table for the current day.

[0061] Specifically, in this embodiment, the gateway maps the corresponding PLC protocol through the defined plc_services interface body. For example, collecting Modbus RTU protocol data will trigger the plc_mgmt_write interface to configure the collection parameters, and the mdbs_cmd_node_read interface to perform frame collection. After the collected data is parsed through the mdbs_data_parsing interface, it is displayed on the web status page by the show_stat thread. At the same time, the sqlite_write_history_data_table interface is called to retrieve the data table for the current date from the already created database and insert the current data.

[0062] S103, when it is determined that the reporting thread callback trigger period has been reached, the message group is searched and reported, wherein the message group consists of recent data records within a preset period in the database DB;

[0063] Specifically, step S103 includes: creating a data linked list through the fourth interface, and extracting all data IDs that need to be reported from the linked list nodes of the data linked list;

[0064] The data ID and the current absolute timestamp are used as key-value pairs to match the data in the data table for that day. The filtered data is fed back into a complete record and then packaged to generate a message packet.

[0065] Specifically, in this embodiment, after the callback trigger period of the reporting thread connected via MQTT is reached, the `sqlite_read_history_data_table` interface is called to find the most recent data records and assemble them into a JSON message for reporting. This part uses a data linked list created by `list_for_each_safe`. All data IDs that need to be reported are extracted from the linked list nodes, and then matched against the current absolute timestamp as key-value pairs in the SQLite form. The selected data is then fed back as a complete record for packet assembly.

[0066] S104, when it is determined that the message packet is valid and the communication with the docking platform is abnormal, the message packet is stored in the cache table in the database DB;

[0067] In one possible embodiment of the present invention, after storing the message packet in the cache table in the database DB when it is determined that the message packet is valid and the communication with the docking platform is abnormal, the method further includes: when it is determined that the communication with the docking platform is reconnected, calling the third interface to find all the unreported data in the cache table during the disconnection period, and reporting them to the docking platform one by one.

[0068] Specifically, in this embodiment, after determining the validity of the packet, the determination is made through the sending interface, such as send_json. If the communication with the platform is not normal at present, such as in the case of disconnection, the current packet is stored in another cache table FF_BKDATA_TX in the database (X is the sequence number of different data centers 1, 2, 3...). After reconnecting to the platform, the interruption resume transmission will be triggered. Similarly, the sqlite_read_history_data_table interface is called to find all the unreported records during the disconnection period and report them one by one.

[0069] S105, when it is determined that the message packet is valid and the communication with the docking platform is normal, the message packet is sent to the docking platform.

[0070] In one possible embodiment of the present invention, after sending the message packet to the docking platform when it is determined that the message packet is valid and the communication with the docking platform is normal, the method further includes: when it is determined that there is a problem with the sending of the message packet, storing the failed message in the cache table in the database DB.

[0071] When communication with the docking platform is re-established, the third interface is invoked to find all unreported data in the cache table during the disconnection period, and each data item is reported to the docking platform.

[0072] Specifically, in this embodiment, after determining the validity of the packet, the sending interface, such as send_json, is used to determine if the communication with the platform is normal. If so, the mosquitto_publish interface will be called to send the packet directly. If a problem occurs during sending, it usually triggers an active disconnection, which is done through the disconnect_callback_v25 callback interface. Then, the failed sending message is stored in the database, and the disconnection and reconnection mechanism is also used for processing.

[0073] In summary, the intelligent gateway data storage deployment method primarily addresses the platform's need to acquire historical data over a specific period. However, due to storage space constraints, careful configuration of storage time periods and handling of used capacity release are crucial, including periodically deleting, transferring, and compressing old data. The key to this method is improving data efficiency. It utilizes an SQLite database for storage, whereas existing technologies store data via text. The differences are as follows: First, database storage is convenient and stable, eliminating the need for redundant operations for each storage operation. It only requires calling pre-processed interfaces and SQLite commands. The intelligent gateway data storage deployment method, however, requires numerous specific processing steps depending on customer needs, which is time-consuming and prone to errors. Second, database storage is highly efficient and accurate for adding, deleting, and modifying individual or batches of data. For example, retrieving a single data entry from 1GB of data in a database takes only nanoseconds, while the intelligent gateway data storage deployment method requires tens of seconds – a significant difference. Third, data stored in a database is less prone to loss and easier to transfer. Conversely, the intelligent gateway data storage deployment method is susceptible to data loss if synchronization is not properly handled; a single anomaly can lead to the loss of a large amount of data.

[0074] In short, the intelligent gateway data storage deployment method can structurally store large amounts of PLC centralized procurement data, facilitating effective retrieval and access for users. It allows for data classification and storage, providing fast query capabilities. Furthermore, it effectively maintains data consistency and integrity, reduces data redundancy, and the data stored in the SQLite database ensures data validity and prevents corruption. The database itself also has a function to avoid duplicate data, further reducing redundancy. Simultaneously, it meets the sharing and security requirements of applications. Storing data in a database is often for security reasons. For example, if all data from different users were stored on disk files, the confidentiality of certain security organizations would be compromised. Storing data in a database allows querying and modifying only the data of a specific user, thus ensuring data security.

[0075] Please see Figure 4 A second embodiment of the present invention provides a smart gateway data storage deployment device, comprising:

[0076] The data acquisition unit 201 is used to start the main thread and three sub-threads when the gateway process starts, to obtain the data table of the day in the database DB, configure the acquisition protocol, and trigger the gateway to perform the acquisition task.

[0077] The data insertion unit 202 is used to parse the collected data through an interface, generate parsed data, and insert the parsed data into the data table for the day.

[0078] The message generation unit 203 is used to search for and report a message group after it is determined that the reporting thread callback trigger period has been reached. The message group consists of recent data records in the database DB within a preset period.

[0079] The message caching unit 204 is used to store the message packet in the cache table of the database DB when it is determined that the message packet is valid and the communication with the docking platform is abnormal.

[0080] The message sending unit 205 is used to send the message packet to the docking platform when it is determined that the message packet is valid and the communication with the docking platform is normal.

[0081] A third embodiment of the present invention provides a smart gateway data storage deployment device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a smart gateway data storage deployment method as described in any of the above embodiments.

[0082] The fourth embodiment of the present invention provides a readable storage medium storing a computer program, which can be executed by the processor of the device where the storage medium is located to implement a smart gateway data storage deployment method as described in any of the above embodiments.

[0083] Exemplary examples show that the computer program described in the third and fourth embodiments of the present invention can be divided into one or more modules, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in implementing a smart gateway data storage deployment device. For example, the apparatus described in the second embodiment of the present invention.

[0084] The processor referred to can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the intelligent gateway data storage deployment method, connecting various parts of the method via various interfaces and lines.

[0085] The memory can be used to store the computer programs and / or modules. The processor, by running or executing the computer programs and / or modules stored in the memory and calling the data stored in the memory, implements various functions of a smart gateway data storage deployment method. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, text conversion function, etc.), etc.; the data storage area may store data created based on the use of the mobile phone (such as audio data, text message data, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital card (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0086] If the implemented module is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0087] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0088] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions that fall within the scope of the present invention are within the scope of protection of the present invention.

Claims

1. A method for deploying data storage in a smart gateway, characterized in that, include: When the gateway process starts, it initiates a main thread and three sub-threads: a configuration thread, a data collection thread, and a display thread. The main thread handles reporting to the platform, the configuration thread performs automated operations, and the data collection and display threads perform database read / write operations, retrieving the current day's data from the database (DB), configuring the data collection protocol, and triggering the gateway to perform the data collection task. Specifically: If the database DB does not exist in the storage device, then the database DB will be created. If the database DB exists in the storage device, check if the data table for the current day exists. If not, create a data table for the current day and set a timer inside the infinite loop of the display thread. When the timer expires, a new data table for the current day is automatically created, and when the number of data tables reaches a preset value, the data table with the earliest date is deleted. Configure the data acquisition protocol to trigger the gateway to perform the data acquisition task, where the data ID of the register data is used as a unique identifier; The collected data is parsed through an interface to generate parsed data, and the parsed data is then inserted into the data table for that day. Once the callback trigger period for the reporting thread is determined to have expired, a message packet is retrieved and reported. This message packet consists of recent data records from the database DB within a preset period, specifically: A data linked list is created through the fourth interface, and all data IDs that need to be reported are extracted from the linked list nodes of the data linked list; The data ID and the current absolute timestamp are used as key-value pairs to match the data table of the day. The filtered data is fed back into a complete record and then packaged to generate a message packet. When it is determined that the message packet is valid but the communication with the docking platform is abnormal, the message packet is stored in the cache table in the database DB. When it is determined that the message packet is valid and the communication with the docking platform is normal, the message packet is sent to the docking platform.

2. The smart gateway data storage deployment method according to claim 1, characterized in that, The collected data is parsed through an interface to generate parsed data, which is then inserted into the data table for that day. Specifically: The PLC protocol is mapped by defining the first interface body; The collected data is parsed through the second interface to generate parsed data; Display the show_stat thread corresponding to the parsed data on the web status page; The third interface is called to query the corresponding data table for the current day from the database DB, and the parsed data is inserted into the data table for the current day.

3. The intelligent gateway data storage deployment method according to claim 2, characterized in that, When it is determined that the message packet is valid but communication with the docking platform is abnormal, after storing the message packet in the cache table in the database DB, the process further includes: When it is determined that communication with the docking platform has been re-established, the third interface is invoked to search for all unreported data in the cache table during the disconnection period, and each data item is reported to the docking platform.

4. The smart gateway data storage deployment method according to claim 3, characterized in that, After determining that the message packet is valid and communication with the docking platform is normal, and sending the message packet to the docking platform, the process further includes: When it is determined that there is a problem in sending the message group packet, the failed message is stored in the cache table in the database DB; When communication with the docking platform is re-established, the third interface is invoked to find all unreported data in the cache table during the disconnection period, and each data item is reported to the docking platform.

5. A smart gateway data storage deployment device, characterized in that, include: The data acquisition unit is used to start a main thread and three sub-threads when the gateway process starts. The three sub-threads are a configuration thread, an acquisition thread, and a display thread. The main thread is used for reporting to the platform, the configuration thread is used for automation, and the acquisition and display threads are used for database read / write operations, retrieving the current day's data table from the database (DB), configuring the acquisition protocol, and triggering the gateway to perform the acquisition task. Specifically: If the database DB does not exist in the storage device, then the database DB will be created. If the database DB exists in the storage device, check if the data table for the current day exists. If not, create a data table for the current day and set a timer inside the infinite loop of the display thread. When the timer expires, a new data table for the current day is automatically created, and when the number of data tables reaches a preset value, the data table with the earliest date is deleted. Configure the data acquisition protocol to trigger the gateway to perform the data acquisition task, where the data ID of the register data is used as a unique identifier; The data insertion unit is used to parse the collected data through an interface, generate parsed data, and insert the parsed data into the data table for the current day. The message generation unit is used to retrieve and report a message packet after determining that the callback trigger period of the reporting thread has been reached. The message packet consists of recent data records within a preset period in the database DB. Specifically: A data linked list is created through the fourth interface, and all data IDs that need to be reported are extracted from the linked list nodes of the data linked list; The data ID and the current absolute timestamp are used as key-value pairs to match the data table of the day. The filtered data is fed back into a complete record and then packaged to generate a message packet. The message caching unit is used to store the message packet in the cache table of the database DB when it is determined that the message packet is valid and the communication with the docking platform is abnormal. The message sending unit is used to send the message packet to the docking platform when it is determined that the message packet is valid and the communication with the docking platform is normal.

6. A smart gateway data storage deployment device, characterized in that, The device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement a smart gateway data storage deployment method as described in any one of claims 1 to 4.

7. A readable storage medium, characterized in that, The storage medium contains a computer program that can be executed by the processor of the device where the storage medium is located, to implement a smart gateway data storage deployment method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Industrial gateway data supplemental reporting method and industrial gateway

    CN109347942A

  • Performance data storage method and system for storage area network equipment

    CN110456986A