Communication method, device, computer equipment and computer readable storage medium

By automatically converting the QtRO interface to the ZMQ interface, the ease of use and compatibility of QtRO and ZMQ in inter-process communication is solved, and an inter-process communication solution that takes into account both ease of use and openness is realized.

CN112579309BActive Publication Date: 2024-11-12SHINING 3D TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910934752.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-09-29
Publication Date
2024-11-12
Estimated Expiration
2039-09-29

AI Technical Summary

Technical Problem

The existing QtRO and ZMQ have their own shortcomings in inter-process communication. QtRO only supports Qt meta information, while the ZMQ interface is not easy to use, the learning curve is steep, and lacks compatibility.

Method used

By obtaining the Qt element information in QtRO, determining its type, and converting it to a ZMQ interface based on the type through the matching ZMQ server socket, thereby realizing automatic conversion of QtRO and ZMQ interfaces. Combining the advantages of both, taking into account both Ease of use and openness.

Benefits of technology

It realizes that QtRO is still used in the underlying module communication, and developers can continue to use QtRO to develop functional modules, while the upper layer can use the ZMQ interface, allowing access to other development languages ​​and frameworks, improving the ease of use and openness of inter-process communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112579309B_ABST
    Figure CN112579309B_ABST
Patent Text Reader

Abstract

The present application relates to a communication method, apparatus, computer equipment and computer-readable storage medium, wherein the communication method includes obtaining Qt meta information in QtRO and determining the type of Qt meta information; accessing the Qt meta information through a matching ZMQ server socket according to the type of Qt meta information; and processing the Qt meta information through the accessed ZMQ server socket. The communication method provided by the present application accesses the Qt meta information through a matching ZMQ server socket according to the type of Qt meta information in QtRO, and can automatically convert the interface of QtRO into a ZMQ interface, thereby realizing that the underlying module communication is still QtRO, and developers can still use QtRO to develop various functional modules; using the ZMQ interface at the upper layer, it can allow a variety of other development languages ​​and frameworks to access, taking into account the ease of use and openness of inter-process communication.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a communication method, device, computer equipment and computer-readable storage medium. Background Art

[0002] Inter-Process Communication (IPC) is a commonly used technology in software development. It can help us divide complex software systems into modules and then develop them separately. Qt Metadata Remote Objects (QtRO for short) is an inter-process communication library that comes with the Qt Metadata Library. It makes it very convenient for developers to use it just like a local QObject object. ZeroMQ (ZMQ for short) is an open source network communication library that implements higher-level network communication semantics such as REQ / REP, PUB / SUB, etc. on the basis of system-level sockets. When using ZMQ to develop network communication, developers do not need to care about the cumbersome handshake protocol, error handling and other details at the bottom layer, but directly use the upper-level semantics for rapid development. At present, ZMQ has reached version v4.3.2 and is very stable. ZMQ itself is implemented in C++, but because it is open source and easy to use, many languages ​​support ZMQ, such as Python, JavaScript, etc., and it is widely used.

[0003] However, the disadvantage of QtRO is that it only supports Qt metadata and does not support other development frameworks; the disadvantage of ZMQ is that its interface is not as easy to use as QtRO, and its learning curve is steeper than that of QtRO. Summary of the invention

[0004] The present application provides a communication method, apparatus, computer device and computer-readable storage medium, which can automatically convert the QtRO interface into a ZMQ interface, thereby combining the advantages of QtRO and ZMQ and avoiding the disadvantages of both, taking into account the ease of use and openness of inter-process communication.

[0005] A communication method, the method comprising:

[0006] Get the Qt meta information in QtRO and determine the type of Qt meta information;

[0007] According to the type of Qt meta information, access the Qt meta information through a matching ZMQ server socket;

[0008] The Qt meta information is processed through the connected ZMQ server socket.

