Simulation data recording and playback method and device, computer equipment and storage medium
By using middleware to build message headers and thread pools in parallel processing in simulation data playback, the problem of high complexity and low efficiency of simulation data playback in the prior art is solved, and efficient simulation data processing and playback are achieved.
Patent Information
- Application Number
- CN202411280165.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-10
AI Technical Summary
There are problems of high complexity, low efficiency and poor reusability in the playback of existing simulation data, which is mainly due to the need for manual encoding, analysis and conversion.
The data of multiple simulation units are obtained through middleware, the message header is constructed based on the preset format, and the data is stored as a preset format file. The message data is processed in parallel by using a thread pool to achieve efficient playback of the simulation data.
It improves the efficiency of simulated data playback, simplifies the data processing process, reduces the complexity of manual intervention, and improves the reusability of data processing.
Smart Images

Figure CN119105888A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of simulation data technology, and in particular to a simulation data recording and playback method, device, computer equipment and storage medium. Background Art
[0002] As a tool to simulate the real environment or system behavior, simulation technology has been widely used in all walks of life. In the simulation process, due to the complexity of the system and the requirements of simulation accuracy, a large amount of simulation data is often generated. In order to facilitate the subsequent review analysis and training review, the simulation process data can be recorded, and then the simulation run is sent to send the simulation data, thereby realizing the separation of business such as review analysis and training review from the simulation process. With the continuous advancement of technology, the recording and playback of simulation data has become a key link in the simulation process.
[0003] The general data recording technology adopts file storage technology, and realizes the long-term preservation and backup of simulation data through the file system. Data recording forms a collection file with simulation data in a certain format. When playing back the data, the message data in the collection file needs to be processed to be converted into simulation data.
[0004] However, when converting message data from files into simulation data for playback, the processing flow includes custom message header parsing, object instance handle replacement, and simulation time data replacement. Only after the processing is completed can the data be sent to the simulation run. At this time, manual encoding parsing and conversion are required according to the pre-defined data message format requirements, which has the disadvantages of high complexity, low efficiency, and poor reusability. Summary of the invention
[0005] Based on this, it is necessary to provide a simulation data recording and playback method, device, computer equipment and storage medium that can improve efficiency in order to solve the above technical problems.
[0006] A simulation data recording and playback method, the method comprising:
[0007] Acquire multiple simulation data of multiple simulation units through middleware;
[0008] Constructing a corresponding message header according to each simulation data based on a specified format, adding a corresponding message header to each simulation data to obtain corresponding message data, and storing all message data in a preset format file in the order of receiving from the middleware to complete the recording of the simulation data, wherein the message header includes a message type and a message class;
[0009] Obtain playback designation, read each message data in the file in sequence according to the playback designation, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing;
[0010] The multiple threads in the thread pool perform business processing on the multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware.
[0011] In one embodiment, the message header constructed based on the prescribed format includes 4 parts, wherein:
[0012] The first part indicates the message type of the simulation data, including object class, interaction class and object instance class;
[0013] The second part indicates the message class, and the message type further indicates the object class subclass and the interaction class subclass for the object class or interaction class;
[0014] The third part represents the message object. When the message type is an object instance class, the object instance handle needs to be assigned;
[0015] The fourth part indicates the message length, which is the length of the simulation data.
[0016] In one embodiment, after obtaining the playback specification, the thread pool is initialized according to the number of message class subtypes required in the file to determine the number of threads.
[0017] In one embodiment, after obtaining the playback instruction, a thread in the initialized thread pool parses the message header of the message data, assigns it to the corresponding thread for subsequent business processing, and then reads the next message data in sequence.
[0018] In one embodiment, allocating the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing includes:
[0019] Assign message data to designated threads for business processing according to message type and message class, where each object class subclass and interaction class subclass is only processed in one thread;
[0020] Each of the threads may process message data of one subclass or multiple subclasses through pre-configuration.
[0021] In one embodiment, when allocating message data, the message data is allocated to a designated thread according to a preset mapping relationship between message subclasses and threads.
[0022] The present application also provides a simulation data recording and playback device, the device comprising:
[0023] A simulation data acquisition module, used to acquire multiple simulation data of multiple simulation units through middleware;
[0024] A simulation data recording module, used to construct a corresponding message header according to each simulation data based on a specified format, add a corresponding message header to each simulation data to obtain corresponding message data, and store all message data in a preset format file in the order received from the middleware to complete the recording of simulation data, wherein the message header includes a message type and a message class;
[0025] A simulation data playback module is used to obtain playback designation, read each message data in the file in order according to the playback designation, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing;
[0026] The simulation data sending module is used for multiple threads in the thread pool to perform business processing on multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware.
[0027] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0028] Acquire multiple simulation data of multiple simulation units through middleware;
[0029] Constructing a corresponding message header according to each simulation data based on a specified format, adding a corresponding message header to each simulation data to obtain corresponding message data, and storing all message data in a preset format file in the order of receiving from the middleware to complete the recording of the simulation data, wherein the message header includes a message type and a message class;
[0030] Obtain playback designation, read each message data in the file in sequence according to the playback designation, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing;
[0031] The multiple threads in the thread pool perform business processing on the multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware.
[0032] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0033] Acquire multiple simulation data of multiple simulation units through middleware;
[0034] Constructing a corresponding message header according to each simulation data based on a specified format, adding a corresponding message header to each simulation data to obtain corresponding message data, and storing all message data in a preset format file in the order of receiving from the middleware to complete the recording of the simulation data, wherein the message header includes a message type and a message class;
[0035] Obtain playback designation, read each message data in the file in sequence according to the playback designation, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing;
[0036] The multiple threads in the thread pool perform business processing on the multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware.
[0037] The above-mentioned simulation data recording and playback method, device, computer equipment and storage medium, construct a corresponding message header based on a prescribed format according to each of the multiple simulation data of multiple simulation units obtained by the middleware, add the corresponding message header to each simulation data to obtain the corresponding message data, and store all the message data in a preset format file in the order of receiving from the middleware to complete the recording of the simulation data, wherein the message header includes the message type and the message class, and then read each message data in the file in sequence according to the playback specification, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing, and then the multiple threads in the thread pool perform business processing on the multiple message data in parallel to obtain the corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware. The use of this method can effectively improve the efficiency of simulation data playback. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of a flow chart of a simulation data recording and playback method in one embodiment;
[0039] Figure 2 A schematic diagram of the location of data records in a training simulation business application in one embodiment;
[0040] Figure 3 A schematic diagram of a custom message header format in an embodiment;
[0041] Figure 4 A schematic diagram of the location of data playback in a training simulation business application in one embodiment;
[0042] Figure 5 A schematic diagram of a simulated data message format in an embodiment;
[0043] Figure 6 A flow chart of data processing of a simulation service thread pool in one embodiment;
[0044] Figure 7 This is a graph of the experimental results of the linear treatment scheme in an experiment;
[0045] Figure 8 This is a graph showing the experimental results of a dual-thread solution in an experiment;
[0046] Fig. 9 This is a graph of the experimental results of this scheme in an experiment;
[0047] Fig.10 A structural block diagram of a simulation data recording and playback device in one embodiment;
[0048] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0050] In view of the problems in the prior art of high complexity, low efficiency and poor reusability when encoding, parsing and converting the simulation data during playback, in this application, Figure 1 As shown, a simulation data recording and playback method is provided, which specifically includes the following steps:
[0051] Step S100: obtaining multiple simulation data of multiple simulation units through the middleware.
[0052] Step S110, construct a corresponding message header according to each simulation data based on the specified format, add the corresponding message header to each simulation data to obtain the corresponding message data, and store all the message data as a preset format file in the order of receiving from the middleware to complete the recording of the simulation data, wherein the message header includes the message type and message class.
[0053] Step S120, obtaining playback designation, reading each message data in the file in sequence according to the playback designation, parsing the message header of the message data, and allocating the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing.
[0054] Step S130 , multiple threads in the thread pool perform business processing on multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit through the middleware in sequence.
[0055] In this embodiment, based on the optimization of forming message data from data recording simulation business data, the message data is converted to simulation business data for data playback. A method for efficient playback of simulation data based on a combination of a custom message header and a thread pool is proposed. The method first uses the standard format of data in simulation operation to quickly define message data and message types between files and data recording and data playback. Secondly, a thread pool is created to process simulation business in parallel, which can greatly improve the overall performance of converting message data to simulation business data. Among them, the custom message header can quickly obtain the message type and message class through parsing, so as to assign it to the corresponding thread for processing, so that the content of the simulation data can be confirmed quickly and efficiently, which is convenient for rapid data parsing and processing.
[0056] In step S100, the simulation data to be recorded and replayed is the simulation data cached in the middleware system. Data recording and playback participate in simulation operation through the middleware subsystem. Middleware is the basic support part of the simulation operation support system. By providing the message communication service and simulation service required for the integrated joint operation of LVC training resources, it provides support for the development, integration, testing, and operation of related training simulation units, and realizes data transmission and collaborative operation between each other.
[0057] In this embodiment, relevant simulation data may be received from the middleware and recorded according to the content of the configuration file according to a preset configuration file.
[0058] In step S110, when recording the simulation data, the location of the data record in the training simulation business application is as follows: Figure 2 Each simulation unit transmits simulation data through the middleware, and the data recording access middleware only accepts simulation data, further processes the simulation data in the order of reception to facilitate subsequent data playback operations, and finally records the data to a file through file storage technology.
[0059] When recording data, it is possible to distinguish whether the simulation data is object-type data or interactive-type data. If it is not processed and directly stored in a file, it will not only be very difficult to distinguish the data during data playback, but it will also cause trouble to the business logic, which will bring a huge disaster to the overall playback time.
[0060] Among them, data records mainly record object class data and interaction class data during the simulation operation. Objects are abstractions of transactions in the real world or in the imagined scenario, and objects have a continuous existence time during the operation of the simulation system. Objects are composed of and described by attributes, and objects can be inherited. Object class data is the data of object attribute updates. Interaction is an abstraction of messages transmitted between objects in the real world or in the imagined scenario. Interaction is transient, can be inherited, and is composed of and described by parameters. Interaction class data is the data sent interactively. Different simulation systems are interconnected through object attribute updates and interactive sending under the middleware, which helps to release the value of data, improve the efficiency of data utilization, and provide more comprehensive and accurate information support for decision-making.
[0061] In this embodiment, the message header format is customized between data recording and data playback to facilitate distinguishing message types, thereby improving the efficiency of understanding message data during data playback.
[0062] In this embodiment, the message header constructed based on the prescribed format includes 4 parts, and its message format is as follows: Figure 3 As shown, the first part indicates the message type of the simulation data, including object class, interaction class and object instance class. The second part indicates the message class. The message type further indicates the object class subclass and interaction class subclass for the object class or interaction class. The third part indicates the message object. When the message type is the object instance class, the object instance handle needs to be assigned. The fourth part indicates the message length. The message length is the length of the simulation data.
[0063] Specifically, these four parts are represented by 4 bytes respectively.
[0064] The first part "Message Type" is used to distinguish whether it is object class data, interaction class data or object instance data. This step is related to whether the third part "Message Object" has a value. Because the interaction is transient, and the object has a continuous existence time during the operation of the simulation system, the object instance data needs to be assigned in the "Message Object".
[0065] The second part "Message Class" is used to distinguish different object class data or different interaction class data. That is to say, the object class and interaction class also include multiple subclasses. There are multiple object class data and multiple interaction class data in the simulation run. Different object class data have different attributes, and different interaction class parameters are different. It is necessary to distinguish them in order to quickly find the corresponding data.
[0066] The third part "message object" exists because there will be different object instances for a certain object class data, which is used to distinguish different object instances. When replaying message data in the same file, the object class instance handle is dynamically registered in the co-simulation, so it is necessary to re-register the instance to obtain the handle during replay, and form a mapping relationship with the instance handle in the message data. The object instance handle needs to be updated during subsequent replay.
[0067] The fourth part "Message Length" indicates the length of the received simulation data, so that when the data is played back, a complete simulation data can be read from the file. The "Message Length" parameter needs to be entered when sending simulation data interface.
[0068] Next, after generating a corresponding message header according to the content of each piece of simulation data, the message header is added to the corresponding simulation data to obtain the message data, and all the message data are stored in a file format to complete the recording of the simulation data.
[0069] In step S120, the message data in the file is played back according to the playback specification. The general process is as follows: Figure 4 shown.
[0070] During the entire data playback process, in addition to parsing the custom message header, the data also needs to be simulated for business processing. Only in this way can the sent simulation data be received by other simulation units. The business processing that needs to be done includes: For object class data, it is necessary to know from the simulation data how many object instances exist in the object class simulation data. The format of each object class simulation data message is as follows: Figure 5 As shown. The instance handle of each simulation run is the unique identifier of the object in the simulation run. Although the simulation data is the same, the actual instance handle may have changed, so all instance handles need to be replaced according to the actual situation of the running simulation. If the simulation data time data segment has a value, the time segment data needs to be reassigned, and the assigned value is the time when the data is played back in the simulation run. As you can imagine, this entire business processing process will cause a lot of time consumption. Therefore, after adding the message header according to the defined good message header format during the data recording process, it is also necessary to improve the processing efficiency here in the business processing.
[0071] In this embodiment, multiple threads in a thread pool are used to process business data of multiple message data.
[0072] A thread pool is a design pattern that maintains a set of pre-created threads that can be reused to perform tasks. When a new task needs to be executed, the thread pool assigns the task to an idle thread instead of creating a new thread each time. The thread pool reduces the overhead of thread creation and destruction because threads are reused, and the number of concurrent threads can be controlled by limiting the size of the thread pool to avoid exhausting system resources. Furthermore, the thread pool provides better resource management and scheduling mechanisms, which can improve system stability and performance.
[0073] In this embodiment, after the playback designation is obtained, the thread pool is initialized according to the number of message types of all message data in the file and the number of subtypes of each message class to determine the number of threads.
[0074] In this embodiment, after obtaining the playback instruction, a thread in the initialized thread pool parses the message header of the message data, assigns it to the corresponding thread for subsequent business processing, and then reads the next message data in sequence. The processing process is as follows: Figure 6 shown.
[0075] Specifically, allocating message data to corresponding threads in the thread pool according to the message type obtained after parsing includes: allocating message data to designated threads for business processing according to message type and message class, wherein each object class subclass and interaction class subclass performs business processing in only one thread, and each thread can process message data of one or more subclasses through pre-configuration. When multiple threads process the same object class message data, there may be message data that is later in the sequence and is processed first and sent to the middleware. Placing one object class message data in the same thread for processing can ensure sequentiality. If there are many object instances that need to be updated, the object instance handle can also be bound to the thread ID to facilitate quick updating of the object instance message data.
[0076] In this embodiment, when allocating message data, the message data is allocated to a designated thread according to a preset mapping relationship between message subclasses and threads.
[0077] Specifically, by parsing the first part of the message header, "message type", and the second part, "message class", the ID of the specific object class or interaction class corresponding to the message data can be clearly identified, and the ID is unique in the entire simulation. When initializing the thread pool, the mapping relationship between the object class or interaction class ID and each thread. For example, message data with object class IDs "1" and "2" or interaction class IDs "1" and "2" are processed in thread ID "1", so that the same object class or interaction class message is only processed in one thread.
[0078] In this paper, experiments are also conducted to prove the effectiveness of this method.
[0079] Experimental parameters: The experiment is implemented in C++ language, and the development tool used in the experiment is Qt. First, simulate the simulation and send the simulation data. The data is recorded in a file. Different schemes are used to replay the simulation data. The time consumed by different schemes is recorded. Each scheme is recorded three times and the average value is taken. The number of messages that need to be replayed for data playback is 514132 messages. The timing starts before the file reads the data and ends when all the data is sent. If the thread pool is used, the time consumed by each thread needs to be counted, and the longest time consumed by the thread is taken.
[0080] Experimental results: Table 1 lists the experimental results of the time consumed in replaying the same file using these different methods. The number of messages in the file is 514132. Solution 1 is to read the message header from the file, take out a piece of data, perform business processing on the data and send the simulation data to the simulation run until all the data in the file is read. This is hereinafter referred to as the linear processing solution. Solution 2 is that one thread reads the message header, takes out a piece of data, and temporarily stores the data in an ordered linked list. Another thread takes out the data from the ordered linked list for business processing and sends the data. The termination condition is that the file is read and the ordered linked list is empty. This is hereinafter referred to as the dual-thread solution. Solution 3 is this method. These threads all perform simulation business processing and send the data to the simulation run. Then another thread reads the message header, takes out a piece of data and puts it into a certain thread. This is hereinafter referred to as this solution. The experimental results can be seen at Figure 7-9 .
[0081] Table 1 Experimental data of each scheme
[0082] plan Round 1 Round 2 Round 3 Average time (s) Solution 1 Time Consumption (s) 4.291 4.327 4.305 4.308 Solution 2 Time Consumption (s) 3.195 3.249 3.276 3.240 Time taken for this solution(s) 1.440 1.370 1.440 1.417
[0083] The time consumption of multiple thread solutions is counted, and the overall time consumption is the time consumption of the thread with the longest running time. Table 1 shows the average time consumption required for playback of different experimental solutions. It can be seen that the overall playback time of the linear processing solution is the longest, and the overall playback time of the thread pool processing solution is the shortest. The dual-thread solution improves the performance of the linear processing solution by 24.79%, the thread pool solution improves the performance of the linear processing solution by 67.1%, and this solution improves the performance of the dual-thread processing solution by 56.27%. This shows that the thread pool can process complex business processing in parallel with higher performance.
[0084] In the above-mentioned simulation data recording and playback method, the message data is efficiently converted to the simulation business data based on the custom message header and thread pool. The custom message header is a general framework that facilitates data playback according to the characteristics of the simulation business data. First, according to the message header generated by the data record, a complete simulation data is read, and the simulation data is put into the thread pool for simulation business processing. The message type is identified according to the message header information, the numerical value of the simulation business is replaced, and then the simulation data is sent to the simulation operation. The traditional solution is improved. Among them, the thread pool processes complex simulation business data and the message header format in parallel. It is completely based on the characteristics of the simulation business to efficiently convert the message data to the simulation business, thereby optimizing the problem of forming message data from data records and converting message data to simulation business data for data playback.
[0085] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of the steps, and the steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequentially, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0086] In one embodiment, Fig.10 , provides a simulation data recording and playback device, comprising: a simulation data acquisition module 200, a simulation data recording module 210, a simulation data playback module 220 and a simulation data sending module 230, wherein:
[0087] A simulation data acquisition module 200, used to acquire multiple simulation data of multiple simulation units through middleware;
[0088] The simulation data recording module 210 is used to construct a corresponding message header according to each simulation data based on a specified format, add a corresponding message header to each simulation data to obtain corresponding message data, and store all message data in a preset format file in the order received from the middleware to complete the recording of simulation data, wherein the message header includes a message type and a message class;
[0089] The simulation data playback module 220 is used to obtain playback designation, read each message data in the file in order according to the playback designation, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing;
[0090] The simulation data sending module 230 is used for multiple threads in the thread pool to perform business processing on multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware.
[0091] The specific definition of the simulation data recording and playback device can be found in the above definition of the simulation data recording and playback method, which will not be repeated here. Each module in the above simulation data recording and playback device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0092] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.11 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. 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 computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a simulation data recording and playback method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0093] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0094] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0095] Acquire multiple simulation data of multiple simulation units through middleware;
[0096] Constructing a corresponding message header according to each simulation data based on a specified format, adding a corresponding message header to each simulation data to obtain corresponding message data, and storing all message data in a preset format file in the order of receiving from the middleware to complete the recording of the simulation data, wherein the message header includes a message type and a message class;
[0097] Obtain playback designation, read each message data in the file in sequence according to the playback designation, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing;
[0098] The multiple threads in the thread pool perform business processing on the multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware.
[0099] In one embodiment, 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:
[0100] Acquire multiple simulation data of multiple simulation units through middleware;
[0101] Constructing a corresponding message header according to each simulation data based on a specified format, adding a corresponding message header to each simulation data to obtain corresponding message data, and storing all message data in a preset format file in the order of receiving from the middleware to complete the recording of the simulation data, wherein the message header includes a message type and a message class;
[0102] Obtain playback designation, read each message data in the file in sequence according to the playback designation, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing;
[0103] The multiple threads in the thread pool perform business processing on the multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware.
[0104] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0105] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0106] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A simulation data recording and playback method, characterized in that: The method comprises: Acquire multiple simulation data of multiple simulation units through middleware; Constructing a corresponding message header according to each simulation data based on a specified format, adding a corresponding message header to each simulation data to obtain corresponding message data, and storing all message data in a preset format file in the order of receiving from the middleware to complete the recording of the simulation data, wherein the message header includes a message type and a message class; Obtain playback designation, read each message data in the file in sequence according to the playback designation, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing; The multiple threads in the thread pool perform business processing on the multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware.
2. The simulation data recording and playback method according to claim 1, characterized in that: The message header constructed based on the prescribed format includes 4 parts, among which: The first part indicates the message type of the simulation data, including object class, interaction class and object instance class; The second part indicates the message class, and the message type further indicates the object class subclass and the interaction class subclass for the object class or interaction class; The third part represents the message object. When the message type is an object instance class, the object instance handle needs to be assigned; The fourth part indicates the message length, which is the length of the simulation data.
3. The simulation data recording and playback method according to claim 2, characterized in that: After obtaining the playback specification, the thread pool is initialized according to the number of message class subtypes required in the file to determine the number of threads.
4. The simulation data recording and playback method according to claim 3, characterized in that: After obtaining the playback instruction, a thread in the initialized thread pool parses the message header of the message data, assigns it to the corresponding thread for subsequent business processing, and then reads the next message data in sequence.
5. The simulation data recording and playback method according to claim 4, characterized in that: The method of allocating the message data to the corresponding threads in the thread pool according to the message type and message class obtained after parsing includes: Assign message data to designated threads for business processing according to message type and message class, where each object class subclass and interaction class subclass is only processed in one thread; Each of the threads may process message data of one subclass or multiple subclasses through pre-configuration.
6. The simulation data recording and playback method according to claim 5, characterized in that: When allocating message data, the message data is allocated to a designated thread according to a preset mapping relationship between message subclasses and threads.
7. A simulation data recording and playback device, characterized in that: The device comprises: A simulation data acquisition module, used to acquire multiple simulation data of multiple simulation units through middleware; A simulation data recording module, used to construct a corresponding message header according to each simulation data based on a specified format, add a corresponding message header to each simulation data to obtain corresponding message data, and store all message data in a preset format file in the order received from the middleware to complete the recording of simulation data, wherein the message header includes a message type and a message class; A simulation data playback module is used to obtain playback designation, read each message data in the file in order according to the playback designation, parse the message header of the message data, and distribute the message data to the corresponding thread in the thread pool according to the message type and message class obtained after parsing; The simulation data sending module is used for multiple threads in the thread pool to perform business processing on multiple message data in parallel to obtain corresponding simulation data, and send the simulation data to each simulation unit in sequence through the middleware.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
