A channel extensible process message processing method

By defining bus data receiving functions and adding multiple bus channels in the industrial simulation equipment, the problem of only one message exchange between industrial equipment and the main control platform was solved, enabling simultaneous processing of multiple messages, improving efficiency and saving hardware resources.

CN116909767BActive Publication Date: 2026-06-09TIANJIN JINHANG COMP TECH RES INST
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TIANJIN JINHANG COMP TECH RES INST
Filing Date
2023-07-13
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

The existing industrial equipment and the main control platform can only exchange one message at a time, and cannot process multiple messages at the same time, resulting in low efficiency during the start-up preparation process of industrial equipment.

Method used

Define a bus data receiving function in the industrial simulation equipment, add multiple bus channels with the same number of channels as the main control platform, create a bus data receiving thread for each channel, use a periodic timer to process message information at preset intervals, and locate data fields by index value.

Benefits of technology

It enables the simultaneous processing of multiple request messages, improving information exchange efficiency and saving hardware resources of the simulation equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116909767B_ABST
    Figure CN116909767B_ABST
Patent Text Reader

Abstract

This application provides a channel-scalable process message processing method, comprising the following steps: defining a bus data receiving function, obtaining a first request message based on the received and processed information, the first request message including multiple first message information; adding multiple second channels in an industrial simulation device, the number of second channels being the same as the number of first channels, creating a bus data receiving thread for each second channel, the bus data receiving thread being used to receive the first message information, the type of the second channel being a bus channel; a periodic timer is provided in the industrial simulation device, and at each first preset time interval, corresponding processing is performed according to the index value of the first message information, the index value referring to the position or identifier of each data field in the first message information; multiple messages can be interacted simultaneously, thereby saving hardware resources of the simulation device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer control technology, and specifically to a process message processing method with scalable channels. Background Technology

[0002] Some industrial equipment needs to interact with the main control platform extensively during operation. The data interaction method is response-response. Each interaction requires the main control platform to send a message, which is called a request message. The industrial equipment processes the received message accordingly and replies to the main control platform according to the specified protocol. This message is called a response message. However, the existing industrial equipment and the main control platform can only exchange one piece of information. This process is usually a single business process. But during the startup preparation process of industrial equipment, several business processes need to be processed, which means that multiple pieces of information need to be processed simultaneously.

[0003] During the adaptation process between industrial equipment and the main control platform, considering cost and security, industrial simulation equipment is usually used to replace the actual equipment for verification. Industrial simulation equipment has the same bus interface as industrial equipment, and one industrial simulation equipment can replace one industrial equipment for functional verification. Summary of the Invention

[0004] The purpose of this application is to address the above-mentioned problems by providing a channel-scalable process message processing method applied to a terminal system. The terminal system includes: a main control platform for sending request messages and an industrial simulation device for receiving the request messages. The main control platform has multiple first channels, and the type of the first channels is a bus channel. The channel-scalable process message processing method includes the following steps:

[0005] Define a bus data receiving function, receive the request message according to the bus data receiving function and process it to obtain a first request message, the first request message including multiple first message information;

[0006] Multiple second channels are added to the industrial simulation device, the number of which is the same as the number of the first channels. A bus data receiving thread is created for each second channel. The bus data receiving thread is used to receive the first message information. The type of the second channel is a bus channel.

[0007] The industrial simulation device is equipped with a periodic timer. Every first preset time interval, it performs corresponding processing based on the index value of the first message information. The index value refers to the position or identifier of each data field in the first message information.

[0008] According to the technical solution provided in the embodiments of this application, the step of receiving and processing the request message according to the bus data receiving function includes the following steps:

[0009] Define a data structure ThrdMsg for the transmission of the first message information. The data structure ThrdMsg includes the source of the current first message information in the industrial simulation device, the data pointer MsgPtr of the current first message information, and the length MsgLen of the current first message information.

[0010] Define a message queue, which is used to receive, store and transmit the first request message;

[0011] Define variables for the data structure ThrdMsg, and write the channel number of the first message information into the current source of the first message information;

[0012] The main loop is defined as an infinite loop, which receives the first message information in a blocking manner to obtain the first request message.

[0013] According to the technical solution provided in the embodiments of this application, after the step of defining the type of the main loop as an infinite loop to receive the first message information in a blocking manner, the method further includes:

[0014] The first memory of the data pointer MsgPtr of the current first message information is requested according to the first predetermined rule. The first memory is used to store the first message information. The first predetermined rule is the request length of the first memory and the starting address of the first memory, wherein the request length is length and the starting address is pBuff.

[0015] According to the technical solution provided in the embodiments of this application, a two-dimensional array is applied based on the number of the second channels and the maximum number of bytes in the first request message. The row information of the two-dimensional array is the number of the second channels, and the column information is the maximum number of bytes in the first request message.

[0016] According to the technical solution provided in the embodiments of this application, the element type of the two-dimensional array is byte type.

[0017] According to the technical solution provided in the embodiments of this application, the step of defining a message queue, wherein the message queue is used to receive, store, and transmit the first request message, specifically includes:

[0018] The second memory is requested according to the second predetermined rule. The second memory is used to store the first request message. The second predetermined rule is that the length of the second memory is SIZE, the starting address is pRecv, and the second memory includes a number of memory units. Each memory unit is a data structure ThrdMsg.

[0019] Receive the first request message and return confirmation information to the main control platform;

[0020] Calculate the number of the first bytes of all the first message information and the number of the second bytes of the data structure ThrdMsg;

[0021] Based on the first byte count and the second byte count, several data packets are obtained.

[0022] According to the technical solution provided in the embodiments of this application, after the step of obtaining several data packets based on the first byte number and the second byte number, the method further includes:

[0023] The system processes several data packets in a loop, parses out the index value of each first message information to obtain a first index value, and copies the data in the index value into the two-dimensional array according to the second channel number. The first index value includes the content of each first message information in the second channel and the function corresponding to the content. The second channel number is the label on each second channel.

[0024] Compared with the prior art, the beneficial effects of this application are as follows: This application first defines a bus data receiving function in the industrial simulation device. Based on the request message received by the bus data receiving function from the main control platform, it processes the message to obtain a first request message, which includes multiple first message information. Multiple second channels are added to the industrial simulation device, with the number of second channels matching the number of first channels, and both the first and second channels being bus channels. A bus data receiving thread is created for each second channel to receive the first message information. A periodic timer is provided in the industrial simulation device. At each first preset time interval, the first request message is processed according to the index value of the first message information, where the index value refers to the position or identifier of each data field in the first message information. During use… First, based on the number of the first channels, a second channel with the same number as the first channels is added to the industrial simulation equipment. Then, a bus data receiving thread is created for each second channel to receive the first message information. Then, at a first preset time interval, the first message information is processed accordingly based on its index value. This application first defines a bus data receiving function for receiving request messages sent by the main control platform. After processing the request message, the first request message is obtained. By adding a second channel in the industrial equipment that is the same as the first channel of the main control platform, each channel can receive the first message information. Then, the first message information is processed accordingly according to the first preset time interval. This allows for the simultaneous processing of multiple request messages, that is, the simultaneous interaction of multiple messages, thereby saving hardware resources of the simulation equipment. Attached Figure Description

[0025] Figure 1 A flowchart illustrating an scalable process message processing method provided in an embodiment of this application. Detailed Implementation

[0026] To enable those skilled in the art to better understand the technical solution of this application, the application will be described in detail below with reference to the accompanying drawings. The description in this section is only exemplary and explanatory, and should not be used to limit the scope of protection of this application.

[0027] This application provides a channel-scalable process message processing method, such as... Figure 1 As shown, the method is applied to a terminal system, which includes a main control platform for sending request messages and an industrial simulation device capable of receiving the request messages. The industrial simulation device is provided with multiple first channels, and the type of the first channels is a bus channel.

[0028] S1. Define a bus data receiving function, receive the request message according to the bus data receiving function and process it to obtain a first request message, the first request message including multiple first message information;

[0029] S2. Add multiple second channels to the industrial simulation device. The number of second channels is the same as the number of first channels. Create a bus data receiving thread for each second channel. The bus data receiving thread is used to receive the first message information. The type of the second channel is a bus channel.

[0030] S3. A periodic timer is provided in the industrial simulation device. Every first preset time interval, the first message information is processed according to the index value of the first message information. The index value refers to the position or identifier of each data field in the first message information.