[0009] In one embodiment, accessing the Qt meta-information through a matching ZMQ server socket according to the type of the Qt meta-information includes: the type of the Qt meta-information includes attributes, signals, and slots, and the attributes include Notify, Read, and Write; the ZMQ server socket includes a PUB socket and a REP socket;

[0010] Connect the Notify of signals and properties through the PUB socket of the ZMQ server;

[0011] Convert the Read and Write operations of the attributes to operations through the REP socket of the ZMQ server;

[0012] Convert QtRO's slot function call into a REP socket call through the ZMQ server.

[0013] In one embodiment, the Notify of the signal and property is accessed through the PUB socket of the ZMQ server, including:

[0014] A dynamic slot function is generated according to the Qt metasystem; the dynamic slot function uses the PUB socket of the ZMQ server to send data;

[0015] According to Qt's signal and slot mechanism, the dynamic slot function is connected with the Notify of the signal and property in QtRO;

[0016] In the dynamic slot function, the parameters of Signal and Notify are obtained, and the parameters are used as the architecture for sending the PUB socket.

[0017] In one embodiment, converting the slot function call of QtRO into a REP socket call through the ZMQ server includes:

[0018] For each slot function, create a corresponding REP server, which includes the REP socket of the ZMQ server;

[0019] The name of each slot function in QtRO is monitored by the REP server as the first slot function name;

[0020] Receive a REQ request and obtain the slot function name of the REQ request as the second slot function name;

[0021] If the first slot function name is consistent with the second slot function name, the corresponding slot function in QtRO is called through the REP socket, and the return value is returned to the client through the REP server.

[0022] In one embodiment, converting the slot function call of QtRO into a REP socket call through the ZMQ server includes:

[0023] A REP server is generated for all slot functions in QtRO, and the REP server contains the REP socket of the ZMQ server;

[0024] Receive the REQ request and obtain the slot function name of the REQ request;

[0025] If the slot function name in the QtRO contains the slot function name of the REQ request, the corresponding slot function in the QtRO is called through the REP socket, and the return value is returned to the client through the REP server.

[0026] In one embodiment, converting the Read and Write operations of the attribute into operations performed through a REP socket of the ZMQ server includes:

[0027] Create a REP server on the ZMQ server side, and listen to external ZMQ data packets through the REP server; the REP server includes the REP socket on the ZMQ server side;

[0028] The monitored ZMQ data packet is compared with the data in the REP server to write the corresponding data through the REP socket or call the corresponding data through the REP socket.

[0029] In one embodiment, the ZMQ data packet includes two parts: envelope and payload, wherein the envelope is used to store the signal name or slot function name; and the payload is used to store the actual data.

[0030] In one embodiment, the ZMQ data packet includes an envelope or a payload, and is stored in one of the fields of the ZMQ data packet in a JSON format.

[0031] A communication device, comprising:

[0032] The acquisition module is used to obtain Qt meta information and determine the type of Qt meta information;

[0033] A matching module, for accessing the Qt meta information through a matching ZMQ server socket according to the type of the Qt meta information;

[0034] A processing module is used to process the Qt meta information through the connected ZMQ server socket.

[0035] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0036] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.

[0037] The communication method, apparatus, computer device and computer-readable storage medium provided in the embodiments of the present application include obtaining Qt meta information in QtRO and determining the type of Qt meta information; accessing the Qt meta information through a matching ZMQ server socket according to the type of Qt meta information; and processing the Qt meta information through the accessed ZMQ server socket. The communication method provided in the present application accesses the Qt meta information through a matching ZMQ server socket according to the type of Qt meta information in QtRO, and can automatically convert the interface of QtRO into a ZMQ interface, thereby realizing that the underlying module communication is still QtRO, and developers can still use QtRO to develop various functional modules; using the ZMQ interface at the upper layer, it can allow a variety of other development languages ​​and frameworks to access, taking into account the ease of use and openness of inter-process communication. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0039] Figure 1 A flow chart of a communication method provided by an embodiment;

[0040] Figure 2 A schematic diagram of Qt meta information forwarding in QtRO provided by an embodiment;

