An OPC UA server system based on numerical control system
By adopting the communication acquisition module and protocol analysis module of the OPCUA server system in CNC machine tools, and using the OPCUA standard institutional data model for data mapping and non-blocking communication, the problems of equipment information interoperability and low response efficiency are solved, and the problem of low response efficiency is solved. The high availability and latching of data improves the versatility and interoperability of the system.
Patent Information
- Application Number
- CN202210199776.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-02
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-03-02
AI Technical Summary
In the field of CNC machine tools, the existing technology has a wide variety of equipment information, non-uniform data formats, and large differences in communication interfaces, resulting in cumbersome data collection, classification, and analysis. The versatility, interoperability, and reuse rate of equipment and software are low, and When the network is disconnected or the line is unavailable, the data before the power outage cannot be latched, resulting in low response efficiency.
The communication collection module, assignment module and protocol parsing and reading module based on the OPCUA server system are used to collect and store data through time polling and multi-thread concurrency through the communication thread pool, and the OPCUA standard institutional data model is used for data mapping. Implement non-blocking communication and data cleaning to ensure high availability and latching of data.
It solves the interoperability problem between domestic non-standard production equipment and international standard protocols, reduces resource occupation, improves the high availability of communication channels, avoids lagging, and successfully latches the data before power outage, improving the system's external response efficiency. .
Smart Images

