A communication method, computing device and storage medium between CAD front end and back end

The asynchronous messaging of CAD front-end and back-end is realized through the Electron framework and ZeroMQ, which solves the problem of inefficient front-end communication in CAD secondary development, improves the stability and scalability of the system, and is suitable for CAD applications with multiple platforms and multiple clients. .

CN118502991BActive Publication Date: 2024-12-24BEIJING YUANHUI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410956754.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-17
Publication Date
2024-12-24
Estimated Expiration
2044-07-17

AI Technical Summary

Technical Problem

In the secondary development of CAD, the existing technology lacks effective front-end and back-end communication methods, resulting in low efficiency, high complexity, limited scalability, low reliability and poor adaptability, making it difficult to meet real-time interaction and multiple The requirement for client collaboration.

Method used

The Electron framework is used to build the front-end module and ZeroMQ middleware module. The middleware module realizes asynchronous message delivery between the front-end and back-end through the middleware module, ensures low latency, high concurrency and integrity of messages, and dynamically adjusts the system parameters through the adaptive control module to Adapt to different load conditions.

Benefits of technology

It realizes efficient, reliable and flexible communication between the front and back ends, improves the stability and scalability of the system, is suitable for CAD applications with multiple platforms and multiple clients, and enhances the real-time and user experience of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118502991B_ABST
    Figure CN118502991B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of CAD secondary development, and discloses a communication method, computing device and storage medium for the front-end and back-end of a CAD. The method comprises the steps of: constructing a front-end module and a back-end module in a computing device, wherein the back-end module comprises one or more CAD clients; constructing a middleware module according to the front-end module and the back-end module; in response to receiving a user operation according to the front-end module, the front-end module generates a message according to the user operation and the client ID of the target CAD client to be operated; and encapsulating the message and sending it to the target CAD client through the middleware module, so as to realize the unified encapsulation of data and instructions, and facilitate the back-end module to parse and process the message after the middleware module sends the message to the back-end module. The method solves the technical problem that in the secondary development of CAD, most UI interfaces used by the secondary development plug-ins of CAD are coded according to the MFC framework provided by Microsoft, and the front-end and back-end separation is not performed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of CAD secondary development, and in particular to a communication method, computing equipment and storage medium between a CAD front end and a back end. Background Art

[0002] CAD (Computer-Aided Design) is a software that uses computer technology to assist in design and drawing. By using specialized CAD software, you can create, modify and optimize various designs, from simple two-dimensional graphics to complex three-dimensional models. In engineering design, CAD plays a vital role, providing an efficient, accurate and visual way to create and edit designs. CAD secondary development refers to the secondary development and customization of CAD based on its flexible openness, making it more suitable for a specific design field.

[0003] The publication number is CN115688209A, and the name of the invention is a CAD secondary development survey and drawing auxiliary design system, which belongs to the field of CAD secondary development technology. The disclosed system includes: establishing a standard survey graphic library and realizing survey and design drawing auxiliary tools; survey project and drawing information setting; plane drawing hole layout; setting a unified hole depth for the survey holes on the CAD drawing; marking the hole depth for all selected survey hole depth text field contents; selecting multiple holes on the CAD drawing to connect the selected holes with the profile; then selecting the holes and profile lines, disconnecting or connecting the selected survey holes with the profile lines, and reordering the profile line drawing points; exporting or importing data on the CAD drawing as needed; checking the content of the survey CAD drawing and giving error prompts.

[0004] The publication number is CN110826185A, and the invention name is a method for establishing a bearing parts library based on CAD secondary development, which belongs to the field of CAD secondary development technology. The disclosed method includes: extracting all types and main size parameters of bearings according to the national standard manual, and establishing a CAD bearing model parameter database; establishing a mathematical operation model and a human-machine dialog box model by determining the number and relative position of the characteristic points of the bearing; realizing automatic modeling of various types of bearings by designing a driver; verifying the feasibility of the method through specific examples; and finally adding the invention as a drawing function of CAD to the CAD main interface.

[0005] However, in the secondary development of CAD, most of the UI interfaces used in CAD secondary development plug-ins are coded based on the MFC framework provided by Microsoft, without separation of the front-end and back-end. However, the communication needs between the front-end interface and the back-end service are still common.

[0006] To this end, a new communication method, computing device and storage medium between the CAD front end and back end are needed. Summary of the invention

[0007] To this end, the present invention provides a communication method, a computing device and a storage medium for a CAD front end and a back end, in an effort to solve the above problems.

[0008] According to one aspect of the present invention, a communication method for a CAD front-end and back-end, a computing device and a storage medium are provided, which are suitable for execution in a computing device, and the method comprises the steps of: constructing a front-end module and a back-end module in a computing device, the back-end module comprising one or more CAD clients; constructing a front-end module and a back-end module in a computing device, the back-end module comprising one or more CAD clients; constructing a middleware module according to the front-end module and the back-end module; in response to receiving a user operation according to the front-end module, the front-end module generates a message according to the user operation and the client ID of the target CAD client to be operated; and encapsulating the message and sending it to the target CAD client through the middleware module.

[0009] Optionally, the multiple CAD clients are CAD clients of different types.

[0010] Optionally, the front-end module is built using the Electron framework, the middleware module is built using ZeroMQ, and the message encapsulation format is JSON or Protobuf.

