Disclosure of Invention
The QT-based cross-platform data communication method and system provided by the invention can achieve the effect of uniformly and completely managing the network condition by separately and independently designing the data transmission function of the bottom layer of the Ethernet and the upper application program, so that the Ethernet does not depend on an operating system and a hardware environment, thereby avoiding repeated work and various conflicts of the network, and have good flexibility, expansibility and low coupling.
In a first aspect, the present invention provides a QT-based cross-platform data communication method, including:
receiving communication data or file transmission data of an upper computer or a lower computer;
carrying out classification processing, priority processing or sub-packet processing on the communication data or the file transmission data and forming a data packet sending queue so that the communication data or the file transmission data can be transmitted between an upper computer and a lower computer with different operating systems;
and sending the data packet sending queue to a lower computer or uploading the data packet to an upper computer.
Optionally, the classifying, prioritizing, or packetizing the communication data or the file transmission information and forming a data packet transmission queue includes:
carrying out classification processing or subpackage processing on the communication data or the file transmission data;
calling a related function in a network operation dynamic library for supporting files, memories, commands or sending/receiving and opening a path;
calling a related function in a network communication dynamic library for providing remote login, obtaining/network address or specified state, and putting classified or sub-packaged communication data or file transmission data into a corresponding queue in a data packet sending queue according to priority;
and inquiring each queue in the data packet sending queue according to a priority algorithm, and sending the data of each queue to a destination address.
Optionally, the issuing the data packet sending queue to the lower computer or uploading the data packet sending queue to the upper computer includes:
acquiring network communication interfaces appointed to be transmitted by each queue in a data packet transmission queue;
and issuing each queue to a lower computer or uploading each queue to an upper computer according to the network communication interface.
Optionally, after the classifying, prioritizing, or packetizing the communication data or the file transfer data and forming a data packet sending queue, the method further includes:
and acquiring time information and adding the time information into a data packet sending queue.
Optionally, the obtaining and adding the time information to the data packet sending queue includes:
packaging the communication data and the file transmission data to form a first data packet and sending the first data packet to a history station, adding time information into the first data packet by the history station to form a second data packet, and synchronizing the second data packet in the whole network;
and adding the second data packet into the data packet sending queue.
Optionally, after uploading the data packet sending queue to the upper computer, the method further includes:
analyzing and processing according to the data packet sending queue and acquiring corresponding communication data or file transmission data;
and generating a corresponding message according to the corresponding communication data or the file transmission data and informing the upper application software.
Optionally, after uploading the data packet sending queue to the upper computer, the method further includes:
receiving network data and obtaining a data type;
and sending the data to the destination address according to the data type.
In a second aspect, the present invention provides a QT-based cross-platform data communication system, comprising:
the receiving module is used for acquiring communication data or file transmission data of the upper computer or the lower computer;
the data communication assembly is used for carrying out classification processing, priority processing or sub-packet processing on the communication data or the file transmission data and forming a data packet sending queue so that the communication data or the file transmission data can be transmitted between an upper computer and a lower computer with different operating systems;
and the network communication component is used for sending the data packet sending queue to the lower computer or uploading the data packet sending queue to the upper computer.
Optionally, the data communication component comprises:
the network operation dynamic library is used for supporting files, memories, commands or sending/receiving;
the first calling unit is used for calling the related functions in the network operation dynamic library and opening a path;
the network communication dynamic library is used for providing remote login, obtaining/network address or specified state;
the second calling unit is used for calling related functions in the network communication dynamic library and putting communication data or file transmission data into a corresponding queue in a data packet sending queue according to the priority;
and the sending unit is used for inquiring each queue in the data packet sending queues according to the priority algorithm and sending the data of each queue to the destination address.
Optionally, the network communication component comprises:
the device comprises an acquisition unit, a transmission unit and a processing unit, wherein the acquisition unit is used for acquiring network communication interfaces appointed to be transmitted by each queue in a data packet transmission queue;
and the transmission unit is used for transmitting each queue to the lower computer or uploading the queue to the upper computer according to the network communication interface.
Optionally, the system further comprises:
the data packet sending module is used for packaging the communication data and the file transmission data to form a first data packet and sending the first data packet to the history station;
a synchronization module for receiving the second data packet and synchronizing the second data packet;
and the processing module is used for adding the second data packet into the data packet sending queue.
Optionally, the system further comprises:
the analysis processing module is used for carrying out analysis processing according to the data packet sending queue and acquiring corresponding communication data or file transmission data;
and the notification module is used for generating a corresponding message according to the corresponding communication data or the file transmission data and notifying the upper application software.
The cross-platform data communication method and system based on QT provided by the embodiment of the invention mainly receive the communication data or the file transmission data of the upper computer, classify, prioritize or packetize the communication data or the file transmission data and form a data packet sending queue, so that the communication data or the file transmission data are issued to the lower computer and corresponding operations are executed by the lower computer without depending on an operating system and a hardware environment between the lower computer and the upper computer, and therefore, the work of configuration synchronization, process control, file maintenance and the like of the lower computer is realized. Or receiving the communication data or the file transmission data of the lower computer, uploading the processed data to a receiving queue of the upper computer, and realizing real-time state monitoring work on the lower computer.
The method in the embodiment of the invention mainly utilizes the independent design of the data transmission function of the bottom layer of the Ethernet and the upper application program, thereby not depending on an operating system and a hardware environment, achieving the effect of uniformly and completely managing the network condition, further avoiding repeated work and various conflicts of the network, and having good flexibility, expansibility and low coupling.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention provides a QT-based cross-platform data communication method, as shown in FIG. 1, the method comprises the following steps:
s1, receiving communication data or file transmission data of the upper computer or the lower computer;
s2, carrying out classification processing, priority processing or subpackage processing on the communication data or the file transmission data and forming a data packet sending queue so that the communication data or the file transmission data can be transmitted between an upper computer and a lower computer with different operating systems;
and S3, sending the data packet sending queue to a lower computer or uploading the data packet to an upper computer.
The embodiment of the invention provides a cross-platform data communication method based on QT, wherein the QT: a cross-platform C + + graphical user interface application;
cross-platform: the method is independent of operating systems and hardware environments, and the application developed under one operating system can still normally run when the application is put under the other operating system;
a history station: the server for keeping the historical data for a long time and having the function of directly sending out the control command;
an upper computer: refers to a computer that can directly send out control commands;
a lower computer: and a computer for directly controlling the equipment to acquire the equipment condition.
The method of the embodiment mainly receives the communication data or the file transmission data of the upper computer, performs classification processing, priority processing or sub-packet processing on the communication data or the file transmission data, and forms a data packet sending queue, so that the method does not depend on an operating system and a hardware environment between the lower computer and the upper computer, and also issues the communication data or the file transmission data to the lower computer and executes corresponding operations by the lower computer, thereby realizing the work of configuration synchronization, process control, file maintenance and the like of the lower computer.
Or receiving the communication data or the file transmission data of the lower computer, performing classification processing, priority processing or sub-packet processing on the communication data or the file transmission data, forming a data packet sending queue, so that the communication data or the file transmission data are split according to a data format, priority and data transmission load, then uploading the split data or the file transmission data to a receiving queue of the upper computer, and informing upper application software in a message mode after the split data or the file transmission data are correspondingly processed by the upper computer; the communication data or the file transmission data are all communication data and file transmission data required by upper-layer application software, and therefore real-time state monitoring work is achieved on the lower computer.
The method in the embodiment mainly utilizes the separated and independent design of the data transmission function of the bottom layer of the Ethernet and the upper application program, so that the method does not depend on an operating system and a hardware environment, achieves the effect of uniformly and completely managing the network condition, further avoids repeated work and various conflicts of the network, and has good flexibility, expansibility and low coupling.
Optionally, as shown in fig. 2 to 4, the performing classification processing, priority processing, or packetization processing on the communication data or the file transmission information and forming a data packet sending queue includes:
carrying out classification processing or subpackage processing on the communication data or the file transmission data;
calling a related function in a network operation dynamic library for supporting files, memories, commands or sending/receiving and opening a path;
calling a related function in a network communication dynamic library for providing remote login, obtaining/network address or specified state, and putting classified or sub-packaged communication data or file transmission data into a corresponding queue in a data packet sending queue according to priority;
and inquiring each queue in the data packet sending queue according to a priority algorithm, and sending the data of each queue to a destination address.
Specifically, in this embodiment, the upper computer performs classification processing, priority processing or sub-packet processing on the communication data or the file transmission information, and forms a data packet sending queue, and first performs classification processing or sub-packet processing on the communication data or the file transmission information according to the type and size of the data when the communication data or the file transmission information is sent to a destination address in an application program; for example, when the data size of the file transmission information is greater than a set value, the file transmission information is divided into at least two smaller data packets, so that the efficiency of the cross-platform data communication is improved. Then, calling a related function in the network operation dynamic library and opening a path; calling a related function in the network communication dynamic library and putting the communication data or the file transmission data after classification processing or sub-packet processing into a corresponding queue in a data packet sending queue according to the priority; and finally, inquiring each queue in the data packet sending queue according to a priority algorithm, and sending the data of each queue to a destination address. The data packet sending queue comprises the following components in sequence from high priority to low priority: the data communication method comprises an instant sending queue, a command sending queue, a fast memory queue, a medium-speed memory queue, a slow memory queue and a file queue, wherein each queue can comprise a plurality of data packets or files, and further provides a data communication method for communication between single-machine application programs and communication between different machine application programs on the basis of improving the efficiency of data communication.
Wherein the packetization process includes:
judging whether the size of the data packet exceeds a set value, if so, executing the next step; if not, priority processing is carried out;
detecting the network load of the Ethernet, judging whether the network load of the Ethernet exceeds a threshold value, and if so, executing the next step; if not, priority processing is carried out;
determining the sub-packet quantity according to the network load of the Ethernet with the size of the data packet, and sub-packaging the data packet according to the sub-packet quantity. Therefore, the load monitoring of the Ethernet is effectively realized, and the data communication efficiency is ensured. In this embodiment, the network load of the ethernet in the method is no more than 20% at most, and preferably, the network load of the ethernet is less than 10%.
In this embodiment, the communication data includes all data packets that need network transmission, such as an inter-station status data packet, a real-time data table data packet, a historical data packet, a command packet, and a request packet; the file transmission information includes all file data which needs network transmission and synchronization, such as configuration files, Log files and the like. The data communication method transmits the data packet transmission queue formed by the classification processing, the priority processing or the sub-packet processing of the multiple types of data packets such as the memory data, the real-time data, the command data, the operation instruction, the file data, the state data, the response data and the like between the upper computer and the lower computer of the Windows operating system or the winning kylin operating system or between the upper computer and the upper computer by the method, so that the problems of incompatibility and mutual transmission of data between the upper computer and the lower computer of the Windows operating system or the winning kylin operating system or between the upper computer and the upper computer are avoided, and the flexibility, the expansibility and the low coupling of the data communication method are further improved.
In summary, in the method of this embodiment, the communication data or the file transmission data is firstly subjected to classification processing or sub-packet processing to form corresponding data packets, then priority processing is performed on the data packets to form a data packet sending queue, and then priority control on the data packet sending queue is implemented according to the priority algorithm, so that the data packets with different priorities are sent according to a high-priority first-sending principle, priority sending of important data is ensured, and processing efficiency is improved.
Optionally, the issuing the data packet sending queue to the lower computer or uploading the data packet sending queue to the upper computer includes:
acquiring network communication interfaces appointed to be transmitted by each queue in a data packet transmission queue;
and issuing each queue to a lower computer or uploading each queue to an upper computer according to the network communication interface.
Specifically, in the method of this embodiment, when each queue is issued to the lower computer according to the network communication interface, the lower computer receives the data packets in the data packet transmission queue to the received data queue, and correspondingly analyzes the data packets in the received data queue, extracts the corresponding command, and executes the command, for example, the method may perform control such as starting with parameters, starting at fixed time, stopping at fixed time, monitoring, etc. on the process of the lower computer in a process control command packet manner; or, the method can also carry out operations of starting online, starting online at fixed time, stopping online at fixed time and the like on other lower computers in a station control command packet mode; or, the method can also realize the communication between the points, including one-to-one or one-to-many point-to-point communication, and the communication between the points includes a TCP transmission mode and a non-connection UDP transmission mode. The TCP approach is used for large data block replication and synchronization, and the UDP is used for small data transmission. For example, the periodic data is transmitted by UDP, and the event data is transmitted by TCP.
Or when the data packet sending queue is sent to the lower computer and the upper computer cannot be directly sent to the lower computer, the data packet sending queue is forwarded to the lower computer through the remote controller, wherein the upper computer sends the data packet sending queue to the remote controller, and then the remote controller sends the corresponding data packet sending queue to the corresponding lower computer.
Meanwhile, the network communication interface used for transmitting data and each application program between the upper computer and the lower computer or between the upper computer and the upper computer or between the lower computer and the lower computer under different operating system platforms (Windows or kylin), in the embodiment, includes: the system comprises a process notification sending interface on the same computer, a process notification sending interface between different computers, a file sending interface, a memory synchronous sending interface and an operation data sending interface; for example, when sending a notification to a specified process on a specified machine, the send notification packet structure is as shown in FIG. 3.
The interface provided for other application programs in the method of the embodiment includes: the method of the embodiment runs under different operating systems (Windows or Chinese kylin), but the two different operating systems have different definitions of the message, so the embodiment adopts a local Socket technology encapsulation message mechanism of QT to realize message communication between processes, and an external interface mode adopts a Windows-like message mode.
Optionally, after the classifying, prioritizing, or packetizing the communication data or the file transfer data and forming a data packet sending queue, the method further includes:
and acquiring time information and adding the time information into a data packet sending queue.
Specifically, the method according to this embodiment adds the time information to the data packet transmission queue to achieve the function of timing data, where the time information is mainly periodically transmitted to the entire network by the history station, and other stations passively receive the time information data and modify their own clocks to keep the time information data consistent with the history station.
Optionally, the obtaining and adding the time information to the data packet sending queue includes:
packaging the communication data and the file transmission data to form a first data packet and sending the first data packet to a history station, adding time information into the first data packet by the history station to form a second data packet, and synchronizing the second data packet in the whole network;
and adding the second data packet into the data packet sending queue.
Specifically, the method according to this embodiment mainly adds time information to a packet sending queue, so that the packet sending queue can implement timing calibration, for example, as shown in fig. 4, after the lower computer executes an operation, corresponding operation processing data is formed, the data is packaged to form a first packet without time information, the first packet is sent to the master history station and/or the slave history station through a packet sending module, then the time information is added to the first packet through the master history station to form a second packet with time information, the slave history station and the lower computer synchronize the second packet at the same time, and finally the lower computer adds the second packet to the packet sending queue and uploads the second packet to the upper computer, thereby implementing operation feedback on the upper computer.
The method can also identify the type of a data packet, and determine to put the data packet into an input interface queue or an output interface queue according to the type of the data packet, wherein the data packet comprises an analog quantity data packet and a digital quantity operation queue; the analog quantity packet type is one, the digital quantity operation queue comprises a picture digital quantity operation packet type and a non-picture digital quantity operation packet type, and the non-picture digital quantity operation packet type is an artificial digit-setting value. The image operation packet needs DO zero clearing processing, and the non-image operation packet cannot be cleared. And the above two kinds of data packets are written by the PC where the operator is located, but the time stamp with the time information is written when the data is packed by the master history station,
optionally, after uploading the data packet sending queue to the upper computer, the method further includes:
analyzing and processing according to the data packet sending queue and acquiring corresponding communication data or file transmission data;
and generating a corresponding message according to the corresponding communication data or the file transmission data and informing the upper application software.
Optionally, after uploading the data packet sending queue to the upper computer, the method further includes:
receiving network data and obtaining a data type;
and sending the data to the destination address according to the data type.
Specifically, in the method of this embodiment, after the data packet transmission queue is uploaded to the upper computer, or after the remote controller transmits the data packet transmission queue to the upper computer, the method further includes receiving network data and determining the type of the network data, and if the data is AO, DO, or the like, the network data is put into an interface input queue; if the command is received, immediately notifying the target application program; if the data is the memory data for the application program, the data is put into a receiving memory queue, and the upper application program is immediately informed to receive the processing.
An embodiment of the present invention further provides a QT-based cross-platform data communication system, as shown in fig. 5, the system includes:
the receiving module is used for acquiring communication data or file transmission data of the upper computer or the lower computer;
the data communication assembly is used for carrying out classification processing, priority processing or sub-packet processing on the communication data or the file transmission data and forming a data packet sending queue so that the communication data or the file transmission data can be transmitted between an upper computer and a lower computer with different operating systems;
and the network communication component is used for sending the data packet sending queue to the lower computer or uploading the data packet sending queue to the upper computer.
The QT-based cross-platform data communication system provided by the embodiment of the invention mainly receives communication data or file transmission data of an upper computer through a receiving module, performs classification processing, priority processing or sub-packet processing on the communication data or the file transmission data through a data communication assembly, and forms a data packet sending queue, so that the data packet sending queue is independent of an operating system and a hardware environment between a lower computer and the upper computer, and finally, the communication data or the file transmission data are sent to the lower computer through a network communication assembly and corresponding operations are executed by the lower computer, so that the work of configuration synchronization, process control, file maintenance and the like of the lower computer is realized.
Or receiving the communication data or the file transmission data of the lower computer, performing classification processing, priority processing or sub-packet processing on the communication data or the file transmission data, forming a data packet sending queue, so that the communication data or the file transmission data are split according to a data format, priority and data transmission load, then uploading the split data or the file transmission data to a receiving queue of the upper computer, and informing upper application software in a message mode after the split data or the file transmission data are correspondingly processed by the upper computer; the communication data or the file transmission data are all communication data and file transmission data required by upper-layer application software, and therefore real-time state monitoring work is achieved on the lower computer.
The system in this embodiment is mainly implemented by separately and independently designing the data transmission function of the bottom layer of the ethernet network and the upper layer application program, so that the system does not depend on an operating system and a hardware environment, achieves the effect of uniformly and completely managing the network status, further avoids repeated work and various conflicts of the network, and has good flexibility, expansibility and low coupling.
Optionally, as shown in fig. 6, the data communication component includes:
the network operation dynamic library is used for supporting files, memories, commands or sending/receiving;
the first calling unit is used for calling the related functions in the network operation dynamic library and opening a path;
the network communication dynamic library is used for providing remote login, obtaining/network address or specified state;
the second calling unit is used for calling related functions in the network communication dynamic library and putting communication data or file transmission data into a corresponding queue in a data packet sending queue according to the priority;
and the sending unit is used for inquiring each queue in the data packet sending queues according to the priority algorithm and sending the data of each queue to the destination address.
Optionally, the network communication component comprises:
the device comprises an acquisition unit, a transmission unit and a processing unit, wherein the acquisition unit is used for acquiring network communication interfaces appointed to be transmitted by each queue in a data packet transmission queue;
and the transmission unit is used for transmitting each queue to the lower computer or uploading the queue to the upper computer according to the network communication interface.
Optionally, the system further comprises:
the data packet sending module is used for packaging the communication data and the file transmission data to form a first data packet and sending the first data packet to the history station;
a synchronization module for receiving the second data packet and synchronizing the second data packet;
and the processing module is used for adding the second data packet into the data packet sending queue.
Optionally, the system further comprises:
the analysis processing module is used for carrying out analysis processing according to the data packet sending queue and acquiring corresponding communication data or file transmission data;
and the notification module is used for generating a corresponding message according to the corresponding communication data or the file transmission data and notifying the upper application software.
The system of this embodiment may be configured to implement the technical solutions of the method embodiments, and the implementation principles and technical effects are similar, which are not described herein again.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.