[0041] Figure 3 A flowchart of an embodiment of the invention for accessing Notify of signals and properties through a PUB socket of a ZMQ server;

[0042] Figure 4 A schematic diagram of the connection between a signal and a dynamic slot function in QtRO provided by an embodiment;

[0043] Figure 5 A flowchart of converting a slot function call of QtRO into a REP socket call through a ZMQ server provided by an embodiment;

[0044] Figure 6 is a structural block diagram of a communication device in one embodiment;

[0045] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0046] In order to facilitate the understanding of the present application, in order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present application, and the preferred embodiments of the present application are given in the accompanying drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thoroughly understood. The present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present application, so the present application is not limited by the specific embodiments disclosed below.

[0047] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In the description of the present application, the meaning of "several" is at least one, such as one, two, etc., unless otherwise clearly and specifically defined.

[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0049] Figure 1 A flow chart of a communication method provided by an embodiment, such as Figure 1 As shown, the communication method includes steps 110 to 130, wherein:

[0050] Step 110, obtaining Qt meta information in QtRO and determining the type of the Qt meta information.

[0051] QtRO uses Qt's signals and slots for programming communication. The unique Source / Replica mode makes the remote service call just like a local QObject. All underlying link serialization and deserialization are automatically completed by QtRO with Qt metadata. QtRO is essentially a point-to-point communication network. Each process accesses the QtRO network through the QRemote Object Node. The function providing node (which can be understood as a server) needs to use the QRemote Object Host to register a QObject derived class that provides actual functions into the QtRO network, and then other programs that use the function connect to the Host through their respective QRemote Object Nodes, and then acquire a Replica of the function object. After the Replica is initialized, the program can use the signals, slots, and properties in the Replica, just as if the function class is local, which is very convenient to use.

[0052] There are three types of Qt meta information: properties, signals, and slots, where properties are further divided into read, write, and notify.

[0053] Among them, the signal is similar to the function in form, can have parameters, and has no return value. Usually, the signal can have up to 10 parameters. The slot can have up to 10 parameters and can have a return value.

[0054] Step 120: Access the Qt meta information through a matching ZMQ server socket according to the type of the Qt meta information.

[0055] Qt uses signals and slots instead of pointers, which can bind two unrelated objects together to achieve communication between objects. For signals, when an object changes state, the signal is emitted by the object, and the object is only responsible for sending the signal, and it does not need to care who receives the signal at the other end. For slots, they are used to receive signals, and slots are just ordinary object member functions. A slot does not know whether there are any signals connected to itself, and the object does not need to understand the specific communication mechanism. In the process of information system development, an intermediate object is required to establish a message path between the server and the client every time the interface data is obtained from the server.

[0056] ZMQ has multiple working modes, two of which are commonly used:

[0057] 1. Publish-subscribe mode PUB / SUB. In this mode, the server is responsible for broadcasting, and the client (i.e., the subscriber) sets filtering keywords to subscribe to the publisher. This mode is a cross-connection between the information broadcast mode and the publisher does not need to know the details of the subscriber, while the subscriber can subscribe to different broadcast information as needed.

[0058] 2. Request-response mode REQ / REP. In this mode, the server waits for the client to make a service request, then processes it and finally returns a response result. It is similar to a Web server.

[0059] ZMQ server sockets include PUB sockets and REP sockets. PUB sockets are used for broadcasting, and REP sockets are used for replying. Sockets can understand interfaces, and can receive and send signals through interfaces. If Qt meta information is accessed through PUB sockets, ZMQ works in publish-subscribe mode PUB / SUB. If Qt meta information is accessed through REP sockets, ZMQ works in request-reply mode REQ / REP.

[0060] Since different types of Qt meta-information correspond to different working modes, this embodiment accesses the Qt meta-information through a matching ZMQ server socket according to the type of Qt meta-information and its corresponding working mode, so that the QtRO interface can be automatically converted into a ZMQ interface, thereby realizing the organic combination of QtRO and ZMQ.