[0011] Optionally, before responding to the user operation received by the front-end module, the method further includes: one or more CAD clients included in the back-end module send port parameters and client IDs of each CAD client to the front-end module through the middleware module.

[0012] Optionally, the user operation is a startup operation; the front-end module generates a message according to the user operation and the client ID of the target CAD client to be operated; and the message is encapsulated and sent to the target CAD client through the middleware module, including: the front-end module generates a startup message according to the startup operation of the CAD client and the client ID of the target CAD client to be started; the front-end module encapsulates the startup message to obtain the encapsulated startup message; the middleware module sends the encapsulated startup message to the target CAD client according to the port parameters.

[0013] Optionally, the user operation is a file selection operation, and the front-end module generates a message according to the user operation and the client ID of the target CAD client to be operated; and encapsulates the message and sends it to the target CAD client through the middleware module, including: the front-end module generates a file selection message according to the file selection operation and the client ID of the target CAD client of the file to be selected; the front-end module encapsulates the file selection message to obtain the encapsulated file selection message; the middleware module sends the encapsulated file selection message to the target CAD client according to the port parameters.

[0014] Optionally, the user operation also includes closing the UI interface operation, and the method also includes: the front-end module generates a closing message based on the closing UI interface operation and the client ID of the target CAD client; the front-end module encapsulates the closing message to obtain the encapsulated closing message; the middleware module sends the encapsulated closing message to the target CAD client according to the port parameters, so that the target CAD client deregisters system resources.

[0015] Optionally, the message includes the client ID of the target CAD client, the operation command of the user operation, and the carried transmission information.

[0016] Optionally, the message also includes a serial number, which is a globally increasing integer used to identify the order in which the front-end module receives user operations; the target CAD client includes a processing queue; the method also includes: the target CAD client stores the messages in the processing queue; the target CAD client selects the messages with the smallest serial numbers from the processing queue in order of the serial numbers for processing; after processing the messages, the target CAD client sends a confirmation message to the front-end module through the middleware module to notify the front-end module to update the processed serial numbers according to the confirmation message.

[0017] Optionally, after the front-end module generates a message based on the user operation and the client ID of the target CAD client to be operated, and encapsulates the message and sends it to the target CAD client through the middleware module, the method also includes: the front-end module determines whether a confirmation message is received within a preset time, and if not, re-encapsulates the message and sends it to the target CAD client through the middleware module.

[0018] Optionally, before the target CAD client processes the message, the method also includes: the target CAD client compares whether the serial number of the message is the same as the serial number of a processed message. If so, the message is not processed, and a confirmation message is directly sent to the front-end module through the middleware module.

[0019] Optionally, the target CAD client also includes an error queue, and the method also includes: if an error occurs when the target CAD client processes a message, the message is added to the error queue; the target CAD client sends an error message to the front-end module through the middleware module based on the message in the error queue, and the error message includes the cause of the error and a solution.

[0020] Optionally, the computing device also includes an adaptive control module; the front-end module also includes a front-end monitoring module, and the target CAD client also includes a back-end monitoring module. The front-end monitoring module and the back-end monitoring module are used to collect system status data. The method also includes: the adaptive control module determines the system load index based on the system status data; and dynamically adjusts the system parameters based on the load index.

[0021] Optionally, the system status data includes the length of the message sending queue and the message processing time; the adaptive control module determines the system load index based on the system status data; and the system parameters are dynamically adjusted according to the load index, including: the adaptive control module uses the message queue length, message processing time and target load as parameters to determine the adjustment parameters of the middleware module; the front-end module adjusts the high water level of the middleware module's outbound messages according to the adjustment parameters, and the target CAD client adjusts the high water level of the middleware module's incoming messages according to the adjustment parameters.

[0022] According to another aspect of the present invention, a computing device is provided, comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for executing any method of the communication method of the CAD front end and back end, the computing device, and the storage medium according to the present invention.

[0023] According to another aspect of the present invention, a computer-readable storage medium storing one or more programs is provided, wherein the one or more programs include instructions which, when executed by a computing device, enable the computing device to execute any one of the methods of communication between a CAD front end and a back end, a computing device, and a storage medium according to the present invention.

[0024] The present invention discloses a communication method, computing device and storage medium for the front-end and back-end of a CAD, which are suitable for execution in a computing device. The present invention constructs a front-end module and a back-end module in the computing device, so that the front-end and back-end for operating the CAD are separated, and a middleware module is constructed according to the front-end module and the back-end module, so as to facilitate the establishment of communication between the front-end module and the back-end module. In response to receiving a user operation according to the front-end module, the front-end module generates a message according to the user operation and the client ID of the target CAD client to be operated; and the message is encapsulated and sent to the target CAD client through the middleware module, so as to realize the unified encapsulation of data and instructions, so that after the middleware module sends the message to the back-end module, the back-end module parses and processes the message. The present invention solves the technical problem that in the secondary development of CAD, most of the UI interfaces used in the secondary development plug-ins of CAD are coded according to the MFC framework provided by Microsoft, without separating the front-end and back-end. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] To achieve the above and related purposes, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings, which indicate various ways in which the principles disclosed herein can be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The above and other purposes, features and advantages of the present disclosure will become more apparent by reading the following detailed description in conjunction with the accompanying drawings. Throughout the present disclosure, the same reference numerals generally refer to the same parts or elements.

[0026] Figure 1 A flow chart showing a communication method between a CAD front end and a back end according to an exemplary embodiment of the present invention is shown;