[0031] Specifically, in this embodiment, a bus data receiving function is first defined for the industrial simulation device. This function receives the request message sent by the main control platform and processes it accordingly to obtain a first request message, which includes multiple first message information. Multiple second channels are added to the industrial simulation device, with the number of second channels matching the number of first channels. The second channels are of bus type. A bus data receiving thread is created for each second channel, and this thread receives the first message information. A periodic timer is provided in the industrial simulation device. Every first preset time interval, the periodic timer processes the first message information according to its index value. The index value indicates the position or identifier of each data field in each first message information. Using the index value, each first message information can be quickly located, thereby improving the retrieval efficiency. In this embodiment, the index value is of type INT.

[0032] Furthermore, the step of receiving and processing the request message according to the bus data receiving function includes the following steps:

[0033] Define a data structure ThrdMsg for the transmission of the first message information. The data structure ThrdMsg includes the source of the current first message information in the industrial simulation device, the data pointer MsgPtr of the current first message information, and the length MsgLen of the current first message information.

[0034] Define a message queue, which is used to receive, store and transmit the first request message;

[0035] Define variables for the data structure ThrdMsg, and write the channel number of the first message information into the current source of the first message information;

[0036] The main loop is defined as an infinite loop, which receives the first message information in a blocking manner to obtain the first request message.

[0037] Specifically, in this embodiment, receiving and processing the request message according to the bus data receiving function includes the following steps:

[0038] First, a data structure ThrdMsg needs to be defined for the first message information. ThrdMsg includes the first channel number of the first message information from the central control platform, i.e., the specific first channel number of the first message information received by the industrial simulation device from the central control platform. It also includes a data pointer MsgPtr for the current first message information and the length MsgLen for the current first message information. The data pointer MsgPtr points to the data in the first message, allowing the program to access and process the data. In network communication, a message is the basic unit of network transmission. When a program needs to send or receive data, it needs to encapsulate the data into a message for transmission. At the receiving end, the program needs to parse the message to obtain the data. MsgPtr points to the data in the first message, allowing the program to directly access the data in the message for parsing and processing. Therefore, in this embodiment, the program can directly access the data in the first message information for parsing and processing.

[0039] Then, a message queue is defined, which is used to receive, store, and transmit the first request message. The message queue is a mechanism used to transmit messages between different applications.

[0040] Then, it is necessary to define variables of the data structure ThrdMsg and write the channel number of the first message information into the source of the current first message information, so as to inform the bus data receiving function which first channel in the central control platform the first message information it received came from. Then, the variables of the data structure ThrdMsg are directly passed to the bus data receiving function as parameters. Inside the bus data receiving function, the specific data can be obtained by accessing the variables of the data structure ThrdMsg.

[0041] Then, the main loop is defined as an infinite loop, and the first message information is received in a blocking manner. When the main loop is executed, the program will wait to receive the first message information until it is received. During this period, the program will be blocked at this point and will not execute other code.

[0042] First, define the data structure ThrdMsg for the first message message. Then, define the message queue, followed by the variables of the ThrdMsg data structure. Finally, define the type of the main loop as an infinite loop. This ensures that when the message queue and the variables of the ThrdMsg data structure are used in the infinite loop, they have been correctly defined and initialized.

[0043] When receiving the first message information in a blocking manner, different methods are adopted for different buses according to their characteristics. For the CAN bus, a temporary buffer BuffTemp is first defined, and then a bus driver acquisition function flexcanGetCnt is defined. The bus driver acquisition function is used to obtain the pointer of the bus driver structure of a specific bus. Then, the number of buffered first message information num in a certain second channel is obtained using the bus driver acquisition function flexcanGetCnt. After the CAN bus receives the first message information, it will automatically number the first message information to distinguish different messages. Then, it will loop num times and store the CAN data in the temporary buffer BuffTemp. The CAN data includes the ID number of each first message information and the length of each first message information. The total length of all first messages is calculated. Then, the CAN data in the temporary buffer BuffTemp is copied to the starting address pBuff. Then, the value of the starting address pBuff is assigned to the data pointer MsgPtr of the current first message information, and the total length legth is assigned to the length MsgLen of the current first message information.

