A secondary packaging method for polymorphic simulation models based on shared memory

Through the quadratic simulation model quadratic encapsulation method based on shared memory, the problem of models of different programming languages ​​or versions running in a unified simulation framework is solved, and the consistency of the model platform, mode and multi-instance operation is achieved.

CN115390830BActive Publication Date: 2025-05-02CHINESE PEOPLES LIBERATION ARMY UNIT 92941
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210998493.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-19
Publication Date
2025-05-02
Estimated Expiration
2042-08-19

AI Technical Summary

Technical Problem

In fine-grained simulation test systems, simulation models developed by multiple units are difficult to call directly in a unified simulation framework due to different programming languages ​​or versions, and there are problems such as running platform, mode and multi-instance support.

Method used

The polymorphic simulation model secondary encapsulation method based on shared memory is adopted. By establishing information interaction protocols for shared memory communication and component programs that establish corresponding models in the simulation framework, the coordinated operation of models of different programming languages ​​or versions and the unified simulation framework is realized.

Benefits of technology

It integrates packaged models using different programming languages ​​or versions into a unified simulation framework to achieve the purpose of collaborative operation of each model, and solves the consistency problem of platform, mode and multi-instance operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115390830B_ABST
    Figure CN115390830B_ABST
Patent Text Reader

Abstract

The purpose of the present invention is to provide a shared memory-based polymorphic simulation model secondary packaging method, which can be used to integrate packaging models compiled in different programming languages ​​or different versions into a unified simulation framework to achieve the purpose of collaborative operation of various models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of simulation technology, and in particular relates to a secondary packaging method of a polymorphic simulation model based on shared memory. Background Art

[0002] In the construction of fine-grained simulation test systems, it is often necessary to integrate simulation models developed by multiple units and encapsulated into dynamic link libraries, and during the simulation process, each model may generate multiple instances. Due to different model developers, different programming languages ​​or different versions, some models can only run on the Win32 platform, some models can only run on the X64 platform; some models can only run in Debug mode, some models can only run in Release mode; some models do not support multi-instance operation, making it difficult to directly call the model interface provided by the dynamic link library in the simulation framework. Summary of the invention

[0003] In view of this, the purpose of the present invention is to provide a polymorphic simulation model secondary packaging method based on shared memory, which can be used to integrate packaging models (dynamic link libraries) compiled in different programming languages ​​​​(or different versions) into a unified simulation framework to achieve the purpose of collaborative operation of various models.

[0004] A shared memory-based polymorphic simulation model secondary packaging method, comprising:

[0005] Step 1: Establish an information interaction protocol for shared memory communication: Analyze the interaction information between the model and the simulation system framework, distinguish between model running instruction information and model status feedback information, and establish information interaction protocols respectively.

[0006] Step 2: Establish the component program of the corresponding model in the simulation framework: According to the modeling constraints of the simulation framework, use the shared memory as the communication medium to establish the simulation component for communication between the simulation system and the model program, so as to drive various operation instructions of the simulation system and data interaction between other entities in the system and the simulation model program, specifically:

[0007] Step 21: Generate a shared memory name and a shared memory read / write event name according to the model instance ID, that is, one model instance corresponds to one shared memory and one shared memory read / write event;

[0008] Step 22: Create corresponding shared memory and shared memory read / write event according to the shared memory name and shared memory read / write event name in step 21;

[0009] Step 23, using the model instance ID as a command line parameter, calling the executable file of the model program to create a running instance of the model;

[0010] Step 24: Write the model initialization information into the corresponding shared memory, and send a shared memory write event to the model program;

[0011] Step 25: In each simulation cycle of the simulation framework, perform the following steps:

[0012] Wait for shared memory read event;

[0013] Read the shared memory to obtain the running data of the model running instance;

[0014] Check the status of the model running instance:

[0015] When in the initialization state or the advancement state, the instructions and data for advancing the model running instance are written into the corresponding shared memory, and a shared memory write event is sent;

[0016] When it is in fault or exit state, the model exit instruction is written into the shared memory, a shared memory write event is sent, and then the model instance is destroyed;

