Train running simulation software framework design method and train running simulation software framework
Patent Information
- Application Number
- CN202311413137.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-27
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-10-27
AI Technical Summary
但无法实现通讯接口的灵活适配与扩展
[0034]与现有技术相比,本发明的优点和积极效果在于:
Smart Images

Figure CN117216883B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of rail transit technology and relates to train simulation technology. Specifically, it relates to a design method and a train running simulation software framework with a flexibly configurable interface. Background Technology
[0002] Simulation software tools are a primary method and means for functional testing and verification of products in the rail transit field. Before a product is put into application in the rail transit field, it is usually necessary to use simulation software tools as the host computer or controlled object of the product to simulate different operating conditions in the actual operation process and to debug the product's operating status or control performance. As an important part of the debugging process, simulation software tools can save a lot of debugging time and resources.
[0003] For the same type of product, the core functionality of the simulation software tools required for testing changes relatively little, but the interface functionality changes significantly, mainly including changes to the interface protocol and data dictionary. Rewriting the simulation software tools solely because of interface differences leads to low efficiency and redundant workload. Adding or upgrading new features to the core software functionality requires upgrading different tool versions simultaneously, resulting in a large workload.
[0004] Chinese patent application CN 114265578 A discloses an embedded robot software framework and its implementation method, applicable to application software for embedded robots. The framework is divided into five layers: a hardware driver layer, a data interaction layer, a data processing layer, a control algorithm layer, and a business logic layer (application layer). The software functions of each layer are clearly defined, and the interaction methods between layers are constrained. Dividing the software into five layers aims to reduce the coupling between modules and improve the maintainability and scalability of the software. However, it cannot achieve flexible adaptation of communication interfaces.
[0005] Chinese patent application CN 107145353 A discloses a software framework and its design method, applicable to application software running on a terminal. The software framework is divided into a dependency shell layer, an adapter layer, a common resource layer, and a project module layer, with clear definitions of the function of each layer and limitations on the dependencies between layers. Dividing the software into four layers aims to reduce coupling between modules and improve the software's maintainability and scalability. However, it cannot achieve flexible adaptation of communication interfaces.
[0006] Chinese Patent Publication No. CN 112714170 B discloses a general ground software framework system and application with configurable communication protocols. The system includes: a communication layer consisting of a TCP communication module, a UDP communication module, and a Commsvr communication module, used to implement TCP, UDP, and Commsvr communication respectively; an interface layer for protocol management functions; a message layer for managing specific protocols, matching protocols with data packets, and data packet assembly; and a message broker layer for providing data reading services to users. Dividing the software into four layers aims to improve the speed of new ground software development, thereby increasing system development efficiency. However, it cannot achieve flexible adaptation and expansion of the communication interface. Summary of the Invention
[0007] To address the aforementioned problems in the prior art, this invention provides a design method and framework for train running simulation software, which enables flexible adaptation and expansion of communication interfaces.
[0008] In a first aspect, the present invention provides a method for designing a train running simulation software framework, the steps of which are as follows:
[0009] The software framework is divided into thread A, which executes software algorithms and functional logic, and thread B, which executes software external interactions. The two threads interact and synchronize data through a queue.
[0010] The thread B adopts a state machine framework, and four node event modules are added to the state machine: a data receiving module, a data parsing module, a data packet assembly module, and a data sending module. The four node event modules together form an interface adaptation module.
[0011] Add mode numbers corresponding to different communication protocols in the interface adaptation module to the configuration file;
[0012] When thread B has multiple interface interaction modes, thread B sets the mode number in the configuration file as the destination number. When thread B is initialized, thread B reads the mode number in the configuration file once, and the interface adaptation module executes the communication protocol corresponding to that mode number.
[0013] In some embodiments, thread A sequentially executes queue receiving, software algorithm and functional logic, and queue sending.
[0014] In some embodiments, the communication protocol includes at least Ethernet communication protocol, serial communication protocol, and RS-485 communication protocol.
[0015] In some embodiments, when new functions need to be added, the software algorithm and functional logic executed in thread A can be modified based on the existing software.
[0016] In a second aspect, the present invention provides a train running simulation software framework, which is designed using the train running simulation software framework design method described in the first aspect of the present invention. The framework includes thread A, thread B and a configuration file. Thread A is used to execute software algorithms and functional logic, and thread B is used to execute software external interactions. The two threads interact and synchronize data through a queue. The configuration file contains mode numbers corresponding to different communication protocols in thread B.
[0017] The thread B includes an interface adaptation module and a first initialization module; the first initialization module sets the mode number set in the configuration file as the destination number; when initializing thread B, the first initialization module reads the mode number in the configuration file once so that the interface adaptation module executes the communication protocol corresponding to the mode number.
[0018] The interface adaptation module includes:
[0019] The data receiving module is used to receive external data;
[0020] The data parsing module is used to parse external data according to different communication protocols;
[0021] The data packet assembly module is used to assemble the data received from thread A into packet data according to different communication protocols.
[0022] The data sending module is used to send the packet data to external devices.
[0023] In some embodiments, thread B further includes:
[0024] The first queue receiving module is used to receive data sent by thread A and send the received data to the data packet assembly module for data packet assembly.
[0025] The first queue sending module is used to receive the data parsed by the data parsing module and send the received parsed data to thread A.
[0026] In some embodiments, thread A includes:
[0027] The second initialization module is used to initialize thread A;
[0028] The second queue receiving module is used to receive the parsed data sent by the first queue sending module;
[0029] The function execution module is used to execute software algorithms and functional logic based on the data received by the second queue receiving module;
[0030] The second queue sending module is used to send the data obtained by the function execution module from executing the software algorithm and functional logic to the first queue receiving module.
[0031] In some embodiments, thread B further includes:
[0032] A data receiving interface is used to connect to an external device. The data receiving interface receives external data sent by the external device and transmits the external data to the data receiving module.
[0033] A data transmission interface is used to connect to an external device. The data transmission interface receives packet data sent by the data transmission module and transmits the packet data to the external device.
[0034] Compared with the prior art, the advantages and positive effects of the present invention are as follows:
[0035] (1) The train running simulation software framework design method and train running simulation software framework of the present invention divide the software into thread A, which executes the software algorithm and functional logic, and thread B, which executes the software external interaction. This makes the main function of the software and the data interaction function independent of each other, enabling adaptation to different devices and different communication protocols, while not affecting the main function of the software, and realizing flexible adaptation and expansion of the communication interface.
[0036] (2) The train running simulation software framework design method and train running simulation software framework of the present invention divide the software function into two threads: the main function and the interface interaction. The thread data interaction is carried out through the queue, thereby realizing the decoupling of the interface and the function.
[0037] (3) The train running simulation software framework design method and the train running simulation software framework of this invention adopt a state machine framework in thread B (i.e., the interface interaction thread) to realize independent event design and minimal functional design. The interface adaptation module is designed, which consists of four event modules: data sending module, data receiving module, data parsing module, and data packet assembly module. Different interfaces adapt to different communication protocols according to different interface requirements. Only the mode number in the configuration file needs to be read once during software initialization to adapt to the corresponding communication protocol, realizing flexible configuration of the interface. At the same time, since thread A and thread B are independent of each other, thread A does not need to be adjusted during the interface adaptation process, and the queue sending and receiving of thread B is also unaffected.
[0038] (4) The train running simulation software framework design method and the train running simulation software framework of this invention can be used to add or upgrade new functions simply by modifying the function execution module of thread A on the basis of the existing software. This avoids the repetitive work of upgrading the functions of multiple versions of the program and further avoids the problem of incompatibility between multiple versions of functions. Attached Figure Description
[0039] Figure 1 This is a flowchart illustrating the train running simulation software framework design method described in this embodiment of the invention.
[0040] Figure 2 This is a structural block diagram of the train running simulation software framework described in an embodiment of the present invention.
[0041] In the diagram, 1 represents thread A, 2 represents thread B, and 3 represents the configuration file. Detailed Implementation
[0042] The present invention will now be described in detail through exemplary embodiments. However, it should be understood that, without further description, elements, structures, and features in one embodiment may be advantageously incorporated into other embodiments.
[0043] Existing simulation software tools for product function testing and verification in the rail transit field, for the same type of product, have testing requirements with relatively small changes in the main function but large changes in interface functions. However, rewriting the simulation software tool due to different interfaces is inefficient and results in repetitive work. Furthermore, when adding or upgrading new functions to the main software, different tool versions need to be upgraded simultaneously, further increasing the workload. This invention provides a train running simulation software framework design method and a train running simulation software framework. The software is divided into thread A, which executes software algorithms and functional logic, and thread B, which executes external software interactions. This makes the main software function and data interaction function independent, enabling adaptation to different devices and communication protocols without affecting the main software function, and achieving flexible adaptation and expansion of the communication interface. The following detailed description of the above-mentioned train running simulation software framework design method and train running simulation software framework, with reference to the accompanying drawings, is provided.
[0044] See Figure 1 The first aspect of this invention provides a method for designing a train running simulation software framework, the steps of which are as follows:
[0045] S1. The software framework is divided into thread A, which executes software algorithms and functional logic, and thread B, which executes software external interactions. The two threads interact and synchronize data through a queue.
[0046] S2. The thread B adopts a state machine framework, and four node event modules are added to the state machine: a data receiving module, a data parsing module, a data packet assembly module, and a data sending module. The four node event modules together form an interface adaptation module.
[0047] Specifically, the interface adaptation module incorporates different communication protocols. The data parsing module executes these communication protocols when parsing data, and the data packetizing module executes them when assembling data.
[0048] It should be noted that thread B employs a state machine framework. It receives data from thread A via a queue, receives data from external sources through a data receiving module, and parses the external data according to different communication protocols through a data parsing module. Simultaneously, it executes data packetization, data transmission, and queue transmission through timed trigger events. Specifically, the data packetization module assembles data received from thread A into packets according to different communication protocols and sends them to external devices through the data transmission module. Thread B then sends the parsed data from thread B back to thread A via queue transmission.
[0049] S3. Add the mode number corresponding to different communication protocols in the interface adaptation module to the configuration file.
[0050] Specifically, the communication protocol includes, but is not limited to, Ethernet communication protocol, serial communication protocol, and RS-485 communication protocol. It can also be RS-232 communication protocol, Modbus communication protocol, MPI communication protocol, TCP communication protocol, UDP communication protocol, etc. The specific protocol can be configured according to actual needs.
[0051] It should be noted that different communication protocols correspond to different mode numbers. For example, mode number 1 corresponds to the Ethernet communication protocol, mode number 2 corresponds to the serial communication protocol, and mode number 3 corresponds to the RS485 communication protocol.
[0052] S4. When thread B has multiple interface interaction modes, thread B sets the mode number in the configuration file as the destination number. When thread B is initialized, thread B reads the mode number in the configuration file once, and the interface adaptation module executes the communication protocol corresponding to the mode number.
[0053] In some embodiments, thread A executes queue receiving, software algorithms and functional logic, and queue sending sequentially. This execution order facilitates thread A's computation and logical processing of external data, improving efficiency.
[0054] Specifically, thread A receives data from thread B through a queue, executes software algorithms and functional logic on the data, and sends the calculation results back to thread B through the queue.
[0055] In some embodiments, a function modification step is also included: when a new function needs to be added, the software algorithm and functional logic executed in thread A can be modified based on the existing software. This avoids the repetitive work of upgrading the function of multiple versions of the program and further avoids the problem of function incompatibility between multiple versions.
[0056] It's important to note that since threads A and B are independent, thread A does not need adjustment during the interface adaptation process, and thread B's queue sending and receiving remain unaffected. In other words, adapting to different devices and communication protocols will not impact the core functionality (i.e., the software algorithm and functional logic) of software thread A. Similarly, adding new features only requires modifying the core functionality (i.e., the software algorithm and functional logic) of thread A, without affecting thread B's queue interface adaptation and interaction capabilities.
[0057] The train running simulation software framework designed by the above-described train running simulation software framework design method in this invention is applicable to various software development languages, including C, C++, LabVIEW, etc.
[0058] The train running simulation software framework designed using the above-described train running simulation software framework design method according to embodiments of the present invention enables flexible switching of software communication interfaces under different devices and different interface protocols when used for testing rail vehicle running products. This allows for flexible switching between different devices and topologies with only a single train running simulation software framework design, improving efficiency and saving time and resources.
[0059] See Figure 2 The second aspect of the present invention also provides a train running simulation software framework, which is designed using the train running simulation software framework design method described in the first aspect of the present invention. The train running simulation software framework includes thread A, thread B and configuration file. Thread A is used to execute software algorithms and functional logic, and thread B is used to execute software external interaction. The two threads interact and synchronize data through a queue. The configuration file contains mode numbers corresponding to different communication protocols in thread B.
[0060] The thread B includes an interface adaptation module and a first initialization module; the first initialization module sets the mode number set in the configuration file as the destination number; when initializing thread B, the first initialization module reads the mode number in the configuration file once so that the interface adaptation module executes the communication protocol corresponding to the mode number.
[0061] The interface adaptation module includes:
[0062] The data receiving module is used to receive external data;
[0063] The data parsing module is used to parse external data according to different communication protocols;
[0064] The data packet assembly module is used to assemble the data received from thread A into packet data according to different communication protocols.
[0065] The data sending module is used to send the packet data to external devices.
[0066] In the software framework described in this embodiment of the invention, when thread B has multiple interface interaction modes, the first initialization module sets the mode number in the configuration file as the destination number. When the first initialization module initializes thread B, it reads the mode number in the configuration file once, and the interface adaptation module executes the communication protocol corresponding to that mode number. For example, if the communication protocol corresponding to the mode number is the Ethernet communication protocol, the data parsing module and the data packet assembly module in the interface adaptation module execute the Ethernet communication protocol. Specifically, the data parsing module parses external data according to the Ethernet communication protocol, and the data packet assembly module assembles the data received from thread A into packetized data according to the Ethernet communication protocol.
[0067] The software framework described in this embodiment of the invention allows for the addition of new features simply by modifying the software algorithm and functional logic executed in thread A, based on the existing software. This avoids repetitive work in upgrading features across multiple versions and further mitigates the problem of feature incompatibility between different versions.
[0068] It's important to note that since threads A and B are independent, thread A does not need adjustment during the interface adaptation process, and thread B's queue sending and receiving remain unaffected. In other words, adapting to different devices and communication protocols will not impact the core functionality (i.e., the software algorithm and functional logic) of software thread A. Similarly, adding new features only requires modifying the core functionality (i.e., the software algorithm and functional logic) of thread A, without affecting thread B's queue interface adaptation and interaction capabilities.
[0069] Specifically, the protocols include, but are not limited to, Ethernet communication protocols, serial communication protocols, and RS-485 communication protocols. They can also include RS-232 communication protocols, Modbus communication protocols, MPI communication protocols, TCP communication protocols, UDP communication protocols, etc. The specific protocols can be configured according to actual needs.
[0070] It should be noted that different communication protocols correspond to different mode numbers. For example, mode number 1 corresponds to the Ethernet communication protocol, mode number 2 corresponds to the serial communication protocol, and mode number 3 corresponds to the RS485 communication protocol.
[0071] In some embodiments, thread B further includes:
[0072] The first queue receiving module is used to receive data sent by thread A and send the received data to the data packet assembly module for data packet assembly.
[0073] The first queue sending module is used to receive the data parsed by the data parsing module and send the received parsed data to thread A.
[0074] In some embodiments, thread A includes:
[0075] The second initialization module is used to initialize thread A;
[0076] The second queue receiving module is used to receive the parsed data sent by the first queue sending module;
[0077] The function execution module is used to execute software algorithms and functional logic based on the data received by the second queue receiving module;
[0078] The second queue sending module is used to send the data obtained by the function execution module from executing the software algorithm and functional logic to the first queue receiving module.
[0079] In some embodiments, thread B further includes:
[0080] A data receiving interface is used to connect to an external device. The data receiving interface receives external data sent by the external device and transmits the external data to the data receiving module.
[0081] A data transmission interface is used to connect to an external device. The data transmission interface receives packet data sent by the data transmission module and transmits the packet data to the external device.
[0082] The train running simulation software framework described above is applicable to various software development languages, including C, C++, LabVIEW, etc.
[0083] The train running simulation software framework described above, when used to test rail vehicle running products, enables flexible switching of software communication interfaces under different devices and interface protocols. It eliminates the need for multiple rewrites of the train running simulation software framework due to different interfaces; only the mode number in the configuration file needs to be read once during thread B initialization to execute the corresponding communication protocol in the interface adaptation module. This allows for flexible switching between different devices and topologies, improving efficiency and saving time and resources.
[0084] The above embodiments are used to explain the present invention, but not to limit the present invention. Any modifications and changes made to the present invention within the spirit and scope of the claims shall fall within the protection scope of the present invention.
Claims
1. A design method for a train running simulation software framework, used for real-time simulation testing of rail vehicle running products, characterized in that, The steps are as follows: The software framework is divided into thread A, which executes the train running simulation software algorithm and train running simulation functional logic, and thread B, which executes the interaction of the train running simulation software with external multi-device interfaces. The two threads interact and synchronize data through independent data queues. The thread B adopts a state machine framework, and four node event modules are added to the state machine: a data receiving module, a data parsing module, a data packet assembly module, and a data sending module. The four node event modules together form a train simulation dedicated interface adapter module. Add mode numbers corresponding to different communication protocols in the interface adaptation module to the configuration file; When thread B has multiple interface interaction modes, thread B sets the mode number in the configuration file as the destination number. When thread B is initialized, thread B reads the mode number in the configuration file once. The interface adaptation module executes the communication protocol corresponding to the mode number to realize one-click configuration switching of the communication protocol and adapt the interface. When new features need to be added, only the software algorithm and functional logic executed in thread A need to be modified on the basis of the existing software, without changing the interface interaction functional logic of thread B.
2. The train running simulation software framework design method as described in claim 1, characterized in that, Thread A executes queue receiving, software algorithm and functional logic, and queue sending sequentially.
3. The train running simulation software framework design method as described in claim 1, characterized in that, The communication protocols include at least Ethernet communication protocol, serial port communication protocol, and RS-485 communication protocol.
4. A train running simulation software framework, designed using the train running simulation software framework design method as described in any one of claims 1-3, characterized in that, It includes thread A, thread B and configuration file. Thread A is used to execute software algorithms and functional logic, and thread B is used to perform software external interaction. The two threads interact and synchronize data through a queue. The configuration file contains mode numbers corresponding to different communication protocols in thread B. The thread B includes an interface adaptation module and a first initialization module; The first initialization module sets the mode number set in the configuration file as the destination number. When initializing thread B, the first initialization module reads the mode number in the configuration file once so that the interface adaptation module executes the communication protocol corresponding to the mode number. The interface adaptation module includes: The data receiving module is used to receive external data; The data parsing module is used to parse external data according to different communication protocols; The data packet assembly module is used to assemble the data received from thread A into packet data according to different communication protocols. The data sending module is used to send the packet data to external devices.
5. The train running simulation software framework as described in claim 4, characterized in that, Thread B also includes: The first queue receiving module is used to receive data sent by thread A and send the received data to the data packet assembly module for data packet assembly. The first queue sending module is used to receive the data parsed by the data parsing module and send the received parsed data to thread A.
6. The train running simulation software framework as described in claim 5, characterized in that, Thread A includes: The second initialization module is used to initialize thread A; The second queue receiving module is used to receive the parsed data sent by the first queue sending module; The function execution module is used to execute software algorithms and functional logic based on the data received by the second queue receiving module; The second queue sending module is used to send the data obtained by the function execution module from executing the software algorithm and functional logic to the first queue receiving module.
7. The train running simulation software framework as described in claim 4, characterized in that, Thread B also includes: A data receiving interface is used to connect to an external device. The data receiving interface receives external data sent by the external device and transmits the external data to the data receiving module. A data transmission interface is used to connect to an external device. The data transmission interface receives packet data sent by the data transmission module and transmits the packet data to the external device.
Citation Information
Patent Citations
Software framework and design method for software framework
CN107145353A
A general-purpose ground software framework system with configurable communication protocols and its application.
CN112714170B
Universal ground software framework system capable of configuring communication protocol and application
CN112714170A
Distributed numerical simulation comprehensive analysis platform based on cloud computing and construction method thereof
CN113536501A