Data forwarding method
Technical Field
The invention relates to the technical field of H04L, in particular to a data forwarding method.
Background
Chinese patent with patent application number CN201710941310.7 discloses a data forwarding method and device, which solves the problem of inconvenience and insecurity in communication, but does not disclose the problem of increasing the speed of sending data to different terminals.
In the traditional software system used at present, the io processing efficiency is always the bottleneck of the system, particularly, collected data needs to be forwarded to a plurality of terminals, and finally, data received by a certain terminal is too long in delay, and received sampling data are discontinuous, so that drawn curves are discontinuous, and the use experience of a user is influenced.
Disclosure of Invention
In order to solve the above problem, the present invention provides a data forwarding method, comprising the steps of:
s1, acquiring data in a programmable logic controller through an acquisition thread and sending the data to an industrial personal computer;
s2, storing the obtained data through different cache regions in the industrial personal computer;
and S3, transmitting the data acquired from the cache region to the terminal through a transmission thread through network transmission.
Preferably, the data is read out from the programmable logic controller to the memory by the acquisition thread and is copied to the plurality of buffer areas.
Preferably, the data obtained in the buffer area is forwarded to each terminal by creating a plurality of transmission threads.
The data are continuously read from the programmable logic controller to be stored in the memory through the acquisition thread and are copied to the plurality of cache regions, then the plurality of threads are established, the data in the cache regions are respectively forwarded to each terminal, more data are supported to be sent, the frequent io operation in a single thread is avoided, and the data throughput of the system is improved.
Preferably, the cache area in S2 includes a PC forwarding cache area, a tablet forwarding cache area, and a cloud forwarding cache area.
Preferably, the plurality of transmission threads in S3 include a PC forwarding thread, a tablet forwarding thread, and a cloud forwarding thread.
Preferably, the terminal in S3 includes a PC terminal, a tablet terminal, a mobile phone terminal, and a cloud terminal.
Preferably, the cloud is a cloud server.
Preferably, the acquiring data in the programmable logic controller is acquiring exercise training data generated by an exercise machine controlled by a servo motor.
Preferably, the obtained exercise training data is viewed in the terminal.
Preferably, the obtained exercise training data are checked in a PC (personal computer) end system, a tablet end APP (application) and a mobile phone end APP.
Preferably, the creating of the plurality of transfer threads realizes the task of data transfer to be distributed to multiple threads for execution.
Advantageous effects
The method can continuously read the data from the programmable logic controller to the memory through the acquisition thread, and copy the data to the plurality of cache regions, then create the plurality of threads, respectively forward the data in the cache regions to each terminal, support sending more data, avoid frequently performing io operation in a single thread, and improve the data throughput of the system.
The method can greatly improve the data throughput of the system, and disperse the time-consuming io operation into multiple threads for execution, so that the probability of communication delay is greatly reduced.
The method can support to send more data, and avoids the problem that when the number of the terminals is more, the time delay of the terminal receiving the data after the sequence is longer, which affects the user experience.
The method of the invention realizes that the data is transmitted to each terminal through multithreading at the same time after being collected, thereby fully playing the advantage of multi-core of the prior computer, avoiding the frequent io operation in a single thread and improving the data throughput of the system.
Drawings
FIG. 1 is a schematic flow diagram of the process of the present invention.
Detailed description of the invention
Fig. 1 provides a data forwarding method, which includes the following steps:
s1, acquiring data in a programmable logic controller through an acquisition thread and sending the data to an industrial personal computer;
s2, storing the obtained data through different cache regions in the industrial personal computer;
and S3, transmitting the data acquired from the cache region to the terminal through a transmission thread through network transmission.
In one embodiment, the data is read from the programmable logic controller to the memory by the collection thread and copied to the plurality of buffer areas.
In one embodiment, the data obtained in the buffer is forwarded to each terminal by creating a plurality of transmission threads.
The data are continuously read from the programmable logic controller to be stored in the memory through the acquisition thread and are copied to the plurality of cache regions, then the plurality of threads are established, the data in the cache regions are respectively forwarded to each terminal, more data are supported to be sent, the frequent io operation in a single thread is avoided, and the data throughput of the system is improved.
In one embodiment, the cache area in S2 includes a PC forwarding cache area, a tablet forwarding cache area, and a cloud forwarding cache area.
In one embodiment, the plurality of transmission threads in S3 include a PC forwarding thread, a tablet forwarding thread, and a cloud forwarding thread.
The data throughput of the system is greatly improved by setting a plurality of transmission threads, and the time-consuming io operation is dispersed into multiple threads for execution, so that the probability of communication delay is greatly reduced.
In one embodiment, the terminal in S3 includes a PC terminal, a tablet terminal, a mobile phone terminal, and a cloud terminal.
In one embodiment, the cloud is a cloud server.
In one embodiment, the acquiring data in the programmable logic controller is acquiring exercise training data generated by a servo motor controlled exercise machine.
In one embodiment, the exercise training data is exercise data obtained by exercising in different training modes.
In an embodiment, the obtained exercise training data is viewed in a PC end system, a tablet end APP and a mobile phone end APP.
In one embodiment, the creating of the multiple transfer threads enables the task of data transfer to be distributed among multiple threads for execution.
The method supports sending more data, and avoids the problem that when the number of the terminals is large, the time delay of receiving the data by the terminal after the sequence is large, and the user experience is influenced.
The method of the invention realizes that the data is transmitted to each terminal through multithreading at the same time after being collected, thereby fully playing the advantage of multi-core of the prior computer, avoiding the frequent io operation in a single thread and improving the data throughput of the system.