[0061] The ZMQ server socket that matches the type of Qt meta information can be understood as: the working mode of the ZMQ server socket is similar to the working mode corresponding to the type of Qt meta information. Only in this way can the working modes and interfaces of QtRO and ZMQ be organically combined.

[0062] Step 130: Process the Qt meta information through the connected ZMQ server socket.

[0063] The communication method provided in this embodiment includes obtaining Qt meta information in QtRO and determining the type of Qt meta information; according to the type of Qt meta information, accessing the Qt meta information through a matching ZMQ server socket; processing the Qt meta information through the accessed ZMQ server socket. The communication method provided in this application accesses the Qt meta information through a matching ZMQ server socket according to the type of Qt meta information in QtRO, and can automatically convert the interface of QtRO into a ZMQ interface, thereby realizing that the underlying module communication is still QtRO, and developers can still use QtRO to develop various functional modules; using the ZMQ interface at the upper layer, it can allow a variety of other development languages ​​and frameworks to access, taking into account the ease of use and openness of inter-process communication.

[0064] In one embodiment, if Figure 2 As shown, according to the type of Qt meta information, accessing the Qt meta information through a matching ZMQ server socket includes:

[0065] Connect the Notify of signals and properties through the PUB socket of the ZMQ server;

[0066] Convert the Read and Write operations of the attributes to operations through the REP socket of the ZMQ server;

[0067] Convert QtRO's slot function call into a REP socket call through the ZMQ server.

[0068] Since in the QtRO communication process, the Notify of signals and properties is emitted by the object, and the object is only responsible for sending signals, it does not need to care who receives the signal at the other end. This communication mechanism is similar to the publish-subscribe mode PUB / SUB of ZMQ. Therefore, this embodiment accesses the signals and Notify in QtRO through the PUB socket of the ZMQ server to send the signals and Notify in QtRO through the subscription mode of ZMQ.

[0069] Since in the QtRO communication process, the slot is used to receive signals, and the slot is just an ordinary object member function, the slot itself does not know whether there is any signal connected to itself, and the object does not need to understand the specific communication mechanism. The communication mechanism of the slot is similar to the request-response mode REQ / REP of ZMQ, both of which are similar to the server, waiting for the remote client to call, and then returning the result after running the relevant functions. Therefore, this embodiment converts the slot function call of QtRO into a call through the REP socket of the ZMQ server. In addition, for the Read and Write of the attribute, since only a response result is returned in the end, this communication mechanism is also similar to the request-response mode REQ / REP of ZMQ, so this embodiment converts the Read and Write operations of the attribute into operations through the REP socket of the ZMQ server.

[0070] In one embodiment, if Figure 3 As shown, the Notify of the signal and property is accessed through the PUB socket of the ZMQ server, including steps 310 to 330, wherein:

[0071] Step 310, a dynamic slot function is generated according to the metasystem of Qt; the dynamic slot function internally uses the PUB socket of the ZMQ server to send data.

[0072] Step 320, according to the signal and slot mechanism of Qt, establish a connection between the dynamic slot function and the Notify of the signal and attribute in QtRO.

[0073] Step 330, in the dynamic slot function, obtain the parameters of the signal and Notify, and use the parameters as the architecture sent by the PUB socket.

[0074] For each signal and property Notify, a dynamic slot function is generated according to Qt's metasystem to connect with the signal and property Notify. In the dynamic slot function, all parameters sent with the signal and property Notify can be obtained in turn, and used as the framework frames when the ZMQ server PUB socket sends, thereby realizing the automatic conversion from signal and property Notify to PUB socket.

