Numerical control machine tool simulator and numerical control machine tool simulation method
By designing a CNC machine tool simulator, using the simulated machining process to generate data and transmitting it using the target communication protocol, the problems of high cost and low efficiency in the development and testing of CNC machine tools are solved, and an efficient and simple development and testing process is achieved.
Patent Information
- Application Number
- CN202410632904.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-21
- Publication Date
- 2024-09-03
AI Technical Summary
When developing and testing on CNC machine tools, there are problems such as higher cost, lower efficiency and inconvenient operation.
Design a CNC machine tool simulator, including a request receiving module, a processing module and a data sending module. It generates data by simulating the processing process of CNC machine tools, and uses the target communication protocol for data transmission. The message structure includes encrypted numbers to improve security and efficiency.
It effectively reduces development and testing costs, improves efficiency, is simple to operate, and achieves accurate simulation of CNC machine tool communication protocols and machining processes.
Smart Images

Figure CN118584899A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of numerical control equipment, and in particular to a numerical control machine tool simulator and a numerical control machine tool simulation method. Background Art
[0002] Computer Numerical Control (CNC) machine tools are machine tools that use numerical control technology to achieve automated processing. Compared with traditional manual or semi-automatic machine tools, CNC machine tools have the advantages of high precision, high efficiency, and good repeatability. Therefore, they are widely used in various industrial fields, such as automobile manufacturing, aerospace, and electronic manufacturing. In the process of developing and testing CNC machine tools, developers need to frequently interact with the machine tool hardware to obtain the actual processing data of the machine tool hardware.
[0003] However, this approach is subject to many limitations, such as development and testing on actual CNC machine tools, which leads to high costs, low efficiency, and inconvenient operation. Summary of the invention
[0004] The present invention provides a numerical control machine tool simulator and a numerical control machine tool simulation method, so as to solve the problems in the prior art of developing and testing on actual numerical control machine tools, resulting in high cost, low efficiency and inconvenient operation.
[0005] The present invention provides a numerical control machine tool simulator, comprising:
[0006] A request receiving module, used for receiving a collection request sent by a collector;
[0007] A processing module, configured to obtain the data to be sent from the numerical control machine tool simulation data based on the acquisition request, wherein the numerical control machine tool simulation data is data generated by simulating a machining process of the numerical control machine tool;
[0008] A data sending module is used to send the data to be sent to the collector based on a preset target communication protocol. The message structure of the target communication protocol includes a message body, and the message body includes at least two message content parts. All of the message content parts constitute the data to be sent. An encryption number is set between adjacent message content parts. The encryption number is determined based on a timestamp and a target length. The target length refers to the sum of the lengths of two currently adjacent message content parts.
[0009] In one embodiment of the present invention, the message body further includes: a request count, the request count being the cumulative number of the acquisition requests received after the CNC machine tool simulator is started;
[0010] The encryption number is determined based on the request count, a timestamp, and the target length.
[0011] In one embodiment of the present invention, the message structure further includes a message header and a message tail;
[0012] The message header includes: a fixed start character and a message length, wherein the message length refers to the total length of the current message;
[0013] The message tail is a first fixed end character or a second fixed end character, the first fixed end character indicates that there are continuous messages after the current message, and the second fixed end character indicates that the current message is the last message of this data transmission;
[0014] The request receiving module is specifically used to perform message parsing on the collection request based on the target communication protocol when the collection request is received; in the process of parsing the message of the collection request, if the first fixed terminator is detected, wait for collecting the remaining first continuous messages until the second fixed terminator is detected; if the second fixed terminator is detected, uniformly process and feedback all the first continuous messages currently accumulated, and the first continuous message refers to the message data of the collection request.
[0015] In one embodiment of the present invention, the data sending module is specifically used to, during the process of data sending, if the first fixed end character is detected, wait for collecting the remaining second continuous messages until the second fixed end character is detected; if the second fixed end character is detected, all the second continuous messages currently accumulated and collected are sent to the collector, and the second continuous message is the message data to be sent to the collector.
[0016] In one embodiment of the present invention, the data sending module is also specifically used to transcode the message body of any second continuous message based on a preset transcoding format to obtain first intermediate data; based on a preset target base, perform base conversion on the first intermediate data to obtain second intermediate data; use a preset encryption tool to encrypt the second intermediate data to obtain third intermediate data; determine the third intermediate data as the new message body of the current second continuous message to complete message body encryption; and when it is determined that all the second continuous messages currently accumulated have completed message body encryption, send the second continuous messages uniformly.
[0017] In one embodiment of the present invention, the acquisition request includes an acquisition point address and a reporting mode, the acquisition point address and the reporting mode are both information pre-configured in the collector, and the acquisition request is used to instruct the processing module to scan the CNC machine tool simulation data to obtain target data located at the acquisition point address;
[0018] The reporting mode includes: scanning reporting and change reporting. When the reporting mode is scanning reporting, the processing module determines the target data obtained by scanning as the data to be sent; when the reporting mode is change reporting, the processing module compares the currently obtained target data with the target data obtained by the last scan. If there is a difference between the currently obtained target data and the target data obtained by the last scan, the currently obtained target data is determined as the data to be sent.
[0019] In one embodiment of the present invention, it further includes:
[0020] A communication module, configured to receive a first connection request sent by the collector, and to establish a single connection with the collector based on the first connection request, wherein the first connection request is a single connection request, and the single connection means disconnecting after performing a single data transmission;
[0021] The communication module is also used to receive a second connection request sent by the collector, and establish a long connection with the collector based on the second connection request. The second connection request is issued by the collector when it is determined that an abnormality has occurred in a single connection. The collection request is issued after the collector determines that a single connection or a long connection with the CNC machine tool simulator has been established.
[0022] In one embodiment of the present invention, the single connection refers to a connection method based on the HTTP protocol, and the single connection is a default connection method between the collector and the CNC machine tool simulator.
[0023] The present invention also provides a numerical control machine tool simulation method, comprising:
[0024] Receive a collection request sent by a collector;
[0025] Based on the acquisition request, the data to be sent is obtained from the numerical control machine tool simulation data, wherein the numerical control machine tool simulation data is data generated by simulating a machining process of the numerical control machine tool;
[0026] Based on a preset target communication protocol, the data to be sent is sent to the collector. The message structure of the target communication protocol includes a message body. The message body includes at least two message content parts. All the message content parts constitute the data to be sent. An encryption number is set between adjacent message content parts. The encryption number is determined based on a timestamp and a target length. The target length refers to the sum of the lengths of two currently adjacent message content parts.
[0027] The present invention also provides a numerical control machine tool simulation control method based on the numerical control machine tool simulator as described above, comprising:
[0028] When it is determined that the basic information configuration is completed, a communication connection is established between the CNC machine tool simulator and the collector, wherein the basic information configuration includes: a first basic information configuration for the CNC machine tool simulator, and a first basic information configuration and a second basic information configuration for the collector, wherein the first basic information includes: an IP address and a port of the CNC machine tool simulator, and the second basic information includes: a scanning frequency and a collection point address;
[0029] In the case of successful connection, based on the scanning frequency, the collector is controlled to send the acquisition request to the CNC machine tool simulator, the acquisition request including the acquisition point address; the acquisition request is used to instruct the CNC machine tool simulator to determine the data located at the acquisition point address in the CNC machine tool simulation data as the data to be sent, and send the data to be sent to the collector;
[0030] Control the collector to visualize the received data.
[0031] The present invention also provides a numerical control machine tool simulation control system based on the numerical control machine tool simulator as described above, comprising:
[0032] A first control module is used to establish a communication connection between the CNC machine tool simulator and the collector when it is determined that the basic information configuration is completed, wherein the basic information configuration includes: a first basic information configuration for the CNC machine tool simulator, and a first basic information configuration and a second basic information configuration for the collector, wherein the first basic information includes: an IP address and a port of the CNC machine tool simulator, and the second basic information includes: a scanning frequency and a collection point address;
[0033] A second control module is used to control the collector to send the acquisition request to the CNC machine tool simulator based on the scanning frequency when the connection is successful, wherein the acquisition request includes the acquisition point address; the acquisition request is used to instruct the CNC machine tool simulator to determine the data located at the acquisition point address in the CNC machine tool simulation data as the data to be sent, and send the data to be sent to the collector;
[0034] The third control module is used to control the collector to visualize the received data.
[0035] Beneficial effects of the present invention: The numerical control machine tool simulator and numerical control machine tool simulation method proposed by the present invention are provided with a request receiving module in the numerical control machine tool simulator for receiving a collection request sent by a collector; a processing module is provided for obtaining the data to be sent from the numerical control machine tool simulation data based on the collection request, and the numerical control machine tool simulation data is data generated by simulating the processing process of the numerical control machine tool; a data sending module is also provided for sending the data to be sent to the collector based on a preset target communication protocol, and the message structure of the target communication protocol includes a message body, and the message body includes at least two message content parts, and all message content parts constitute the data to be sent, and an encryption number is provided between adjacent message content parts, and the encryption number is determined based on a timestamp and a target length, and the target length refers to the sum of the lengths of the two currently adjacent message content parts. The numerical control machine tool simulator can better realize the simulation of the communication protocol and processing process of the numerical control machine tool, effectively reduce the development cost and the testing cost, improve the development and testing efficiency, and is relatively simple to operate. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A schematic diagram of the structure of a numerical control machine tool simulator provided by one embodiment of the present invention;
[0037] Figure 2 A schematic diagram of a flow chart of a numerical control machine tool simulation method provided in one embodiment of the present invention;
[0038] Figure 3 A schematic flow chart of a numerical control machine tool simulation control method provided in one embodiment of the present invention;
[0039] Figure 4 An exemplary schematic diagram of a configuration interface of a numerical control machine tool simulator provided by an embodiment of the present invention;
[0040] Figure 5 An exemplary schematic diagram of a configuration interface of a collector provided by an embodiment of the present invention;
[0041] Figure 6 An exemplary schematic diagram of another configuration interface of a collector provided by an embodiment of the present invention;
[0042] Figure 7 An exemplary schematic diagram of a collector display interface provided by an embodiment of the present invention;
[0043] Figure 8 A schematic diagram of the structure of a numerical control machine tool simulation control system provided by one embodiment of the present invention;
[0044] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0045] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0046] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0047] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.
[0048] Combine the following Figures 1 to 9 , the CNC machine tool simulator and CNC machine tool simulation method provided by the present invention are explained.
[0049] See also Figure 1 , Figure 1 A schematic diagram of the structure of a numerical control machine tool simulator provided by an embodiment of the present invention, such as Figure 1 As shown, the CNC machine simulator comprises:
[0050] The request receiving module 110 is used to receive the collection request sent by the collector;
[0051] The processing module 120 is used to obtain the data to be sent from the CNC machine tool simulation data based on the acquisition request, wherein the CNC machine tool simulation data is data generated by simulating the processing process of the CNC machine tool;
[0052] The data sending module 130 is used to send the data to be sent to the collector based on a preset target communication protocol. The message structure of the target communication protocol includes a message body. The message body includes at least two message content parts. All the message content parts constitute the data to be sent. An encryption number is set between adjacent message content parts. The encryption number is determined based on a timestamp and a target length. The target length refers to the sum of the lengths of two currently adjacent message content parts. The request receiving module 110, the processing module 120 and the data sending module 130 are connected.
[0053] It should be noted that the CNC machine tool simulator in this embodiment can simulate the communication protocol and processing process of the CNC machine tool, has strong stability and high accuracy, greatly reduces the development and testing cost and difficulty of the CNC machine tool, does not need to rely on actual machine tool resources, and effectively improves the development and testing efficiency of the CNC machine tool.
[0054] It should also be noted that due to the large number of brands of CNC machine tools, the communication protocols used by each brand of CNC machine tools are quite different, and the current communication protocol structure of CNC machine tools is relatively complex, the parsing process is very cumbersome, time-consuming, and occupies a large amount of memory, which is not conducive to simulation development and testing. Therefore, in this embodiment, a self-developed target communication protocol is adopted to simulate the communication protocol of CNC machine tools. The target communication protocol has low complexity, is easy to parse, has high security, and transmits faster. Specifically, the target communication protocol in this embodiment divides the data to be sent into at least two message content parts, and sets an encryption number between two adjacent message content parts, which is determined based on the timestamp and the target length. Compared with the communication protocol of existing CNC machine tools, the target communication protocol in this embodiment, by adopting the above-mentioned message structure, can reduce the complexity of the message, reduce the message volume, increase the message transmission speed, and is easy to parse. In addition, the encryption number is unique, which can effectively improve the security of the transmitted message.
[0055] It should be mentioned that by adopting the above-mentioned target communication protocol to simulate the communication protocol of the CNC machine tool, it is possible to accurately simulate the communication protocol of the CNC machine tool, which helps to improve the operating efficiency and stability of the CNC machine tool simulator.
[0056] It is also necessary to mention that the processing module 120 is also used to simulate the machining process of the CNC machine tool when the CNC machine tool simulator is started to obtain the CNC machine tool simulation data. The existing CNC machine tool simulation model can be used to simulate the machining process of the CNC machine tool.
[0057] In some embodiments, the message body further includes: a request count, where the request count is the cumulative number of acquisition requests received after the CNC machine tool simulator is started.
[0058] It should be noted that by setting the request count in the message body, it is convenient to subsequently determine the encrypted number based on the request count, timestamp and target length, and it is convenient for the data receiving end to parse the encrypted number based on the request count.
[0059] Further, the encryption number is determined based on the request count, timestamp and target length. Specifically, regarding the method for determining the encryption number, the encryption number can be obtained by performing a preset operation on the request count, timestamp and target length. The preset operation can be set according to actual conditions, such as summing the request count, timestamp and target length, and determining the obtained sum as the encryption number, or determining the first n (n=1, 2, 3...) bits of the sum as the encryption number. In this embodiment, the operation method of the preset operation is not limited. In the actual processing process, the preset operation can be set accordingly, and it is only necessary to ensure that the encryption number is determined based on the request count, timestamp and target length to ensure the uniqueness of the encryption number and improve the security of communication.
[0060] In order to reduce the complexity of the encryption number, in some embodiments, the encryption number is determined based on the target number, and the target number is the sum of the request count, the timestamp, and the target length. Further, the encryption number is the first digit or the first multiple digits of the target number. For example, the first 4 digits of the target number are determined as the encryption number, and if the target number is less than 4 digits, it is padded to the right with zeros, etc.
[0061] The following is a specific example to illustrate the method for generating the encryption number in the above embodiment.
[0062] First, obtain the data source of the encrypted number, which includes: request count, timestamp and target length (the sum of the lengths of the two adjacent message content parts). Secondly, sum all the data in the above data sources. Specifically, sum the request count, timestamp and target length to obtain the target number. Finally, take the first 4 digits of the target number as the encrypted number. Among them, if the target number is less than 4 digits, it is padded to the right with zeros. It should be noted that this embodiment only exemplifies the method for generating encrypted numbers. Therefore, in the specific implementation process, the data source of the encrypted number can be adjusted according to actual conditions, such as using request count and timestamp as the data source of the encrypted number. Similarly, the processing of data in the data source can also be adjusted according to actual conditions, such as subtracting the request count, timestamp and target length in turn and taking the absolute value. The number of digits of the encrypted number can also be set according to actual conditions, which will not be repeated here.
[0063] In some embodiments, the message structure also includes a message header and a message tail.
[0064] The message header includes: a fixed start character and a message length, and the message length refers to the total length of the current message.
[0065] The message tail is a first fixed terminator or a second fixed terminator, the first fixed terminator indicates that there are continuous messages after the current message, and the second fixed terminator indicates that the current message is the last message of this data transmission.
[0066] It should be noted that multiple continuous message processing mechanisms are designed in the target communication protocol in this embodiment, which is specifically reflected in the above embodiment that a first fixed end symbol or a second fixed end symbol is set at the end of the message to facilitate the CNC machine tool simulator to uniformly process continuous messages, reduce the data processing pressure of the CNC machine tool simulator, reduce the number of communications, and improve the performance of the CNC machine tool simulator.
[0067] The request receiving module 110 is specifically used to perform message parsing on the collection request based on the target communication protocol when the collection request is received; in the process of parsing the message of the collection request, if the first fixed terminator is detected, wait for collecting the remaining first continuous messages until the second fixed terminator is detected; if the second fixed terminator is detected, uniformly process and feedback all the first continuous messages currently accumulated, and the first continuous message refers to the message data of the collection request.
[0068] It should be noted that the unified processing and feedback of all the first continuous messages currently accumulated includes: parsing all the first continuous messages currently accumulated, obtaining the collection point addresses corresponding to all the first continuous messages, thereby obtaining the data of all the collection point addresses from the CNC machine tool simulation data and providing feedback. This method can realize the unified processing of continuous messages, avoid the problem of high data processing pressure of the CNC machine tool simulator caused by multiple processing of multiple continuous messages, and effectively reduce the number of communications.
[0069] In some embodiments, the data sending module 130 is specifically used to wait for the collection of the remaining second continuous messages until the second fixed end character is detected during the data sending process if the first fixed end character is detected; if the second fixed end character is detected, all the second continuous messages currently accumulated and collected are uniformly sent to the collector, and the second continuous message is the message data to be sent to the collector. Similarly, the data sending module 130 can uniformly process the continuous messages to be sent by adopting the above-mentioned multiple continuous message processing mechanism, which can effectively reduce the number of communications with the collector and help improve the performance of the CNC machine tool simulator.
[0070] Table 1 below is an example of the message structure of the target communication protocol, see Table 1 below:
[0071] Table 1 Example of target communication protocol message structure
[0072]
[0073] It should be noted that the fixed start character may be 0x30, etc., and the fixed end character may be 0x65 or 0x66, wherein 0x65 refers to the first fixed end character, and 0x66 refers to the second fixed end character. In Table 1, the data to be sent is exemplarily divided into two message content parts according to the length, namely the first message content part and the second message content part. It should be mentioned that since most of the CNC machine tool data are short data, the message volume can be reduced as much as possible by dividing the data to be sent into the first message content part and the second message content part in Table 1. It can be understood that there are corresponding encryption numbers between two adjacent message content parts. Compared with dividing the data to be sent into three or more message content parts, the data to be sent in Table 1 is divided into two message content parts, which can reduce the message mention, and reduce the complexity of message generation and parsing, which is helpful to improve the performance of the CNC simulator. It should be mentioned that in Table 1, the data to be sent is evenly divided according to the length of the data to be sent to obtain the first message content part and the second message content part. When the length of the data to be sent is an even number, the length a of the first message content part is the same as the length b of the second message content part. When the length of the data to be sent is an odd number, the length a of the first message content part = the length b+1 of the second message content part, or the length b of the second message content part = the length a+1 of the first message content. In addition, the encrypted number in Table 1 above occupies 4 bytes.
[0074] In order to further improve the security of message transmission, in some embodiments, the data sending module 130 is also specifically used to transcode the message body of any second continuous message based on a preset transcoding format to obtain first intermediate data; based on a preset target base, perform base conversion on the first intermediate data to obtain second intermediate data; use a preset encryption tool to encrypt the second intermediate data to obtain third intermediate data; determine the third intermediate data as the new message body of the current second continuous message to complete message body encryption; and when it is determined that all the second continuous messages currently accumulated have completed message body encryption, send the second continuous messages uniformly.
[0075] It should be noted that the transcoding format may be an ASCII (American Standard Code for Information Interchange) transcoding format, etc. The target system may be hexadecimal, etc. The encryption tool may be base64 (a data encoding encryption tool), etc. By adopting the above steps to encrypt the message body, the security of message transmission can be further improved.
[0076] In some embodiments, the acquisition request includes an acquisition point address and a reporting mode, and the acquisition point address and the reporting mode are both pre-configured information in the collector. The acquisition request is used to instruct the processing module 120 to scan the CNC machine tool simulation data to obtain the target data located at the acquisition point address.
[0077] It should be noted that, in some embodiments, the acquisition request also includes: scanning frequency, IP address and port of the CNC machine tool simulator. The scanning frequency refers to the acquisition frequency, that is, the frequency of scanning the CNC machine tool simulation data. The scanning frequency, IP address and port of the CNC machine tool simulator are all pre-configured in the collector.
[0078] The reporting mode includes: scanning reporting and change reporting. When the reporting mode is scanning reporting, the processing module 120 determines the target data obtained by scanning as the data to be sent; when the reporting mode is change reporting, the processing module 120 compares the target data currently obtained with the target data obtained by the last scan. If there is a difference between the target data currently obtained and the target data obtained by the last scan, the target data currently obtained is determined as the data to be sent.
[0079] It should be noted that by setting the above two reporting modes, different data reporting requirements of developers can be met.
[0080] In order to facilitate the establishment of a communication connection between the collector and the CNC machine tool simulator, and to ensure the stability of the connection between the two, in some embodiments, it also includes:
[0081] The communication module is used to receive a first connection request sent by the collector, and establish a single connection with the collector based on the first connection request. The first connection request is a single connection request, and the single connection means disconnecting after a single data transmission.
[0082] The communication module is also used to receive a second connection request sent by the collector, and establish a long connection with the collector based on the second connection request. The second connection request is issued by the collector when it is determined that an abnormality has occurred in a single connection. The collection request is issued after the collector determines that a single connection or a long connection with the CNC machine tool simulator has been established.
[0083] It should be noted that the above embodiment provides dual connection modes, namely, single connection and long connection. The two connection modes constitute redundancy. When one of the connection modes has a connection abnormality or timeout, it automatically switches to another connection mode to ensure the stability of the communication connection between the collector and the CNC machine tool simulator.
[0084] It should also be noted that the single connection refers to a connection method based on the HTTP protocol, that is, HTTP (Hypertext Transfer Protocol) is used as the underlying protocol to establish a connection between the collector and the CNC machine tool simulator, and each connection or connection request is valid for a single time, so that it can be used and sold immediately, which can greatly reduce the amount of communication process. The long connection refers to a connection with the socket protocol as the underlying protocol. In this embodiment, a single connection, that is, a connection method based on the HTTP protocol, is used as the default connection method. When a single connection has a connection exception or timeout, a long connection between the collector and the CNC machine tool processor is established.
[0085] In this embodiment, if a long connection is established between the collector and the CNC machine simulator, the collector will spontaneously send a piece of empty data to the CNC machine simulator at a preset time interval according to the preset heartbeat rule, and clean up the empty data after the communication is completed. In this way, it can be ensured that a long-term effective connection can be achieved even without data transmission, so that the collector and the CNC machine simulator maintain stable and long-term data exchange, ensuring the efficiency and reliability of the entire simulation process.
[0086] The CNC machine tool simulator in the above embodiment, by accurately simulating the communication protocol and processing process of the CNC machine tool, enables developers and testers to perform efficient and low-cost development and testing work in a virtual environment, thereby improving the development efficiency and product quality of the CNC machine tool.
[0087] The numerical control machine tool simulation method provided by the present invention is described below. The numerical control machine tool simulation method described below and the numerical control machine tool simulator described above can be referenced to each other.
[0088] Please refer to Figure 2 This embodiment also provides a numerical control machine tool simulation method, the execution subject of which is a numerical control machine tool simulator, and the method includes:
[0089] S210: receiving a collection request sent by a collector.
[0090] S220: Based on the acquisition request, obtain the data to be sent from the CNC machine tool simulation data, where the CNC machine tool simulation data is data generated by simulating a machining process of the CNC machine tool.
[0091] S230: Based on the preset target communication protocol, the data to be sent is sent to the collector, the message structure of the target communication protocol includes a message body, the message body includes at least two message content parts, all the message content parts constitute the data to be sent, and an encryption number is set between adjacent message content parts, the encryption number is determined based on the timestamp and the target length, and the target length refers to the sum of the lengths of the two adjacent message content parts. The CNC machine tool simulation method in this embodiment can better realize the simulation of the communication protocol and processing process of the CNC machine tool, effectively reduce the development cost and testing cost, improve the development and testing efficiency, and is simple to operate and has strong stability.
[0092] In some embodiments, after receiving the acquisition request, the method further includes:
[0093] Based on the target communication protocol, the collection request is parsed; during the message parsing of the collection request, if the first fixed terminator is detected, wait for the collection of the remaining first continuous messages until the second fixed terminator is detected; if the second fixed terminator is detected, all the first continuous messages currently accumulated are uniformly processed and fed back, and the first continuous message refers to the message data of the collection request.
[0094] In some embodiments, based on a preset target communication protocol, the step of sending the data to be sent to the collector includes:
[0095] During the data sending process, if the first fixed end character is detected, wait for collecting the remaining second continuous messages until the second fixed end character is detected; if the second fixed end character is detected, all the second continuous messages currently accumulated and collected are sent to the collector, and the second continuous message is the message data to be sent to the collector.
[0096] In some embodiments, the step of sending all the second continuous messages currently accumulated and collected to the collector comprises:
[0097] Based on a preset transcoding format, the message body of any second continuous message is transcoded to obtain first intermediate data; based on a preset target base, the first intermediate data is converted to obtain second intermediate data; using a preset encryption tool, the second intermediate data is encrypted to obtain third intermediate data; the third intermediate data is determined as the new message body of the current second continuous message to complete message body encryption; when it is determined that all the second continuous messages currently accumulated have completed message body encryption, the second continuous messages are sent uniformly.
[0098] In some embodiments, based on the acquisition request, the step of obtaining the data to be sent from the numerical control machine tool simulation data includes:
[0099] Scanning the numerical control machine tool simulation data to obtain target data located at the acquisition point address;
[0100] The reporting mode includes: scanning reporting and change reporting. When the reporting mode is scanning reporting, the processing module determines the target data obtained by scanning as the data to be sent; when the reporting mode is change reporting, the processing module compares the currently obtained target data with the target data obtained by the last scan. If there is a difference between the currently obtained target data and the target data obtained by the last scan, the currently obtained target data is determined as the data to be sent.
[0101] In some embodiments, it also includes:
[0102] receiving a first connection request sent by the collector, and establishing a single connection with the collector based on the first connection request, wherein the first connection request is a single connection request, and the single connection means disconnecting after performing a single data transmission;
[0103] Receive a second connection request sent by the collector, and establish a long connection with the collector based on the second connection request. The second connection request is issued by the collector when it is determined that an abnormality has occurred in a single connection. The collection request is issued after the collector determines that a single connection or a long connection with the CNC machine tool simulator has been established.
[0104] Please refer to Figure 3 This embodiment also provides a numerical control machine tool simulation control method based on the numerical control machine tool simulator as described above, comprising:
[0105] S310: When it is determined that the basic information configuration is completed, establish a communication connection between the CNC machine tool simulator and the collector. The basic information configuration includes: a first basic information configuration for the CNC machine tool simulator, and a first basic information configuration and a second basic information configuration for the collector, the first basic information includes: the IP address and port of the CNC machine tool simulator, and the second basic information includes: the scanning frequency and the collection point address. In some embodiments, the second basic information also includes a reporting mode.
[0106] S320: If the connection is successful, based on the scanning frequency, control the collector to send the acquisition request to the CNC machine tool simulator. The acquisition request includes the acquisition point address; the acquisition request is used to instruct the CNC machine tool simulator to determine the data located at the acquisition point address in the CNC machine tool simulation data as the data to be sent, and send the data to be sent to the collector.
[0107] S330: Control the collector to display the received data visually. The CNC machine tool simulation control method in this embodiment can realize flexible control of the CNC machine tool simulation process, thereby realizing efficient CNC machine tool simulation.
[0108] The numerical control machine tool simulation method and the numerical control machine tool simulation control method in the above embodiment are further explained below with a specific embodiment.
[0109] Assuming that CNC machine tool simulation is currently required, basic information configuration is first required, that is, the first basic information configuration for the CNC machine tool simulator, and the first basic information configuration and the second basic information configuration for the collector.
[0110] Figure 4 This is an exemplary schematic diagram of a configuration interface of a CNC machine tool simulator provided by an embodiment of the present invention. Figure 4The step of configuring the first basic information of the CNC machine tool simulator includes: starting the CNC machine tool simulator, and performing the first basic information configuration in the dialog box (Dialog) of the configuration interface popped up by the CNC startup simulator, that is, configuring the IP address and port of the CNC machine tool simulator. Figure 4 The exemplary IP address is 127.0.0.1, and the exemplary port is 5555. The dialog box is also configured with a clear button and a start button. The clear button is used to clear the information configured in the current dialog box, and the start button is used to start the CNC machine simulator based on the currently configured information.
[0111] Figure 5 This is an exemplary schematic diagram of a configuration interface of a collector provided by an embodiment of the present invention. Figure 5 , Figure 5 In the configuration interface of the collector, configure the first basic information, namely the IP address and port of the CNC machine simulator. By configuring the first basic information in the collector, it is convenient to establish a communication connection between the collector and the CNC machine simulator in the future. Therefore, Figure 5 The IP address, port and Figure 4 The configuration contents are the same as in , that is, the IP address is 127.0.0.1 and the port is 5555.
[0112] Figure 6 This is an exemplary schematic diagram of another configuration interface of a collector provided by an embodiment of the present invention. Figure 6 In the configuration interface shown, developers can configure the second basic information, which includes: scanning frequency (ms, milliseconds), reporting mode and collection point address ( Figure 6 The scanning frequency can be configured according to the actual needs of the developer, such as 5000ms. The reporting modes include scanning reporting and change reporting, which can be selected by the developer according to actual needs. The point address includes: system status, current fast rate, current manual rate, current feed rate, current handwheel or single-step rate, machine tool coordinates, relative coordinates, absolute coordinates, acquisition of all coordinates, processing time, startup time, target number of processed pieces, target number of processed pieces, processing count information, total number of processed pieces, and program number, etc. Figure 6 The system status bit address is selected as an example.
[0113] Secondly, after completing the basic information configuration, establish a communication connection between the CNC machine simulator and the collector. Specifically, 1. Determine the communication interface, that is, determine the communication interface used between the collector and the CNC machine simulator, such as a serial port, Ethernet interface or USB interface. 2. Establish a physical connection, that is, establish a physical connection between the CNC machine simulator and the collector through the selected communication interface, such as through a serial line connection or through a network connection. 3. Open the communication port, that is, open the communication port in the CNC machine simulator, and wait for the connection request sent by the collector. The connection request can be the first connection request or the second connection request. 4. Initiate a connection request, that is, the collector initiates a connection request to the simulator, and the connection request is an instruction or a handshake signal to establish a communication connection. 5. Establish a connection, that is, after receiving the connection request sent by the collector, the CNC machine simulator completes the establishment of a communication connection with the collector. 6. Data exchange, that is, the collector sends a collection request or instruction to the CNC machine simulator, and the CNC machine simulator processes the collection request or instruction and provides corresponding feedback. 7. Close the connection, that is, when the communication is completed or no longer needed, the collector and the CNC machine tool simulator can terminate the communication and release related resources by sending a command to close the connection. 8. Error handling. It is understandable that during the communication process, errors such as connection timeout and communication interruption may occur. Therefore, after closing the connection, the collector and the CNC machine tool simulator can perform corresponding error handling to achieve closed-loop control of the entire simulation process and ensure the stability and reliability of the communication. It should also be mentioned that an automatic reconnection logic is designed in this embodiment, that is, on the basis of the dual connection method provided in the above embodiment, when one connection method is abnormal, it automatically switches to another connection method to achieve automatic reconnection and ensure the stability and reliability of the communication process.
[0114] Then, data collection is performed. Specifically, the collector sends a collection request to the CNC machine tool simulator. The CNC machine tool simulator analyzes and processes the collection request, including data decoding, format conversion, and data storage. After that, the data to be sent is fed back to the collector.
[0115] Afterwards, the collector parses and displays the received data. The parsing process usually includes data decoding, format conversion, and data storage. If data operations are involved, the parsed data can be operated accordingly and then visualized. By visually displaying the received data, developers can easily identify the data collected by the collector. Figure 7 For an exemplary schematic diagram of a collector display interface provided by an embodiment of the present invention, please refer to Figure 7The display interface has a point list and function buttons such as add, import, export, refresh, disable and delete. In this display interface, data such as point identification, point name, value (i.e. data of the point), data quality, data time and point type are displayed. Among them, the point names include: system status, total number of processed parts and machine tool coordinates. The value of each point is as follows Figure 7 The data quality can be GOOD, etc. The point type can be time series, etc.
[0116] Finally, data is stored and recorded. Specifically, the collector and CNC machine simulator record the timestamp and operating status of the data transmission to facilitate subsequent data analysis and fault diagnosis.
[0117] Through the above process, the data interaction between the collector and the simulator can be better realized, and the simulation of CNC machine tools can be better realized, providing reliable data support for the monitoring, debugging and optimization of CNC machine tools with low cost and high flexibility.
[0118] The numerical control machine tool simulation control system provided by the present invention is described below. The numerical control machine tool simulation control system described below and the numerical control machine tool simulation control method described above can be referred to each other.
[0119] Please refer to Figure 8 The numerical control machine tool simulation control system provided in this embodiment based on the numerical control machine tool simulator as described above includes:
[0120] The first control module 810 is used to establish a communication connection between the CNC machine tool simulator and the collector when it is determined that the basic information configuration is completed, wherein the basic information configuration includes: a first basic information configuration for the CNC machine tool simulator, and a first basic information configuration and a second basic information configuration for the collector, wherein the first basic information includes: an IP address and a port of the CNC machine tool simulator, and the second basic information includes: a scanning frequency and a collection point address;
[0121] The second control module 820 is used to control the collector to send the acquisition request to the CNC machine tool simulator based on the scanning frequency when the connection is successful, wherein the acquisition request includes the acquisition point address; the acquisition request is used to instruct the CNC machine tool simulator to determine the data located at the acquisition point address in the CNC machine tool simulation data as the data to be sent, and send the data to be sent to the collector;
[0122] The third control module 830 is used to control the collector to display the received data visually. The first control module 810, the second control module 820 and the third control module 830 are connected.
[0123] In some embodiments, an electronic device is also provided, which may be a server, and its internal structure is shown in FIG. Fig. 9 As shown. The electronic device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, the functions or steps on the server side of the above method are implemented.
[0124] In some embodiments, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: receiving an acquisition request sent by a collector; based on the acquisition request, obtaining data to be sent from numerical control machine tool simulation data, the numerical control machine tool simulation data being data generated by simulating a machining process of the numerical control machine tool; based on a preset target communication protocol, sending the data to be sent to the collector, the message structure of the target communication protocol including a message body, the message body including at least two message content parts, all message content parts constituting the data to be sent, an encryption number being provided between adjacent message content parts, the encryption number being determined based on a timestamp and a target length, the target length referring to the sum of the lengths of two currently adjacent message content parts. Alternatively, the following steps are implemented: when it is determined that the basic information configuration is completed, a communication connection is established between the CNC machine tool simulator and the collector, the basic information configuration includes: a first basic information configuration for the CNC machine tool simulator, and a first basic information configuration and a second basic information configuration for the collector, the first basic information includes: the IP address and port of the CNC machine tool simulator, the second basic information includes: the scanning frequency and the collection point address; when the connection is successful, based on the scanning frequency, the collector is controlled to send a collection request to the CNC machine tool simulator, the collection request includes the collection point address; the collection request is used to instruct the CNC machine tool simulator to determine the data located at the collection point address in the CNC machine tool simulation data as the data to be sent, and send the data to be sent to the collector; the collector is controlled to visualize the received data.
[0125] In some embodiments, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: receiving an acquisition request sent by a collector; based on the acquisition request, obtaining data to be sent from CNC machine tool simulation data, the CNC machine tool simulation data being data generated by simulating the processing process of the CNC machine tool; based on a preset target communication protocol, sending the data to be sent to the collector, the message structure of the target communication protocol includes a message body, the message body includes at least two message content parts, all the message content parts constitute the data to be sent, an encryption number is provided between adjacent message content parts, the encryption number is determined based on a timestamp and a target length, and the target length refers to the sum of the lengths of two currently adjacent message content parts. Alternatively, the following steps are implemented: when it is determined that the basic information configuration is completed, a communication connection is established between the CNC machine tool simulator and the collector, the basic information configuration includes: a first basic information configuration for the CNC machine tool simulator, and a first basic information configuration and a second basic information configuration for the collector, the first basic information includes: the IP address and port of the CNC machine tool simulator, the second basic information includes: the scanning frequency and the collection point address; when the connection is successful, based on the scanning frequency, the collector is controlled to send a collection request to the CNC machine tool simulator, the collection request includes the collection point address; the collection request is used to instruct the CNC machine tool simulator to determine the data located at the collection point address in the CNC machine tool simulation data as the data to be sent, and send the data to be sent to the collector; the collector is controlled to visualize the received data.
[0126] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or electronic device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0127] The flow chart and block diagram in the accompanying drawings illustrate the possible implementation architecture, function and operation of the method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0128] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A numerical control machine tool simulator, characterized in that: include: A request receiving module, used for receiving a collection request sent by a collector; A processing module, configured to obtain the data to be sent from the numerical control machine tool simulation data based on the acquisition request, wherein the numerical control machine tool simulation data is data generated by simulating a machining process of the numerical control machine tool; A data sending module is used to send the data to be sent to the collector based on a preset target communication protocol. The message structure of the target communication protocol includes a message body, and the message body includes at least two message content parts. All of the message content parts constitute the data to be sent. An encryption number is set between adjacent message content parts. The encryption number is determined based on a timestamp and a target length. The target length refers to the sum of the lengths of two currently adjacent message content parts.
2. The CNC machine tool simulator according to claim 1, characterized in that: The message body also includes: a request count, which is the cumulative number of acquisition requests received after the CNC machine tool simulator is started; The encryption number is determined based on the request count, a timestamp, and the target length.
3. The CNC machine tool simulator according to claim 1, characterized in that: The message structure also includes a message header and a message tail; The message header includes: a fixed start character and a message length, wherein the message length refers to the total length of the current message; The message tail is a first fixed end character or a second fixed end character, the first fixed end character indicates that there are continuous messages after the current message, and the second fixed end character indicates that the current message is the last message of this data transmission; The request receiving module is specifically used to perform message parsing on the collection request based on the target communication protocol when the collection request is received; in the process of parsing the message of the collection request, if the first fixed terminator is detected, wait for collecting the remaining first continuous messages until the second fixed terminator is detected; if the second fixed terminator is detected, uniformly process and feedback all the first continuous messages currently accumulated, and the first continuous message refers to the message data of the collection request.
4. The CNC machine tool simulator according to claim 3, characterized in that: The data sending module is specifically used to wait for collecting the remaining second continuous messages until the second fixed end character is detected if the first fixed end character is detected during the data sending process; if the second fixed end character is detected, all the second continuous messages currently accumulated and collected are sent to the collector, and the second continuous message is the message data to be sent to the collector.
5. The CNC machine tool simulator according to claim 4, characterized in that: The data sending module is also specifically used to transcode the message body of any second continuous message based on a preset transcoding format to obtain first intermediate data; based on a preset target base, convert the first intermediate data to obtain second intermediate data; use a preset encryption tool to encrypt the second intermediate data to obtain third intermediate data; determine the third intermediate data as the new message body of the current second continuous message to complete message body encryption; and when it is determined that all the second continuous messages currently accumulated have completed message body encryption, send the second continuous messages uniformly.
6. The CNC machine tool simulator according to claim 1, characterized in that: The acquisition request includes an acquisition point address and a reporting mode, wherein the acquisition point address and the reporting mode are information pre-configured in the collector, and the acquisition request is used to instruct the processing module to scan the CNC machine tool simulation data to obtain target data located at the acquisition point address; The reporting mode includes: scanning reporting and change reporting. When the reporting mode is scanning reporting, the processing module determines the target data obtained by scanning as the data to be sent; when the reporting mode is change reporting, the processing module compares the currently obtained target data with the target data obtained by the last scan. If there is a difference between the currently obtained target data and the target data obtained by the last scan, the currently obtained target data is determined as the data to be sent.
7. The numerical control machine tool simulator according to claim 1, characterized in that: Also includes: A communication module, configured to receive a first connection request sent by the collector, and to establish a single connection with the collector based on the first connection request, wherein the first connection request is a single connection request, and the single connection means disconnecting after performing a single data transmission; The communication module is also used to receive a second connection request sent by the collector, and establish a long connection with the collector based on the second connection request. The second connection request is issued by the collector when it is determined that an abnormality has occurred in a single connection. The collection request is issued after the collector determines that a single connection or a long connection with the CNC machine tool simulator has been established.
8. A method for simulating a numerically controlled machine tool, characterized in that: include: Receive a collection request sent by a collector; Based on the acquisition request, the data to be sent is obtained from the numerical control machine tool simulation data, wherein the numerical control machine tool simulation data is data generated by simulating a machining process of the numerical control machine tool; Based on a preset target communication protocol, the data to be sent is sent to the collector. The message structure of the target communication protocol includes a message body. The message body includes at least two message content parts. All the message content parts constitute the data to be sent. An encryption number is set between adjacent message content parts. The encryption number is determined based on a timestamp and a target length. The target length refers to the sum of the lengths of two currently adjacent message content parts.
9. A numerical control machine tool simulation control method based on the numerical control machine tool simulator according to claims 1 to 7, characterized in that: include: When it is determined that the basic information configuration is completed, a communication connection is established between the CNC machine tool simulator and the collector, wherein the basic information configuration includes: a first basic information configuration for the CNC machine tool simulator, and a first basic information configuration and a second basic information configuration for the collector, wherein the first basic information includes: an IP address and a port of the CNC machine tool simulator, and the second basic information includes: a scanning frequency and a collection point address; In the case of successful connection, based on the scanning frequency, the collector is controlled to send the acquisition request to the CNC machine tool simulator, the acquisition request including the acquisition point address; the acquisition request is used to instruct the CNC machine tool simulator to determine the data located at the acquisition point address in the CNC machine tool simulation data as the data to be sent, and send the data to be sent to the collector; Control the collector to visualize the received data.
10. A numerically controlled machine tool simulation control system based on the numerically controlled machine tool simulator according to claims 1 to 7, characterized in that: include: A first control module is used to establish a communication connection between the CNC machine tool simulator and the collector when it is determined that the basic information configuration is completed, wherein the basic information configuration includes: a first basic information configuration for the CNC machine tool simulator, and a first basic information configuration and a second basic information configuration for the collector, wherein the first basic information includes: an IP address and a port of the CNC machine tool simulator, and the second basic information includes: a scanning frequency and a collection point address; A second control module is used to control the collector to send the acquisition request to the CNC machine tool simulator based on the scanning frequency when the connection is successful, wherein the acquisition request includes the acquisition point address; the acquisition request is used to instruct the CNC machine tool simulator to determine the data located at the acquisition point address in the CNC machine tool simulation data as the data to be sent, and send the data to be sent to the collector; The third control module is used to control the collector to visualize the received data.