[0044] For serial bus systems, the first step is to assemble the buffered data in the underlying serial driver into packets. This is because the first message received by a serial bus is not a complete packet; only a portion is received at a time. Therefore, it is necessary to wait until all the first messages have been sent and formed into a complete packet before the first message can be parsed. The parsed packet is then extracted and stored in a temporary buffer BuffTemp. The total length of all the first messages in the packet is calculated. The first messages in the temporary buffer BuffTemp are then copied to the starting address pBuff. The value of the starting address pBuff is then assigned to the data pointer MsgPtr of the current first message, and the total length legth is assigned to the length MsgLen of the current first message.

[0045] For Ethernet UDP packet transmission, the received first message information is directly extracted and stored in the temporary buffer BuffTemp. The total length of all first message information is calculated. Then, the first message information in the temporary buffer BuffTemp is copied to the starting address pBuff. The value of the starting address pBuff is assigned to the data pointer MsgPtr of the current first message information, and the total length legth is assigned to the length MsgLen of the current first message information.

[0046] Furthermore, after the step of defining the main loop type as an infinite loop to receive the first message information in a blocking manner, the method further includes:

[0047] The first memory of the data pointer MsgPtr of the current first message information is requested according to the first predetermined rule. The first memory is used to store the first message information. The first predetermined rule is the request length of the first memory and the starting address of the first memory, wherein the request length is length and the starting address is pBuff.

[0048] Specifically, in this embodiment, after defining the main loop as an infinite loop and receiving the first message information in a blocking manner, the method further includes:

[0049] The program needs to request the first memory location of the data pointer MsgPtr of the first message information according to the first predetermined rule. The first memory location is used to store the data of the first message information so that the program can access and process the data of the first message information. MsgPtr is a pointer variable that points to the memory address of the data of the first message information. By accessing this address, the program can read and modify the data of the first message information. The first predetermined rule means that when requesting the second memory location, the request length and the starting address of the second memory location need to be specified, where the request length is length and the starting address is pBuff.

[0050] Furthermore, based on the number of the second channels and the maximum number of bytes in the first request message, a two-dimensional array is requested. The row information of the two-dimensional array is the number of the second channels, and the column information is the maximum number of bytes in the first request message. The element type of the two-dimensional array is byte.

[0051] Specifically, in this embodiment, a two-dimensional array is applied for based on the number of the second channels and the maximum number of bytes in the first request message. The two-dimensional array includes row information and column information. The row information of the two-dimensional array is the number of the second channels, and the column information of the two-dimensional array is the maximum number of bytes in the first request message. In this embodiment, the maximum number of bytes is 256, and the element type of the two-dimensional array is byte.

[0052] Furthermore, the step of defining a message queue, wherein the message queue is used to receive, store, and transmit the first request message, specifically includes:

[0053] The second memory is requested according to the second predetermined rule. The second memory is used to store the first request message. The second predetermined rule is that the length of the second memory is SIZE, the starting address is pRecv, and the second memory includes a number of memory units. Each memory unit is a data structure ThrdMsg.

[0054] Receive the first request message and return confirmation information to the main control platform;

[0055] Calculate the number of the first bytes of all the first message information and the number of the second bytes of the data structure ThrdMsg;

[0056] Based on the first byte count and the second byte count, several data packets are obtained.

[0057] Specifically, in this embodiment, the step of defining the message queue includes the following steps: applying for second memory according to a second predetermined rule, the second memory being used to store the received first request message. The second predetermined rule is: the length of the second memory is SIZE, and the starting address is pRecv. In this embodiment, the length of the second memory is 128 bytes. The second memory includes several memory units, each of which is a data structure ThrdMsg. Each memory unit is used to store a piece of the first message information in the first request message. After the message queue receives the first request message, it means that the request has been successfully sent to the message queue and is waiting to be processed. Then, an acknowledgment message is returned to the main control platform, informing the main control platform that the request has been successfully received and has started processing the request. Then, the number of first bytes (numbytes) of all the first message information and the number of second bytes of the data structure ThrdMsg are calculated. Then, the number of packets (num_packet) of the received data packets can be obtained by dividing the number of first bytes by the number of second bytes.

[0058] Furthermore, after the step of obtaining several data packets based on the first byte count and the second byte count, the method further includes:

[0059] The system iterates through several data packets, parses out the index value of each first message information to obtain a first index value, and copies the data in the index value into the two-dimensional array according to the second channel number. The first index value includes the content of each first message information in the second channel and the function corresponding to the content. The second channel number is the label on each second channel.

[0060] Specifically, in this embodiment, after obtaining the number of received data packets num_packet, these data packets need to be processed in a loop. When processing these data packets in a loop, data needs to be read starting from the first address pRecv. The length of each data packet is the length of the data structure ThrdMsg. Then, the index value of each first message information is parsed out, and the second channel number is extracted according to the first message information's first address pBuff and the first message information's data pointer MsgPtr. After parsing, the first index value is obtained. Then, according to the second channel number and the first index value, the data of the first message information is copied into the two-dimensional array. The second channel number is the label on each second channel.

[0061] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. The above descriptions are only preferred embodiments of this application. It should be noted that due to the limitations of written expression, while there are objectively infinite specific structures, those skilled in the art can make several improvements, modifications, or changes without departing from the principles of this invention, and can also combine the above technical features in an appropriate manner. These improvements, modifications, changes, or combinations, or the direct application of the inventive concept and technical solution to other situations without modification, should all be considered within the scope of protection of this application.

Claims

1. A channel scalable process message handling method applied to a terminal system, the terminal system comprising a master platform for sending a request message, and an industrial simulation device for receiving the request message, wherein, The main control platform has multiple first channels, wherein the type of the first channel is a bus channel, and is characterized by including the following steps: Define a bus data receiving function, receive the request message according to the bus data receiving function and process it to obtain a first request message, the first request message including multiple first message information; Multiple second channels are added to the industrial simulation device, the number of which is the same as the number of the first channels. A bus data receiving thread is created for each second channel. The bus data receiving thread is used to receive the first message information. The type of the second channel is a bus channel. The industrial simulation device is equipped with a periodic timer. At each preset interval, it performs corresponding processing based on the index value of the first message information. The index value refers to the position or identifier of each data field in the first message information. The step of receiving and processing the request message according to the bus data receiving function includes the following steps: Define a data structure ThrdMsg for the transmission of the first message information. The data structure ThrdMsg includes the source of the current first message information in the industrial simulation device, the data pointer MsgPtr of the current first message information, and the length MsgLen of the current first message information. Define a message queue, which is used to receive, store and transmit the first request message; Define variables for the data structure ThrdMsg, and write the channel number of the first message information into the current source of the first message information; The main loop is defined as an infinite loop, which receives the first message information in a blocking manner to obtain the first request message.

2. The channel extensible process message handling method according to claim 1, wherein, Following the step of defining the main loop type as an infinite loop to receive the first message information in a blocking manner, the method further includes: The first memory of the data pointer MsgPtr of the current first message information is requested according to the first predetermined rule. The first memory is used to store the first message information. The first predetermined rule is the request length of the first memory and the starting address of the first memory, wherein the request length is length and the starting address is pBuff.

3. The channel extensible process message handling method according to claim 2, wherein, Based on the number of the second channels and the maximum number of bytes in the first request message, a two-dimensional array is requested, wherein the row information of the two-dimensional array is the number of the second channels, and the column information is the maximum number of bytes in the first request message.

4. The channel extensible process message handling method according to claim 3, wherein, The elements of the two-dimensional array are of byte type.

5. The channel extensible process message handling method according to claim 4, wherein, The step of defining a message queue, wherein the message queue is used to receive, store, and transmit the first request message, specifically includes: The second memory is requested according to the second predetermined rule. The second memory is used to store the first request message. The second predetermined rule is that the length of the second memory is SIZE, the starting address is pRecv, and the second memory includes a number of memory units. Each memory unit is a data structure ThrdMsg. Receive the first request message and return confirmation information to the main control platform; Calculate the number of the first bytes of all the first message information and the number of the second bytes of the data structure ThrdMsg; Based on the first byte count and the second byte count, several data packets are obtained.

6. The channel extensible process message handling method according to claim 5, wherein, The step of obtaining several data packets based on the first byte count and the second byte count further includes: The system processes several data packets in a loop, parses out the index value of each first message information to obtain a first index value, and copies the data in the index value into the two-dimensional array according to the second channel number. The first index value includes the content of each first message information in the second channel and the function corresponding to the content. The second channel number is the label on each second channel.