[0075] Specifically, the process of converting the Notify of a signal or attribute into a ZMQ PUB message is as follows Figure 4 As shown in the figure. On the left is a QtRO signal sigXYZ, and on the right is a dynamic slot function that is automatically and dynamically constructed. It uses the ZMQ PUB socket to send data. The signal in QtRO is connected to the dynamic slot function through Qt's signal and slot mechanism. When the signal occurs, the dynamic slot function will be automatically called, and the ZMQ PUB message will be broadcasted, thus achieving the effect of automatically forwarding the QtRO signal to ZMQ.

[0076] In one embodiment, converting the slot function call of QtRO into a REP socket call through the ZMQ server includes:

[0077] Create a REP server for all slot functions in QtRO, and the REP server contains the REP socket of the ZMQ server;

[0078] Receive the REQ request and obtain the slot function name of the REQ request;

[0079] If the slot function name in the QtRO contains the slot function name of the REQ request, the corresponding slot function in the QtRO is called through the REP socket, and the return value is returned to the client through the REP server.

[0080] In this embodiment, for all slot functions in QtRO, only one REP server is created. The REP server can be understood as a thread, and there is a REP socket of a ZMQ server inside the thread. The REQ request is listened to in the REP server, and the slot function name of the REQ request is obtained. Specifically, the REQ request is a ZMQ data packet, and the REP server obtains the slot function name of the REQ request by checking the envelope field of the data packet. If the slot function name in QtRO contains the slot function name of the REQ request, the corresponding slot function in QtRO is called through the REP socket, and the return value is returned to the client through the REP server.

[0081] In this embodiment, since multiple slot functions correspond to one thread, only one function can be executed at the same time, lacking parallel capabilities. If multiple slot functions are to be executed simultaneously, this solution cannot be executed.

[0082] In one embodiment, if Figure 5 As shown, converting the slot function call of QtRO into a REP socket call through the ZMQ server includes steps 510 to 540, wherein:

[0083] Step 510, for each slot function, create a corresponding REP server, wherein the REP server includes a REP socket of the ZMQ server.

[0084] Step 520: Monitor the name of each slot function in QtRO through the REP server as the first slot function name.

[0085] Step 530: Receive a REQ request, and obtain the slot function name in the REQ request as the second slot function name.

[0086] Step 540: If the first slot function name is consistent with the second slot function name, the corresponding slot function in QtRO is called through the REP socket, and the return value is returned to the client through the REP server.

[0087] The REP server can be understood as a thread, and there is a REP socket of the ZMQ server inside the thread. If there is a slot function named slotXYZ in QtRO that needs to be exposed through ZMQ, you first need to create a corresponding REP server for each slot function, and then listen to the REQ request through the REP server, and obtain the slot function name of the REQ request. Specifically, the REQ request is a ZMQ data packet, and the REP server obtains the slot function name of the REQ request by checking the envelope field of the data packet. Then determine whether the envelope part of the ZMQ data packet is "slotXYZ". If so, it means that the client wants to call the slot function, then call the slot function and send the result back to the client as the reply part of this Request / reply, completing the forwarding from QtRO to ZMQ.

[0088] For each QtRO slot function, this embodiment will automatically generate a thread, and each thread has a REP socket of the ZMQ server. The thread listens to the ZMQ data packet outside and checks the envelope of the data packet. If the envelope contains the function, the slot function of QtRO is called, and then the result is sent back to the client. Since each slot function has an independent thread, each thread can run independently, which means that all slot functions can be executed in parallel. Of course, for operations that require synchronization and mutual exclusion, the developer of the remote client still needs to do a good job of thread synchronization.

[0089] In one embodiment, the ZMQ data packet includes an envelope or a payload, and is stored in one of the fields of the ZMQ data packet in a JSON format.

[0090] In one embodiment, the ZMQ data packet includes two parts, an envelope and a payload, wherein the envelope is used to store the signal name or the slot function name. Envelop can be a string. For QtRO signal and attribute Notify forwarding, the envelope stores the signal name. For QtRO slot function forwarding, the envelope stores the function name. The actual data is stored in the payload. Taking QtRO slot function forwarding as an example, when the thread monitors the external ZMQ data packet, it only needs to check the slot function name in the envelope. If it is consistent with the slot function name in the thread, it means that the client wants to call the slot function. Then, the slot function is called and the result is sent back to the client as the reply part in this Request / reply, completing the forwarding from QtRO to ZMQ.