[0017] Step 3: Re-encapsulate the simulation model: Use a programming language or corresponding version that is compatible with the encapsulated model to re-encapsulate the model in a platform that is compatible with the model dynamic link library or static link library, that is, use a shared memory method to communicate with the model components in the simulation framework to generate an executable file, specifically including:

[0018] Step 31, read the command line parameters, and generate the shared memory name and the shared memory read and write event name according to the parameters;

[0019] Step 32, open the shared memory and the shared memory read and write events;

[0020] Step 33, set the model exit flag to False;

[0021] Step 34, check the model exit flag: if it is True, then end; if it is False, wait for the model's shared memory write event;

[0022] Step 35: read the shared memory to obtain the running data of the model running instance;

[0023] Step 36: Detect the model running instruction of the model and determine:

[0024] If it is an initialization instruction: read the model initialization data in the shared memory, call the model initialization function, and then execute the next step;

[0025] If it is a push instruction: read the model initialization data in the shared memory, then call the model push function and execute the next step;

[0026] If it is an exit instruction: set the model exit flag to True and execute the next step;

[0027] Step 37, write the model instance running status data into the shared memory, send a shared memory read event, and then return to step 34;

[0028] Step 4: During the simulation operation, the model component in the simulation framework starts the executable file obtained by the secondary packaging of the model, and exchanges information through the shared memory;

[0029] Step 5: After a certain instance of the model is finished running, the simulation framework component is notified through the shared memory, and the simulation framework component sends an exit instruction to the executable file. After receiving the instruction, the executable file exits the running.

[0030] The present invention has the following beneficial effects:

[0031] The purpose of the present invention is to provide a simulation model secondary packaging method based on shared memory, which can be used to integrate packaging models (dynamic link libraries) compiled in different programming languages ​​​​(or different versions) into a unified simulation framework to achieve the purpose of collaborative operation of various models. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 It is the workflow diagram of the simulation component;

[0033] Figure 2 This is the workflow diagram of the model secondary packaging program. DETAILED DESCRIPTION

[0034] The present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0035] A shared memory-based polymorphic simulation model secondary packaging method of the present invention comprises the following steps:

[0036] Step 1: Establish an information interaction protocol for shared memory communication: Analyze the interaction information between the model and the simulation system framework, distinguish between model running instruction information and model status feedback information, and establish information interaction protocols respectively.

[0037] Step 2: Establish the component program of the corresponding model in the simulation framework: According to the modeling constraints of the simulation framework, use shared memory as the communication medium to establish the simulation component for communication between the simulation system and the model program, so as to drive various operation instructions of the simulation system and data interaction between other entities in the system and the simulation model program. The workflow diagram of the simulation component is shown in the attached figure. Figure 1 As shown, specifically:

[0038] Step 21: Generate a shared memory name and a shared memory read / write event name according to the model instance ID, that is, one model instance corresponds to one shared memory and one shared memory read / write event;

[0039] Step 22: Create corresponding shared memory and shared memory read / write event according to the shared memory name and shared memory read / write event name in step 21;

[0040] Step 23, using the model instance ID as a command line parameter, calling the executable file of the model program to create a running instance of the model;

[0041] Step 24: Write the model initialization information into the corresponding shared memory, and send a shared memory write event to the model program;

[0042] Step 25: In each simulation cycle of the simulation framework, perform the following steps:

[0043] Wait for shared memory read event;

[0044] Read the shared memory to obtain the running data of the model running instance;

[0045] Check the status of the model running instance:

[0046] When in the initialization state or the advancement state, the instructions and data for advancing the model running instance are written into the corresponding shared memory, and a shared memory write event is sent;

[0047] When it is in a fault or exit state, the model exit instruction is written to the shared memory, a shared memory write event is sent, and then the model instance is destroyed.

[0048] Step 3: Re-encapsulate the simulation model: Use a programming language (or corresponding version) that is compatible with the encapsulated model to re-encapsulate the model in a platform that is compatible with the model dynamic / static link library, that is, use shared memory to communicate with the model components in the simulation framework to generate an executable file. The workflow diagram is shown in the attached figure. Figure 2 As shown, specifically including:

[0049] Step 31, read the command line parameters, and generate the shared memory name and the shared memory read and write event name according to the parameters;

[0050] Step 32, open the shared memory and the shared memory read and write events;

