Calling method and device for machine tool communication drive and electronic equipment
By encapsulating the communication drive of CNC machine tools and decoupling the adapter interface, the problems of low communication efficiency and high cost in the existing technology are solved, and the compatibility of multiple languages and protocols is achieved, thereby improving communication efficiency and system scalability.
Patent Information
- Application Number
- CN202512045395.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-17
AI Technical Summary
In existing technologies, CNC machine tool communication driver libraries have high language coupling, complex protocol adaptation, and low system integration, resulting in low communication efficiency, high cost, and difficulty in achieving unified management and efficient communication for various machine tool types.
By encapsulating each machine tool communication driver, generating dynamic link library files or remote call services, and creating adapters and adapter interfaces of a unified format, the upper-level system and the lower-level machine tool communication driver are decoupled. It supports encapsulation of multiple languages and protocols, and uses a combination of GRPC services and dynamic link libraries for communication.
It improves the communication efficiency between the upper-level system and the lower-level CNC machine tools, reduces communication costs, simplifies the system architecture, enhances system scalability and communication performance, and enables flexible management of different machine tool types.
Smart Images

Figure CN121880046A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and more specifically, to a method, apparatus, and electronic device for invoking machine tool communication drives. Background Technology
[0002] In modern manufacturing, production workshops contain CNC machine tools from different manufacturers and of different models. These CNC machine tools typically use their own dedicated communication protocols and preset communication interfaces (such as RS232 (a serial communication interface standard used for serial data exchange between computers and peripherals), Ethernet, and preset hardware interfaces) to communicate with upper-level systems (such as MES (Manufacturing Execution System) and DNC (Distributed Numerical Control System)). When the upper-level system transmits machining programs or performs other functional controls to these machine tools, traditional solutions often face the following challenges:
[0003] (1) High language coupling: The existing communication driver libraries are usually developed based on specific programming languages (such as C++, C#). When the upper-level system is developed using other types of programming languages (such as Java, Python, Go), the two need to be bridged or rewritten in programming languages, which results in high development costs.
[0004] (2) Complex protocol adaptation: In the existing technology, a complete communication driver needs to be written independently for the communication protocol of each CNC machine tool, resulting in high code redundancy; when the communication protocol is updated or a new type of CNC machine tool needs to be added, the code scalability is low.
[0005] (3) Low system integration: Different types of communication drive modules for different types of CNC machine tools are often deployed independently, making it difficult to achieve unified management and load balancing.
[0006] In summary, when the upper-level system calls the machine tool communication driver corresponding to the lower-level CNC machine tool, the communication between the two based on existing technologies suffers from technical problems such as low communication efficiency and high communication cost.
[0007] There is currently no effective solution to the above problems. Summary of the Invention
[0008] This application provides a method, apparatus, and electronic device for invoking machine tool communication drivers, in order to at least solve the technical problems of low communication efficiency and high communication cost when upper-level systems invoke machine tool communication drivers based on existing technologies.
[0009] According to one aspect of this application, a method for invoking machine tool communication drivers is provided, comprising: encapsulating each machine tool communication driver based on the development language of each of L machine tool communication drivers to obtain a dynamic link library file / remote call service corresponding to each machine tool communication driver, wherein each machine tool communication driver is used to implement communication control of a CNC machine tool; creating a local call module corresponding to the dynamic link library file and a remote call client corresponding to the remote call service, wherein the local call module is used to call the dynamic link library file and the remote call client is used to call the remote call service; creating an adapter corresponding to the local call module and an adapter corresponding to the remote call client to obtain M adapters, wherein the M adapters are configured with adapter interfaces of a uniform format, and each adapter is used to convert the target system's call request to the CNC machine tool into a call request to the local call module / remote call client; and controlling the target system to call the L machine tool communication drivers based on the adapter interfaces corresponding to the M adapters.
[0010] Optionally, before encapsulating each machine tool communication driver based on the development language of each of the L machine tool communication drivers, the calling method of the machine tool communication driver further includes: determining the communication protocol and communication interface supported by each CNC machine tool based on the configuration information of each CNC machine tool that the target system needs to communicate; and determining the development language and driver type of the machine tool communication driver corresponding to each CNC machine tool based on the communication protocol and communication interface supported by each CNC machine tool.
[0011] Optionally, based on the development language of each of the L machine tool communication drivers, each machine tool communication driver is encapsulated, including: detecting whether the development language of each machine tool communication driver belongs to a preset type, wherein the development language of the preset type supports compilation into a dynamic link library file of a preset format; if the development language of the i-th machine tool communication driver among the L machine tool communication drivers does not belong to the preset type, the i-th machine tool communication driver is encapsulated to obtain X remote service interfaces, wherein X is a positive integer; and the X remote service interfaces are used as the remote call service corresponding to the i-th machine tool communication driver.
[0012] Optionally, the X remote service interfaces include at least: a first preset service interface for sending files to the CNC machine tool; a second preset service interface for receiving files from the CNC machine tool; a third preset service interface for deleting files from the CNC machine tool; a fourth preset service interface for obtaining the file list of the CNC machine tool; a fifth preset service interface for establishing a device connection to the CNC machine tool; and a sixth preset service interface for disconnecting the device connection to the CNC machine tool.
[0013] Optionally, based on the development language of each of the L machine tool communication drivers, each machine tool communication driver is encapsulated, including: if the development language of the i-th machine tool communication driver in the L machine tool communication drivers belongs to a preset type, the i-th machine tool communication driver is encapsulated to obtain Y dynamic calling interfaces, where Y is a positive integer; the Y dynamic calling interfaces are used as the dynamic link library file corresponding to the i-th machine tool communication driver.
[0014] Optionally, the Y dynamic calling interfaces include at least: a first preset dynamic interface for initializing the configuration of the CNC machine tool; a second preset dynamic interface for sending files to the CNC machine tool; a third preset dynamic interface for receiving files from the CNC machine tool; a fourth preset dynamic interface for obtaining the working status of the CNC machine tool; a fifth preset dynamic interface for implementing the device connection of the CNC machine tool; and a sixth preset dynamic interface for disconnecting the device connection of the CNC machine tool.
[0015] Optionally, the control target system invokes L machine tool communication drivers based on the adapter interfaces corresponding to M adapters. This includes: after the adapter interface receives a target invocation request from the target system for the target CNC machine tool, parsing the target invocation request to obtain the target configuration information of the target CNC machine tool; based on the target configuration information, searching in a preset driver registry to obtain the target adapter corresponding to the target CNC machine tool, wherein the target adapter is one of the M adapters; detecting the driver type of the machine tool driver communication corresponding to the target CNC machine tool through the target adapter; and invoking the machine tool communication driver corresponding to the target CNC machine tool based on the driver type.
[0016] Optionally, based on the driver type, the machine tool communication driver corresponding to the target CNC machine tool is invoked, including: when the driver type is a first preset type, controlling the target adapter, invoking the remote invoking service based on the remote invoking client, and invoking the machine tool communication driver corresponding to the target CNC machine tool based on the remote service interface in the remote invoking service; when the driver type is a second preset type, controlling the target adapter, invoking the dynamic link library file based on the local invoking module, and invoking the machine tool communication driver corresponding to the target CNC machine tool based on the dynamic invoking interface in the dynamic link library file.
[0017] According to another aspect of this application, a machine tool communication driver invocation device is also provided, comprising: a driver encapsulation unit, used to encapsulate each machine tool communication driver based on the development language of each of the L machine tool communication drivers, to obtain a dynamic link library file / remote call service corresponding to each machine tool communication driver, wherein each machine tool communication driver is used to implement communication control of a CNC machine tool; a communication bridging unit, used to create a local call module corresponding to the dynamic link library file and a remote call client corresponding to the remote call service, wherein the local call module is used to call the dynamic link library file and the remote call client is used to call the remote call service; an adapter service unit, used to create an adapter corresponding to the local call module and an adapter corresponding to the remote call client, to obtain M adapters, wherein the M adapters are provided with adapter interfaces of a unified format, and each adapter is used to convert the target system's call request to the CNC machine tool into a call request to the local call module / remote call client; and a invocation unit, used to control the target system to invoke the L machine tool communication drivers based on the adapter interfaces corresponding to the M adapters.
[0018] According to another aspect of this application, a computer program product is also provided, which stores a computer program, wherein, when the computer program is running, the computer program product is controlled to execute the machine tool communication drive invocation method described above.
[0019] According to another aspect of this application, an electronic device is also provided, wherein the electronic device includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the machine tool communication drive invocation method of any of the above.
[0020] In this application, firstly, based on the development language of each of the L machine tool communication drivers, each machine tool communication driver is encapsulated to obtain a dynamic link library file / remote call service corresponding to each machine tool communication driver. Each machine tool communication driver is used to implement communication control of CNC machine tools. Then, this application creates a local call module corresponding to the dynamic link library file and a remote call client corresponding to the remote call service. The local call module is used to call the dynamic link library file, and the remote call client is used to call the remote call service. Next, this application creates an adapter corresponding to the local call module and an adapter corresponding to the remote call client, resulting in M adapters. The M adapters are configured with adapter interfaces of a unified format. Each adapter is used to convert the target system's call request to the CNC machine tool into a call request to the local call module / remote call client. Finally, this application controls the target system to call the L machine tool communication drivers based on the adapter interfaces corresponding to the M adapters.
[0021] As described above, this application encapsulates machine tool communication drivers written in different programming languages to obtain dynamic link library files or remote call services. Subsequently, this application creates a local call module and a remote call client as a communication bridge between the adapter and the dynamic link library files or remote call services. This achieves layered decoupling of the communication process and compatibility with the programming languages of different machine tool communication drivers. When the upper-level system needs to communicate with the lower-level CNC machine tool, the upper-level system only needs to call the unified interface provided by the adapter to invoke the lower-level machine tool communication driver, without needing to consider the differences in the underlying communication logic of the CNC machine tool. This achieves the technical effect of improving the communication efficiency between the upper-level system and the lower-level CNC machine tool and reducing communication costs, thereby solving the technical problems of low communication efficiency and high communication costs when the upper-level system calls machine tool communication drivers based on existing technologies. Attached Figure Description
[0022] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0023] Figure 1 This is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a machine tool communication drive invocation method according to an embodiment of this application.
[0024] Figure 2 This is a flowchart of an optional machine tool communication driver invocation method according to an embodiment of this application;
[0025] Figure 3 This is an architecture diagram of an optional machine tool communication driver invocation system according to an embodiment of this application;
[0026] Figure 4 This is a schematic diagram of an optional machine tool communication driver invocation device according to an embodiment of this application;
[0027] Figure 5 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0028] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] It should also be noted that all information (including but not limited to CNC machine tool configuration information and call request information) and data (including but not limited to data used for display and analysis) involved in this application are information and data authorized by the user or fully authorized by all parties. For example, if there is an interface between this system and the relevant user or organization, before obtaining the relevant information, it is necessary to send a request to the aforementioned user or organization through the interface, and obtain the relevant information only after receiving consent from the aforementioned user or organization.
[0031] Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of relevant information and data involved in this application all comply with the relevant laws, regulations, and standards of the relevant regions, and necessary confidentiality measures have been taken. This application does not violate public order and good morals. In addition, this application provides a corresponding operation entry point for users to choose to agree to or refuse authorization. If the user chooses to refuse authorization, the corresponding expert decision-making process will be initiated.
[0032] In one alternative embodiment, a communication method based on the native library of CNC machine tools is provided. This method adopts a direct integration mode of the native library. Machine tool manufacturers usually provide native communication development kits corresponding to each type of machine tool. These communication development kits are usually native library files (e.g., files with .dll or .so extensions) written in a specific programming language (e.g., C / C++ or C#).
[0033] When communication is required, the upper-level system directly references these native library files in its code (e.g., desktop applications written in C#). Developers of the upper-level system need to learn and understand the information of the API (Application Programming Interface) in each native library file and directly call these APIs in the business logic to implement business functions such as connecting machine tools, transferring files, and reading status.
[0034] In one optional embodiment, a communication method based on language bridging mode is provided. This scheme is adopted when the development language of the upper-layer application does not match the language of the machine tool library. An example of its implementation is as follows:
[0035] (1) Java-JNI: If the upper-level system uses Java as its development language, a C / C++ JNI (Java Native Interface) wrapper layer needs to be written to encapsulate the C++ style machine tool library functions into native methods that Java can call.
[0036] (2) Python-ctypes / CFFI: If the upper-level system uses Python as its development language, then use ctypes (a Python library for handling C-compatible data types) or CFFI (a Python library for calling C-written functions in Python code) to load functions in C-style .dll files.
[0037] (3) .NET-P / Invoke: Used to call functions in unmanaged C / C++ style .dll files in the .NET platform (a software development platform and environment for building and running applications).
[0038] In one optional embodiment, a communication method based on the Web (World Wide Web) service model is provided. This method uses a preset process (which is typically implemented using Java, Python, or C#) to encapsulate the machine tool communication logic and provides a RESTful API (Representational State Transfer Application Programming Interface) based on the HTTP (Hypertext Transfer Protocol) protocol. When communication is required, this process runs as an HTTP server, and the upper-layer system transmits communication data by sending HTTP requests (e.g., POST / api / machine / fanuc-1 / send-program) along with NC (Numerical Control) program files.
[0039] However, the communication scheme in the above embodiments has the following technical drawbacks in actual use:
[0040] (1) Low scalability: When adding a new type of machine tool, the extension process of the communication logic is cumbersome and the scope of adaptation is large. In the first and second embodiments, it is necessary to add support for the new protocol in the main application or wrapper layer code, and then recompile, test and deploy the entire application. In the third embodiment, it is necessary to modify and restart the entire RESTful API service process.
[0041] (2) Low communication efficiency: In the third embodiment, when communicating based on the HTTP protocol, each communication request requires the establishment of a new TCP (Transmission Control Protocol) connection. The header information is redundant, which makes the data transmission efficiency of serialization / deserialization lower than that of binary protocol, thus making it unsuitable for high-concurrency, large-data-volume NC program real-time transmission application scenarios.
[0042] (3) Communication logic is scattered, integration is low, and it is difficult to manage centrally: In the first and second embodiments, the communication logic connection is scattered in various upper-layer application instances, and it is impossible to manage the communication connection of all machine tools in a unified platform in real time, load balancing, log recording and error diagnosis.
[0043] In summary, the purpose of this technical solution is to overcome the shortcomings of the above-mentioned embodiments. This technical solution provides a machine tool communication method based on GRPC (Remote Procedure Call) service and dynamic link library, the function of which is as follows:
[0044] (1) Provide a unified and efficient interface adaptation mechanism: Through standardized adapter interfaces, the main control architecture of the upload system and the multi-development language and multi-communication protocol encapsulation modules corresponding to the underlying machine tool communication driver are decoupled, thereby reducing the integration complexity of the communication interface and improving the real-time performance of CNC machining program data transmission.
[0045] (2) The communication protocols of different machine tool communication drivers are flexibly encapsulated by multiple development languages: This technical solution supports the encapsulation of different machine tool communication protocols by different development languages (such as C++, Python, Java, C#), and the encapsulation module can be uniformly called by the main control architecture of the upper layer system without repeated development.
[0046] (3) Simplify system architecture and improve communication performance: This technical solution avoids the introduction of a heavy middleware layer. It adopts the method of direct calling of GRPC client and local dynamic link library to realize direct communication between upper system and lower machine tool communication driver, which reduces communication latency and improves communication performance.
[0047] (4) Enhanced system scalability: This technical solution supports the dynamic addition of machine tool types and communication functions without modifying the upper-level system and core service code, thus improving the overall iteration efficiency of the communication system.
[0048] The present invention will now be described in detail with reference to various embodiments.
[0049] Example 1
[0050] According to an embodiment of this application, an embodiment of a machine tool communication driver invocation method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0051] The methods and embodiments provided in this application can be executed on mobile terminals, computer terminals, or similar computing devices. Figure 1 This is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a machine tool communication drive invocation method according to an embodiment of this application. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0052] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0053] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the machine tool communication driver invocation method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the aforementioned machine tool communication driver invocation method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0054] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0055] The display can be configured as a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0056] Under the aforementioned operating environment, this application provides a machine tool communication driver invocation system (hereinafter referred to as the invocation system) for executing the machine tool communication driver invocation method of this application. Figure 2 This is a flowchart of an optional machine tool communication driver invocation method according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:
[0057] Step S201: Based on the development language of each of the L machine tool communication drivers, each machine tool communication driver is encapsulated to obtain the dynamic link library file / remote call service corresponding to each machine tool communication driver. Each machine tool communication driver is used to implement communication control of CNC machine tools.
[0058] Optionally, the L machine tool communication drivers refer to the communication drivers corresponding to L CNC machine tools from different manufacturers and of different models. These L machine tool communication drivers are developed using different programming languages (such as C#, C++, Python, and Java), and the machine tool communication protocols supported by the L machine tool communication drivers are also different.
[0059] Optionally, a dynamic link library (DLL) file refers to a file containing shared code / data corresponding to multiple applications. It can be loaded by other programs and used at runtime. DLL files support cross-platform calls. The file types of DLL files include .dll files and .so files. The calling system determines the file type of the DLL file to be packaged based on the operating system type. For example, when the operating system is the first preset operating system, a .dll format DLL file is used; when the operating system is the second preset operating system, a .so format DLL file is used.
[0060] Optionally, the remote procedure call service, or gRPC service, refers to a high-performance remote procedure call framework. The remote procedure call service provides a fast and lightweight way to call remote services and supports multiple programming languages.
[0061] Optionally, the calling system encapsulates communication drivers of different development languages into a unified format dynamic link library file or remote call service, which solves the compatibility problem of machine tool communication drivers of different driver types in a multi-language environment and improves the flexibility and scalability of the overall communication system. Furthermore, the encapsulated dynamic link library file or remote call service can provide a set of standardized calling interfaces, reducing the difficulty of interface calling and improving communication efficiency.
[0062] Step S202: Create a local call module corresponding to the dynamic link library file and a remote call client corresponding to the remote call service. The local call module is used to call the dynamic link library file, and the remote call client is used to call the remote call service.
[0063] Optionally, if the encapsulation result obtained by the calling system from encapsulating L basic communication drivers includes both dynamic link library files and remote call clients, the calling system simultaneously creates the local call module corresponding to the dynamic link library file and the remote call client corresponding to the remote call service; if the encapsulation result obtained by the calling system from encapsulating L basic communication drivers includes only dynamic link library files, the calling system only creates the local call module corresponding to the dynamic link library file; if the encapsulation result obtained by the calling system from encapsulating L basic communication drivers includes only remote call services, the calling system only creates the remote call client corresponding to the remote call service.
[0064] Optionally, a native calling module refers to a set of code modules that can directly load and call exported functions in a dynamic link library file.
[0065] Optionally, a remote invocation client refers to a client that can remotely invoke GRPC services via a network connection.
[0066] Optionally, the local calling module can directly call dynamic link library files, avoiding the latency caused by serialization / deserialization and network communication, thereby improving data transmission efficiency and real-time communication control. When cross-network calls are required, the GRPC service is called through the remote calling client, which allows the driver to run on different machines or containers, providing higher isolation and fault recovery capabilities, while simplifying the deployment of multi-machine collaborative work.
[0067] Step S203: Create an adapter corresponding to the local calling module and an adapter corresponding to the remote calling client, resulting in M adapters. Each of the M adapters has a uniformly formatted adapter interface. Each adapter is used to convert the target system's call request to the CNC machine tool into a call request to the local calling module / remote calling client.
[0068] Optionally, the adapter interface refers to the set of standard methods exposed by the adapter. The upper-level system calls the corresponding adapter through a unified format interface, thereby calling the encapsulated result (i.e., dynamic link library file, / remote call service) of the machine tool communication driver that needs to be called based on the corresponding adapter, without having to care about the specific implementation details inside the adapter.
[0069] Optionally, the calling system achieves the following by creating an adapter:
[0070] (1) The adapter provides a set of unified calling interfaces, enabling the target system at the upper level to call different types of machine tool communication drivers in the same way, thereby simplifying the design and development of the upper-level system.
[0071] (2) Separation of adaptation logic: The adapter converts the requests of the upper layer application into calls to the lower layer driver, realizing the separation of business logic and driver control logic, making the system more flexible in function expansion and maintenance.
[0072] Step S204: Control the target system and call the communication drivers of L machine tools based on the adapter interfaces corresponding to M adapters.
[0073] Optionally, the target system refers to the upper-level application system that needs to communicate with the CNC machine tool, such as a manufacturing execution system or a distributed CNC system.
[0074] Optionally, a call request refers to a request issued by the target system through the adapter interface. These requests will be interpreted by the adapter and forwarded to the corresponding local call module or remote call client.
[0075] Optionally, by calling the target system based on the adapter interfaces corresponding to M adapters, the system can invoke the communication drivers of L machine tools, achieving the following functions:
[0076] (1) Simplify high-level applications: The target system only needs to focus on business logic, while delegating the specific communication control details to the adapter. Through the adapter interface, the target system can call all drivers in a unified way, which simplifies its development and maintenance work.
[0077] (2) Enhanced scalability: The target system can support more machine tool types by adding new adapters without modifying its core code, thus improving the system's scalability and adaptability.
[0078] As described above, this application encapsulates machine tool communication drivers written in different programming languages to obtain dynamic link library files or remote call services. Subsequently, this application creates a local call module and a remote call client as a communication bridge between the adapter and the dynamic link library files or remote call services. This achieves layered decoupling of the communication process and compatibility with the programming languages of different machine tool communication drivers. When the upper-level system needs to communicate with the lower-level CNC machine tool, the upper-level system only needs to call the unified interface provided by the adapter to invoke the lower-level machine tool communication driver, without needing to consider the differences in the underlying communication logic of the CNC machine tool. This achieves the technical effect of improving the communication efficiency between the upper-level system and the lower-level CNC machine tool and reducing communication costs, thereby solving the technical problems of low communication efficiency and high communication costs when the upper-level system calls machine tool communication drivers based on existing technologies.
[0079] In one optional embodiment, before encapsulating each machine tool communication driver based on the development language of each of the L machine tool communication drivers, the calling system first determines the communication protocol and communication interface supported by each CNC machine tool based on the configuration information of each CNC machine tool that the target system needs to communicate with. Then, the calling system determines the development language and driver type of the machine tool communication driver corresponding to each CNC machine tool based on the communication protocol and communication interface supported by each CNC machine tool.
[0080] Optionally, configuration information refers to a series of data that details the communication characteristics and requirements of the CNC machine tool, including but not limited to the machine tool model, manufacturer, communication protocols supported by the machine tool (such as RS232, TCP / IP (Transmission Control Protocol / Internet Protocol)) and communication interfaces (such as Ethernet interface, serial interface).
[0081] Alternatively, a communication protocol refers to the rules and standards used to regulate data transmission; different machine tools use different communication protocols.
[0082] Optionally, the communication interface refers to the physical or logical entry point for the machine tool to exchange data with external systems.
[0083] Optionally, by analyzing the configuration information of each CNC machine tool that the target system needs to communicate with, the calling system can accurately identify the communication protocols and interface types supported by each machine tool. This provides the necessary basic information for subsequent communication driver selection and integration. At the same time, this step ensures that the target system can flexibly adapt to the communication needs of various machine tools. Even when facing new machine models or updated communication protocols, the calling system can determine the calling strategy for the new type of CNC machine tool based on its configuration information, without the need for large-scale system reconstruction, thereby improving the communication efficiency between the upper-level system and the lower-level CNC machine tools.
[0084] Optionally, the calling system determines the development language and driver type of the machine tool communication driver for each CNC machine tool based on the communication protocol and communication interface supported by each CNC machine tool. The calling system realizes the modularization of the machine tool communication driver, enabling each machine tool communication driver to be developed, tested and deployed independently, thus decoupling the machine tool communication driver from the target system and reducing the architectural complexity of the calling system.
[0085] In one optional embodiment, the calling system first detects whether the development language of each machine tool communication driver belongs to a preset type. The development language of the preset type supports compilation into a dynamic link library file of a preset format. If the development language of the i-th machine tool communication driver among the L machine tool communication drivers does not belong to the preset type, the calling system encapsulates the i-th machine tool communication driver to obtain X remote service interfaces, where X is a positive integer. Then, the calling system uses the X remote service interfaces as the remote call service corresponding to the i-th machine tool communication driver.
[0086] Optionally, the calling system detects the development language of each machine tool communication driver. For machine tool communication drivers developed using a language that can be compiled into dynamic link libraries, the calling system directly compiles them into dynamic link library files. This leverages the low latency and high data transmission efficiency of dynamic link libraries to improve the real-time performance and efficiency of machine tool communication.
[0087] For example, development languages that are not included in the default types include Java and Python.
[0088] Optionally, if the development language of the i-th machine tool communication driver among the L machine tool communication drivers is not a preset type, the calling system encapsulates the i-th machine tool communication driver to obtain X remote service interfaces, thereby realizing communication control of machine tool communication drivers developed by non-preset type development languages, improving the integration and communication reliability of the calling system.
[0089] Optionally, the calling system uses X remote service interfaces as remote call services corresponding to the i-th machine tool communication driver, that is, deploys the X gRPC service interfaces as services that can be remotely called, achieving the following effects:
[0090] (1) Service-oriented: Encapsulating the machine tool communication driver as a service not only promotes code reuse, but also makes driver upgrades and maintenance easier. There is no need to change the caller's code; only the server needs to be updated.
[0091] (2) Network transparency: The deployment and invocation of gRPC services make network communication transparent to upper-layer applications. Even if the machine tool communication driver runs on different machines or containers, upper-layer applications can still invoke gRPC services as if they were calling local functions, increasing the flexibility of the system.
[0092] In summary, through the above steps, regardless of whether the development language of the machine tool communication driver belongs to the preset type or not, it can be efficiently and uniformly called by the upper-level system through appropriate means (dynamic link library or gRPC service), which improves the communication efficiency between the upper-level system and the lower-level machine tool communication driver, and reduces the communication complexity and maintenance cost of the overall communication system.
[0093] In one alternative embodiment, the X remote service interfaces include at least:
[0094] The first preset service interface is used to send files to CNC machine tools;
[0095] The second preset service interface is used to receive files from CNC machine tools;
[0096] The third preset service interface is used to delete files in CNC machine tools;
[0097] The fourth preset service interface is used to obtain the file list of CNC machine tools;
[0098] The fifth preset service interface is used to realize the equipment connection of CNC machine tools;
[0099] The sixth preset service interface is used to disconnect the CNC machine tool from the equipment connection.
[0100] Optionally, the pseudocode for the X remote service interfaces is as follows:
[0101] service DncDriveRpc{
[0102] /
[0103] @brief 010 Interface: The plugin needs to implement the service [Send File].
[0104] @param Device information: Device number, Device type
[0105] @note Batch operations need to be considered
[0106] @Sample usage: Request parameters: [placeholder], Return value: [JSON format]
[0107] /
[0108] rpc SendFile (TransRequest) returns (Reply);
[0109] /
[0110] @brief 020 Interface: The plugin needs to implement a service [file return].
[0111] @param Device information: Device number, Device type
[0112] @note Batch operations need to be considered
[0113] @Sample usage: Request parameters: [json format], Return value: [bool: saved result]
[0114] /
[0115] rpc ReceiveFile (TransRequest) returns (Reply);
[0116] /
[0117] @brief 030 Interface: The plugin needs to implement the service [Delete File].
[0118] @param Device information: Device number, Device type
[0119] @note Batch operations need to be considered
[0120] @Sample usage: Request parameters: [json format], Return value: [bool: saved result]
[0121] /
[0122] rpc DeleteFile (TransRequest) returns (Reply);
[0123] /
[0124] @brief 040 Interface: The plugin needs to implement the service [Get Device File List].
[0125] @param Device information: Device number, Device type
[0126] @note
[0127] @Sample usage: Request parameters: [json format], Return value: [bool: saved result]
[0128] /
[0129] rpc GetFileList (TransRequest) returns (Reply);
[0130] /
[0131] @brief 0100 Interface: The plugin needs to implement the service [Device Connection].
[0132] @param
[0133] @note
[0134] @Sample usage: Request parameters: [json format], Return value: [bool: saved result]
[0135] /
[0136] rpc Connect(TransRequest)returns(Reply);
[0137] /
[0138] @brief 0110 Interface: The plugin needs to implement a service. [Close connection]
[0139] @param
[0140] @note
[0141] @Sample usage: Request parameters: [json format], Return value: [bool: saved result]
[0142] /
[0143] rpc Close(TransRequest)returns(Reply);
[0144] /
[0145] @brief 0120 Interface: The plugin needs to implement a service to [get driver status].
[0146] @param Device information: Device number, Device type
[0147] @note Request parameters: [Placeholder]
[0148] @Sample usage: Request parameters: [placeholder], Return value: [JSON format]
[0149] /
[0150] rpc GetWorkState (TransRequest) returns (Reply);
[0151] }
[0152] / / Request information, which will be specified in JSON format later.
[0153] message TransRequest {
[0154] string deviceIndo = 1;
[0155] string params = 2;
[0156] }
[0157] / / Return information
[0158] message Reply {
[0159] bool success = 1; / / Whether the operation was successful
[0160] int32 status = 2; / / status
[0161] string message = 3; / / Message
[0162] string returnData = 4; / / The returned request data
[0163] }
[0164] Optionally, the calling system defines the above six preset service interfaces, covering all the basic functions required for efficient communication between the upper-level system and the CNC machine tool, including file transfer, directory management, connection establishment and disconnection, thereby providing the upper-level system with control capabilities over the lower-level CNC machine tool. By explicitly defining the first to sixth preset service interfaces, developers of the upper-level system do not need to deeply understand the unique communication protocols of each machine tool. They can directly call the corresponding interfaces according to the interface documentation of the preset service interfaces, thereby simplifying the design and implementation difficulty of the upper-level system. When it is necessary to add a new machine tool type or enhance functions, developers only need to implement the new interface on the gRPC server without modifying the code of the upper-level system. This allows the overall communication system to easily cope with future changes in requirements and has good scalability.
[0165] In one optional embodiment, if the development language of the i-th machine tool communication driver among the L machine tool communication drivers belongs to a preset type, the calling system encapsulates the i-th machine tool communication driver to obtain Y dynamic calling interfaces, where Y is a positive integer. Then, the calling system uses the Y dynamic calling interfaces as the dynamic link library file corresponding to the i-th machine tool communication driver.
[0166] For example, the default programming languages include C++ and C#.
[0167] Optionally, the calling system encapsulates the i-th machine tool communication driver to obtain Y dynamic calling interfaces, which can achieve the following functions:
[0168] (1) Improve communication efficiency: By encapsulating the i-th machine tool communication driver into a dynamic link library file, the upper-level system (such as the main controller developed in C#) can directly call the business function corresponding to the i-th machine tool communication driver locally through dynamic calling interface, avoiding network communication delay and improving communication efficiency and real-time performance.
[0169] (2) Improved code reusability: After being encapsulated as a dynamic link library file, the calling system can reuse the driver code as an independent module in different projects and environments, which simplifies code maintenance and reduces maintenance costs.
[0170] (3) Reduce system resource consumption: Compared with GRPC service, the method of calling dynamic link library files locally reduces the use of network resources and reduces the overall resource consumption of the system.
[0171] Optionally, the calling system uses Y dynamic calling interfaces as the dynamic link library file corresponding to the i-th machine tool communication driver. When the program runs, the required functions and data can be loaded from the dynamic link library file into memory, thereby realizing code sharing and functional expansion. This mechanism has the following functions:
[0172] (1) High modularity and decoupling: The i-th machine tool communication driver is encapsulated as a dynamic link library file and provides services to the outside world through Y dynamic call interfaces, realizing the separation of driver function from the upper system. This modular design is conducive to the expansion and reconstruction of the system.
[0173] (2) Real-time performance and performance optimization: The calling mechanism of dynamic link library files avoids the overhead of network communication and ensures the real-time performance and high performance of communication.
[0174] (3) Simplified deployment and upgrade: Dynamic link library files can be upgraded or replaced without affecting the operation of the upper-level system, thereby simplifying the system deployment and upgrade process and improving maintenance efficiency.
[0175] In summary, by implementing the above steps, the calling system has solved the problem of calling machine tool communication drivers in a multi-language environment, and realized unified management of communication for different types of CNC machine tools.
[0176] In one optional embodiment, the Y dynamic call interfaces include at least:
[0177] The first preset dynamic interface is used to initialize the configuration of the CNC machine tool;
[0178] The second preset dynamic interface is used to send files to the CNC machine tool;
[0179] The third preset dynamic interface is used to receive files from CNC machine tools;
[0180] The fourth preset dynamic interface is used to obtain the working status of the CNC machine tool;
[0181] The fifth preset dynamic interface is used to realize the equipment connection of CNC machine tools;
[0182] The sixth preset dynamic interface is used to disconnect the CNC machine tool from the equipment connection.
[0183] Optionally, the pseudocode corresponding to the Y dynamically invoked interfaces is as follows:
[0184] public interface IBasePlugin
[0185] {
[0186] / / / <summary>
[0187] / / / Initialize private configuration
[0188] / / / < / summary>
[0189] / / / <returns>< / returns>
[0190] public Task <bool>InitPrivateConfigAsync();
[0191] / / / <summary>
[0192] / / / Send File
[0193] / / / < / summary>
[0194] / / / <param name="file"> document
[0195] / / / <returns>< / returns>
[0196] public Task <replymodel>SendFileAsync(DncFileInfo file);
[0197] / / / <summary>
[0198] / / / Receive file
[0199] / / / < / summary>
[0200] / / / <param name="file"> File
[0201] / / / <returns>< / returns>
[0202] public Task <replymodel>ReceiveFileAsync(DncFileInfo file);
[0203] / / / <summary>
[0204] / / / Get work status
[0205] / / / < / summary>
[0206] / / / <returns>< / returns>
[0207] public Task <workstateenum>GetWorkStateAsync();
[0208] / / / <summary>
[0209] / / / Device connection
[0210] / / / < / summary>
[0211] / / / <returns>< / returns>
[0212] public Task <replymodel>ConnectAsync();
[0213] / / / <summary>
[0214] / / / Close connection
[0215] / / / < / summary>
[0216] / / / <returns>< / returns>
[0217] public Task <bool>CloseAsync();
[0218] }
[0219] Optionally, the calling system uses the aforementioned six preset dynamic interfaces for local calls, avoiding network communication latency and overhead, and improving communication speed and real-time performance, making it particularly suitable for time-sensitive industrial control scenarios. Simultaneously, by defining these six preset dynamic interfaces, a unified calling standard is provided. Regardless of the underlying development language or machine tool type, the upper-level system can perform the same operations by calling these interfaces, simplifying application development and maintenance. Furthermore, the definition of the preset dynamic interfaces provides a clear secondary development framework, allowing third-party developers or system integrators to extend or customize these interfaces to adapt to more complex or specific machine tool communication needs, enhancing the system's openness and scalability.
[0220] In one optional embodiment, after the adapter interface receives the target system's target call request for the target CNC machine tool, the calling system first parses the target call request to obtain the target configuration information of the target CNC machine tool. Then, based on the target configuration information, the calling system searches in a preset driver registry to obtain the target adapter corresponding to the target CNC machine tool, where the target adapter is one of M adapters. Then, the calling system detects the driver type of the machine tool driver communication corresponding to the target CNC machine tool through the target adapter. Subsequently, the calling system calls the machine tool communication driver corresponding to the target CNC machine tool based on the driver type.
[0221] Optionally, the calling system parses the target call request to obtain the target configuration information of the target CNC machine tool, thereby automatically identifying the CNC machine tool that needs to communicate with it and its configuration details, without the need for manual configuration or hard coding, thus improving the automation level and ease of use of the overall communication system; moreover, the acquisition of the target configuration information ensures that the system can select and call the most suitable machine tool communication driver based on the specific needs of each CNC machine tool, realizing personalized and efficient communication control.
[0222] Optionally, by pre-setting a preset driver registry, the calling system can quickly locate the corresponding adapter based on the configuration information of the target CNC machine tool, avoiding the inefficient operation of traversing and controlling all machine tool communication drivers, thereby improving the response speed of machine tool services. At the same time, through the preset driver registry, the calling system can easily manage all machine tool communication drivers, including dynamically adding, updating, and deleting drivers, thereby enhancing the scalability and maintainability of the overall communication system.
[0223] Optionally, the drive type refers to the form of the machine tool communication drive, such as a dynamic link library type or a remote service type.
[0224] Optionally, the target adapter detects the driver type of the machine tool driver communication corresponding to the target CNC machine tool, thereby automatically selecting the calling method, i.e., local calling or remote calling, according to the driver type of the target CNC machine tool. This dynamism enables the system to flexibly respond to the communication needs of different machine tools. Upper-level applications call the machine tool communication driver by using a unified adapter interface. Regardless of the driver type, there is no need to care about the underlying calling details, which simplifies the development process and improves code reusability and overall system stability.
[0225] In summary, the above steps describe in detail the entire process from receiving the target call request to parsing the request, finding the adapter, detecting the driver type, and finally calling the machine tool communication driver. The design of this process not only ensures that the communication system can intelligently and efficiently handle requests from upper-layer applications, but also enhances the system's flexibility and scalability through the mechanism of adapters and preset driver registry, providing a technical foundation for achieving unified control of multi-language and multi-type machine tool communication.
[0226] In one optional embodiment, when the driver type is a first preset type, the system control target adapter is invoked, the remote call service is invoked based on the remote call client, and the machine tool communication driver corresponding to the target CNC machine tool is invoked based on the remote service interface in the remote call service; when the driver type is a second preset type, the system control target adapter is invoked, the dynamic link library file is invoked based on the local call module, and the machine tool communication driver corresponding to the target CNC machine tool is invoked based on the dynamic call interface in the dynamic link library file.
[0227] Optionally, when the driver type is the first preset type, the system control target adapter is invoked, and the remote call service is invoked based on the remote call client. Based on the remote service interface in the remote call service, the machine tool communication driver corresponding to the target CNC machine tool is invoked. This achieves the goal of enabling machine tool communication drivers written in different programming languages to be directly invoked by upper-layer applications without additional bridging code, enhancing system compatibility and scalability. Simultaneously, the remote call client application provides network communication capabilities. Even if the machine tool communication driver runs on different machines or containers, the upper-layer application can still invoke it through the remote call client, thereby improving the distribution and flexibility of the overall communication system. Furthermore, although the remote call service involves network communication, because it uses binary format to transmit data and supports streaming transmission, compared to the traditional RESTful API communication method, the remote call service can provide faster and more efficient data transmission and call response, making it suitable for scenarios with high real-time requirements.
[0228] Optionally, when the driver type is the second preset type, the system control target adapter is invoked. Based on the local invocation module, the dynamic link library file is invoked. Based on the dynamic invocation interface in the dynamic link library file, the machine tool communication driver corresponding to the target CNC machine tool is invoked. In this process, the local invocation module directly invokes the dynamic link library file within the same system, avoiding network communication delays and providing lower invocation latency, thus making it suitable for industrial control scenarios with high requirements for real-time performance. At the same time, local invocation avoids the resource consumption of remote communication, such as network bandwidth and server resources, improving resource utilization. The local invocation mechanism reduces the risk of network attacks. Since it does not require cross-network communication, data exchange occurs within the same system, thereby enhancing overall security.
[0229] In summary, the calling system solves the problem of calling multi-language machine tool communication drivers by distinguishing different driver types and providing corresponding calling mechanisms for each type. This not only enables efficient communication between drivers in different development languages but also ensures the real-time performance and security of communication, thereby improving the flexibility and efficiency of industrial automation production systems. At the same time, through the unified interface of the adapter, upper-layer applications do not need to care about the specific implementation and communication methods of the underlying drivers, making system development and maintenance simpler and more efficient.
[0230] As described above, this application encapsulates machine tool communication drivers written in different programming languages to obtain dynamic link library files or remote call services. Subsequently, this application creates a local call module and a remote call client as a communication bridge between the adapter and the dynamic link library files or remote call services. This achieves layered decoupling of the communication process and compatibility with the programming languages of different machine tool communication drivers. When the upper-level system needs to communicate with the lower-level CNC machine tool, the upper-level system only needs to call the unified interface provided by the adapter to invoke the lower-level machine tool communication driver, without needing to consider the differences in the underlying communication logic of the CNC machine tool. This achieves the technical effect of improving the communication efficiency between the upper-level system and the lower-level CNC machine tool and reducing communication costs, thereby solving the technical problems of low communication efficiency and high communication costs when the upper-level system calls machine tool communication drivers based on existing technologies.
[0231] In an optional embodiment, a system for implementing the above-described machine tool communication driver invocation method is also provided. Figure 3 This is an architecture diagram of an optional machine tool communication driver invocation system according to an embodiment of this application, such as... Figure 3 As shown, the system includes a unified service layer, a communication bridging layer, and a driver encapsulation layer.
[0232] Optionally, a driver encapsulation layer is used to standardize and encapsulate machine tool communication drivers (such as the first preset CNC machine tool driver and the second preset CNC machine tool driver), machine tool general protocols, and machine tool general serial ports written in different programming languages, including:
[0233] (1) GRPC service encapsulation (cross-language universal interface):
[0234] For machine tool communication drivers developed in languages that cannot be directly compiled into general dynamic libraries, the calling system packages their driver logic into an independent gRPC service. After the service starts, it listens on a specific port and provides a set of predefined gRPC interfaces. The main control layer can call machine tool communication drivers developed in different languages through gRPC client calls. The gRPC native library supports multiple languages and does not require additional adaptation.
[0235] (2) Dynamic link library encapsulation (high real-time interface):
[0236] For machine tool communication drivers developed using programming languages that can be directly compiled into general-purpose dynamic libraries, such as protocol drivers developed in C#, the calling system directly compiles them into cross-platform dynamic link libraries, and the interface function prototypes are defined according to a unified specification. The main control layer directly loads the dynamic link library to call the interface, avoiding the data transmission overhead of gRPC serialization / deserialization, so that the data communication latency is ≤1ms.
[0237] Optionally, a communication bridging layer, used to implement cross-language calls, includes:
[0238] (1) Local interface bridging:
[0239] For dynamic link library files compiled from unmanaged code such as C / C++, the main architecture uses the .NET platform and P / Invoke technology to directly and efficiently load and call functions in the dynamic link library files.
[0240] For dynamic link library files that provide COM (Component Object Model) component interfaces and are compiled by Delphi (an integrated development environment) or the older VB language, the main architecture, through the .NET platform and based on COM Interop technology, calls these COM components just like calling ordinary .NET objects, thereby indirectly calling the driver functions.
[0241] Through these two mechanisms, the main architecture can perform high-performance in-process communication with the native dynamic link library file driver. Data exchange is carried out directly through memory, which improves communication efficiency.
[0242] (2) Network interface bridging (for GRPC services):
[0243] A GRPC.NET client is built into the main architecture.
[0244] When a machine tool communication driver encapsulated as a gRPC service needs to be invoked (for example, a machine tool communication driver written in Python or Java), the main architecture's gRPC.NET client establishes a connection with the corresponding gRPC server via a network address (e.g., the local loopback address localhost) and invokes its remote methods.
[0245] Optionally, a unified service layer can be used for internal aggregation and to provide a unified API to the outside world.
[0246] (1) Driver Manager:
[0247] The calling system pre-registers a driver registry, which records the driver type (DLL or GRPC) and driver file path / GRPC service address for each machine tool type. Based on the driver registry, the calling system loads all drivers when the upper-layer application system starts and implements driver lifecycle management.
[0248] (2) Customized unified adapter interface:
[0249] The calling system defines a set of standardized core operation interfaces that are independent of specific machine tool protocols, such as: Connect(deviceId), SendFile(deviceId,programData), ReceiveFile(deviceId,programData), and GetStatus(deviceId).
[0250] Then, the calling system writes a corresponding adapter for each type of machine tool communication driver (whether it is a DLL type or a GRPC type). This adapter is used to implement the standardized core operation interface that is independent of the specific machine tool protocol. The adapter is responsible for translating the general "translation" of the upper-level system to the lower-level driver into calls to specific DLL functions or GRPC methods.
[0251] (3) Customize external service interfaces:
[0252] In the unified service layer, the main architecture exposes the capabilities of the unified adapter interface to the upper-layer application through RESTful API or gRPC. The upper-layer application does not need to care about the specific protocol and development language of the underlying machine tool, but only needs to specify the device ID and operation instructions.
[0253] For example, let's illustrate the workflow of calling the system by taking the transfer of NC programs to a CNC machine tool as an example:
[0254] (1) The upper-layer application initiates a call request "SendFile".
[0255] (2) Using the main architecture driver manager, the call request is parsed to obtain the configuration information of "CNC-001". Based on the configuration information, the corresponding driver adapter is found in the preset driver registry.
[0256] (3) The driver adapter detects that the driver type of the machine tool communication driver to be called is "DLL". Then, it calls the SendFile function in the DLL through the local interface bridging method. If the driver type of the machine tool communication driver to be called is "GRPC", the driver adapter calls the SendFile method of the remote service through the GRPC client.
[0257] (4) The underlying machine tool communication driver executes the business logic of communicating with the corresponding CNC machine tool to complete file transfer.
[0258] (5) The operation result is returned along the original path and fed back to the upper layer application.
[0259] As described above, this invocation system adopts a hybrid driver integration model, combining local dynamic library invocation (high performance) and gRPC remote invocation (high compatibility) to handle drivers with different technology stacks. Simultaneously, the system uses a unified adapter design pattern to shield the logical differences between underlying DLL drivers and gRPC drivers, providing a completely consistent operation interface to the upper-layer system and simplifying communication logic. Furthermore, the system uses a centralized registry to configure and manage all drivers, achieving plug-and-play functionality. When expanding to new machine tool types, the system only needs to add configuration and driver files without modifying the main architecture code.
[0260] Example 2
[0261] This application embodiment also provides a machine tool communication driver invocation device. It should be noted that the machine tool communication driver invocation device of this application embodiment can be used to execute the machine tool communication driver invocation method provided in this application embodiment. The following describes the machine tool communication driver invocation device provided in this application embodiment.
[0262] According to an embodiment of this application, an apparatus for implementing the above-described machine tool communication driver invocation method is also provided. Figure 4 This is a schematic diagram of an optional machine tool communication driver invocation device according to an embodiment of this application, such as... Figure 4 As shown, the device includes: a driver encapsulation unit 401, a communication bridging unit 402, an adapter service unit 403, and a calling unit 404.
[0263] Optionally, the driver encapsulation unit 401 is used to encapsulate each machine tool communication driver based on the development language of each of the L machine tool communication drivers, to obtain a dynamic link library file / remote call service corresponding to each machine tool communication driver. Each machine tool communication driver is used to implement communication control of the CNC machine tool. The communication bridging unit 402 is used to create a local call module corresponding to the dynamic link library file and a remote call client corresponding to the remote call service. The local call module is used to call the dynamic link library file, and the remote call client is used to call the remote call service. The adapter service unit 403 is used to create an adapter corresponding to the local call module and an adapter corresponding to the remote call client, to obtain M adapters. The M adapters are set with adapter interfaces of a unified format. Each adapter is used to convert the target system's call request to the CNC machine tool into a call request to the local call module / remote call client. The call unit 404 is used to control the target system to call the L machine tool communication drivers based on the adapter interfaces corresponding to the M adapters.
[0264] In one optional embodiment, the machine tool communication drive invocation device further includes: a first determining unit and a second determining unit.
[0265] Optionally, the first determining unit is used to determine the communication protocol and communication interface supported by each CNC machine tool based on the configuration information of each CNC machine tool that the target system needs to communicate; the second determining unit is used to determine the development language and driver type of the machine tool communication driver corresponding to each CNC machine tool based on the communication protocol and communication interface supported by each CNC machine tool.
[0266] In one optional embodiment, the driver encapsulation unit 401 includes: a language detection subunit, a first encapsulation subunit, and a remote call service determination subunit.
[0267] Optionally, a language detection subunit is used to detect whether the development language of each machine tool communication driver belongs to a preset type, wherein the development language of the preset type supports compilation into a dynamic link library file of a preset format; a first encapsulation subunit is used to encapsulate the i-th machine tool communication driver if the development language of the i-th machine tool communication driver does not belong to the preset type, thereby obtaining X remote service interfaces, where X is a positive integer; a remote call service determination subunit is used to use the X remote service interfaces as the remote call service corresponding to the i-th machine tool communication driver.
[0268] In one optional embodiment, the X remote service interfaces in the machine tool communication-driven invocation device include at least:
[0269] The first preset service interface is used to send files to CNC machine tools;
[0270] The second preset service interface is used to receive files from CNC machine tools;
[0271] The third preset service interface is used to delete files in CNC machine tools;
[0272] The fourth preset service interface is used to obtain the file list of CNC machine tools;
[0273] The fifth preset service interface is used to realize the equipment connection of CNC machine tools;
[0274] The sixth preset service interface is used to disconnect the CNC machine tool from the equipment connection.
[0275] In an optional embodiment, the driver encapsulation unit 401 further includes a second encapsulation subunit and a dynamic link library file determination subunit.
[0276] Optionally, the second encapsulation subunit is used to encapsulate the i-th machine tool communication driver in the case that the development language of the i-th machine tool communication driver in the L machine tool communication drivers belongs to a preset type, to obtain Y dynamic calling interfaces, where Y is a positive integer; the dynamic link library file determination subunit is used to use the Y dynamic calling interfaces as the dynamic link library file corresponding to the i-th machine tool communication driver.
[0277] In one optional embodiment, the Y dynamic calling interfaces in the machine tool communication drive calling device include at least:
[0278] The first preset dynamic interface is used to initialize the configuration of the CNC machine tool;
[0279] The second preset dynamic interface is used to send files to the CNC machine tool;
[0280] The third preset dynamic interface is used to receive files from CNC machine tools;
[0281] The fourth preset dynamic interface is used to obtain the working status of the CNC machine tool;
[0282] The fifth preset dynamic interface is used to realize the equipment connection of CNC machine tools;
[0283] The sixth preset dynamic interface is used to disconnect the CNC machine tool from the equipment connection.
[0284] In an optional embodiment, the calling unit 404 includes: a request parsing subunit, an adapter lookup subunit, a driver type determination subunit, and a driver calling subunit.
[0285] Optionally, the request parsing subunit is used to parse the target call request after the adapter interface receives the target system's target call request for the target CNC machine tool, and obtain the target configuration information of the target CNC machine tool; the adapter lookup subunit is used to search in the preset driver registry based on the target configuration information to obtain the target adapter corresponding to the target CNC machine tool, wherein the target adapter is one of the M adapters; the driver type determination subunit is used to detect the driver type of the machine tool driver communication corresponding to the target CNC machine tool through the target adapter; and the driver call subunit is used to call the machine tool communication driver corresponding to the target CNC machine tool based on the driver type.
[0286] In one optional embodiment, the driving call subunit includes: a first bridging call module and a second bridging call module.
[0287] Optionally, the first bridging call module is used to control the target adapter when the driver type is a first preset type, to call the remote call service based on the remote call client, and to call the machine tool communication driver corresponding to the target CNC machine tool based on the remote service interface in the remote call service; the second bridging call module is used to control the target adapter when the driver type is a second preset type, to call the dynamic link library file based on the local call module, and to call the machine tool communication driver corresponding to the target CNC machine tool based on the dynamic call interface in the dynamic link library file.
[0288] It should be noted that the aforementioned driver encapsulation unit 401, communication bridging unit 402, adapter service unit 403, and calling unit 404 correspond to steps S201 to S204 in the method embodiment. The instances and application scenarios implemented by the aforementioned units and corresponding steps are the same, but are not limited to the content disclosed in the aforementioned embodiments. It should be noted that the aforementioned modules or units may be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The aforementioned modules may also be part of a device and can run in the computer terminal 10 provided in the embodiment.
[0289] Example 3
[0290] Embodiments of this application can also provide an electronic device. Figure 5 This is a structural block diagram of an electronic device according to an embodiment of this application, such as... Figure 5 As shown, the electronic device includes: one or more ( Figure 5 (Only one is shown) processor 502, memory 504, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0291] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and devices in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, to realize the above-mentioned machine tool communication drive calling method.
[0292] The memory may include high-speed random access memory (RAM), and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, which can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks (LANs), mobile communication networks, and combinations thereof.
[0293] The processor can access information and applications stored in memory via a transmission device to execute the following steps: Based on the development language of each of the L machine tool communication drivers, encapsulate each machine tool communication driver to obtain a corresponding dynamic link library file / remote call service. Each machine tool communication driver is used to implement communication control of the CNC machine tool. Create a local call module corresponding to the dynamic link library file and a remote call client corresponding to the remote call service. The local call module is used to call the dynamic link library file, and the remote call client is used to call the remote call service. Create adapters corresponding to the local call modules and adapters corresponding to the remote call clients to obtain M adapters. Each of the M adapters has a unified adapter interface format. Each adapter is used to convert the target system's call request to the CNC machine tool into a call request to the local call module / remote call client. Control the target system to call the L machine tool communication drivers based on the adapter interfaces corresponding to the M adapters.
[0294] This application provides a machine tool communication driver invocation scheme. It encapsulates machine tool communication drivers written in different programming languages to obtain dynamic link library files or remote call services. Then, it creates a local invocation module and a remote invocation client as a communication bridge between the adapter and the dynamic link library file or remote call service. This achieves layered decoupling of the communication process and compatibility with the different programming languages of the machine tool communication drivers. When the upper-level system needs to communicate with the lower-level CNC machine tool, the upper-level system only needs to call the unified interface provided by the adapter to invoke the lower-level machine tool communication driver, without needing to consider the differences in the underlying communication logic of the CNC machine tool. This improves the communication efficiency between the upper-level system and the lower-level CNC machine tool, reduces communication costs, and solves the technical problems of low communication efficiency and high communication costs when the upper-level system calls machine tool communication drivers based on existing technologies.
[0295] Those skilled in the art will understand that Figure 5 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones, tablets, PDAs, mobile internet devices, PADs, and other terminal devices. Figure 5 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 5 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 5 The different configurations shown.
[0296] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0297] Example 4
[0298] Embodiments of this application may also provide a storage medium.
[0299] Optionally, in this embodiment of the application, the storage medium can be used to store the program code executed by the calling method of the machine tool communication driver provided in the above method embodiment.
[0300] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0301] This application also provides a computer program product that, when executed on a data processing device, is adapted to perform the calling method steps of a machine tool communication drive.
[0302] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0303] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0304] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0305] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0306] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0307] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0308] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.< / bool> < / replymodel> < / workstateenum> < / replymodel> < / replymodel> < / bool>
Claims
1. A method for invoking a machine tool communication driver, characterized in that, include: Based on the development language of each of the L machine tool communication drivers, each machine tool communication driver is encapsulated to obtain the dynamic link library file / remote call service corresponding to each machine tool communication driver. Each machine tool communication driver is used to implement communication control of CNC machine tools. Create a local call module corresponding to the dynamic link library file and a remote call client corresponding to the remote call service, wherein the local call module is used to call the dynamic link library file and the remote call client is used to call the remote call service; Create an adapter corresponding to the local calling module and an adapter corresponding to the remote calling client to obtain M adapters. The M adapters are configured with adapter interfaces of a uniform format. Each adapter is used to convert the target system's call request to the CNC machine tool into a call request to the local calling module / the remote calling client. The target system is controlled to invoke the L machine tool communication drivers based on the adapter interfaces corresponding to the M adapters.
2. The method for invoking machine tool communication drivers according to claim 1, characterized in that, Before encapsulating each machine tool communication driver in the development language of L machine tool communication drivers, the calling method of the machine tool communication driver further includes: Based on the configuration information of each CNC machine tool that the target system needs to communicate with, determine the communication protocol and communication interface supported by each CNC machine tool; Based on the communication protocols and interfaces supported by each CNC machine tool, the development language and driver type of the machine tool communication driver corresponding to each CNC machine tool are determined.
3. The method for invoking machine tool communication drivers according to claim 1, characterized in that, Based on the development language of each of the L machine tool communication drivers, each machine tool communication driver is encapsulated, including: The development language of each machine tool communication driver is detected to see if it belongs to a preset type, wherein the development language of the preset type supports compilation into a dynamic link library file of a preset format; If the development language of the i-th machine tool communication driver among the L machine tool communication drivers does not belong to the preset type, the i-th machine tool communication driver is encapsulated to obtain X remote service interfaces, where X is a positive integer; The X remote service interfaces are used as remote call services corresponding to the i-th machine tool communication driver.
4. The method for invoking the machine tool communication driver according to claim 3, characterized in that, The X remote service interfaces include at least: The first preset service interface is used to send files to CNC machine tools; The second preset service interface is used to receive files from CNC machine tools; The third preset service interface is used to delete files in CNC machine tools; The fourth preset service interface is used to obtain the file list of CNC machine tools; The fifth preset service interface is used to realize the equipment connection of CNC machine tools; The sixth preset service interface is used to disconnect the CNC machine tool from the equipment connection.
5. The method for invoking machine tool communication drivers according to claim 1, characterized in that, Based on the development language of each of the L machine tool communication drivers, each machine tool communication driver is encapsulated, including: If the development language of the i-th machine tool communication driver in the L machine tool communication drivers belongs to a preset type, the i-th machine tool communication driver is encapsulated to obtain Y dynamic calling interfaces, where Y is a positive integer; The Y dynamic calling interfaces are used as the dynamic link library files corresponding to the i-th machine tool communication driver.
6. The method for invoking machine tool communication drivers according to claim 5, characterized in that, The Y dynamic call interfaces include at least: The first preset dynamic interface is used to initialize the configuration of the CNC machine tool; The second preset dynamic interface is used to send files to the CNC machine tool; The third preset dynamic interface is used to receive files from CNC machine tools; The fourth preset dynamic interface is used to obtain the working status of the CNC machine tool; The fifth preset dynamic interface is used to realize the equipment connection of CNC machine tools; The sixth preset dynamic interface is used to disconnect the CNC machine tool from the equipment connection.
7. The method for invoking the machine tool communication driver according to claim 1, characterized in that, Controlling the target system, based on the adapter interfaces corresponding to the M adapters, involves calling the L machine tool communication drivers, including: After the adapter interface receives the target system's target call request for the target CNC machine tool, it parses the target call request to obtain the target configuration information of the target CNC machine tool; Based on the target configuration information, a search is performed in the preset driver registry to obtain the target adapter corresponding to the target CNC machine tool, wherein the target adapter is one of the M adapters; The target adapter is used to detect the drive type of the machine tool drive communication corresponding to the target CNC machine tool; Based on the drive type, the machine tool communication driver corresponding to the target CNC machine tool is invoked.
8. The method for invoking the machine tool communication driver according to claim 7, characterized in that, Based on the aforementioned drive type, the machine tool communication driver corresponding to the target CNC machine tool is invoked, including: When the drive type is the first preset type, the target adapter is controlled to call the remote call service based on the remote call client, and the machine tool communication driver corresponding to the target CNC machine tool is called based on the remote service interface in the remote call service; When the driver type is the second preset type, the target adapter is controlled to call the dynamic link library file based on the local call module, and the machine tool communication driver corresponding to the target CNC machine tool is called based on the dynamic call interface in the dynamic link library file.
9. A machine tool communication drive recall device, characterized in that, include: The driver encapsulation unit is used to encapsulate each machine tool communication driver based on the development language of each of the L machine tool communication drivers, to obtain the dynamic link library file / remote call service corresponding to each machine tool communication driver, wherein each machine tool communication driver is used to implement communication control of CNC machine tools; A communication bridging unit is used to create a local calling module corresponding to the dynamic link library file and a remote calling client corresponding to the remote calling service, wherein the local calling module is used to call the dynamic link library file and the remote calling client is used to call the remote calling service; An adapter service unit is used to create an adapter corresponding to the local calling module and an adapter corresponding to the remote calling client, resulting in M adapters. The M adapters are configured with adapter interfaces of a uniform format. Each adapter is used to convert the target system's call request to the CNC machine tool into a call request to the local calling module / the remote calling client. The calling unit is used to control the target system to call the L machine tool communication drivers based on the adapter interfaces corresponding to the M adapters.
10. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the machine tool communication driver invocation method according to any one of claims 1 to 8.
