A method, testing device, and electronic equipment for integrating the source code of a battery management system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2026-08-14
AI Technical Summary
[0008]本发明的目的就在于提供一种电池管理系统源代码集成测试方法,还提供一种电池管理系统源代码集成测试装置及电子设备,以解决缩短集成及测试时间,提高纠错效率的问题
[0028] This invention provides a battery management system source code integration testing device, including an acquisition module, a preset module, a mapping module, an integration module, a compilation module, and a testing module. This device can be configured according to preset files for software interface information, file paths, and test items, allowing for customized integration testing solutions. The testing method is fully automated, visualized, and systematic, requiring no advanced programming language development skills, thus improving work efficiency and reducing development costs. For the integration phase, tabular data can be used to comprehensively match and map integration interfaces and troubleshoot problems, significantly improving efficiency.
Smart Images

Figure CN114924737B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power management system technology, specifically relating to a battery management system source code integration testing method, testing device, and electronic equipment. Background Technology
[0002] As battery management systems become increasingly feature-rich, the number of software interfaces also grows. Faced with these complex interfaces, the common approach is to manually integrate them by writing code based on an interface mapping table. The integration success depends entirely on the experience and skills of the integrator.
[0003] Currently, automation is possible for parts such as automatic compilation and testing, but the integration phase is the key to determining the iteration efficiency of the battery management system software. Manually integrating numerous interfaces can waste several days because it involves hand-written code, making 100% accuracy impossible. Errors are also identified through code reading for debugging, undoubtedly wasting significant time. Slow software iteration will negatively impact the improvement of system software quality.
[0004] Existing technology discloses a software configuration and integration method, including the following steps: acquiring hardware information of a device and determining the functions to be installed on the device; acquiring the code address of the target code corresponding to the function to be installed, and acquiring the target code based on the code address; generating a configuration file based on the hardware information and the functional information of the function to be installed; and integrating the complete software package based on the configuration file and the target code. This method integrates the corresponding files into the complete software package and loads it into the device based on the acquired hardware information, but it cannot achieve automatic mapping and integration between the source file code software interface and the interface in the preset file.
[0005] Existing technology also discloses a source file version information processing method, which includes: obtaining version information of all source files of the target software; recording the version information into the source code according to a preset format; and compiling the source code into the target software. This processing method requires configuration management tool support and mainly involves version number verification.
[0006] Existing technology also discloses a custom automated software testing method, which stores scripts for finding and identifying various controls, encapsulates methods for identifying controls, sets the testing priority and required software functional modules through configuration files, stores test cases for the required software functional modules, places the test cases in the same directory as the executable file (exe) of the program under test, compiles the script program into an executable file (exe), places it in the same directory as the software under test, calls the executable script program to start executing the test cases, the script automatically reads and runs the test cases in the same directory one by one until all test cases have been executed, and verifies whether the test cases pass. However, this testing method requires generating an executable file from the test script and placing the executable file in the same directory as the program under test, which makes it impossible to reuse all subsequent integration testing processes with a single input.
[0007] In summary, existing battery management systems all use traditional manual integration methods during integration. The integration efficiency and accuracy largely depend on the experience and ability of the integration personnel. When troubleshooting, it is necessary to check the code to confirm whether the integration interface is correct, which is not intuitive, takes a long time to confirm, and is inefficient. Summary of the Invention
[0008] The purpose of this invention is to provide a method for integrating and testing the source code of a battery management system, as well as a device and electronic equipment for integrating and testing the source code of a battery management system, in order to solve the problems of shortening integration and testing time and improving error correction efficiency.
[0009] The objective of this invention is achieved through the following technical solution:
[0010] A method for integrating and testing the source code of a battery management system includes the following steps:
[0011] A. Configure the preset file and configure the settings in the preset file;
[0012] B. Automatically obtain interface information from the target file of the battery management system;
[0013] C. Extract the software interface information from the battery management system source code file and perform code mapping;
[0014] D. Compile the mapped battery management system source code to generate an executable file;
[0015] E. Conduct functional testing, compare the actual running results of the battery management system executable file with the preset values in the target file, and determine the integrity of the source code integration based on the comparison results.
[0016] Further, step A specifically involves: selecting the test project in the preset file, configuring the interface information in the file, and configuring the file path.
[0017] Further, step B specifically involves: obtaining all software interface information of the target software from the system software integration information table. The interface information is pre-stored in the system software integration information table and mainly includes the software interface name, data type, interface direction, and corresponding algorithm logic.
[0018] Further, step C specifically involves: reading the software interface information for each file whose source code to be integrated, matching the software interfaces by interface name, type, and interface direction based on the information extracted from the system software integration information table, and determining whether to integrate the algorithm logic code based on whether the content in the algorithm logic column of the system software integration information table is present.
[0019] Furthermore, step C specifically includes the following steps:
[0020] C1. Traverse the interface information text file of the target file. The code in the file after mapping is completed queries the software API defined in the target file by identifying the source files in the integration interface folder.
[0021] C2. Copy the variable interface integration code corresponding to the API into the source file.
[0022] Further, in step D, the executable file is a file generated by the compiler after all source code files have been successfully compiled, which can be programmed into the battery management system using a program programming device.
[0023] Further, step E specifically involves: selecting the functional test items from the preset file, first automatically integrating the program to start the debugger and load the functional test scripts one by one, starting the test device and loading the test scripts corresponding to the debugger functions, testing one by one and outputting a test report.
[0024] A battery management system source code integration testing device includes an acquisition module for acquiring all software interface information of the target file and software; an integration module for integrating the software interfaces extracted from the file with the software interfaces extracted from the source file, and starting other preset software to generate other source code files; and a compilation and testing module for automatically compiling all source code files and calling debugging tools to download the code and perform functional testing.
[0025] Furthermore, it also includes a preset module and a mapping module. The preset module is used to pre-set all the necessary information before the device is run, and to call the mapping module and the test module. The mapping module is used to map the application layer software interface to the basic software interface.
[0026] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein running the computer program executes a method for integrating and testing the source code of the battery management system.
[0027] Compared with the prior art, the beneficial effects of the present invention are:
[0028] This invention provides a battery management system source code integration testing device, including an acquisition module, a preset module, a mapping module, an integration module, a compilation module, and a testing module. This device can be configured according to preset files for software interface information, file paths, and test items, allowing for customized integration testing solutions. The testing method is fully automated, visualized, and systematic, requiring no advanced programming language development skills, thus improving work efficiency and reducing development costs. For the integration phase, tabular data can be used to comprehensively match and map integration interfaces and troubleshoot problems, significantly improving efficiency. Attached Figure Description
[0029] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0030] Figure 1 A schematic diagram provided for one embodiment of the present invention; Detailed Implementation
[0031] The present invention will be further described below with reference to embodiments:
[0032] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0033] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0034] This invention provides a battery management system source code integration testing method. It allows selection of test options from a preset file, centralized management of debugger test scripts in a test case library, and mapping of test options in the preset file to scripts in the library. Test results are automatically generated into a test report. The testing method is configurable and can automatically execute regression testing, incremental testing, or full-function testing according to requirements, significantly improving testing efficiency and contributing to improved software quality.
[0035] Specifically, the following steps are included:
[0036] A. Configure the preset file. Select the test items in the preset file, and configure the interface information and file path in the file. The above configuration can basically confirm all software interface relationships and test content.
[0037] The preset file is a file that allows you to set the project path and test the selection.
[0038] The specific configuration preset file mainly involves selecting the test project, configuring the software interface information according to the interface information table, selecting the interface file path, and selecting the compilation project path. This configuration preset file can be a text file or a host computer program developed based on that text file. Selecting the test project mainly involves choosing test scripts from the test script library. Test scripts can be debugger scripts or test device scripts. Selecting the interface file path is crucial for the program to locate the target file; otherwise, the software interface information cannot be parsed and mapped. Selecting the compilation project path defines the root directory of the file in the Makefile, ensuring correct compilation.
[0039] The specific target file should include a list of application software interfaces, a list of basic software interfaces corresponding to the application software interface list, and pseudocode or standard C language code blocks required for the corresponding application software interfaces and basic software interfaces. The pseudocode needs to use standardized pseudocode vocabulary. A script should be used to translate the pseudocode into standard C language and load it into the application software and basic software integration code segment. This script can be a Python script.
[0040] B. Automatically obtain the interface information of the target file. Retrieve all software interface information of the target software from the system software integration information table. This interface information is pre-stored in the system software integration information table and mainly includes the software interface name, data type, interface direction, and corresponding algorithm logic.
[0041] The target file is a table that maps application software interfaces to basic software interfaces. The table contains software interface names, interface directions, logic code, file names, function names, etc.
[0042] Specifically, the automatic acquisition of interface information from the battery management system target file involves automatically generating application interface integration code based on the mapping relationship between the application layer and the basic software interface in the target file. Simultaneously, it extracts the necessary logic code or pseudo-code to generate corresponding interface logic code segments. Input and output judgments are defined according to the code interface variable specification: the keyword "PPort" indicates output, and the keyword "RPort" indicates input. For code integration, variables in the basic software containing the keyword "RPort" need to be assigned values from software interface variables containing the keyword "PPort" as executor outputs; conversely, variables in the application layer containing the keyword "RPort" need to be assigned values from basic software interface variables containing the keyword "PPort" as signal inputs. During this process, a text file needs to be generated to record the mapped interface code. For each interface mapping relationship, the task allocation relationship in the target file also needs to be extracted. This relationship determines the relationship between the generated interface and the existing software API, and the generated interface mapping needs to map the variable interface to the software API.
[0043] C. Extract the software interface information from the battery management system source code files and perform code mapping. For each source code file to be integrated, read the software interface information, and match the software interfaces according to the interface name, type, and interface direction based on the information extracted from the system software integration information table. Determine whether to integrate algorithm logic code based on the content in the algorithm logic column of the system software integration information table.
[0044] The source code file is a C code file generated based on the target file information.
[0045] Specifically, extracting the software interface information from the source code file and mapping the code mainly involves two steps. The first step is to traverse the interface information text file of the target file. The mapped code in this file queries the software API defined in the target file by identifying the source file in the integration interface folder, and copies the variable interface integration code corresponding to the API into the source file.
[0046] D. Automatically compile the source code of the mapped battery management system to generate an executable file.
[0047] The executable file is a file generated by the compiler after all source code files have been successfully compiled, which can be programmed into the battery management system using a program programming device.
[0048] Specifically, the automatic integration program will run the Makefile to compile the target project. During the compilation process, a compilation report will be generated, and any errors will be generated in a fault report to notify the integration engineer to troubleshoot.
[0049] The integrated software is started sequentially, including: starting the startup script file to launch the model design tool and the basic software configuration tool, and generating source code files in addition to the target files.
[0050] E. Perform functional testing, compare the actual running results of the battery management system executable file with the preset values in the target file; determine the integrity of the source code integration based on the comparison results.
[0051] The source code is compiled into the target software and functional tests are performed. A script file automatically copies the interface integration code file and the tool-generated code file to a compilation path, and starts the compilation software to compile the project. After compilation, the script file starts a preset debugging tool, which automatically runs the selected functional test script and outputs a test report after execution.
[0052] Specifically, the functional testing is performed by selecting the functional test items according to the preset file. First, the integrated program starts the debugger and loads the functional test scripts one by one. Then, the test device starts and loads the test scripts corresponding to the debugger functions. Each function is tested and a test report is output. The test report contains the expected values of each function, and the test functional results can be obtained.
[0053] The present invention provides a battery management system source code integration and testing method that can automatically identify and integrate software interfaces, and can also automatically add custom logic code, greatly improving integration efficiency.
[0054] The present invention relates to a battery management system source code integration testing device, comprising an acquisition module, a preset module, a mapping module, an integration module, and a compilation and testing module. The preset module selects a compilation path and test items, and after startup, directly reads the contents of the mapping module through the selected settings items, compiles the project file through the compilation module, and after compilation, tests the battery management system through the testing module.
[0055] The acquisition module is used to acquire all software interface information of the target file and software; the preset module is used to pre-set all necessary information before the device runs, and to call the mapping module and the testing module; the mapping module is used to map the application layer software interface to the basic software interface; the integration module is used to integrate the software interface extracted from the file with the software interface extracted from the source file, and to start other preset software to generate other source code files; the compilation and testing module is used to automatically compile all source code files and call debugging tools to download the code and perform functional testing.
[0056] The acquisition module is specifically used to read source files and system software integration information tables from a preset path, automatically generate an empty source file, read the software interface names from the system software integration information table, copy them sequentially into the empty file, and differentiate the code generation method according to the software interface direction in the system software integration information table. For basic software output interfaces, an "=" sign, application layer software interface variable, and a semicolon are added after the output interface; for input interfaces, an application layer interface variable and an "=" sign are added before the input interface, and a semicolon is generated after the basic software interface variable. For interfaces with special algorithms, there are two main code generation methods: for output interfaces, the algorithm code from the system software integration information table is copied before the interface assignment equation; for input interfaces, the algorithm code from the system software integration information table is copied after the interface assignment equation.
[0057] The preset module can be a host computer, which can set the compilation project path, the storage path of the target file, and the test items. All the necessary information can be preset before the device runs. This module will start a background program, which can call the mapping module and the test module.
[0058] The mapping module uses a table to visually map application-layer software interfaces to basic software interfaces. This table describes the interface direction, the associated function, the generated C file name, and the logic code segments required for integration. When the background program calls this module, it generates C files with corresponding filenames from all interface rows according to pre-defined rules, and then generates the functions and corresponding interface integration code within these files.
[0059] The integration module is specifically used to record the interface of each source file in the preset path. It iterates through the source files that need interface integration; if the interface name matches a keyword found in the source file, the software interface code is copied to the function interface of the source file to be integrated. This process continues until all software interfaces have been integrated, at which point the process stops and an integration report is generated, showing the interface code that was not successfully integrated. This can be manually checked and confirmed. When this module is executed, it reads the project file path in the preset module, calls the compiler to compile all C files in that path, generates an executable file, and then calls the debugger to burn the executable file into the battery management system.
[0060] The compilation and testing module calls the Makefile to compile all files in the preset paths, generating a compilation report that displays whether compilation was successful. If compilation fails, the report shows the reason for the failure. If compilation is successful, the debugger is invoked, the debugger test script in the preset paths is loaded, preset functional tests are performed, and a test report is generated. The testing device can be configured according to the software interface information, file paths, and test items in the preset file to customize the integration testing solution. The entire process is automated, visualized, and systematic, requiring no advanced programming language development skills, thus improving work efficiency and reducing development costs.
[0061] This invention relates to system software integration testing, which is fully automated and configurable. It enables visualization of integration information, with all information presented in tabular form. It requires minimal skill from integration personnel and automates the entire process from integration to testing, significantly improving work efficiency.
[0062] After the integration module completes its execution, it will load the test scripts into the debugger and start the test equipment through the scripts, start the stimulus and load required for the corresponding test items, establish the test environment, and generate a test report after all test scripts have been executed. The test report will show whether the test results of the test item deviate from the preset range. If there is a deviation, it will be displayed as failure; if there is no deviation, it will be displayed as success.
[0063] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein running the computer program executes a method for integrating and testing the source code of the battery management system.
[0064] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A method for integrating and testing the source code of a battery management system, characterized in that, Includes the following steps: A. Configure the preset file and configure the configuration items in the preset file; select the test project in the preset file, configure the interface information in the file, and configure the file path; B. Automatically acquire interface information of the target file of the battery management system; obtain all software interface information of the target software from the system software integration information table. The interface information is pre-stored in the system software integration information table and mainly includes software interface name, data type, interface direction and corresponding algorithm logic. C. Extract the software interface information from the battery management system source code file and perform code mapping; for each source code file to be integrated, read the software interface information, and match the software interface according to the interface name, type and direction of the information extracted from the system software integration information table. Also, determine whether to integrate the algorithm logic code based on the content in the algorithm logic column of the system software integration information table. C1. Traverse the interface information text file of the target file. The code in the file after mapping is completed queries the software API defined in the target file by identifying the source files in the integration interface folder. C2. Copy the variable interface integration code corresponding to the API into the source file; D. Compile the mapped battery management system source code to generate an executable file; the executable file is the file generated by the compiler after all source code files are successfully compiled and then burned into the battery management system through the program burning device; E. Perform functional testing. Compare the actual running results of the battery management system executable file with the preset values in the target file. Based on the comparison results, determine the integrity of the source code integration. According to the functional test items selected in the preset file, first, the automatic integrated program starts the debugger and loads the functional test scripts one by one. Then, the test equipment starts and loads the test scripts corresponding to the debugger functions. Test each function one by one and output a test report. The testing device used in the battery management system source code integration testing method includes an acquisition module for acquiring all software interface information of the target file and software; and an integration module for integrating the software interfaces extracted from the file with the software interfaces extracted from the source file, and starting other preset software to generate other source code files. The compilation and testing module is used to automatically compile all source code files and call debugging tools to download the code and perform functional testing; it also includes a preset module and a mapping module, wherein the preset module is used to pre-set all necessary information before the device is run, and to call the mapping module and the testing module; The mapping module is used to map application layer software interfaces to basic software interfaces.
2. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein running the computer program performs an integrated testing method for the source code of a battery management system as described in claim 1.
Citation Information
Patent Citations
Electronic equipment integration test system and method
CN110674024A
Unit test code file generation method, electronic device and storage medium
CN111459495A