[0027] Figure 2 A schematic diagram showing a front-end module and a back-end module in a computing device according to an exemplary embodiment of the present invention is shown;

[0028] Figure 3 A schematic diagram showing a UI interface provided by a front-end module according to an exemplary embodiment of the present invention is shown;

[0029] Figure 4 A schematic diagram showing communication between a front-end module and a back-end module according to an exemplary embodiment of the present invention is shown;

[0030] Figure 5 A schematic diagram showing communication between a front-end module and a back-end module according to another exemplary embodiment of the present invention is shown;

[0031] Figure 6a and Figure 6b A schematic diagram of selecting different CAD clients in a front-end module according to an exemplary embodiment of the present invention is shown. DETAILED DESCRIPTION

[0032] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to enable the scope of the present disclosure to be fully conveyed to those skilled in the art. The same reference numerals generally refer to the same components or elements.

[0033] Some existing communication implementation methods currently include but are not limited to HTTP, WebSocket, TCP / IP and other network communication protocols, through which front-end user operations are converted into data instructions and passed to the back-end for processing. However, in actual applications, these traditional technologies may have the following shortcomings:

[0034] Inefficiency: Traditional HTTP requests have a lot of latency and round-trip time, which is not suitable for real-time interaction or frequent data exchange scenarios.

[0035] High complexity: For applications that require guaranteed message order, low-latency responses, or two-way communication, such as dynamic rendering and real-time updates of CAD systems, a simple request-response model may not meet the requirements and requires additional design and maintenance of a complex message queue mechanism.

[0036] Limited scalability: Some traditional solutions have limited performance when processing a large number of concurrent requests, and it is difficult to efficiently support multiple clients connecting simultaneously and working together in real time.

[0037] Low reliability: The original communication mechanism did not fully consider issues such as data integrity and message loss, especially in the transmission of sensitive design information.

[0038] Poor adaptability: For secondary development of specific CAD software, the existing interface docking and data format conversion are not flexible enough, and are not easy to integrate across platforms and devices.

[0039] To this end, the present invention proposes a communication method between a CAD front end and a back end, which is suitable for execution in a computing device.

[0040] Figure 1 FIG. 1 shows a flow chart of a communication method between a CAD front end and a back end according to an exemplary embodiment of the present invention. Figure 1 As shown, firstly, step 110 is performed to construct a front-end module and a back-end module in a computing device, wherein the back-end module may include one or more CAD clients; and a middleware module is constructed according to the front-end module and the back-end module. The front-end module may be constructed using the Electron framework, and the middleware module may be constructed using ZeroMQ. The middleware module is suitable for establishing communication between the front-end module and the back-end module.

[0041] Figure 2 FIG. 1 is a schematic diagram showing a front-end module and a back-end module in a computing device according to an exemplary embodiment of the present invention. Figure 2 As shown, the computing device 200 includes a front-end module 210 , a middleware module 220 , and a back-end module 230 .

[0042] The front-end module 210 can be specifically implemented as a module that provides a UI interface and receives user operations according to the UI interface, such as the user's start or close of the UI interface or the CAD client.

[0043] Figure 3 FIG. 1 is a schematic diagram showing a UI interface provided by a front-end module according to an exemplary embodiment of the present invention. Figure 3 As shown, users can operate the backend CAD client through this UI interface.

[0044] The front-end module 210 can be constructed using the Electron framework to provide a native application experience, and can be easily deployed across platforms to provide a consistent user experience on multiple platforms, such as Windows, macOS, and Linux operating systems; and an exe entry file is set to simplify the user's startup and use process. The present invention does not limit the specific construction framework type of the front-end module 210.

[0045] When the front-end module 210 communicates, command line parameters (such as port and cadid) may be used to configure communication parameters with the back-end module 230 .

[0046] The middleware module 220 is suitable for forwarding the user's instructions to the backend module 230. The backend module 230 is suitable for being implemented as a CAD client. The present invention does not limit the type of CAD software specifically implemented by the CAD client, such as CAD software from different manufacturers such as Siemens, Dassault, and ZW. By setting the front-end and back-end separation, the resources of the front-end module 210 and the back-end module 230 can also be managed separately. When the UI interface provided by the front-end module 210 is closed, a close command is sent to cancel the related resources of the middleware module 220 and / or the back-end module 230, thereby improving the convenience of front-end and back-end resource management.

[0047] According to one embodiment of the present invention, the middleware module 220 can be specifically implemented as an asynchronous message library ZeroMQ. When the middleware module 220 communicates with the front-end module 210, the front-end module 210 can serve as a client of the communication, and the middleware module 220 can serve as a server of the communication. The client of the communication and the server of the communication can use the "REQ-REP" socket type to communicate, and realize the requirements of low-latency communication, high-concurrency communication and communication data integrity between the front-end module 210 and the back-end module 230. Through the efficient and reliable two-way real-time communication of ZeroMQ, it is particularly suitable for CAD application environments with high requirements on response speed. Even in the case of unstable network, it can ensure the accurate delivery and reception of commands and data, thereby enhancing the stability and reliability of the system.

[0048] According to one embodiment of the present invention, in order to deploy the middleware module 220, the present invention first constructs tools and dependencies, specifically: using the Node.js construction tool node-gyp and the JavaScript version of ZeroMQ: ZeroMQ.js, to ensure that the ZeroMQ library can be correctly compiled and used in the Electron environment.