[0091] In one embodiment, the ZMQ data packet includes an envelope or a payload, and is stored in one of the fields of the ZMQ data packet in a JSON format.

[0092] The ZMQ data packet only includes the "envelope" part, which is used to store the signal name (for QtRO signal, property Notify forwarding) or function name (for QtRO slot function forwarding). After the thread listens to the ZMQ data packet, it must first be parsed into a JSON object, and then the "envelop" field in the ZMQ data packet can be obtained, and then processed separately. Parsing and creating JSON objects requires computing time and resources, and some messages do not actually need to be parsed into JSON format. For such messages or processing, JSON parsing becomes an unnecessary overhead.

[0093] In one embodiment, the ZMQ data packet includes two parts: envelope and payload, wherein the envelope is used to store the signal name or slot function name; and the payload is used to store the actual data.

[0094] In this embodiment, Envelop and payload are separated, so that a frame of data can be obtained independently (ZMQ sends and receives data in frames, and a data packet can contain 0 to any number of frames). At this time, the type of the data packet can be quickly determined, and then whether the payload needs to be further parsed according to the type of the ZMQ data packet. This saves a lot of parsing overhead for commands that do not require JSON format.

[0095] In one embodiment, converting the Read and Write operations of the attribute into operations performed through a REP socket of the ZMQ server includes:

[0096] Create a REP server on the ZMQ server side, and listen to external ZMQ data packets through the REP server; the REP server includes the REP socket on the ZMQ server side;

[0097] The monitored ZMQ data packet is compared with the data in the REP server to write the corresponding data through the REP socket or call the corresponding data through the REP socket.

[0098] The conversion of attribute Read and Write operations to REP sockets on the ZMQ server is similar to the conversion of QtRO slot function calls to REP sockets on the ZMQ server, as follows:

[0099] The REP server can be understood as a thread, and there is a REP socket of the ZMQ server inside the thread. The external ZMQ data packet is monitored through the REP server. The ZMQ data packet includes two parts: envelope and payload, where envelope is used to store signal names, slot function names or parameter names; the actual data is stored in the payload. The monitored ZMQ data packet is compared with the data in the REP server. If the data in the external ZMQ data packet monitored is consistent with the data in the REP server, the corresponding data is written through the REP socket or the corresponding data is called through the REP socket. Comparing the ZMQ data packet with the data in the REP server can be comparing the parameter name in the envelope with the parameter name in the REP server. If they are consistent, the actual data stored in the payload is written to the REP server through the REP socket or the corresponding data in the REP server is called through the REP socket.

[0100] It should be understood that although Figure 1 , Figure 3 and Figure 5 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 , Figure 3 and Figure 5 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0101] In one embodiment, Figure 6 As shown, a communication device is provided, including: an acquisition module 610, a matching module 620 and a processing module 630, wherein:

[0102] The acquisition module 610 is used to acquire Qt meta information and determine the type of the Qt meta information.

[0103] The matching module 620 is used to access the Qt meta information through a matching ZMQ server socket according to the type of the Qt meta information.

[0104] The processing module 630 is used to process the Qt meta information through the connected ZMQ server socket.

[0105] In one embodiment, the types of the Qt meta information include attributes, signals and slots, and the attributes include Notify, Read and Write; the ZMQ server socket includes a PUB socket and a REP socket;

[0106] The matching module 620 sends the Notify of the signal and attribute through the PUB socket of the ZMQ server;

[0107] The matching module 620 converts the Read and Write operations of the attributes into operations through the REP socket of the ZMQ server;

[0108] The matching module 620 converts the slot function call of QtRO into a REP socket call through the ZMQ server.