[0051] Step 33, set the model exit flag to False;

[0052] Step 34, check the model exit flag: if it is True, then end; if it is False, wait for the model's shared memory write event;

[0053] Step 35: read the shared memory to obtain the running data of the model running instance;

[0054] Step 36: Detect the model running instruction of the model and determine:

[0055] If it is an initialization instruction: read the model initialization data in the shared memory, call the model initialization function, and then execute the next step;

[0056] If it is a push instruction: read the model initialization data in the shared memory, then call the model push function and execute the next step;

[0057] If it is an exit instruction: set the model exit flag to True and execute the next step;

[0058] Step 37: Write the model instance running status data into the shared memory, send a shared memory read event, and then return to step 34.

[0059] Step 4: During the simulation, the model component in the simulation framework starts the executable file obtained by secondary packaging of the model, and exchanges information through shared memory.

[0060] Step 5: After a certain instance of the model is finished running, the simulation framework component is notified through the shared memory, and the simulation framework component sends an exit instruction to the executable file. After receiving the instruction, the executable file exits the running.

[0061] In summary, the above are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for secondary packaging of a polymorphic simulation model based on shared memory, characterized in that: include: Step 1: Establish an information interaction protocol for shared memory communication: Analyze the interaction information between the model and the simulation system framework, distinguish between model operation instruction information and model status feedback information, and establish information interaction protocols respectively; Step 2: Establish the component program of the corresponding model in the simulation framework: According to the modeling constraints of the simulation framework, use the shared memory as the communication medium to establish the simulation component for communication between the simulation system and the model program, so as to drive various operation instructions of the simulation system and data interaction between other entities in the system and the simulation model program, specifically: Step 21: Generate a shared memory name and a shared memory read / write event name according to the model instance ID, that is, one model instance corresponds to one shared memory and one shared memory read / write event; Step 22: Create corresponding shared memory and shared memory read / write event according to the shared memory name and shared memory read / write event name in step 21; Step 23, using the model instance ID as a command line parameter, calling the executable file of the model program to create a running instance of the model; Step 24: Write the model initialization information into the corresponding shared memory, and send a shared memory write event to the model program; Step 25: In each simulation cycle of the simulation framework, perform the following steps: Wait for shared memory read event; Read the shared memory to obtain the running data of the model running instance; Check the status of the model running instance: When in the initialization state or the advancement state, the instructions and data for advancing the model running instance are written into the corresponding shared memory, and a shared memory write event is sent; When it is in fault or exit state, the model exit instruction is written into the shared memory, a shared memory write event is sent, and then the model instance is destroyed; Step 3: Re-encapsulate the simulation model: Use a programming language or corresponding version that is compatible with the encapsulated model to re-encapsulate the model in a platform that is compatible with the model dynamic link library or static link library, that is, use a shared memory method to communicate with the model components in the simulation framework to generate an executable file, specifically including: Step 31, read the command line parameters, and generate the shared memory name and the shared memory read and write event name according to the parameters; Step 32, open the shared memory and the shared memory read and write events; Step 33, set the model exit flag to False; Step 34, check the model exit flag: if it is True, then end; if it is False, wait for the model's shared memory write event; Step 35: read the shared memory to obtain the running data of the model running instance; Step 36: Detect the model running instruction of the model and determine: If it is an initialization instruction: read the model initialization data in the shared memory, call the model initialization function, and then execute the next step; If it is a push instruction: read the model initialization data in the shared memory, then call the model push function and execute the next step; If it is an exit instruction: set the model exit flag to True and execute the next step; Step 37, write the model instance running status data into the shared memory, send a shared memory read event, and then return to step 34; Step 4: During the simulation operation, the model component in the simulation framework starts the executable file obtained by the secondary packaging of the model, and exchanges information through the shared memory; Step 5: After a certain instance of the model is finished running, the simulation framework component is notified through the shared memory, and the simulation framework component sends an exit instruction to the executable file. After receiving the instruction, the executable file exits the running.

Citation Information

Patent Citations

  • Data interaction method and system based on dual-system shared memory

    CN109783245A

  • Programming method of aircraft real-time simulation program based on simulation software Simulink real-time extension RTX

    CN110674590A