[0049] When building Electron, according to the document address,

[0050] For example: https: / / www.electronjs.org / zh / docs / latest / tutorial / quick-start

[0051] Get the project construction process document. Then create the dependent library according to the following code:

[0052] Bash

[0053] npm install -g node-gyp

[0054] git clone https: / / github.com / electron / electron-quick-start

[0055] cd electron-quick-start

[0056] npm install

[0057] npm install zeromq@6.0.0-beta.17 --zmq-shared.

[0058] Then proceed with the project building and packaging process: build the project structure according to Electron requirements, complete the project dependency installation according to the cnpminstall command, and start the application for local testing according to specific command line parameters. If the test is correct, execute the packaging command npm run build to generate executable files and installation packages suitable for the target platform. After packaging is completed, you can check whether the executable files and installation packages are generated in the output folder.

[0059] The present invention allows developers to create desktop applications that can run on multiple operating system platforms, thereby solving the compatibility problem in different operating system environments. By standardizing the packaging process, corresponding executable files and installation packages can be generated, which is convenient for users to install and use on different platforms, so that the communication method of the present invention has good cross-platform deployment characteristics.

[0060] When performing local testing, use the following command to test whether the application can be started. The specific commands are as follows:

[0061] npm start port=3000 cadid=001.

[0062] When the middleware module 220 communicates with the backend module 230, the TCP / IP protocol can be used to achieve real-time and efficient communication with the backend module 230; the middleware module 220 provides powerful message queuing, distribution and routing capabilities, which can effectively meet the needs of strong real-time and frequent data transmission and reduce network delays.

[0063] According to an example of the present invention, when the front-end module 210 sends a message to the back-end module 230 through the middleware module 220, the message can be encapsulated in JSON format. The present invention does not limit the specific format of the message. The message includes a client ID, an operation command (Code) and a transmission information (Message). The client ID is used to identify and determine the CAD client in the back-end module 230 to communicate. The operation command is used to indicate the type of command to be executed by the back-end module 230, such as web_start, openfile or web_close. The transmission information includes the information to be transmitted, such as an empty string, an absolute file path, etc. Encapsulating the message in a unified format can achieve standardized transmission of data and messages, and has a clear structure for parsing, and does not require each CAD client to set a corresponding message transmission format separately.

[0064] According to an embodiment of the present invention, the middleware module 220 communicates with the backend module 230 using the TCP protocol, and the backend module 230 sends a port parameter (port) and a client ID (cadid) of the CAD client to the frontend module 210 .

[0065] The code for the front-end module 210 to start the UI interface and obtain parameters is as follows:

[0066] Shell

[0067] DftConvertClient.exe port cadid.

[0068] The port parameter (port) can be implemented as 127.0.0.1.

[0069] Then, step 120 is executed. In response to receiving the user operation according to the front-end module 210, the front-end module 210 generates a message according to the user operation and the client ID of the target CAD client to be operated, and encapsulates the message and sends it to the target CAD client through the middleware module 220. The format of the message encapsulation can be JSON or Protobuf.

[0070] According to one embodiment of the present invention, one or more CAD clients included in the backend module 230 send the port parameters and client ID of each CAD client to the frontend module 210 through the middleware module 220. After executing the message, the backend module 230 sends a confirmation message to the frontend module 210 through the middleware module 220.

[0071] It should be noted that the user operation may be a startup operation, a file selection operation, a UI interface closing operation, etc., or may be a drawing operation generated by the user operating the CAD system.

[0072] The user operation can be a startup operation; the front-end module generates a startup message according to the startup operation of the CAD client and the client ID of the target CAD client to be started; the front-end module encapsulates the startup message to obtain the encapsulated startup message; the middleware module sends the encapsulated startup message to the target CAD client according to the port parameters.

[0073] Specifically, the front-end module 210 is connected to the TCP port specified in the back-end module 230 through the middleware module 220, and sends a startup command to the back-end module 230 in the form of a message. The front-end module 210 uses a REQ type socket for communication. After the back-end module 230 is started, it sends a confirmation message of successful startup. The message specifically includes:

[0074] {"id":"cadid","code":"web_start","msg":""}.

[0075] User operations also include file selection operations. After receiving the file selection operation, the front-end module 210 generates a file selection message based on the file selection operation and the client ID of the target CAD client of the file to be selected; the front-end module 210 encapsulates the file selection message to obtain the encapsulated file selection message; the middleware module 220 sends the encapsulated file selection message to the target CAD client according to the port parameters.

[0076] When performing a file selection operation, when the front-end module 210 receives a user operation of selecting a file from the user according to the UI interface, the front-end module 210 encapsulates the absolute path of the selected file into a message in a predetermined format through the middleware module 220 and sends it to the back-end module 230, thereby achieving precise control of the CAD software and data transmission. The message specifically includes:

[0077] {"id":"cadid","code":"openfile","msg":"absolute file path"}.

[0078] User operations also include closing the UI interface operation. After receiving the closing UI interface operation, the front-end module 210 generates a closing message based on the closing UI interface operation and the client ID of the target CAD client; the front-end module 210 encapsulates the closing message to obtain the encapsulated closing message; the middleware module 220 sends the encapsulated closing message to the target CAD client according to the port parameters, so that the target CAD client deregisters the system resources.