[0109] In one embodiment, the matching module 620 sends the Notify of the signal and attribute through the PUB socket of the ZMQ server, including:

[0110] A dynamic slot function is generated according to the Qt metasystem; the dynamic slot function uses the PUB socket of the ZMQ server to send data;

[0111] According to Qt's signal and slot mechanism, the dynamic slot function is connected with the Notify of the signal and property in QtRO;

[0112] In the dynamic slot function, the parameters of Signal and Notify are obtained, and the parameters are used as the architecture for sending the PUB socket.

[0113] In one embodiment, the matching module 620 converts the slot function call of QtRO into a REP socket call through the ZMQ server, including:

[0114] For each slot function, create a corresponding REP server, which includes the REP socket of the ZMQ server;

[0115] The name of each slot function in QtRO is monitored by the REP server as the first slot function name;

[0116] Receive a REQ request and obtain the slot function name of the REQ request as the second slot function name;

[0117] If the first slot function name is consistent with the second slot function name, the corresponding slot function in QtRO is called through the REP socket, and the return value is returned to the client through the REP server.

[0118] In one embodiment, the matching module 620 converts the slot function call of QtRO into a REP socket call through the ZMQ server, including:

[0119] A REP server is generated for all slot functions in QtRO, and the REP server contains the REP socket of the ZMQ server;

[0120] Receive the REQ request and obtain the slot function name of the REQ request;

[0121] If the slot function name in the QtRO contains the slot function name of the REQ request, the corresponding slot function in the QtRO is called through the REP socket, and the return value is returned to the client through the REP server.

[0122] In one embodiment, the matching module 620 converts the Read and Write operations of the attribute into operations performed through the REP socket of the ZMQ server, including:

[0123] Create a REP server on the ZMQ server side, and listen to external ZMQ data packets through the REP server; the REP server includes the REP socket on the ZMQ server side;

[0124] The monitored ZMQ data packet is compared with the data in the REP server to write the corresponding data through the REP socket or call the corresponding data through the REP socket.

[0125] In one embodiment, the ZMQ data packet includes two parts: envelope and payload, wherein the envelope is used to store the signal name or slot function name; and the payload is used to store the actual data.

[0126] In one embodiment, the ZMQ data packet includes an envelope or a payload, and is stored in one of the fields of the ZMQ data packet in a JSON format.

[0127] The communication device provided in the embodiment of the present application includes an acquisition module 610, a matching module 620 and a processing module 630. The acquisition module 610 acquires the Qt meta information in QtRO and determines the type of Qt meta information; the matching module 620 accesses the Qt meta information through the matching ZMQ server socket according to the type of Qt meta information; the processing module 630 processes the Qt meta information through the accessed ZMQ server socket. The communication device provided in the present application accesses the Qt meta information through the matching ZMQ server socket according to the type of Qt meta information in QtRO, and can automatically convert the interface of QtRO into a ZMQ interface, thereby realizing that the module communication at the bottom layer is still QtRO, and developers can still use QtRO to develop various functional modules; using the ZMQ interface at the upper layer, it can allow a variety of other development languages ​​and frameworks to access, taking into account the ease of use and openness of inter-process communication.

[0128] For the specific definition of the communication device, please refer to the definition of the communication method above, which will not be repeated here. Each module in the above communication device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0129] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a communication method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0130] Those skilled in the art will understand that Figure 7The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0131] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0132] Get the Qt meta information in QtRO and determine the type of Qt meta information;

[0133] According to the type of Qt meta information, access the Qt meta information through a matching ZMQ server socket;

[0134] The Qt meta information is processed through the connected ZMQ server socket.

[0135] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0136] Get the Qt meta information in QtRO and determine the type of Qt meta information;

[0137] According to the type of Qt meta information, access the Qt meta information through a matching ZMQ server socket;

[0138] The Qt meta information is processed through the connected ZMQ server socket.

