Wireless gun communication data backup method and device and storage medium
By using an adaptive compression algorithm and the mapping relationship between the target workpiece serial number and the cache group number, the problem of data storage and retransmission of lithium battery wireless guns in complex electromagnetic interference environments was solved, realizing complete data storage and orderly retransmission, and ensuring transparent management and quality traceability of the production process.
Patent Information
- Application Number
- CN202610464082.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-09
- Publication Date
- 2026-06-26
Smart Images

Figure CN122294096A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data backup technology, and in particular to a method, apparatus and storage medium for wireless gun communication data backup. Background Technology
[0002] Lithium-ion battery-operated wireless bolt tightening guns are key tools in modern assembly lines, widely used in bolt tightening operations in industries such as automotive manufacturing and 3C electronics. To meet the needs of real-time monitoring and end-to-end data traceability in the production process, lithium-ion battery-operated wireless bolt tightening guns typically establish a wireless communication link with a host computer via a Wi-Fi module. This transmits waveform data such as torque and angle generated during the tightening process, as well as tightening result data, to the host computer in real time, enabling transparent management and quality traceability of the production process.
[0003] In actual workshop operations, lithium battery wireless guns typically communicate wirelessly with host computers within a 10-meter range. Initial solutions often use 2.4GHz Wi-Fi modules to establish the communication link. However, the workshop environment presents complex sources of electromagnetic interference, including: radio frequency interference from mobile phones, computers, and other devices; network bandwidth contention caused by multiple devices operating concurrently; electromagnetic and noise interference from production equipment such as motors; and the obstruction and absorption of wireless signals by dense crowds. These interference factors lead to frequent communication anomalies in 2.4GHz Wi-Fi communication within the workshop environment. Specifically, this manifests as: frequent TCP (Transmission Control Protocol) connection interruptions, particularly noticeable during peak periods of concentrated equipment operation; and data frame loss, preventing the host computer from fully receiving the tightening data transmitted by the lithium battery wireless gun, resulting in gaps in production process monitoring and incomplete data traceability chains.
[0004] To avoid the dense interference of the 2.4GHz band, existing technologies attempt to migrate the Wi-Fi module's communication frequency band to the 5GHz band, supplemented by an external gain antenna to improve signal strength. Experimental data shows that the above hardware optimization measures can significantly reduce the packet loss rate and disconnection rate of data transmission. However, in extremely harsh network environments where residual interference such as motor electromagnetic interference and radio frequency interference exists, there is still a residual risk of TCP connection interruption and data frame loss. Once communication is interrupted, the tightening data collected in real time by the lithium battery wireless gun cannot be transmitted to the host computer in time, directly leading to interruption of production monitoring and loss of data traceability.
[0005] Furthermore, the control chip for lithium-ion wireless guns (such as the STM32F411) is limited to only 128k SRAM (Static Random-Access Memory). Simply using data caching to handle communication interruptions can easily lead to memory overflow; without caching, data integrity in extreme scenarios cannot be guaranteed. Simultaneously, if cached data is resent out of order after TCP reconnection, it can easily cause data corruption, affecting the accuracy of data traceability. Moreover, if the resending process is not properly coordinated with the production schedule, it may lead to delays in the transmission of subsequent real-time production data. Therefore, how to achieve complete data storage during communication interruptions and orderly resending after reconnection, ensuring data traceability integrity, has become an urgent technical problem to be solved. Summary of the Invention
[0006] This application provides a wireless gun communication data backup method, device, and storage medium to achieve complete data storage during communication interruption and orderly retransmission after reconnection, ensuring data traceability and integrity.
[0007] In a first aspect, this application provides a method for backing up wireless gun communication data, the method comprising: In the event of a TCP interruption, the dynamic waveform data is adaptively compressed to generate compressed waveform data. The compressed waveform data and the static result data are stored in the corresponding backup cache, and the dynamic waveform data and the static result data in the original cache are cleared. Based on the compressed waveform data and the static result data, a storage mapping relationship between the target workpiece number and the cache group number is established, and based on the storage mapping relationship, the compressed waveform data and the static result data are respectively allocated to the preset cache groups in the backup cache area; In the case of TCP reconnection, the data retransmission order is determined according to the storage mapping relationship, and the compressed waveform data and the static result data are read from each of the preset cache groups based on the data retransmission order, and the compressed waveform data and the static result data are uploaded to the host computer. The dynamic waveform data refers to the waveform data collected during the operation of the target workpiece by the wireless gun, and the static result data refers to the result data collected after the operation of the target workpiece by the wireless gun is completed.
[0008] Secondly, this application also provides a wireless gun communication data backup device, the device comprising: The layered cache backup module is used to adaptively compress dynamic waveform data to generate compressed waveform data in the event of a TCP interruption, store the compressed waveform data and static result data in the corresponding backup cache area, and clear the dynamic waveform data and static result data in the original cache area. The mapping storage module is used to establish a storage mapping relationship between the target workpiece number and the cache group number based on the compressed waveform data and the static result data, and to allocate the compressed waveform data and the static result data to the preset cache groups in the backup cache area based on the storage mapping relationship. The data retransmission module is used to determine the data retransmission order according to the storage mapping relationship in the case of TCP reconnection, and read the compressed waveform data and the static result data from each of the preset cache groups based on the data retransmission order, and upload the compressed waveform data and the static result data to the host computer.
[0009] Thirdly, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to implement the wireless gun communication data backup method described above.
[0010] This application discloses a method, apparatus, and storage medium for backing up wireless gun communication data. The method includes: in the event of a TCP interruption, adaptively compressing dynamic waveform data to generate compressed waveform data; storing the compressed waveform data and static result data in a corresponding backup buffer; and clearing the dynamic waveform data and static result data from the original buffer; establishing a storage mapping relationship between the target workpiece sequence number and the buffer group number based on the compressed waveform data and the static result data; and allocating the compressed waveform data and the static result data to preset buffer groups in the backup buffer based on the storage mapping relationship; in the event of TCP reconnection, determining the data retransmission order based on the storage mapping relationship; reading the compressed waveform data and the static result data from each preset buffer group based on the data retransmission order; and uploading the compressed waveform data and the static result data to a host computer; wherein the dynamic waveform data is waveform data collected during the operation of the target workpiece by the wireless gun, and the static result data is result data collected after the operation of the target workpiece by the wireless gun is completed. By employing an adaptive compression algorithm to compress waveform data during TCP disconnection, this application addresses the memory overflow issue and improves access efficiency by establishing a mapping between workpiece sequence numbers and cache group numbers. After TCP reconnection, the retransmission order is determined based on the mapping relationship, and data is retransmitted in this order, achieving complete data storage during communication interruption and orderly retransmission after reconnection, thus ensuring data traceability and integrity. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic flowchart illustrating a wireless gun communication data backup method provided in an embodiment of this application; Figure 2 A schematic block diagram of a wireless gun communication data backup device provided for embodiments of this application; Figure 3 A schematic block diagram of the structure of a computer device provided for an embodiment of this application. Detailed Implementation
[0013] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0014] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.
[0015] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0016] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0017] This application provides a method, apparatus, and storage medium for backing up wireless gun communication data. The method can be applied to servers. By employing an adaptive compression algorithm to compress waveform data during TCP disconnection, it solves the memory overflow problem. Furthermore, by establishing a mapping relationship between workpiece sequence numbers and cache group numbers, it improves access efficiency. After TCP reconnection, the retransmission order is determined based on the mapping relationship, and data is retransmitted in this order. This achieves complete data storage during communication interruption and orderly retransmission after reconnection, ensuring data traceability and integrity.
[0018] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0019] Please see Figure 1 , Figure 1 This is a schematic flowchart illustrating a wireless gun communication data backup method provided in an embodiment of this application. This wireless gun communication data backup method can be applied to a server to achieve complete data storage during communication interruptions and orderly retransmission after reconnection, ensuring data traceability and integrity.
[0020] like Figure 1 As shown, the wireless gun communication data backup method specifically includes steps S10 to S30.
[0021] Step S10: In the event of a TCP interruption, the dynamic waveform data is adaptively compressed to generate compressed waveform data. The compressed waveform data and the static result data are stored in the corresponding backup cache area, and the dynamic waveform data and the static result data in the original cache area are cleared. This embodiment uses a lithium-ion battery-powered wireless screwdriver as an application scenario in the complex electromagnetic environment of a workshop. The control chip for the wireless screwdriver is an STM32F411 (with built-in 128k SRAM), which communicates with the host computer via a 5G band Wi-Fi module and an external IPEX antenna. During production, each screw tightening completes a set of operations, generating corresponding dynamic waveform data (one point is collected every 3ms during tightening, dual-channel, for a total of 2000 raw points) and static result data (including 31 parameters such as torque value, pass status, and tightening time, with a volume of 62 bytes). The screw number starts from 0 and increments, cycling to 255 before rewinding.
[0022] It should be noted that all the values involved in this embodiment are for illustrative purposes only and do not constitute any limitation on the corresponding technical features.
[0023] Specifically, the wireless gun collects dynamic waveform data in real time during the tightening process. Every 100 consecutive waveform points generated (taking 300ms) triggers a write operation, temporarily storing the data in the original buffer area, which has a storage space of 2 channels × 10k points.
[0024] After a set of screws is tightened, the complete dynamic waveform data for that set is acquired (original number of points N=2000). Adaptive compression is then performed: the extraction interval is determined based on the original number of points. Since the original number of points exceeds 625 but does not exceed 1250, it is set to extract one point every other point, i.e., retaining one point out of every two points. This results in 2 channels × 500 compressed waveform points, preserving the main characteristics of the waveform while compressing the data volume.
[0025] After compression, the compressed waveform data is migrated to the waveform compression backup area in the backup cache. At the same time, the static result data generated after the group is tightened is written to the original cache all at once and immediately backed up to the result backup area in the backup cache.
[0026] Clear the dynamic waveform data and static result data of this group of data in the original buffer area to free up space for the data acquisition of subsequent groups. Subsequent groups (such as groups 99 to 105) are processed in the same way to ensure that all data during the disconnection period is stored completely.
[0027] Step S20: Establish a storage mapping relationship between the target workpiece number and the cache group number based on the compressed waveform data and the static result data, and allocate the compressed waveform data and the static result data to the preset cache groups in the backup cache area based on the storage mapping relationship; Specifically, the backup cache area pre-defines 14 cache groups (group numbers 0-13) for waveform data and 30 cache groups (group numbers 0-29) for result data. For each group of compressed waveform data, the target cache group number is calculated based on its screw serial number and G1=n mod K1 and G2=n mod K2. This is done by dividing the screw serial number (target workpiece serial number) by 14 and taking the remainder; the remainder is the group number where the waveform data should be stored. Similarly, for static result data, the group number where the result data should be stored is obtained by dividing the screw serial number by 30 and taking the remainder.
[0028] Taking screws in groups 98 to 105 as an example: Group 98: Waveform group number = 98 divided by 14 with a remainder of 0, stored in waveform group 0; Result group number = 98 divided by 30 with a remainder of 8, stored in result group 8.
[0029] Group 99: Waveform group number = 1, store in waveform group 1; Result group number = 9, store in result group 9.
[0030] Group 100: Waveform group number = 2, store in waveform group 2; Result group number = 10, store in result group 10.
[0031] Group 101: Waveform group number = 3, store in waveform group 3; Result group number = 11, store in result group 11.
[0032] Group 102: Waveform group number = 4, store in waveform group 4; Result group number = 12, store in result group 12.
[0033] Group 103: Waveform group number = 5, store in waveform group 5; Result group number = 13, store in result group 13.
[0034] Group 104: Waveform group number = 6, store in waveform group 6; Result group number = 14, store in result group 14.
[0035] Group 105: Waveform group number = 7, store in waveform group 7; Result group number = 15, store in result group 15.
[0036] In another embodiment, the compression waveform data of the 100th screw is stored in waveform buffer group 2 (because 100 mod 14 = 2), and its result data is stored in result buffer group 10 (because 100 mod 30 = 10).
[0037] Through the above mapping, all disconnected data is precisely allocated to the designated cache group according to the screw number. Each group of data has a unique corresponding storage location, which not only avoids data confusion, but also lays the foundation for fast subsequent reading.
[0038] Step S30: In the case of TCP reconnection, determine the data retransmission order according to the storage mapping relationship, and read the compressed waveform data and the static result data from each of the preset cache groups based on the data retransmission order, and upload the compressed waveform data and the static result data to the host computer. The dynamic waveform data refers to the waveform data collected during the operation of the target workpiece by the wireless gun, and the static result data refers to the result data collected after the operation of the target workpiece by the wireless gun is completed.
[0039] Specifically, once the electromagnetic interference in the workshop decreases and the TCP connection is successfully reconnected, the data retransmission process is initiated to ensure that the data during the disconnection period is uploaded to the host computer in ascending order of screw serial number and seamlessly integrated with real-time production data.
[0040] The latest data recorded in the waveform backup area is read, and the waveform data of the most recently completed group of screws (group 105) is stored in group 7. According to the storage mapping relationship, group 7 corresponds to the latest data, so the retransmission order should be: first retransmit the subsequent groups (groups 8 to 13), then retransmit the previous groups (groups 0 to 6), and finally retransmit the current group (group 7). The specific order is: 8→9→10→11→12→13→0→1→2→3→4→5→6→7. Following the above order, all data from groups 98 to 105 are sent sequentially. The screw sequence numbers received by the host computer are 98, 99, 100, 101, 102, 103, 104, and 105, which is completely consistent with the production sequence. The waveform data and the result data correspond one-to-one, without any errors or losses.
[0041] Once the replacement is completed, immediately switch to normal production mode to continue transmitting the 106th set of real-time tightening data and subsequent sets. This embodiment discloses a method, apparatus, and storage medium for backing up wireless gun communication data. The method includes: in the event of a TCP (Transmission Control Protocol) interruption, adaptively compressing dynamic waveform data to generate compressed waveform data; storing the compressed waveform data and static result data in a corresponding backup buffer; and clearing the dynamic waveform data and static result data from the original buffer. A storage mapping relationship between the target workpiece sequence number and the buffer group number is established based on the compressed waveform data and the static result data, and the compressed waveform data and the static result data are allocated to preset buffer groups in the backup buffer based on the storage mapping relationship. In the event of TCP reconnection, the data retransmission order is determined according to the storage mapping relationship, and the compressed waveform data and the static result data are read from each of the preset buffer groups based on the data retransmission order, and then uploaded to a host computer. Through this method, this application solves the memory overflow problem by using an adaptive compression algorithm to compress waveform data when TCP is disconnected, and improves access efficiency by establishing a mapping relationship between the workpiece sequence number and the buffer group number. After TCP reconnection, the retransmission order is determined based on the mapping relationship, and data is retransmitted in the retransmission order. This achieves complete data storage during communication interruption and orderly retransmission after reconnection, ensuring data traceability and integrity.
[0042] based on Figure 1 In the illustrated embodiment, step S10 includes: Obtain the number of original waveform points in the dynamic waveform data; The compression step size is calculated based on the number of points in the original waveform according to the preset compression step size formula; The dynamic waveform data is adaptively compressed according to the compression step size to generate the compressed waveform data.
[0043] Specifically, after a set of screw tightening operations are completed, the number of original acquisition points for the set of dynamic waveform data is determined. The wireless gun continuously acquires waveform data from the start to the end of tightening. The sampling frequency of each channel is fixed at one point every 3ms. The number of original waveform points N for the set is obtained by recording the start and end times or by directly counting the number of waveform points stored in the buffer.
[0044] Taking this embodiment as an example, the tightening process lasts for 6 seconds and the sampling interval is 3ms. Therefore, the number of original points in a single channel is 6000ms÷3ms=2000 points, and the total number of points in the dual channels is 4000 points. Therefore, N=2000 is used as the input parameter for subsequent compression calculation.
[0045] In a specific embodiment, the preset compression step size formula is: Where N is the number of original waveform points, the backup buffer corresponding to the compressed waveform data is a compressed backup area, and M is the single-channel storage capacity threshold of the compressed backup area. This is for rounding up.
[0046] Specifically, based on the preset compression step size formula The compression step size is determined by the target number of compression points (e.g., 625 points per channel). The rules for determining the compression step size are as follows: First, determine the relationship between N and 625. If N does not exceed 625, it means that the original data volume is within the storage capacity and no compression is needed, so the step size is 1; if N exceeds 625, then determine the step size according to the multiple relationship to ensure that the number of points after compression does not exceed 625.
[0047] The specific judgment logic is as follows: When N is between 626 and 1250, the compression step size is 2, that is, 1 point is extracted from every 2 points; When N is between 1251 and 2500, the compression step size is 4, that is, 1 point is extracted from every 4 points, and so on.
[0048] In this embodiment, N=2000, which is in the range of 1251 to 2500. Therefore, the compression step size is determined to be 4, that is, in every 4 consecutive original waveform points, only the first point is retained and the other 3 points are discarded.
[0049] After determining the compression step size to be 4, for each channel, starting from the first waveform point, one point is collected every 4 points, that is, the waveform data at positions 1, 5, 9, 13, etc. are retained. The original 2000 points are compressed into 500 points (2000÷4=500), which is exactly suitable for the storage capacity of 625 points per channel in the compressed backup area.
[0050] During compression, data from both channels is processed simultaneously to ensure a one-to-one correspondence between waveform points in each channel. After compression, 500 compressed waveform points are generated for each channel, with each point retaining its original data format (e.g., 2 bytes representing a value). The two sets of compressed waveform data (a total of 1000 points, approximately 2000 bytes, across both channels) are used as a complete compressed waveform dataset, ready to be migrated to the backup cache.
[0051] based on Figure 1 In the illustrated embodiment, step S20 includes: The target workpiece number is obtained based on the compressed waveform data and the static result data; The cache group number is determined by a preset modulus calculation formula and the serial number of each target workpiece, and a storage mapping relationship is established between the cache group number and the serial number of the target workpiece. According to the storage mapping relationship, the compressed waveform data and the static result data are allocated to the preset cache group corresponding to the cache group number of the target workpiece number.
[0052] The preset modulo operation formula includes a waveform modulo operation formula and a result modulo operation formula. The waveform modulo operation formula is G1=n mod K1, and the result modulo operation formula is G2=n mod K2. G1 is the cache group number corresponding to the compressed waveform data, G2 is the cache group number corresponding to the static result data, K1 is the number of preset cache groups corresponding to the compressed waveform data, and K2 is the number of preset cache groups corresponding to the static result data.
[0053] Specifically, after a single set of screw tightening operations is completed and compressed waveform data and static result data are generated, the target workpiece number (i.e., screw number) n corresponding to that set of data is obtained. This number is a unique identifier generated by the wireless gun during continuous operation, with a value range of 0 to 255. After every 255 screws are tightened, the count automatically wraps back to 0 and restarts.
[0054] For compressed waveform data, the waveform backup buffer has a total of K1=14 buffer groups (group numbers 0-13). Substituting the target workpiece number n into the waveform modulus calculation formula G1=n mod 14, the buffer group number G1 corresponding to this group of compressed waveform data is calculated.
[0055] For static result data, the result backup cache has K2=30 cache groups (group numbers 0-29). Substitute the target workpiece number n into the result modulo operation formula G2=n mod 30 to calculate the cache group number G2 corresponding to this group of static result data.
[0056] The compressed waveform data is written to the preset cache group G1 in the waveform compression backup area. For example, if the target workpiece number n=100, then G1=100 mod 14=2, that is, the compressed waveform data of the 100th screw is stored in waveform cache group 2.
[0057] The static result data is written to the preset cache group with group number G2 in the result backup cache area. For example, if the target workpiece number n=100, then G2=100 mod 30=10, that is, the static result data of the 100th screw is stored in the result cache group 10.
[0058] based on Figure 1 In the illustrated embodiment, step S30 includes: Obtain the latest waveform cache group number of the latest set of compressed waveform data and the latest result cache group number of the latest set of static result data in the backup cache area, respectively; The order of data retransmission for the compressed waveform data is determined based on the latest waveform cache group number and the preset fixed mapping table, and the order of data retransmission for the static result data is determined based on the latest result cache group number and the preset fixed mapping table.
[0059] Specifically, taking this embodiment as an example, during the disconnection period, screw operations for groups 98 to 105 are completed, with the latest group being group 105. According to the storage mapping relationship: the compressed waveform data for group 105 is stored in waveform cache group 7 (105 mod 14 = 7), and the static result data is stored in result cache group 15 (105 mod 30 = 15). Therefore, the latest waveform cache group number is 7, and the latest result cache group number is 15.
[0060] In a specific embodiment, before determining the data resending order of the compressed waveform data according to the latest waveform cache group number and the preset fixed mapping table, and before determining the data resending order of the static result data according to the latest result cache group number and the preset fixed mapping table, the process includes: The preset cache group with a group number greater than the latest result cache group number is designated as the subsequent cache group, the preset cache group with a group number less than the latest result cache group number is designated as the preceding cache group, and the preset cache group corresponding to the latest result cache group number is designated as the current cache group. Set the priority of the subsequent cache group to high, the priority of the previous cache group to low, and the priority of the current cache group to medium to determine the preset fixed mapping table.
[0061] Specifically, the design of the solidified mapping table is based on the cyclical nature of the storage mapping relationship: first, all subsequent groups after the latest group number are reissued, then all previous preceding groups are reissued, and finally the current group itself is reissued, so as to ensure that the workpiece serial numbers corresponding to the read data are arranged in ascending order.
[0062] The waveform backup area has 14 cache groups (group numbers 0-13). The latest waveform cache group number is 7. According to the fixed mapping table, the retransmission order corresponding to group number 7 is: 8→9→10→11→12→13→0→1→2→3→4→5→6→7 The rules for determining this order are as follows: 1. List all subsequent group numbers (8 to 13) greater than 7, sorted in ascending order; 2. List all prefix numbers less than 7 (0 to 6), sorted in ascending order; 3. List the current group number 7 itself.
[0063] Since the actual data storage group numbers during the disconnection period are 0 to 7 (corresponding to workpiece serial numbers 98 to 105), when reading in the above order, the actual data groups are 0, 1, 2, 3, 4, 5, 6, 7, corresponding to workpiece serial numbers 98, 99, 100, 101, 102, 103, 104, 105.
[0064] The backup area has 30 cache groups (group numbers 0-29). The latest result cache group number is 15. According to the same fixed mapping table rules, the reissue order corresponding to group number 15 is: 16→17→...→29→0→1→2→...→14→15.
[0065] Specifically, the subsequent groups 16 to 29 are reissued first, followed by the preceding groups 0 to 14, and finally the current group 15. During the disconnection period, the result data of groups 98 to 105 are stored in result groups 8 to 15. When reading in this order, the groups with actual data are 8, 9, 10, 11, 12, 13, 14, and 15 (corresponding to workpiece numbers 98 to 105).
[0066] In a specific embodiment, step S30 further includes: The compressed waveform data is read from the backup cache according to the data resending order; The compressed waveform data is divided into at least one data block according to a preset block division rule, and data header identification information is added to each data block. Each data block containing the data header identification information is uploaded to the host computer.
[0067] Specifically, to improve transmission reliability and avoid timeouts or failures that may occur during the single transmission of large amounts of data, each set of compressed waveform data is divided into blocks and encapsulated before transmission. A basic data block consists of 500 waveform points (for dual-channel data, this means 500 points per channel, totaling 1000 points; the specific block threshold can be adjusted based on the actual storage structure). If the total number of points (single-channel points) in a set of compressed waveform data does not exceed 500 points, it is considered a complete data block and does not need to be split. If the total number of points in the compressed waveform data exceeds 500 (e.g., 625 points after compression), it is split into multiple data blocks: the first data block contains the first 500 points, the second data block contains the remaining 125 points, and so on. For each split data block, the system adds a preset header identifier to the beginning of the data block. The header identifier is a fixed two-byte field "AA 55" (hexadecimal), used by the host computer to identify the starting position and type of the data block.
[0068] In a specific embodiment, after uploading each data block containing the data header identification information to the host computer, the process includes: Read the static result data corresponding to the compressed waveform data that has been uploaded to the host computer from the backup cache as the result data to be uploaded; According to the preset merging rules, the data to be uploaded are merged into at least one merged result data packet, and a data header identifier is added to each merged result data packet before uploading it to the host computer.
[0069] Specifically, for the currently processed cache group (e.g., waveform cache group 8), the system first determines the target workpiece number (screw number) n corresponding to the compressed waveform data in that group. Since there is a mapping relationship G1 = n mod 14 between the waveform cache group number and the workpiece number, one or more workpiece numbers corresponding to the current group can be obtained through reverse lookup or record lookup. For example, waveform cache group 8 may store screw data with workpiece numbers 8, 22, 36… etc., satisfying n mod 14 = 8.
[0070] Based on the determined workpiece number n, substitute it into the result data storage mapping formula G2=n mod 30 to calculate the result cache group number corresponding to the workpiece number. Locate the preset cache group with group number G2 in the result backup cache area, and read the static result data stored in this group (including 31 parameters such as torque value, qualified status, tightening time, etc., totaling 62 bytes) as the result data to be uploaded.
[0071] Multiple sets of data to be uploaded are packaged using preset merging rules to improve transmission efficiency and reduce TCP link occupancy time. Multiple consecutive sets of static data are merged into a single data packet. The maximum number of merged groups can be set to 10, which avoids transmission timeouts caused by excessively large single packets and effectively reduces the number of small packets.
[0072] Following the order of the remaining cache groups to be uploaded in the current resend sequence, the corresponding static result data is read sequentially and temporarily stored in the merge buffer. When the number of result data groups in the merge buffer reaches 10, or when the total number of remaining result data groups in the current resend sequence is less than 10, the merge packet generation operation is triggered. For the generated merge result data packet, preset header identification information is added to the header of the data packet, and the merge result data packet with the added header identification is uploaded to the host computer through the reconnected TCP connection.
[0073] Please see Figure 2 , Figure 2 This is a schematic block diagram of a wireless gun communication data backup device provided in an embodiment of this application. This wireless gun communication data backup device is used to execute the aforementioned wireless gun communication data backup method. The wireless gun communication data backup device can be configured on a server.
[0074] like Figure 2 As shown, the wireless gun communication data backup device 400 includes: The layered cache backup module 410 is used to adaptively compress dynamic waveform data to generate compressed waveform data in the event of a TCP interruption, store the compressed waveform data and static result data in the corresponding backup cache area, and clear the dynamic waveform data and static result data in the original cache area. The mapping storage module 420 is used to establish a storage mapping relationship between the target workpiece number and the cache group number based on the compressed waveform data and the static result data, and to allocate the compressed waveform data and the static result data to the preset cache groups in the backup cache area based on the storage mapping relationship. The data retransmission module 430 is used to determine the data retransmission order according to the storage mapping relationship in the case of TCP reconnection, and read the compressed waveform data and the static result data from each of the preset cache groups based on the data retransmission order, and upload the compressed waveform data and the static result data to the host computer.
[0075] Furthermore, the tiered cache backup module 410 includes: The original waveform point acquisition unit is used to acquire the original waveform point count in the dynamic waveform data; The compression step size calculation unit is used to calculate the compression step size based on the number of points of the original waveform according to a preset compression step size formula. The compressed waveform data generation unit is used to adaptively compress the dynamic waveform data according to the compression step size to generate the compressed waveform data.
[0076] Furthermore, the mapping storage module 420 includes: The target workpiece serial number acquisition unit is used to acquire the target workpiece serial number based on the compressed waveform data and the static result data; The storage mapping relationship establishment unit is used to determine the cache group number by means of a preset modulo operation formula and the serial number of each target workpiece, and to establish a storage mapping relationship between the cache group number and the serial number of the target workpiece; A preset cache group allocation unit is used to allocate the compressed waveform data and the static result data to the preset cache group corresponding to the cache group number of the target workpiece number according to the storage mapping relationship.
[0077] The preset modulo operation formula includes a waveform modulo operation formula and a result modulo operation formula. The waveform modulo operation formula is G1=n mod K1, and the result modulo operation formula is G2=n mod K2. G1 is the cache group number corresponding to the compressed waveform data, G2 is the cache group number corresponding to the static result data, K1 is the number of preset cache groups corresponding to the compressed waveform data, and K2 is the number of preset cache groups corresponding to the static result data.
[0078] Furthermore, the data retransmission module 430 includes: The latest cache group number acquisition unit is used to acquire the latest waveform cache group number of the latest group of compressed waveform data and the latest result cache group number of the latest group of static result data in the backup cache area, respectively. The retransmission order determination unit is used to determine the data retransmission order of the compressed waveform data according to the latest waveform cache group number and the preset solidified mapping table, and to determine the data retransmission order of the static result data according to the latest result cache group number and the preset solidified mapping table.
[0079] Furthermore, the data retransmission module 430 also includes: The cache group determination unit is used to designate the preset cache group with a group number greater than the latest result cache group number as the subsequent cache group, designate the preset cache group with a group number less than the latest result cache group number as the preceding cache group, and determine the preset cache group corresponding to the latest result cache group number as the current cache group. The solidified mapping table determination unit is used to set the priority of the subsequent cache group to high, the priority of the previous cache group to low, and the priority of the current cache group to medium, thereby determining the preset solidified mapping table.
[0080] Furthermore, the data retransmission module 430 includes: A compressed waveform data reading unit is used to read the compressed waveform data from the backup buffer according to the data retransmission order; The waveform data separating unit is used to divide the compressed waveform data into at least one data block according to a preset segmentation rule, and to add data header identification information to each data block. The data block upload unit is used to upload each data block containing the data header identification information to the host computer.
[0081] Furthermore, the data retransmission module 430 includes: The data to be uploaded result determination unit is used to read the static result data corresponding to the compressed waveform data that has been uploaded to the host computer from the backup cache as the data to be uploaded result; According to the preset merging rules, the data to be uploaded are merged into at least one merged result data packet, and a data header identifier is added to each merged result data packet before uploading it to the host computer.
[0082] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the above-described apparatus and modules can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0083] The aforementioned device can be implemented as a computer program, which can be used in, for example... Figure 3 It runs on the computer device shown.
[0084] Please see Figure 3 , Figure 3 This is a schematic block diagram illustrating the structure of a computer device according to an embodiment of this application. The computer device may be a server.
[0085] See Figure 3 The computer device includes a processor, memory, and network interface connected via a system bus, wherein the memory may include non-volatile storage media and internal memory.
[0086] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions that, when executed, cause the processor to perform any wireless gun communication data backup method.
[0087] The processor provides computing and control capabilities, supporting the operation of the entire computer device.
[0088] The internal memory provides an environment for the execution of computer programs in non-volatile storage media. When the computer program is executed by the processor, it enables the processor to perform any wireless gun communication data backup method.
[0089] This network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that... Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0090] It should be understood that the processor can be a Central Processing Unit (CPU), but it can also be 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. Among these, a general-purpose processor can be a microprocessor or any conventional processor.
[0091] In one embodiment, the processor is configured to run a computer program stored in memory to perform the following steps: In the event of a TCP interruption, the dynamic waveform data is adaptively compressed to generate compressed waveform data. The compressed waveform data and the static result data are stored in the corresponding backup cache, and the dynamic waveform data and the static result data in the original cache are cleared. Based on the compressed waveform data and the static result data, a storage mapping relationship between the target workpiece number and the cache group number is established, and based on the storage mapping relationship, the compressed waveform data and the static result data are respectively allocated to the preset cache groups in the backup cache area; In the case of TCP reconnection, the data retransmission order is determined according to the storage mapping relationship, and the compressed waveform data and the static result data are read from each of the preset cache groups based on the data retransmission order, and the compressed waveform data and the static result data are uploaded to the host computer. The dynamic waveform data refers to the waveform data collected during the operation of the target workpiece by the wireless gun, and the static result data refers to the result data collected after the operation of the target workpiece by the wireless gun is completed.
[0092] In one embodiment, dynamic waveform data is adaptively compressed to generate compressed waveform data, which is used to achieve: Obtain the number of original waveform points in the dynamic waveform data; The compression step size is calculated based on the number of points in the original waveform according to the preset compression step size formula; The dynamic waveform data is adaptively compressed according to the compression step size to generate the compressed waveform data.
[0093] In one embodiment, the preset compression step size formula is: Where N is the number of original waveform points, the backup buffer corresponding to the compressed waveform data is a compressed backup area, and M is the single-channel storage capacity threshold of the compressed backup area. This is for rounding up.
[0094] In one embodiment, a storage mapping relationship between the target workpiece sequence number and the cache group number is established based on the compressed waveform data and the static result data, and the compressed waveform data and the static result data are allocated to preset cache groups in the backup cache area based on the storage mapping relationship, to achieve the following: The target workpiece number is obtained based on the compressed waveform data and the static result data; The cache group number is determined by a preset modulus calculation formula and the serial number of each target workpiece, and a storage mapping relationship is established between the cache group number and the serial number of the target workpiece. According to the storage mapping relationship, the compressed waveform data and the static result data are allocated to the preset cache group corresponding to the cache group number of the target workpiece number.
[0095] The preset modulo operation formula includes a waveform modulo operation formula and a result modulo operation formula. The waveform modulo operation formula is G1=n mod K1, and the result modulo operation formula is G2=n mod K2. G1 is the cache group number corresponding to the compressed waveform data, G2 is the cache group number corresponding to the static result data, K1 is the number of preset cache groups corresponding to the compressed waveform data, and K2 is the number of preset cache groups corresponding to the static result data.
[0096] In one embodiment, in the case of TCP reconnection, the data retransmission order is determined according to the storage mapping relationship to achieve: Obtain the latest waveform cache group number of the latest set of compressed waveform data and the latest result cache group number of the latest set of static result data in the backup cache area, respectively; The order of data retransmission for the compressed waveform data is determined based on the latest waveform cache group number and the preset fixed mapping table, and the order of data retransmission for the static result data is determined based on the latest result cache group number and the preset fixed mapping table.
[0097] In one embodiment, before determining the data retransmission order of the compressed waveform data based on the latest waveform cache group number and the preset fixed mapping table, and before determining the data retransmission order of the static result data based on the latest result cache group number and the preset fixed mapping table, the following is implemented: The preset cache group with a group number greater than the latest result cache group number is designated as the subsequent cache group, the preset cache group with a group number less than the latest result cache group number is designated as the preceding cache group, and the preset cache group corresponding to the latest result cache group number is designated as the current cache group. Set the priority of the subsequent cache group to high, the priority of the previous cache group to low, and the priority of the current cache group to medium to determine the preset fixed mapping table.
[0098] In one embodiment, the compressed waveform data and the static result data are read from each of the preset cache groups based on the data retransmission order, and the compressed waveform data and the static result data are uploaded to the host computer to achieve the following: The compressed waveform data is read from the backup cache according to the data resending order; The compressed waveform data is divided into at least one data block according to a preset block division rule, and data header identification information is added to each data block. Each data block containing the data header identification information is uploaded to the host computer.
[0099] In one embodiment, after uploading each data block containing the data header identification information to the host computer, it is used to achieve: Read the static result data corresponding to the compressed waveform data that has been uploaded to the host computer from the backup cache as the result data to be uploaded; According to the preset merging rules, the data to be uploaded are merged into at least one merged result data packet, and a data header identifier is added to each merged result data packet before uploading it to the host computer.
[0100] The embodiments of this application also provide a computer-readable storage medium storing a computer program, the computer program including program instructions, and the processor executing the program instructions to implement any of the wireless gun communication data backup methods provided in the embodiments of this application.
[0101] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, SmartMedia Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device.
[0102] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for backing up wireless gun communication data, characterized in that, include: In the event of a TCP interruption, the dynamic waveform data is adaptively compressed to generate compressed waveform data. The compressed waveform data and the static result data are stored in the corresponding backup cache, and the dynamic waveform data and the static result data in the original cache are cleared. Based on the compressed waveform data and the static result data, a storage mapping relationship between the target workpiece number and the cache group number is established, and based on the storage mapping relationship, the compressed waveform data and the static result data are respectively allocated to the preset cache groups in the backup cache area; In the case of TCP reconnection, the data retransmission order is determined according to the storage mapping relationship, and the compressed waveform data and the static result data are read from each of the preset cache groups based on the data retransmission order, and the compressed waveform data and the static result data are uploaded to the host computer. The dynamic waveform data refers to the waveform data collected during the operation of the target workpiece by the wireless gun, and the static result data refers to the result data collected after the operation of the target workpiece by the wireless gun is completed.
2. The wireless gun communication data backup method according to claim 1, characterized in that, The step of adaptively compressing dynamic waveform data to generate compressed waveform data includes: Obtain the number of original waveform points in the dynamic waveform data; The compression step size is calculated based on the number of points in the original waveform according to the preset compression step size formula; The dynamic waveform data is adaptively compressed according to the compression step size to generate the compressed waveform data.
3. The wireless gun communication data backup method according to claim 2, characterized in that, The preset compression step size formula is: Where N is the number of original waveform points, the backup buffer corresponding to the compressed waveform data is a compressed backup area, and M is the single-channel storage capacity threshold of the compressed backup area. This is for rounding up.
4. The wireless gun communication data backup method according to claim 1, characterized in that, The step of establishing a storage mapping relationship between the target workpiece sequence number and the cache group number based on the compressed waveform data and the static result data, and allocating the compressed waveform data and the static result data to preset cache groups in the backup cache area based on the storage mapping relationship, includes: The target workpiece number is obtained based on the compressed waveform data and the static result data; The cache group number is determined by a preset modulus calculation formula and the serial number of each target workpiece, and a storage mapping relationship is established between the cache group number and the serial number of the target workpiece. According to the storage mapping relationship, the compressed waveform data and the static result data are allocated to the preset cache group corresponding to the cache group number of the target workpiece number; The preset modulo operation formula includes a waveform modulo operation formula and a result modulo operation formula. The waveform modulo operation formula is G1=n mod K1, and the result modulo operation formula is G2=n mod K2. G1 is the cache group number corresponding to the compressed waveform data, G2 is the cache group number corresponding to the static result data, K1 is the number of preset cache groups corresponding to the compressed waveform data, and K2 is the number of preset cache groups corresponding to the static result data.
5. The wireless gun communication data backup method according to claim 1, characterized in that, In the case of TCP reconnection, determining the data resending order based on the storage mapping relationship includes: Obtain the latest waveform cache group number of the latest set of compressed waveform data and the latest result cache group number of the latest set of static result data in the backup cache area, respectively; The order of data retransmission for the compressed waveform data is determined based on the latest waveform cache group number and the preset fixed mapping table, and the order of data retransmission for the static result data is determined based on the latest result cache group number and the preset fixed mapping table.
6. The wireless gun communication data backup method according to claim 1, characterized in that, Before determining the data retransmission order of the compressed waveform data according to the latest waveform cache group number and the preset fixed mapping table, and before determining the data retransmission order of the static result data according to the latest result cache group number and the preset fixed mapping table, the following steps are included: The preset cache group with a group number greater than the latest result cache group number is designated as the subsequent cache group, the preset cache group with a group number less than the latest result cache group number is designated as the preceding cache group, and the preset cache group corresponding to the latest result cache group number is designated as the current cache group. Set the priority of the subsequent cache group to high, the priority of the previous cache group to low, and the priority of the current cache group to medium to determine the preset fixed mapping table.
7. The wireless gun communication data backup method according to claim 5, characterized in that, The step of reading the compressed waveform data and the static result data from each of the preset cache groups based on the data retransmission order, and uploading the compressed waveform data and the static result data to the host computer includes: The compressed waveform data is read from the backup cache according to the data resending order; The compressed waveform data is divided into at least one data block according to a preset block division rule, and data header identification information is added to each data block. Each data block containing the data header identification information is uploaded to the host computer.
8. The wireless gun communication data backup method according to claim 7, characterized in that, After uploading each data block containing the data header identification information to the host computer, the process includes: Read the static result data corresponding to the compressed waveform data that has been uploaded to the host computer from the backup cache as the result data to be uploaded; According to the preset merging rules, the data to be uploaded are merged into at least one merged result data packet, and a data header identifier is added to each merged result data packet before uploading it to the host computer.
9. A wireless gun communication data backup device, characterized in that, include: The layered cache backup module is used to adaptively compress dynamic waveform data to generate compressed waveform data in the event of a TCP interruption, store the compressed waveform data and static result data in the corresponding backup cache area, and clear the dynamic waveform data and static result data in the original cache area. The mapping storage module is used to establish a storage mapping relationship between the target workpiece number and the cache group number based on the compressed waveform data and the static result data, and to allocate the compressed waveform data and the static result data to the preset cache groups in the backup cache area based on the storage mapping relationship. The data retransmission module is used to determine the data retransmission order according to the storage mapping relationship in the case of TCP reconnection, and read the compressed waveform data and the static result data from each of the preset cache groups based on the data retransmission order, and upload the compressed waveform data and the static result data to the host computer.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to implement the wireless gun communication data backup method as described in any one of claims 1 to 8.