[0079] When the UI interface provided by the front-end module 210 is closed, a closing command is sent to the back-end module 230 in the form of a message through the middleware module 220. After receiving the closing command, the back-end module 230 deregisters the corresponding CAD client. The present invention also deregisters the resources of the closed target CAD client in the middleware module 220 and the back-end module 230.

[0080] The messages obtained by closing the command encapsulation include:

[0081] {"id":"cadid","code":"web_close","msg":""}.

[0082] Through the above steps, the present invention can clearly define the interactive process of starting, file operation and closing of the front-end module 210 and the back-end module 230, and strengthen the controllability and consistency of system operation. Through clear data and command encapsulation standards and interactive logic, the later maintenance cost is reduced and the scalability and reusability of the system are enhanced.

[0083] Figure 4 FIG. 2 shows a schematic diagram of a front-end module communicating with a back-end module according to an exemplary embodiment of the present invention. Figure 4 As shown, the front-end module 210 can implement a UI interface and communicate with the CAD client of the back-end module 230 through the middleware module 220 .

[0084] The present invention can be connected to different CAD clients through only one UI interface, such as CAD clients of different manufacturers: Siemens, Dassault, ZW, etc., for secondary development. Users may have the need to use different CAD clients, and each CAD client requires the same development function, for example, they all need to convert the PDV data format. At this time, the same UI interface can be provided to control different CAD clients to achieve the same function. That is, multiple CAD clients that connect to the back-end module can communicate through the Internet through only one front-end module, and ZMQ technology, such as the asynchronous message library ZeroMQ, can be used during communication.

[0085] Figure 5 A schematic diagram of a front-end module communicating with a back-end module according to another exemplary embodiment of the present invention is shown. The back-end module 230 includes a plurality of CAD clients: a first CAD client, a second CAD client, and a third CAD client. The front-end module 210 can communicate with the plurality of CAD clients through the middleware module 220.

[0086] Figure 6a and Figure 6b FIG. 2 shows a schematic diagram of selecting different CAD clients in a front-end module according to an exemplary embodiment of the present invention. Figure 6a As shown, when you click Figure 6a After selecting "Plugin Converter" in the Figure 6b The interface shown in Figure 6b Select the CAD client with which to communicate in the interface shown.

[0087] Since a front-end module 210 communicates with multiple CAD clients of the back-end module 230 using asynchronous message queues, the order and consistency of messages may be affected. For example, if the front-end sends multiple drawing instructions to the back-end for processing, if the message queue does not guarantee a strict order, the post-processing instructions may be executed first, resulting in incorrect drawing results.

[0088] According to one embodiment of the present invention, the present invention adds a sequence number to each message that the front-end module 210 is to send to the back-end module 230. The sequence number is a globally increasing integer, which is used to identify the order in which the front-end module 210 receives user operations, and is also the order in which the back-end module 230 executes the instructions of the corresponding operations, that is, the sequence number identifies the order in which the front-end module 210 receives user operations, and the target CAD client includes a processing queue, and the method also includes: the target CAD client stores the message in the processing queue; the target CAD client selects the message with the smallest sequence number from the processing queue in order according to the sequence number for processing; after the target CAD client finishes processing the message, it sends a confirmation message to the front-end module 210 through the middleware module 220 to notify the front-end module 210 to update the processed sequence number according to the confirmation message.

[0089] The target CAD client executes according to the sequence number. The sequence number can be set using a global variable and set to an increasing integer to ensure that each operation has a unique identifier. For example, the front-end module 210 uses the current_sequence_number global variable to set the sequence number, and increments the variable each time a message is generated, and the sequence number and operation data are packaged together to generate a message, such as:

[0090] {

[0091] "sequence_number": 1,

[0092] "operation":"draw_line",

[0093] "data": {"start": [0, 0],"end": [100,100]}

[0094] }.

[0095] The front-end module 210 sends the message to the target CAD client through the middleware module 220. After receiving the message, the target CAD client adds the message to the processing queue, which can be specifically implemented as a priority queue (Priority Queue), and stores the message so that the message can be sorted according to the sequence number in the priority queue. When the target CAD client processes the message according to the priority queue, it selects the message with the smallest sequence number from the priority queue for processing. After processing, a confirmation message including the sequence number is sent to the front-end module 210. The front-end module 210 updates the processed sequence number according to the confirmation message to ensure the consistency of the message order.

[0096] According to one embodiment of the present invention, the message queue system may experience message loss or duplication. For example, the front-end module 210 sends an instruction to save a drawing to the back-end module 230. If the message is lost during transmission, the drawing data cannot be saved. If the message is processed repeatedly, data redundancy or conflict may occur.

[0097] According to one embodiment of the present invention, the front-end module 210 determines whether a confirmation message is received within a preset time. If not, the message is repackaged and sent to the target CAD client through the middleware module 220. The preset time can be set based on experience. The target CAD client compares the sequence number of the message to see if it is the same as the sequence number of the processed message. If so, the message is not processed and a confirmation message is directly sent to the front-end module 210 through the middleware module 220. The present invention implements a message confirmation mechanism in the front-end module 210. After each message is sent, the front-end module 210 waits for a confirmation message from the target CAD client. If a confirmation message is not received within a certain period of time, the front-end module 210 resends the message.