[0139] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0140] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0141] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A communication method, characterized in that: The method comprises: Obtain Qt meta information in QtRO and determine the type of Qt meta information; the type of Qt meta information includes attributes, signals and slots, and the attributes include Notify, Read and Write; According to the type of Qt meta information, the Qt meta information is accessed through a matching ZMQ server socket; the ZMQ server socket includes a PUB socket and a REP socket; when the Qt meta information is accessed through the PUB socket, ZMQ works in the publish-subscribe mode PUB / SUB; when the Qt meta information is accessed through the REP socket, ZMQ works in the request-response mode REQ / REP; Processing the Qt meta information through the connected ZMQ server socket; The accessing of the Qt meta information through a matching ZMQ server socket according to the type of the Qt meta information includes: Connect the Notify of signals and properties through the PUB socket of the ZMQ server; Convert the Read and Write operations of the attributes to operations through the REP socket of the ZMQ server; Convert QtRO's slot function call into a REP socket call through the ZMQ server.

2. The method according to claim 1, characterized in that The Notify of the signal and property is accessed through the PUB socket of the ZMQ server, including: A dynamic slot function is generated according to the Qt metasystem; the dynamic slot function uses the PUB socket of the ZMQ server to send data; According to Qt's signal and slot mechanism, the dynamic slot function is connected with the Notify of the signal and property in QtRO; In the dynamic slot function, the parameters of Signal and Notify are obtained, and the parameters are used as the architecture for sending the PUB socket.

3. The method according to claim 1, characterized in that The conversion of the QtRO slot function call into a REP socket call via the ZMQ server includes: For each slot function, create a corresponding REP server, which includes the REP socket of the ZMQ server; The name of each slot function in QtRO is monitored by the REP server as the first slot function name; Receive a REQ request and obtain the slot function name of the REQ request as the second slot function name; If the first slot function name is consistent with the second slot function name, the corresponding slot function in QtRO is called through the REP socket, and the return value is returned to the client through the REP server.

4. The method according to claim 1, characterized in that The conversion of the QtRO slot function call into a REP socket call via the ZMQ server includes: A REP server is generated for all slot functions in QtRO, and the REP server contains the REP socket of the ZMQ server; Receive the REQ request and obtain the slot function name of the REQ request; If the slot function name in the QtRO contains the slot function name of the REQ request, the corresponding slot function in the QtRO is called through the REP socket, and the return value is returned to the client through the REP server.

5. The method according to claim 3, characterized in that: The conversion of the Read and Write operations of the attributes into operations performed through the REP socket of the ZMQ server includes: Create a REP server of the ZMQ server, and listen to external ZMQ data packets through the REP server; the REP server includes the REP socket of the ZMQ server; The monitored ZMQ data packet is compared with the data in the REP server to write the corresponding data through the REP socket or call the corresponding data through the REP socket.

6. The method according to claim 5, characterized in that The ZMQ data packet includes two parts: envelope and payload, wherein envelope is used to store signal names or slot function names; payload is used to store actual data; or, The ZMQ data packet includes an envelope or a payload, and is stored in one of the fields of the ZMQ data packet in a JSON format.

7. A communication device, characterized in that: The device comprises: An acquisition module, used to acquire Qt meta information and determine the type of Qt meta information; the type of Qt meta information includes attributes, signals and slots, and the attributes include Notify, Read and Write; A matching module is used to access the Qt meta information through a matching ZMQ server socket according to the type of Qt meta information; the ZMQ server socket includes a PUB socket and a REP socket; when the Qt meta information is accessed through the PUB socket, ZMQ works in a publish-subscribe mode PUB / SUB; when the Qt meta information is accessed through the REP socket, ZMQ works in a request-response mode REQ / REP; A processing module, used for processing the Qt meta information through the connected ZMQ server socket; The matching module is also used to connect the Notify of signals and properties through the PUB socket of the ZMQ server; Convert the Read and Write operations of the attributes to operations through the REP socket of the ZMQ server; Convert QtRO's slot function call into a REP socket call through the ZMQ server.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.