Figure CN114710519B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of numerical control machine tools, and in particular to an OPC UA server system based on a numerical control system. Background Art
[0002] In the field of CNC machine tools, there are great differences in communication interfaces and communication data among manufacturers. In addition, there are many types of information in different devices and the data formats are not unified. This makes data collection, classification and analysis very cumbersome. Once the digital equipment in a workshop is replaced or upgraded, it is often necessary to modify the workshop information system software and redeploy it, which greatly increases the difficulty of implementation and reduces the versatility, interoperability and reuse rate of equipment and software.
[0003] At the same time, during the workshop data collection process, when there are line blockages, network disconnections, etc., the past collection equipment will often "reset to zero" and fail to lock the data before the power failure.
[0004] In addition, when a multi-threaded server model responds to hundreds or thousands of connection requests, creating too many threads will cause serious resource occupation, causing the threads to enter a locked state, reducing the system's external response efficiency. Summary of the invention
[0005] The present invention provides an OPC UA server system based on a numerical control system, so as to overcome the technical problems of low versatility of current machine tool server software, inability to lock data before power failure, low efficiency in external response, etc.
[0006] In order to achieve the above object, the technical solution of the present invention is:
[0007] An OPC UA server system based on a numerical control system comprises: a communication acquisition module, an assignment module and a protocol parsing and reading module;
[0008] The communication acquisition module includes a communication thread pool, which uses a time polling method and a multi-threaded concurrent method to collect and store machine tool data information; wherein the communication thread pool sets a thread pool, and each thread pool corresponds to a communication channel, and the communication channel exchanges messages with the internal Socket server port of the machine tool through the Socket method, thereby realizing data communication between the communication thread pool and the machine tool;
[0009] The assignment module is used to assign node data to the machine tool data information to obtain machine tool buffer data;
[0010] The protocol parsing and reading module is used to read the machine tool buffer data and initialize the machine tool buffer data, load the initialized machine tool data information into the OPCUA standard structured data model, and assign the variable type in the OPCUA standard structured data model in the form of a string, thereby obtaining the mapping relationship between the machine tool data information and the variable type, forming a mapping table, and the operator realizes the classification of the machine tool data information by reading the string and the mapping table.
[0011] Furthermore, the machine tool buffer data initialization specifically includes: loading OPCUA configuration data, wherein loading OPCUA configuration data includes loading machine tool buffer data, loading encryption certificates, loading setting information of access users and clock synchronization settings.
[0012] Furthermore, the communication thread pool presets dynamic threads.
[0013] Furthermore, the communication module communicates with the machine tool in a non-blocking manner when performing data communication.
[0014] Furthermore, the mapping relationship between the machine tool data information and the variable type is obtained by: capturing data packets of the data field values in the machine tool buffer data and the character strings of the variable types in the structured data model of the OPCUA standard to obtain the mapping relationship between the machine tool data information and the variable type.
[0015] Furthermore, the assignment module uses a static variable assignment method to assign node data to the machine tool data information.
[0016] Furthermore, the protocol parsing and reading module also includes data cleaning and assignment of values to the OPCUA standard structured data model.
[0017] Furthermore, the data cleaning specifically includes: converting the structured data model of the OPC UA standard in the default XML format into a format that matches the machine tool data information.
[0018] Beneficial effects: The present invention solves the problem that domestic non-standard production equipment, such as the CNC machine tool in this solution, cannot communicate (interoperate) with international standard protocols. The variable types in the structured data model of the OPCUA standard are assigned in the form of strings to obtain the mapping relationship between machine tool data information and variable types; the problem of excessive resource occupation caused by the collection of hundreds of items from a single device is solved; the machine tool data information is collected and stored in a time polling method and a multi-threaded concurrent method, which solves the high availability of the communication channel during high-speed communication, so that the operation process does not produce a jamming phenomenon, and at the same time, the data before the power failure is locked is saved. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0020] Figure 1 This is a schematic diagram of the OPC UA server system structure of the present invention;
[0021] Figure 2 It is a data flow diagram of the static data variable assignment information of the present invention;
[0022] Figure 3 This is a logic diagram for data acquisition model acquisition of the present invention. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0024] This embodiment provides an OPC UA server system based on a numerical control system, such as Figure 1-2 , including: communication acquisition module, assignment module and protocol parsing and reading module;
[0025] The communication module includes a communication thread pool, which uses an event polling method and a multi-threaded concurrent method to collect and store machine tool data information; wherein, the communication thread pool sets a thread pool, and each thread pool corresponds to a communication channel, and the communication channel exchanges messages with the internal Socket server port of the machine tool through the Socket method, thereby realizing data communication between the communication thread pool and the machine tool; specifically, the event polling collection method is realized through a timer scheduling mechanism, which includes a single polling cycle that can call or execute multiple instructions at the same time and generate controllable collection points, and the control range includes name, collection cycle, number of threads, whether they are not killed by other processes in the system, etc.;
[0026] The assignment module is used to assign node data to the machine tool data information to obtain machine tool buffer data;
[0027] The protocol parsing and reading module is used to read the machine tool buffer data, initialize the machine tool buffer data, load the initialized machine tool data information into the OPCUA standard structured data model, and assign the variable type (name, accessible node name and access permission) in the OPCUA standard structured data model in the form of a string, thereby obtaining the mapping relationship between the machine tool data information and the variable type, forming a mapping table, and the operator realizes the classification of the machine tool data information by reading the string and the mapping table. The specific mapping table includes a dynamic information table and a static information table.
[0028] The following are the dynamic information table and the static information table in the embodiment of the present application:
[0029]
[0030]
[0031]
[0032]
[0033] Table 1. Dynamic information table
[0034] Browse Name describe content cx-test-staticInfo-CncId Machine number 1 cx-test-staticInfo-CncSeriesModel Machine model KMC400S-U cx-test-staticInfo-CncName Machine tool name Five-axis vertical machining center cx-test-staticInfo-CncBrand Manufacturer Brand KEDE cx-test-staticInfo-CncProductionDate Production Date 2021 / 12 / 12 cx-test-staticInfo-CncWarranty Warranty Status In Bao cx-test-staticInfo-CncCallCenter Contact Details 0411-0000000 cx-test-staticInfo-CncAuthorizationCode Authorization Code 10.2.176.225
[0035] Table 2. Static information table
[0036] In a specific embodiment, the machine tool buffer data initialization specifically includes: loading the OPC UA configuration class, and the loading of the OPC UA configuration class includes loading the machine tool buffer data, loading the encryption certificate, loading the setting information of the access user and the clock synchronization setting.
[0037] In a specific embodiment, the communication thread pool presets dynamic threads, which can adapt well to different computers and automatically initialize and allocate reasonable system usage resources. The preset dynamic threads are specifically minimum thread planning based on the number of CPU cores of each machine tool equipment. For example, the preset threads are 2 times or 4 times the number of cores, and the threads are set high or low according to the device configuration.
[0038] In a specific embodiment, the communication module communicates in a non-blocking manner when performing data communication. The non-blocking communication method prevents each thread from being interfered with by any other, and the software process will not be stuck after the user has a network interruption request. It better meets the safety requirements of on-site production equipment, such as CNC machine tools. After the data is mapped, the system interface is developed to allow users to configure it clearly; the non-blocking method is specifically: the non-blocking effect is achieved through a multi-threaded method. In this embodiment, a multi-threaded method is used to define each acquisition task to each thread in the thread pool, which is independent of each other and has its own life cycle, so that a single process will not be stuck or wait for a long time.
[0039] Specifically, the non-blocking method is mainly based on a communication thread object and a communication instruction set, wherein the communication instruction set uses a memory buffer to collect results to meet the request result that can receive instant data response.
[0040] Given that machine tools and other equipment are used as data providers, anti-sticking and packet loss processing has been done, and the basic requirements for data provision are met. The entire process is implemented in a non-blocking asynchronous manner through JAVA's asynchronous interface. The entire communication process is as follows:
[0041] (1) Initialize the communication channel;
[0042] (2) Register the channel selector, write it into the thread queue, and set necessary settings such as whether it is a long connection and the timeout period;
[0043] (3) Implementing event polling through a timer scheduling mechanism, where the events are reading data in the buffer and sending machine tool message information;
[0044] (4) Handle connection and read and write events;
[0045] (5) After successful processing, close the channel and release resources;
[0046] (6) Capture the data packet and take out the data field value associated with the entity object data from the queue (buffer), that is, the actual data of the device.
[0047] In a specific embodiment, the mapping relationship between machine tool data information and variable types is obtained by: capturing data packets with data field values in the machine tool buffer data and character strings of variable types in the structured data model of the OPCUA standard to obtain the mapping relationship between machine tool data information and variable types; the data packet capture process is: sending a communication instruction to the machine tool end, the machine tool will return the corresponding data message packet, that is, the data packet, whose format is the XML key-value pair format, and obtaining the character set information in the channel through the Socket communication channel to realize streaming acquisition, that is, the data of the message packet in the network transmission layer, thereby realizing the capture of the data packet.
[0048] In a specific embodiment, the assignment module uses a static variable assignment method to assign node data to machine tool data information, which can reduce memory resource overhead caused by repeated object reconstruction.
[0049] In a specific embodiment, the protocol parsing and reading module also includes performing data cleaning on the structured data model of the OPCUA standard and then assigning values. The data cleaning specifically includes: converting the structured data model of the OPCUA standard in the default XML format into a format that matches the machine tool data information, such as Int type, Double type, and String type.
[0050] In the specific application process, the CNC system needs to be tested for communication before use to test whether the system can be connected with the machine tool.
[0051] Specifically, the OPCUA standard structured data model can be divided into directories, methods, variables, views, etc., which are used to form the standard data format defined by the OPCUA Foundation. One model corresponds to one information unit, and each information unit contains several sub-variable information, such as the axis coordinate directory contains X, Y, Z axis information, etc. Obtaining the mapping relationship between machine tool data information and variable types and saving them in the machine tool system memory can better meet real-time requirements, and after the nodes continue to expand to hundreds or thousands, it will not cause too much resource pressure on the system.
[0052] Specifically, the communication between this system and the machine tool equipment is carried out in Socket mode, that is, when this system communicates, the client initiates the message exchange with the internal Socket server interface of the machine tool, and it is carried out at a certain frequency. That is, write the client program of Socket communication. However, the traditional Socket client communication program has a blocking mechanism, and the communication blocking problem is solved by a non-blocking framework. And on this basis, increase the CPU concurrent threads to improve the asynchronous communication capability. Get the number of cores of the current computer processor. If the CNC system is a 4-core processor, design the thread (number of acquisition points) X (number of CPU cores) + 2. The two added threads are treated as a redundant solution to ensure that there is always a redundant thread to supply the disconnection and reconnection channel. You can also design communication use cases to solve the problems of jamming, busyness, and excessive resource usage in the data acquisition process.
[0053] Specifically, in each time slice in the communication module, multiple threads are used to concurrently execute acquisition operations. At the same time, each acquisition operation is assigned 2 dynamic threads to meet the threads reused for connection recovery after disconnection, data path abnormalities, etc. At the same time, the data communication with the machine tool adopts a non-blocking design so that each thread is not interfered with by each other, and the software process will not be stuck after the user requests a network interruption. It better meets the safety requirements of on-site production equipment such as CNC machine tools. After the data is mapped, the interface of this system is developed to allow users to configure it clearly.
[0054] Specifically, the node information calls the corresponding object of the entity class object (machine tool data information) to assign values to the node class. The OPCUA Foundation defines several life cycles, such as subscription, modification, unsubscription, and shutdown. This system sets the corresponding interface to achieve real-time transformation of this process under the monitoring of the node monitor class. The monitor class is a class inherited by each node, and its purpose is to monitor the subscription actions of other systems on this node, such as subscription, modification, and cancellation.
[0055] Specifically, the life cycle status of the OPCUA node is determined by calling related functions to subscribe, modify, and cancel.
[0056] Specifically, the machine tool data information includes spindle feed rate, spindle ratio, axis load (torque), axis load (current), current coordinates, remaining coordinates, program coordinates, machine tool status, current tool information, number of processed parts on the day, etc.
[0057] The following is an embodiment of the machine tool spindle information acquisition test in the present invention:
[0058] The communication layer of the total communication acquisition module of the present invention is divided into an interface class: EchoOfSpindle, an interface implementation class: SpindleService, a business communication class: SpindleHandler, and a data acquisition model is provided in the communication acquisition module. The data acquisition model acquisition logic is as follows: Figure 3 As shown, specifically, a thread pool is provided in the data acquisition model, and the spindle information of the machine tool is collected by polling and multi-threaded concurrent methods. After successful collection, the thread is cancelled and the corresponding resources are released, and the next collection thread is generated to enter the queue and wait; if the collection is unsuccessful, the thread is also cancelled and the next collection thread is generated to enter the queue and wait; multiple instantaneous threads are used for data collection, and the collection frequency can be lowered according to the characteristics of certain data, such as data with high real-time requirements, such as 200ms. The frequency is controlled by a timer, as shown below.
[0059] Threads are defined in the SpindleService implementation class. A new thread is created each time. The thread name is "spindleServer" and it does not reside in the system's total thread pool.
[0060] The communication acquisition module sends a communication instruction to the machine tool, opens the internal Socket server port of the machine tool, and the internal Socket server of the machine tool sends the corresponding node data. The assignment module assigns the node data to obtain the machine tool buffer data; the protocol parsing and reading module loads the OPCUA standard structured data model and assigns it in the form of a string. After obtaining the string, the machine tool returns the response data and the corresponding communication result, filters the information and assigns it to the static object (machine tool spindle information). After assignment, it is: SpindleDTO.setO1(Double.valueOf(over.text())), where SpindleDTO is a static variable of the spindle override information, and its override information value is "100"; the user accesses the spindle override test result.
[0061] If a communication error occurs, an error notification will be issued and the error will be output as an error.log file in the directory where the system is located.
[0062] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An OPC UA server system based on a numerical control system, characterized in that: include: Communication acquisition module, assignment module and protocol parsing and reading module; The communication acquisition module includes a communication thread pool, which uses a time polling method and a multi-threaded concurrent method to collect and store machine tool data information; wherein, the communication thread pool sets a thread pool, and the thread pool sets a corresponding communication channel, and the communication channel exchanges messages with the internal Socket server port of the machine tool through the Socket method, thereby realizing data communication between the communication thread pool and the machine tool; the communication acquisition module uses a non-blocking method to communicate with the machine tool when performing data communication; the non-blocking method is a non-blocking asynchronous method, which is realized through the asynchronous interface of JAVA, and the entire communication process is as follows: (1) Initialize the communication channel; (2) Register the channel selector, write it into the thread queue, and set whether it is a long connection and the necessary timeout settings; (3) Implementing event polling through a timer scheduling mechanism, where the events are reading data in the buffer and sending machine tool message information; (4) Handle connection and read and write events; (5) After successful processing, close the channel and release resources; (6) Capture the data packet and take out the data field value associated with the entity object data from the queue buffer, that is, the actual data of the device; The assignment module is used to assign node data to the machine tool data information to obtain machine tool buffer data; The protocol parsing and reading module is used to read the machine tool buffer data, initialize the machine tool buffer data, load the OPCUA standard structured data model into the initialized machine tool data information, and assign the variable type in the OPCUA standard structured data model in the form of a string, thereby obtaining a mapping relationship between the machine tool data information and the variable type, forming a mapping table, and the operator classifies the machine tool data information by reading the string and the mapping table; obtaining the mapping relationship between the machine tool data information and the variable type is specifically: performing data packet capture on the data field value in the machine tool buffer data and the string of the variable type in the OPCUA standard structured data model, and obtaining the mapping relationship between the machine tool data information and the variable type; The data packet capture process is as follows: the communication command is sent to the machine tool end, and the machine tool returns the corresponding data message packet, i.e., the data packet, whose format is the XML key-value pair format, and the character set information in the channel is obtained through the Socket communication channel to realize the stream acquisition; Among them, increasing the CPU concurrent threads, that is, obtaining the number of current computer processor cores, the redundant processing solution formula is to make the design thread (collection point number) X (CPU core number) + 2; The OPCUA standard structured data model is divided into directories, methods, variables, and views to form a standard data format defined by the OPCUA Foundation, that is, one model corresponds to one information unit, each information unit contains a number of sub-variable information, and then the mapping relationship between the machine tool data information and the variable type is obtained and saved in the machine tool system memory. In each time slice in the communication acquisition module, multiple threads are used to concurrently execute acquisition operations, and at the same time, two dynamic threads are newly allocated for each acquisition operation.
2. The OPC UA server system based on a numerical control system as claimed in claim 1, characterized in that: The machine buffer data initialization is specifically as follows: loading OPCUA configuration data, wherein loading OPCUA configuration data includes loading machine buffer data, loading encryption certificates, loading access user settings and clock synchronization settings.
3. The OPC UA server system based on a numerical control system as claimed in claim 2, characterized in that: The communication thread pool presets dynamic threads.
4. The OPC UA server system based on a numerical control system as claimed in claim 1, characterized in that: The assignment module uses a static variable assignment method to assign node data to machine tool data information.
5. The OPC UA server system based on a numerical control system as claimed in claim 4, characterized in that: The protocol parsing and reading module also includes performing data cleaning and value assignment on the structured data model of the OPC UA standard.
6. The OPC UA server system based on a numerical control system as claimed in claim 5, characterized in that: The data cleaning specifically includes: converting the structured data model of the OPC UA standard in the default XML format into a format that matches the machine tool data information.
Citation Information
Patent Citations
Multi-sensor data acquisition method and system based on numerical control machine tool
CN112230603A