[0098] According to one embodiment of the present invention, the front-end module 210 includes a dictionary to record messages for which no confirmation messages have been received in the dictionary; it is determined whether the messages in the dictionary have not received corresponding confirmation messages for more than a preset time; if so, the message is resent to the target CAD client through the middleware module 220.

[0099] The dictionary of the front-end module 210 can be implemented through the pending_messages field to store unconfirmed messages, where the key is the sequence number and the value is the message content. The front-end module 210 starts a timer to wait for the confirmation message. If the confirmation message is not received within the timeout period, the message is resent.

[0100] The target CAD client records the message ID of the processed message. The message ID can be specifically implemented as the serial number of the message. Before processing the message, the target CAD client checks whether the serial number of the message has been processed to avoid repeated processing. If the message has been processed, a confirmation message is directly sent to the front-end module 210.

[0101] The target CAD client can create a collection, such as processed_messages, to store the processed message IDs, such as the message serial numbers. Before processing a message, check whether the message ID is in the collection. If it has been processed, directly send a confirmation message to the front-end module 210; otherwise, process the message and add the message ID to the collection.

[0102] According to one embodiment of the present invention, the asynchronous characteristics of the message queue may introduce delays. For example, when the front-end module 210 sends a real-time preview request to the target CAD client, if the delay in message queue processing is high, the real-time preview effect of the front-end module 210 will be affected and the user experience will deteriorate.

[0103] The present invention optimizes the configuration of the middleware module 220 and implements an asynchronous processing mechanism in the front-end module 210 .

[0104] When optimizing the configuration of the middleware module 220, the high water mark of the outgoing message and the high water mark of the incoming message are adjusted to reduce the delay of message transmission. For example, the ZMQ_SNDHWM and ZMQ_RCVHWM parameters are adjusted to control the high water mark of sending and receiving. The adjustment code is as follows:

[0105] socket.setsockopt(zmq.SNDHWM, 1000)

[0106] socket.setsockopt(zmq.RCVHWM, 1000).

[0107] When implementing the asynchronous processing mechanism on the front end, the user interface is not blocked after sending the message, allowing the user to continue other operations. This can be implemented using a multithreaded or asynchronous programming model. The specific code is as follows:

[0108] import threading

[0109] def send_message(message):

[0110] socket.send_json(message)

[0111] threading.Thread(target=send_message, args=(message,)).start().

[0112] Implement efficient message processing logic on the target CAD client to minimize processing time. For example, you can use multi-threading or asynchronous programming models to process messages to avoid blocking. The specific code is as follows:

[0113] import threading

[0114] def process_message(message):

[0115] # Message processing logic

[0116] pass

[0117] threading.Thread(target=process_message, args=(message,)).start().

[0118] According to one embodiment of the present invention, the present invention also dynamically adjusts parameters such as the high water mark of outgoing messages and the high water mark of incoming messages of the middleware module 220. Reasonable setting of parameters such as the high water mark of outgoing messages and the high water mark of incoming messages of the middleware module 220 is crucial to the performance and stability of the system. Too large parameter settings may lead to insufficient memory and increased message processing delays, while too small parameter settings may lead to message loss and blocking of message sending. By dynamically adjusting these parameters, the optimal performance of the system can be maintained under different load conditions.

[0119] In actual applications, appropriate parameter settings can be selected according to the specific needs and load conditions of the system. For example, for applications with high real-time requirements, smaller parameters such as the high water mark for outgoing messages and the high water mark for incoming messages can be selected to reduce message processing delays; for applications that require high fault tolerance, larger parameters such as the high water mark for outgoing messages and the high water mark for incoming messages can be selected to reduce the risk of message loss. Through reasonable parameter settings and dynamic adjustments, the system can be ensured to run efficiently and stably under different loads.

[0120] In order to cope with different CAD projects and user operation changes, the present invention provides an adaptive control algorithm. The adaptive control algorithm is based on adaptive control theory and feedback control mechanism, and ensures that the system can maintain optimal performance under different loads by real-time monitoring and adjusting system parameters.

[0121] The computing device further includes an adaptive control module; the front-end module 210 further includes a front-end monitoring module, and the target CAD client further includes a back-end monitoring module, and the front-end monitoring module and the back-end monitoring module are used to collect system status data. The front-end monitoring module is adapted to determine the length of the message queue for sending messages by the front-end module 210, and the back-end monitoring module is adapted to determine the message processing time for the target CAD client to process messages. The adaptive control module determines the system load index according to the system status data; and dynamically adjusts the system parameters according to the load index.

[0122] Among them, the present invention can determine the length of the message sending queue and the message processing time according to the front-end monitoring module and the back-end monitoring module; the adaptive control module determines the adjustment parameters of the middleware module 220 based on the adaptive control algorithm, using the message queue length, message processing time and target load as parameters; the front-end module 210 adjusts the high water level of the outbound messages of the middleware module 220 according to the adjustment parameters, and the target CAD client adjusts the high water level of the incoming messages of the middleware module 220 according to the adjustment parameters.

[0123] First, the monitoring module collects system operation status data, including parameters such as message queue length, message processing time, CPU usage, memory usage, etc. Specifically, the front-end monitoring module and the back-end monitoring module are implemented in the front-end module and the target CAD client respectively to collect system status data regularly; when collecting system status data regularly, a timer or background thread can be set to collect data regularly, and the data is stored for subsequent analysis.

[0124] The monitoring module then calculates the system load index based on the collected system operation status data, including calculating the moving average of the message queue length, the moving average of the message processing time, etc. The present invention can be provided with a calculation module to regularly calculate the system load index and return it to the monitoring module, and use methods such as moving average to smooth the data and reduce the impact of short-term fluctuations. The moving average can be achieved through a sliding window, and the window size is adjusted according to system characteristics and requirements.

[0125] Finally, an adaptive control algorithm is set to dynamically adjust the parameters such as the high water mark of the outgoing message and the high water mark of the incoming message of the middleware module 220 according to the system load index; specifically, an adaptive control module is set to dynamically adjust the system parameters based on the feedback control theory. When dynamically adjusting the system parameters, a proportional-integral-differential (PID) control algorithm can be used as an adaptive control algorithm to adjust the configuration parameters of the middleware module 220 according to the system load index. The adaptive control module is set with a target load, and uses the PID control algorithm to adjust the system parameters by calculating the error, that is, the difference between the actual load and the target load, so as to minimize the error.

[0126] According to one embodiment of the present invention, the present invention sets the target load as follows: the target load is set to a moving average of the message queue length not exceeding 500, and a moving average of the message processing time not exceeding 50ms; the present invention also sets an adaptive control module to calculate the error once a minute, and adjusts the parameters such as the high water mark of outbound messages and the high water mark of incoming messages of the middleware module 220 according to the PID control algorithm.

[0127] Finally, the adaptive control module instructs the adjustment module to dynamically adjust parameters such as the high water mark of outgoing messages and the high water mark of incoming messages of the middleware module 220 according to the output of the adaptive control algorithm.

[0128] According to one embodiment of the present invention, configuration adjustment modules are implemented in the front-end module 210 and the target CAD client respectively, and the configuration parameters of the middleware module 220 are dynamically adjusted according to the output of the adaptive control algorithm; specifically, parameters such as the high water mark of outgoing messages and the high water mark of incoming messages are dynamically set through the interface of the middleware module 220, which can be specifically implemented as parameters such as ZMQ_SNDHWM and ZMQ_RCVHWM of ZeroMQ. If the system load is too high, the front-end adjustment module of the front-end module 210 increases the ZMQ_SNDHWM parameter from 1000 to 1500, and the back-end adjustment module of the target CAD client increases the ZMQ_RCVHWM parameter from 1000 to 1500.

[0129] According to one embodiment of the present invention, when the user of the front-end module 210 frequently performs drawing operations on the CAD client of the back-end module 230, the message queue length continues to increase, the system load is too high, and the user experience is affected; the present invention dynamically adjusts the configuration parameters of the middleware module 220 through the following steps to improve system performance.

[0130] First, the system status is monitored. The front-end monitoring module of the front-end module 210 collects the message queue length once a second and finds that the message queue length continues to exceed 1000. The back-end monitoring module of the target CAD client collects the message processing time once a second and finds that the message processing time continues to exceed 100ms.

[0131] The calculation module calculates the moving average of the message queue length once a minute and finds that the average value is 1200, which exceeds the preset threshold of 1000; the moving average of the message processing time is calculated once a minute and finds that the average value is 120ms, which exceeds the preset threshold of 100ms.

[0132] The present invention sets the target load as the moving average of the message queue length not exceeding 500, and the moving average of the message processing time not exceeding 50ms. The adaptive control module calculates the error once a minute, and adjusts the parameters such as the high water mark of the outgoing message and the high water mark of the incoming message of the middleware module 220 according to the PID control algorithm.

[0133] Finally, the configuration of the middleware module 220 is dynamically adjusted: the front-end adjustment module of the front end increases the ZMQ_SNDHWM parameter from 1000 to 1500, and the back-end adjustment module of the target CAD client increases the ZMQ_RCVHWM parameter from 1000 to 1500.

[0134] After the configuration adjustment, the front-end monitoring module of the front-end module 210 continues to collect the message queue length and finds that the average value drops to 800, and the system load is relieved. The back-end monitoring module of the target CAD client continues to collect the message processing time and finds that the processing time drops to 60ms, and the system performance is improved.

[0135] According to an embodiment of the present invention, the present invention also sets an error processing and retry mechanism in the message queue. For example, the front-end module 210 sends a complex drawing calculation request to the back-end, and the back-end processing fails. It is necessary to notify the front-end processing failure and retry, so an error queue and a retry mechanism are set.

[0136] First, the timeout and retry mechanism is implemented in the front-end module 210. If the processing result, such as a confirmation message, is not received within a certain period of time, the process will automatically retry or prompt the user. If the confirmation message is not received within the timeout period, the message will be resent. If multiple retries are still unsuccessful, the user will be prompted that the process failed.

[0137] According to one embodiment of the present invention, the target CAD client also includes an error queue. If an error occurs when the target CAD client processes a message, the message is added to the error queue. The target CAD client sends an error message to the front-end module 210 through the middleware module 220 based on the message in the error queue. The error message includes the cause of the error and a solution.

[0138] An error queue is set on the target CAD client, and the failed message is transferred to the error queue for subsequent processing, such as using error_queue to store the failed message. When processing the message, if an error occurs, the message is transferred to the error_queue and an error message is sent to the front-end module 210.

[0139] After the target CAD client fails to process the message, it sends an error message back to the front end, and the error message includes the cause of the error and a suggested solution. The front end module 210 performs corresponding processing according to the error message.

[0140] An example of an error message is as follows:

[0141] {

[0142] "sequence_number": 1,

[0143] "status":"error",

[0144] "error_message":"Invalid operation data",

[0145] "suggested_solution":"Check the operation dataformat"

[0146] }.

[0147] The front-end module 210 performs corresponding processing according to the error message, such as prompting the user to check the format of the operation data.

[0148] It should be noted that the storage medium (computer-readable medium) mentioned above in the present application may be a computer-readable signal medium or a non-transitory computer-readable storage medium or any combination of the above two. The non-transitory computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of non-transitory computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0149] In the present application, a non-transitory computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus, or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a non-transitory computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0150] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0151] The above description is only a partial embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.

[0152] In addition, although each operation is described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the application. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0153] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A communication method between a CAD front end and a back end, suitable for execution in a computing device, characterized in that: The method comprises: Constructing a front-end module and a back-end module in the computing device, wherein the front-end module and the back-end module are constructed in the same computing device, and the back-end module includes one or more CAD clients; constructing a middleware module according to the front-end module and the back-end module; In response to receiving a user operation according to the front-end module, the front-end module generates a message according to the user operation and the client ID of the target CAD client to be operated; and encapsulates the message and sends it to the target CAD client through the middleware module; The message includes the client ID of the target CAD client, the operation command of the user operation and the carried transmission information, and the serial number, wherein the serial number is a globally increasing integer used to identify the order in which the front-end module receives the user operation; the target CAD client includes a processing queue; the target CAD client stores the message in the processing queue, and the target CAD client selects the message with the smallest serial number from the processing queue in order of the serial number for processing; after processing the message, the target CAD client sends a confirmation message to the front-end module through the middleware module to notify the front-end module to update the processed serial number according to the confirmation message; The front-end module generates a message according to the user operation and the client ID of the target CAD client to be operated; and after the message is packaged and sent to the target CAD client through the middleware module, the front-end module determines whether a confirmation message is received within a preset time. If not, the message is re-packaged and sent to the target CAD client through the middleware module; The target CAD client compares the serial number of the message to see if it is the same as the serial number of the processed message. If so, the message is not processed and a confirmation message is directly sent to the front-end module through the middleware module. The target CAD client also includes an error queue. If an error occurs when the target CAD client processes a message, the message is added to the error queue. The target CAD client sends an error message to the front-end module through the middleware module according to the message in the error queue. The error message includes the cause of the error and a solution. The computing device further includes an adaptive control module; the front-end module further includes a front-end monitoring module, and the target CAD client further includes a back-end monitoring module, the front-end monitoring module and the back-end monitoring module are used to collect system status data, and the adaptive control module determines the system load index according to the system status data; and dynamically adjusts the system parameters according to the load index; The system status data includes the length of the message sending queue and the message processing time; the adaptive control module determines the system load index according to the system status data; and the system parameters are dynamically adjusted according to the load index, including: the adaptive control module uses the length of the message sending queue, the message processing time and the target load as parameters to determine the adjustment parameters of the middleware module; the front-end module adjusts the high water level of the middleware module's outbound messages according to the adjustment parameters, and the target CAD client adjusts the high water level of the middleware module's incoming messages according to the adjustment parameters.

2. The method according to claim 1, characterized in that The multiple CAD clients are CAD clients of different types.

3. The method according to claim 1, characterized in that The front-end module is built using the Electron framework, the middleware module is built using ZeroMQ, and the message encapsulation format is JSON or Protobuf.

4. The method according to claim 1, characterized in that Before responding to receiving a user operation according to the front-end module, the method further includes: The one or more CAD clients included in the back-end module send the port parameters and client ID of each CAD client to the front-end module through the middleware module.

5. The method according to claim 4, characterized in that The user operation is a start operation; The front-end module generates a message according to the user operation and the client ID of the target CAD client to be operated; and encapsulating the message and sending it to the target CAD client through the middleware module, including: The front-end module generates a startup message according to the startup operation of the CAD client and the client ID of the target CAD client to be started; The front-end module encapsulates the startup message to obtain an encapsulated startup message; The middleware module sends the encapsulated startup message to the target CAD client according to the port parameter.

6. The method according to claim 4, characterized in that The user operation is a file selection operation. The front-end module generates a message according to the user operation and the client ID of the target CAD client to be operated; and encapsulating the message and sending it to the target CAD client through the middleware module, including: The front-end module generates a file selection message according to the file selection operation and the client ID of the target CAD client of the file to be selected; The front-end module encapsulates the file selection message to obtain an encapsulated file selection message; The middleware module sends the encapsulated selection file message to the target CAD client according to the port parameter.

7. The method according to claim 4 or 5, characterized in that The user operation also includes closing the UI interface operation, and the method also includes: The front-end module generates a closing message according to the closing UI interface operation and the client ID of the target CAD client; The front-end module encapsulates the close message to obtain an encapsulated close message; The middleware module sends the encapsulated close message to the target CAD client according to the port parameter, so that the target CAD client deregisters system resources.

8. A computing device, characterized in that include: one or more processors; Memory; as well as One or more devices comprising instructions for performing any of the methods according to claims 1 to 7.

9. A computer-readable storage medium storing one or more programs, characterized in that: The one or more programs include instructions which, when executed by a computing device, cause the computing device to perform any one of the methods according to claims 1 to 7.