Software adaptation methods, devices, equipment and media for multi-level controllers of energy storage systems
By acquiring and compiling the platform description files and application description files of the multi-level controllers of the energy storage system, firmware adapted to the target controller is generated, which solves the problems of long software development cycle and inconsistency of multi-level controllers in the energy storage system, and realizes efficient reuse and resource matching of software among multi-level controllers.
Patent Information
- Application Number
- CN202611318177.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-28
- Publication Date
- 2026-11-17
AI Technical Summary
In existing technologies, the software development of multi-level controllers in energy storage systems is independent of each other due to differences in hardware platforms and resource configurations, resulting in long development cycles and inconsistencies.
By obtaining the platform description file of the software platform and the application description file of the target controller, the platform source code of the software platform and the application source code of the target controller are compiled based on these files to generate firmware adapted to the target controller, thereby achieving high software reuse among multiple controllers.
This enables high reuse of energy storage software across multiple controllers, reduces development and maintenance costs, shortens the development cycle, and ensures that the generated firmware matches the hardware resources and functional requirements of the target controller.
Smart Images

Figure CN123114475A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of energy storage technology, and more specifically, to a software adaptation method, apparatus, device, and medium for a multi-level controller of an energy storage system. Background Technology
[0002] Energy storage systems typically employ a multi-level controller architecture, with significant differences in the hardware platforms of each level of controller. Low-power controllers typically use Cortex-M3 level processors, running bare metal or lightweight RTOS (Real-Time Operating System), and are resource-constrained; medium-power controllers use Cortex-M4 level processors and run RTOS; while high-power controllers use Cortex-A7 dual-core processors, run Linux systems, and have abundant resources.
[0003] In existing technologies, the software development of each level of the controller is usually independent, with each maintaining its own code branch. Due to differences in operating environment and resource configuration, the implementation of the same functional module varies across different levels. For example, modules such as data access interfaces, communication protocol stacks, and logging need to be developed and maintained separately in each level of the controller. When the underlying hardware platform changes or functional requirements are adjusted, multiple code branches need to be modified synchronously, resulting in a long development cycle and a high risk of inconsistencies.
[0004] Therefore, how to achieve efficient software reuse and flexible adaptation of multi-level controllers under different hardware computing power conditions has become an urgent technical problem to be solved. Summary of the Invention
[0005] This application provides a software adaptation method, apparatus, device, and medium for multi-level controllers of energy storage systems, which can improve the code reuse rate and development efficiency of energy storage software among multi-level controllers.
[0006] In a first aspect, embodiments of this application provide a software adaptation method for a multi-level controller of an energy storage system, the method comprising: Obtain the platform description file of the software platform and the application description file of the target controller in the multi-level controller; the platform description file defines: all capability levels and all software functional modules supported by the software platform; the application description file defines: the computing power level of the target controller, and the information of the functional modules required by the target controller; different capability levels correspond to controllers with different computing power levels; Based on the platform description file and the application description file, the platform source code of the software platform and the application source code of the target controller are compiled to generate firmware adapted to the target controller.
[0007] Optionally, the software platform is an energy storage battery management system (BMS) software platform, and the multi-level controller includes: a battery pack management unit (BMU), a battery cluster control unit (BCU), and a battery array management unit (BAU).
[0008] Optionally, the step of compiling the platform source code of the software platform and the application source code of the target controller according to the platform description file and the application description file to generate firmware adapted to the target controller includes: The platform description file and the application description file are merged to generate the product description file of the target controller; the product description file defines: the capability level and the function enable flag; The firmware adapted to the target controller is generated by compiling the product description file, the platform source code of the software platform, and the application source code of the target controller.
[0009] Optionally, the step of compiling the product description file, the platform source code of the software platform, and the application source code of the target controller to generate firmware adapted to the target controller includes: Read the capability level from the product description file to obtain the capability level identifier; Read the function enable flag from the product description file to obtain conditional compilation instructions; Based on the capability level identifier and the conditional compilation instructions, the platform source code is trimmed to obtain the trimmed platform source code; The trimmed platform source code and the application source code are compiled to generate firmware adapted to the target controller.
[0010] Optionally, the product description file also defines: requirement data object configuration, requirement theme configuration, and requirement link configuration; The method further includes: Read the definition information from the requirement data object configuration, requirement theme configuration, and requirement link configuration in the product description file, and generate strongly typed interface definition information; Read the declaration information from the requirement data object configuration, requirement theme configuration, and requirement link configuration in the product description file, and generate a static initialization table; The step of compiling the trimmed platform source code and the application source code to generate firmware adapted to the target controller includes: Based on the strongly typed interface definition information and the static initialization table, the trimmed platform source code and the application source code are compiled to generate firmware adapted to the target controller.
[0011] Optionally, the step of trimming the platform source code according to the capability level identifier and the conditional compilation instructions to obtain the trimmed platform source code includes: Based on the capability level identifier, the pruning rules corresponding to the target controller are determined; different capability levels correspond to different pruning rules; Based on the function enable flag in the conditional compilation directive, determine the code of the enabled function module from all functional module code in the platform source code; Using the aforementioned trimming rules, the code of the enabled functional module is trimmed to obtain the trimmed platform source code.
[0012] Optionally, the pruning rules include: a set of availability functions corresponding to the capability level; the capability level includes four levels: the first level corresponds to low computing power MCUs, message delivery degenerates to direct call mode, upgrades and maintenance use basic modules, and process isolation is not supported; the second level corresponds to medium computing power MCUs, and the interface supports a limited number of channels; the third level corresponds to high computing power MCUs, and the interface supports more channels; the fourth level corresponds to SoC processors, the interface supports multiple channels, upgrades and maintenance use file system modules, and process isolation is supported; The process involves using the trimming rules to trim the code of the enabled functional module, resulting in the trimmed platform source code, including: The usability feature set in the trimming rules is used to trim the code of the enabled feature module to obtain the trimmed platform source code.
[0013] Optionally, the method further includes: Based on the time-stamping requirements of the data theme in the product description file, determine the time-stamping enable flag of the data object bound to the data theme; The timestamp enable flag is passed to the data object, and the data object is registered to the static initialization table, so that the firmware runtime determines whether to obtain the timestamp based on the timestamp enable flag of the data object.
[0014] Optionally, the platform description file defines a default publishing strategy according to the data object category, with different categories of data objects corresponding to different default publishing times; The application description file configures a custom publishing strategy for the data topic. The custom strategy overrides the default publishing strategy and serves as the actual effective strategy for the data topic. Topics that do not configure the custom strategy will use the default publishing strategy.
[0015] Optionally, before obtaining the platform description file of the software platform and the application description file of the target controller in the multi-level controller, the method further includes: The software platform is divided into functional modules, resulting in multiple functional modules. These multiple functional modules include at least: a data management module, a communication management module, and an auxiliary tool module. There are no circular dependencies among the multiple functional modules. The dependency of the auxiliary tool module on the data management module is an optional dependency. When the auxiliary tool module is not enabled, the dependency relationship is automatically eliminated at compile time. A unified operating system abstraction interface is provided for multiple functional modules, and each functional module is used to access system resources through the operating system abstraction interface when it is invoked.
[0016] Optionally, the data management module provides a unified read / write interface and a publish / subscribe interface. The read / write interface is used to access data objects registered within the controller, and the publish / subscribe interface is used for data exchange between different application modules within the controller. The method further includes: Under the capability level that supports process isolation constraints, the isolation check of the process isolation constraint is compiled into the registration process identifier of the data object at compile time and bound to the read and write interface. The registration process identifier is used to verify at runtime whether the caller is the registration process of the data object. Cross-process access returns an error code at runtime. At the capability level that does not support process isolation constraints, the isolation check of the process isolation constraints is compiled into a no-operation at compile time and bound to the read / write interface.
[0017] Optionally, the communication management module provides a unified transceiver interface, which includes: link identifiers for multiple communication links. Each link identifier only identifies the communication protocol type and does not contain device addressing information. The device addressing information is defined by the application layer in the message payload.
[0018] Optionally, the hardware board of the target controller is a general-purpose PCB, and products with different hardware configurations are produced through BOM-differentiated soldering. Each optional hardware functional module has reserved pads and traces on the PCB. The presence or absence of a module is determined by whether the corresponding device is soldered according to the BOM. The capability parameters in the product description file correspond one-to-one with the BOM soldering configuration, and the initialization code and driver code corresponding to unsoldered modules are automatically trimmed during compilation. The method further includes: After the firmware is burned to the hardware board of the target controller, the status of each hardware functional module on the hardware board is read when the target controller is powered on and started. A consistency check is performed between the status of the hardware functional modules and the corresponding capability parameters in the product description file to obtain the check result. If the verification result indicates that the state of any hardware functional module in the hardware board is inconsistent with the corresponding capability parameter, an alarm will be triggered and operation will be prevented.
[0019] Secondly, embodiments of this application also provide a software adaptation device for a multi-level controller of an energy storage system, the device comprising: The acquisition module is used to acquire the platform description file of the software platform and the application description file of the target controller in the multi-level controller; the platform description file defines: all capability levels and all software functional modules supported by the software platform; the application description file defines: the computing power level of the target controller, and the information of the functional modules required by the target controller; different capability levels correspond to controllers with different computing power levels; The compilation module is used to compile the platform source code of the software platform and the application source code of the target controller according to the platform description file and the application description file, and generate firmware adapted to the target controller.
[0020] Thirdly, embodiments of this application also provide a computer device, including: a processor, a memory, and a bus, wherein the memory stores program instructions executable by the processor, and when the computer device is running, the processor communicates with the memory via the bus, and the processor executes the program instructions to perform the steps of the software adaptation method for a multi-level controller of an energy storage system as described in any of the first aspects.
[0021] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the software adaptation method for a multi-level controller of an energy storage system as described in any of the first aspects.
[0022] This application provides a software adaptation method, apparatus, device, and medium for multi-level controllers in an energy storage system. First, the platform description file of the software platform and the application description file of the target controller are obtained. The platform description file defines all capability levels and software functional modules supported by the platform, while the application description file defines the computing power level of the target controller and its required functional modules. Different capability levels correspond to controllers with different computing power levels. Then, based on the aforementioned platform description file and application description file, the platform source code of the software platform and the application source code of the target controller are compiled to generate firmware precisely adapted to the target controller. Through this method, only the application description file needs to be modified to generate corresponding firmware for each level of controller with different computing power levels and functional requirements. This achieves high reusability of the software platform among multi-level controllers, effectively reducing the development and maintenance costs of energy storage software in scenarios with multiple product lines and multiple controller models, significantly shortening the development cycle, and ensuring that the generated firmware matches the hardware resources and functional requirements of the target controller. Attached Figure Description
[0023] To more clearly illustrate the technical solutions of the embodiments of this application, 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 this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 A flowchart illustrating a software adaptation method for a multi-level controller of an energy storage system provided in an embodiment of this application; Figure 2 A schematic diagram illustrating the process of generating a product description file and compiling it in a software adaptation method for a multi-level controller of an energy storage system provided in this application embodiment; Figure 3 A schematic diagram illustrating the process of generating firmware for the target controller in a software adaptation method for a multi-level controller of an energy storage system provided in this application embodiment; Figure 4 A flowchart illustrating the generation of compilation auxiliary information in a software adaptation method for a multi-level controller of an energy storage system provided in this application embodiment; Figure 5 A flowchart illustrating the process of trimming platform source code in a software adaptation method for a multi-level controller of an energy storage system provided in this application embodiment; Figure 6 A flowchart illustrating the configuration of a data object time stamp enable flag in a software adaptation method for a multi-level controller of an energy storage system provided in this application embodiment; Figure 7 A flowchart illustrating the construction of a software platform architecture in a software adaptation method for a multi-level controller of an energy storage system provided in this application embodiment; Figure 8 A schematic diagram of the software and hardware consistency verification process in a software adaptation method for a multi-level controller of an energy storage system provided in this application embodiment; Figure 9 This is a diagram showing the architecture of a BMS software platform. Figure 10 A schematic diagram of a software adaptation device for a multi-level controller of an energy storage system provided in an embodiment of this application; Figure 11 This is a schematic diagram of a computer device provided in an embodiment of this application. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0026] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0027] It should be noted that similar labels 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.
[0028] Before providing a detailed explanation of this application, let's first introduce its application scenarios.
[0029] In energy storage systems, due to significant differences in computing resources, storage space, and operating system environment among controllers at different levels, traditional software adaptation solutions often develop a separate code branch for each controller level. This results in the same functional module requiring multiple independent code implementations in different controllers, which not only increases the development workload but also makes subsequent functional upgrades and maintenance require synchronous modifications across multiple branches, easily introducing inconsistencies.
[0030] Based on this, this application provides a software adaptation method, apparatus, device, and medium for multi-level controllers in energy storage systems. First, the platform description file of the software platform and the application description file of the target controller are obtained. The platform description file defines all capability levels and all software functional modules supported by the platform, while the application description file defines the computing power level of the target controller and the information of its required functional modules. Different capability levels correspond to controllers with different computing power levels. Then, based on the aforementioned platform description file and application description file, the platform source code of the software platform and the application source code of the target controller are compiled to generate firmware that is precisely adapted to the target controller. This achieves high reusability of the software platform among multi-level controllers, effectively reducing the development and maintenance costs of energy storage software in scenarios with multiple product lines and multiple controller models, significantly shortening the development cycle, and ensuring that the generated firmware matches the hardware resources and functional requirements of the target controller.
[0031] The following explanation, in conjunction with the accompanying drawings, uses several embodiments to illustrate the concepts.
[0032] The software adaptation method for the multi-level controller of the energy storage system provided in this application embodiment can be executed by a computer device pre-configured with a software platform and compilation tools, such as a server or a personal computer.
[0033] Figure 1 A flowchart illustrating a software adaptation method for a multi-level controller of an energy storage system provided in this application embodiment is shown below. Figure 1 As shown, the software adaptation method for the multi-level controller of the energy storage system includes: S101, Obtain the platform description file of the software platform and the application description file of the target controller in the multi-level controller.
[0034] The platform description file defines: all capability levels and all software functional modules supported by the software platform; the application description file defines: the computing power level of the target controller, and information on the functional modules required by the target controller; and controllers with different computing power levels corresponding to different capability levels.
[0035] In one possible implementation, the software platform is a Battery Management System (BMS) software platform, and the multi-level controllers include: a Battery Module Unit (BMU), a Battery Cluster Control Unit (BCU), and a Battery Array Unit (BAU). The following explanation uses the BMS software platform as an example; however, the software adaptation method provided in this application is not limited to battery management systems and can also be applied to other embedded systems with multi-level controller architectures.
[0036] Specifically, the platform description file is pre-written by the platform developers and describes all available capabilities of the BMS software platform. In the platform description file, all software functional modules include at least a data management module, a communication management module, and an auxiliary tool module. The data management module is responsible for providing data read / write and publish / subscribe capabilities; the communication management module is responsible for providing send / receive capabilities for various communication protocols; and the auxiliary tool module is responsible for providing auxiliary capabilities such as log recording, data waveform recording, and remote upgrades.
[0037] Capability levels are categorized by the platform based on the controller's computing power. For example, it can be divided into four levels, with higher levels supporting greater algorithm complexity and data throughput, and correspondingly increasing hardware computing power requirements. For instance, levels one to three typically adapt to MCUs (Microcontroller Units) with different performance levels, meeting needs ranging from basic logic control to complex real-time algorithms; level four addresses scenarios requiring high-performance parallel computing and large-scale data processing, typically adapting to higher-performance processor platforms such as SoCs (System-on-Chip). Furthermore, the platform description file also defines: all data object categories supported by the platform and their corresponding default publishing strategies, as well as all communication protocol types supported by the platform and their corresponding link identifiers. In one possible implementation, the platform description file is written in YAML format, describing all the above-mentioned available capabilities in a structured manner.
[0038] The target controller can be any one of BMU, BCU, or BAU. The application description file (AVF) is written by the application developers based on the product requirements of the target controller, describing its specific computing power level and the actual functional modules required. For example, for a low-end BMU product, its computing power level is Level 1, and the required functional modules only include basic data acquisition and CAN communication; while for a high-end BAU product, its computing power level is Level 4, and the required functional modules include the entire communication protocol stack, data waveform recording, and remote upgrade modules. Furthermore, the AVF also defines: the configuration of each data object required by the target controller, the configuration of each data topic and the corresponding publishing strategy, as well as the configuration of each communication link and the corresponding link identifier. Similarly, in one possible implementation, the AVF is written in YAML format.
[0039] S102, based on the platform description file and application description file, compiles the platform source code of the software platform and the application source code of the target controller to generate firmware adapted to the target controller.
[0040] Specifically, using the platform description file and application description file as configuration inputs, the platform source code of the software platform and the application source code of the target controller are jointly submitted to the compiler for compilation. During the compilation process, the compiler determines the computing power level of the target controller based on the computing power level defined in the application description file, and determines the platform functional modules to be retained based on the functional module information defined in the application description file. Then, the platform source code is adapted and trimmed, retaining only the functional module code that matches the application description file. Simultaneously, the application source code and the trimmed platform source code are compiled and linked to finally generate firmware adapted to the target controller. The firmware only contains the binary code of the functional modules actually enabled by the target controller; the code of inactive functional modules does not occupy firmware storage space.
[0041] In the above Figure 1 Based on the corresponding embodiments, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system.
[0042] In one possible implementation, the data object publishing strategy employs a two-tier configuration mechanism. The first tier is the category default strategy: the platform description file defines default publishing strategies for data object categories, with different categories corresponding to different default publishing times. For example, analog quantity data objects default to a periodic publishing strategy, while state quantity data objects default to a change-based publishing strategy. The second tier is the topic overriding strategy: the application description file configures custom publishing strategies for data topics. When a custom publishing strategy is configured for a data topic in the application description file, the custom strategy overrides the default publishing strategy defined in the platform description file and becomes the actual effective strategy for that data topic; data topics without a configured custom strategy use the default publishing strategy defined in the platform description file.
[0043] Understandably, through the configuration mechanism of the aforementioned two-tiered release strategy, platform developers can uniformly configure the default release timing for various data objects in the platform description file, reducing repetitive configuration work; while product developers can customize release strategies for specific data topics as needed in the application description file, achieving flexible adjustments. The default release strategy and the custom release strategy are managed independently in each configuration file, which reduces configuration redundancy in multi-product scenarios while ensuring customization flexibility for special needs scenarios.
[0044] In this embodiment, only the application description file needs to be changed to generate corresponding firmware for each level of controller with different computing power and functional requirements. This realizes the high reuse of the software platform among multiple controllers, effectively reduces the development and maintenance costs of energy storage software in scenarios with multiple product lines and multiple controller models, significantly shortens the development cycle, and ensures that the generated firmware matches the hardware resources and functional requirements of the target controller.
[0045] In the above Figure 1 Based on the corresponding embodiments, in order to more clearly demonstrate the process of generating product description files, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system. Figure 2 This application provides a schematic diagram illustrating the process of generating a product description file and compiling it in a software adaptation method for a multi-level controller of an energy storage system. Figure 2 As shown, in S102 above, the platform source code of the software platform and the application source code of the target controller are compiled according to the platform description file and the application description file to generate firmware adapted to the target controller, including: S210 merges the platform description file and the application description file to generate the product description file for the target controller.
[0046] The product description file defines the following: the capability level and the function activation flag.
[0047] Specifically, the platform description file and the application description file are merged to generate a complete configuration file for the target controller, namely the product description file. During the merging process, based on the full capability list in the platform description file, and according to the computing power level, required functional module information, and release strategy configuration of each data topic declared in the application description file, the actual capability level, specific functional modules, and corresponding release strategies used by the target controller are selected from the full capability list and written into the product description file.
[0048] More specifically, the capability level in the product description file is determined based on the computing power level in the application description file, and its value is one of the predefined capability levels in the platform description file. The function enable flag is the activation flag for the functional modules required by the target controller. For example, in one possible implementation, the platform description file defines three functional modules: a CAN communication module, an IEC104 communication module, and a data recording module. However, the application description file only requires the CAN communication module. In this case, the function enable flag in the product description file is configured such that the CAN communication module is marked as "enabled," and the other modules are marked as "disabled."
[0049] Understandably, by dividing the platform into two layers—platform description files and application description files—the definition of platform capabilities is decoupled from the definition of product requirements. When a new capability is added to the platform, only the platform description file needs to be modified; all existing product application description files can inherit the configuration options of the new capability without modification. When a new product model is added, only a new application description file needs to be written for that product; the platform description file does not need any modification.
[0050] The S220 compiles the product description file, the platform source code of the software platform, and the application source code of the target controller to generate firmware adapted to the target controller.
[0051] The platform source code is a collection of code for all general functional modules pre-written by the software platform, implementing all software functional modules declared in the platform description file. The application source code is a collection of code for business logic specific to the target controller. For example, when the target controller is a BMU, the application source code may include cell balancing control logic and SOX estimation algorithm. SOX is a general term for battery state estimation, which includes at least the estimation of State of Charge (SOC), State of Health (SOH), and State of Power (SOP). When the target controller is a BAU, the application source code may include protection logic (referring to safety response strategies under fault scenarios such as battery overvoltage, overtemperature, and overcurrent) and black-start logic (referring to the process by which the controller completes power-on startup by relying on its own timing or event detection mechanism without external wake-up signal).
[0052] Specifically, using the capability level and function activation flags defined in the product description file as configuration inputs, the platform source code and application source code are jointly submitted to the compiler for compilation. During compilation, the compiler determines the target controller's computing power level based on the capability level in the product description file, determines the platform function modules to be retained based on the function activation flags, and then performs adaptive trimming on the platform source code, retaining only the function module code matching the function activation flags. Simultaneously, the application source code and the trimmed platform source code are compiled and linked to ultimately generate firmware adapted to the target controller. The firmware only contains the binary code of the function modules actually enabled by the target controller; the code of inactive function modules does not occupy firmware storage space.
[0053] In this embodiment, a product description file is generated by merging the platform description file and the application description file of the target controller. Then, the platform source code is adapted and compiled according to the product description file to generate firmware that matches the computing power level and functional requirements of the target controller. This achieves high reuse of software code among multi-level controllers and significantly reduces the development and maintenance costs of software under a multi-level controller architecture.
[0054] In the above Figure 2 Based on the corresponding embodiments, in order to more clearly demonstrate the process of compiling according to the product description file, platform source code and application source code to generate firmware adapted to the target controller, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system. Figure 3This application provides a schematic diagram illustrating the process of generating firmware for a target controller in a software adaptation method for a multi-level controller of an energy storage system. Figure 3 As shown, in S220 above, the firmware adapted to the target controller is generated by compiling the product description file, the platform source code of the software platform, and the application source code of the target controller, including: S310: Read the capability level from the product description file to obtain the capability level identifier.
[0055] The product description file defines the capability levels, which are selected from all predefined capability levels in the platform description file based on the actual computing power level of the target controller. Capability level identifiers are symbolic marks for the compiler to recognize and process, used to characterize the target controller's computing power level and corresponding resource constraints during the compilation process.
[0056] Specifically, before the compilation phase begins, the code generator reads the capability level field from the product description file and converts it into a macro definition form that the compiler can recognize, namely the capability level identifier, for subsequent trimming and control condition compilation, so that the same set of source code can be adapted to target controllers with different computing power levels.
[0057] S320 reads the feature enable flags from the product description file and obtains the conditional compilation instructions.
[0058] The product description file defines feature enable flags, which indicate whether the required functional modules for the target controller are enabled or disabled. Conditional compilation directives are compiler preprocessor-recognizable macros used to control whether the platform source code corresponding to each functional module participates in the compilation process.
[0059] Specifically, before the compilation phase begins, the code generator iterates through the feature enable flags in the product description file and generates corresponding conditional compilation instructions for each feature module. In one possible implementation, for feature modules with the feature enable flag set to "enabled," corresponding macro definition instructions are generated; for feature modules with the feature enable flag set to "disabled," corresponding macro undefinition instructions are generated, or no instructions are generated.
[0060] Capability level identifiers and conditional compilation directives together form the basis for trimming during compilation. Capability level identifiers determine the overall trimming strategy and intensity, while conditional compilation directives control the specific scope of trimming on a module-by-module basis.
[0061] S330 trims the platform source code based on the capability level identifier and conditional compilation instructions to obtain the trimmed platform source code.
[0062] Specifically, during the preprocessing stage of compilation, the compiler reads the capability level identifier and conditional compilation directives, and trims the platform source code to obtain the trimmed platform source code. For functional modules marked as "enabled" in the conditional compilation directives, the corresponding platform source code is retained; for functional modules marked as "disabled," the corresponding platform source code is deleted. Simultaneously, based on the computing power level information carried in the capability level identifier, the conditional branches related to computing power in the retained functional module source code are further filtered, retaining implementation branches that match the target controller's computing power and deleting implementation branches that do not match the target controller's computing power. The trimmed platform source code only contains the code of functional modules that are actually enabled by the target controller and match its computing power.
[0063] It should be noted that the deleted functional module code will not be included in the subsequent compilation and linking stages, thus minimizing the firmware size.
[0064] The S340 compiles the trimmed platform source code and application source code to generate firmware adapted to the target controller.
[0065] Specifically, the compiler compiles the trimmed platform source code and the target controller's application source code to generate firmware adapted to the target controller. Since the trimmed platform source code only contains the functional module code actually enabled by the target controller, and the capability level identifier has already completed the selection of computing power-related adaptation branches during the compilation process, the final generated firmware matches the hardware computing power and functional requirements of the target controller in both the function set and the underlying implementation.
[0066] In this embodiment, by reading the capability level and function enable flag in the product description file, capability level identifiers and conditional compilation instructions are generated respectively. Based on these, the platform source code is trimmed in the preprocessing stage of compilation. Finally, the trimmed platform source code and application source code are compiled and linked to generate firmware. This avoids the maintenance difficulties of trimming rules being scattered throughout the code in the traditional manual trimming method, and greatly improves the automation level of firmware generation for multiple product models.
[0067] In the above Figure 3 Based on the corresponding embodiments, in order to more clearly demonstrate the process of generating strongly typed interface definition information and static initialization table according to the product description file and using them for compilation, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system. Figure 4 This application provides a schematic diagram illustrating the process of generating compilation auxiliary information in a software adaptation method for a multi-level controller of an energy storage system, as shown in the embodiments of this application. Figure 4 As shown, based on the above S310-S340, the method further includes: In this embodiment, the product description file also defines: requirement data object configuration, requirement topic configuration, and requirement link configuration.
[0068] The requirement data object configuration is used to declare the data objects and their attributes that the target controller needs to access, such as cell voltage, temperature, and fault status. The requirement topic configuration is used to declare the data topics that the target controller needs to use, and each topic is used to carry the publication and subscription of specific types of data. The requirement link configuration is used to declare the communication links and their protocol types that the target controller needs to use.
[0069] S410 reads the definition information from the requirement data object configuration, requirement theme configuration, and requirement link configuration in the product description file, and generates strongly typed interface definition information.
[0070] Specifically, before the compilation phase begins, the code generator reads the requirement data object configuration, requirement topic configuration, and requirement link configuration from the product description file. The definition information refers to the type and structure information of each configuration item, such as the name and data type of the data object, the name and data type of the topic, and the name and protocol type of the link.
[0071] The code generator generates strongly typed interface definition information based on the above definition information. Specifically, the strongly typed interface definition information includes: a unique enumeration constant generated for each data object, used to uniquely identify the corresponding data object at compile time; and a type-checked function declaration, where the parameter types of the function declaration are limited to the aforementioned enumeration constants. This ensures that the data object identifier passed by the caller is type-checked at compile time, avoiding runtime data access exceptions due to incorrect identification.
[0072] In one possible implementation, the product description file declares two data objects for the required data objects: cell voltage and temperature. The code generator then generates an enumeration type definition containing two enumeration constants, corresponding to the two data objects respectively. Simultaneously, it generates a data reading function declaration, where the first parameter is limited to this enumeration type. If the application code passes a non-enumeration type parameter when calling this function, the compiler will directly report an error.
[0073] S420 reads the declaration information from the requirement data object configuration, requirement theme configuration, and requirement link configuration in the product description file and generates a static initialization table.
[0074] Among them, the declaration information refers to the specific values and instantiation information of each configuration item, such as the initial value of the data object, storage address allocation information, topic publication cycle, and specific communication parameters of the link.
[0075] Specifically, the code generator reads the declaration information from the product description file and converts it into a static data structure that the compiler can process, namely the static initialization table. The static initialization table contains attribute information such as the storage address, initial value, and time stamp enable flags of each data object. The static initialization table is generated as an array of constant structures. After compilation, the array is stored in the read-only data segment of the firmware. At runtime, no dynamic parsing is required; the attribute information of each data object is directly read through a fixed address.
[0076] In practice, the definition and declaration information in the requirement data object configuration, requirement theme configuration, and requirement link configuration are defined in separate areas within the same product description file. The code generator distinguishes between definition and declaration information by identifying different keywords or field areas, and executes generation operations S410 and S420 respectively. It can be understood that S410 and S420 are parallel generation operations based on different types of information within the same product description file; there is no strict order of execution between them. In practice, S410 can be executed first, S420 can be executed first, or both generation operations can be executed simultaneously.
[0077] Accordingly, S340 compiles the trimmed platform source code and application source code to generate firmware adapted to the target controller, including: The S430 compiles the trimmed platform source code and application source code based on the strongly typed interface definition information and static initialization table to generate firmware adapted to the target controller.
[0078] Specifically, the trimmed platform source code, the target controller's application source code, strongly typed interface definition information, and static initialization table are all submitted to the compiler as inputs during the compilation phase.
[0079] During compilation, enumeration type definitions and type-checked function declarations in the strongly typed interface definition information participate in type verification during the compilation phase. When the compiler performs syntax analysis on the trimmed platform source code and application source code, it performs type verification on all input parameters of the data access interface calls in the application source code according to the enumeration types specified in the strongly typed interface definition information. If the data object identifier passed by the caller does not match the enumeration type, the compiler directly outputs a type error and terminates compilation, thus preventing data access exceptions caused by incorrect data object identifiers during the compilation phase.
[0080] During the compilation phase, the static initialization table is treated as a constant data structure by the compiler. In the resulting firmware, the storage address and initial value of each data object in the static initialization table are fixed. This constant data is then stored in the read-only data segment of the firmware during the subsequent linking phase. At runtime, the data access interface reads data directly from the fixed address corresponding to that data object in the static initialization table based on the data object identifier passed in by the caller, without requiring any runtime address resolution or dynamic configuration loading.
[0081] After compilation, firmware adapted to the target controller is generated. The firmware includes type information for type verification, as well as read-only constant data for all data objects in the static initialization table. This allows the data access interface to efficiently read the attribute information of each data object in a direct addressing manner when the firmware runs on the target controller. Furthermore, the data object identifier passed by the caller has been type-verified during the compilation phase, fundamentally eliminating data access anomalies caused by incorrect identifiers.
[0082] In this embodiment, by reading the definition and declaration information in the product description file, strong-typed interface definition information and static initialization table are generated respectively, so that data object access errors are detected during the compilation stage. At the same time, zero parsing overhead for runtime data access is achieved, and the compiled firmware is optimized in terms of both security and performance.
[0083] In the above Figure 3 Based on the corresponding embodiments, in order to more clearly demonstrate the process of tailoring the platform source code according to the capability level identifier and conditional compilation instructions, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system. Figure 5 This application provides a flowchart illustrating the process of tailoring the platform source code in a software adaptation method for a multi-level controller of an energy storage system. Figure 5 As shown, in S330 above, the platform source code is trimmed according to the capability level identifier and conditional compilation instructions, resulting in the trimmed platform source code, which includes: S510 determines the pruning rules corresponding to the target controller based on the capability level identifier.
[0084] Different ability levels correspond to different trimming rules.
[0085] Specifically, there is a one-to-one correspondence between capability level identifiers and pruning rules. Based on the capability level identifier of the current target controller, a pruning rule corresponding to that level is matched and selected from a predefined set of pruning rules. Different capability levels correspond to different pruning rules, which define the availability constraints of system resources and the trade-off strategies for functional modules under different computing power levels. For example, in one embodiment, the capability levels are divided into four levels: Level 1 corresponds to low computing power MCUs, and its pruning rule is that it does not support dynamic loading, does not support databases, and does not support complex waveform recording; Level 2 corresponds to medium computing power MCUs, and its pruning rule is that it supports data recording through limited channels but does not support multi-process isolation; Level 3 corresponds to high computing power MCUs, and its pruning rule is that it supports a complete set of functions but has no process isolation requirements; Level 4 corresponds to SoC processors, and its pruning rule is that it supports all functions, including process isolation. By determining the pruning rules that match the capability level of the target controller, it is ensured that the pruned platform source code is adapted to the hardware computing power of the target controller in terms of both function set and resource requirements.
[0086] S520 determines the code for enabling a feature module from all feature module code in the platform source code based on the feature enable flag in the conditional compilation directive.
[0087] Specifically, the code generator reads conditional compilation instructions, traverses each functional module in the platform's source code, and, based on the functional enable flag corresponding to each functional module, filters out the code of functional modules with the functional enable flag set to "enabled" from all functional module code, marking them as the code of enabled functional modules to be retained; the code of functional modules with the functional enable flag set to "disabled" is marked as the code to be deleted.
[0088] S530 uses a trimming rule to trim the code of enabled functional modules, resulting in the trimmed platform source code.
[0089] Specifically, the code for enabling functional modules typically contains multiple implementation branches targeting different capability levels. The compiler first deletes the code for non-enabled functional modules entirely, preventing subsequent compilation. Then, based on the specific constraints in the pruning rules corresponding to the current target controller's capability level, it retains the implementation branches in the code for enabling functional modules that match the target controller's computing power, and deletes those that do not. For example, in one possible implementation, the data management module code contains two implementation branches depending on whether process isolation is supported: when the target controller is at the fourth capability level (supporting process isolation), the implementation branch containing process isolation logic is retained; when the target controller is at the first capability level (not supporting process isolation), the implementation branch without process isolation logic is retained.
[0090] After the above processing, the trimmed platform source code is obtained. The trimmed platform source code contains only the code of the functional modules actually enabled by the target controller, and among the code of each retained functional module, only the implementation branches that match the computing power level of the target controller are included. Thus, the trimmed platform source code precisely matches the target controller in both the functional set and the underlying implementation dimensions.
[0091] In this embodiment, by determining the trimming rules that match the target controller based on the capability level identifier, filtering out the code of the enabled functional modules from the full platform source code based on the function enable flag in the conditional compilation instructions, and then trimming the code of the enabled functional modules using the trimming rules, the organic combination of computing power adaptation trimming at the capability level dimension and module on-demand trimming at the function enable dimension is achieved. Controllers with different computing power levels share the same set of platform source code, and the trimming process is completed automatically, which greatly improves the efficiency of firmware generation for multiple product models.
[0092] In the above Figure 5 Based on the corresponding embodiments, to more clearly demonstrate the process of trimming the code of the enabled functional module using trimming rules, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system. Optionally, in S530 above, the code of the enabled functional module is trimmed using trimming rules, resulting in the trimmed platform source code, which includes: In this embodiment, the pruning rules include: a set of usability features corresponding to the capability level.
[0093] Capability levels are divided into four levels from low to high, each corresponding to a different set of available functions. The four levels are: Level 1 corresponds to low-performance MCUs, where message delivery degenerates to a direct call mode, upgrades and maintenance use basic modules, and process isolation is not supported; Level 2 corresponds to medium-performance MCUs, with limited interface channels; Level 3 corresponds to high-performance MCUs, with multiple interface channels; and Level 4 corresponds to SoC processors, with multiple interface channels, upgrades and maintenance using file system modules, and support for process isolation. For example, the set of availability features corresponding to each capability level is shown in Table 1 below: Table 1. Diagram of the available function sets corresponding to capability levels
[0094] Among them, the message sending column indicates the implementation method of message delivery mechanism between application modules: general modules indicate that all levels support message sending function; the interface list indicates the number and capability of communication interface channels provided by the target controller; the upgrade and maintenance column indicates the implementation method of firmware upgrade function: basic modules indicate that upgrade is completed through simple protocol, and file system modules indicate upgrade mechanism based on file system; the process isolation column indicates whether data isolation and access control between multiple processes are supported.
[0095] S610 uses the set of usability features in the trimming rules to trim the usability features of the code of the enabled feature modules, resulting in the trimmed platform source code.
[0096] Specifically, the set of usability features in the trimming rules defines a set of available features for each capability level.
[0097] During the preprocessing stage, the compiler, based on the target controller's capability level, retrieves the set of usability features corresponding to that capability level from the pruning rules and performs usability feature pruning on the code of the enabled feature modules. Within the code of the enabled feature modules, the same feature module can contain multiple implementation branches corresponding to different feature levels. The compiler reads the feature identifier associated with each feature one by one and matches that feature identifier with entries in the usability feature set: if the feature identifier belongs to the usability feature set, the implementation branch corresponding to that feature is retained; otherwise, the implementation branch is not included in the compilation scope.
[0098] For example, the communication management module code contains multiple implementation branches for different numbers of channels: a first implementation branch supporting a limited number of channels, a second implementation branch supporting more channels, and a third implementation branch supporting multiple channels. When the target controller's capability level is level two, the interface entry in the availability feature set is defined as "Support (Limited Channels)". During pruning, the compiler retains the first implementation branch corresponding to "Limited Channels" and prunes the second and third implementation branches. When the target controller's capability level is level four, the interface entry in the availability feature set is defined as "Support (Multi-Channels)". During pruning, the preprocessor retains the third implementation branch corresponding to "Multi-Channels".
[0099] For example, the message sending mechanism in the communication management module has two implementation branches: direct invocation and full message queue. When the target controller's capability level is Level 1, the message sending in the availability feature set is defined as "degenerate mode (direct invocation)," and the compiler retains the implementation branch of the direct invocation mode while pruning the implementation branch of the full message queue mode. When the target controller's capability level is Level 4, the message sending in the availability feature set is defined as "full mode," and the compiler retains the implementation branch of the full message queue mode while pruning the implementation branch of the direct invocation mode.
[0100] For example, the data management module code contains two implementation branches: one that supports process isolation and one that does not. When the target controller's capability level is Level 1, the process isolation entry in the availability feature set is defined as "not supported." During pruning, the compiler retains the implementation branch corresponding to "not supported" and prunes the implementation branch that supports process isolation. When the target controller's capability level is Level 4, the process isolation entry in the availability feature set is defined as "supported." During pruning, the compiler retains the implementation branch corresponding to "supported" and prunes the implementation branch that does not support process isolation.
[0101] Understandably, usability feature tailoring is a further refinement of the feature module selection process. Determining the code for enabled feature modules is a holistic selection at the feature module level, deciding which feature modules to retain and which to delete. This step, however, is a selection at the feature characteristic level within each feature module. Within the code of the already selected retainable feature modules, it further determines whether to retain or delete the specific implementation code corresponding to each feature within that feature module, based on the feature entries in the usability feature set.
[0102] In this embodiment, the compiler determines the corresponding set of available functions based on the capability level of the target controller, and filters the implementation of each functional feature within the code of the enabled functional module item by item, retaining the code that matches the set of available functions and deleting the code that does not match the set of available functions, thereby further improving the matching accuracy between the firmware and the hardware computing power of the target controller.
[0103] In the above Figure 4 Based on the corresponding embodiments, in order to more clearly demonstrate the process of configuring the time-stamp enable flag of the data object and registering it to the static initialization table, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system. Figure 6 This is a flowchart illustrating the configuration of the data object time-stamp enable flag in a software adaptation method for a multi-level controller of an energy storage system provided in an embodiment of this application. Figure 6 As shown, based on the above S410-S430, the method further includes: S710 determines the time-stamping enable flag of the data object bound to the data subject based on the time-stamping requirements of the data subject in the product description file.
[0104] The product description file defines requirement topic configurations. Each data topic declares corresponding timestamp requirements during configuration. Timestamp requirements indicate whether the data carried by that data topic needs to carry timestamps. The timestamp enable flag indicates at runtime whether the data object needs to obtain a system timestamp.
[0105] Specifically, the code generator reads the requirement theme configuration from the product description file and iterates through the time stamp requirement field of each data theme. For each data theme, based on its declared time stamp requirement, it determines whether the data theme needs a timestamp. Subsequently, based on the binding relationship between the data theme and data objects, the code generator finds the data object bound to the data theme and passes the time stamp requirement of the data theme to the corresponding data object.
[0106] In practice, a data object may be bound to multiple data topics simultaneously. When multiple data topics are bound to the same data object, their timestamp requirements may not be entirely consistent: some data topics may require a timestamp, while others may not. If any one of the data topics requires a timestamp, the timestamp enable flag for that data object is determined to be true (i.e., a timestamp needs to be obtained); if all bound data topics do not require a timestamp, the timestamp enable flag for that data object is determined to be false (i.e., a timestamp does not need to be obtained).
[0107] The S720 passes the timestamp enable flag to the data object and registers the data object to the static initialization table so that the firmware can determine whether to obtain the timestamp at runtime based on the timestamp enable flag of the data object.
[0108] Specifically, the time stamp enable flag of each data object is registered as an attribute of the data object, along with other attribute information such as the data object's storage address and initial value, in the static initialization table. After registration, the static initialization table stores complete attribute information for each data object, including the time stamp enable flag of that data object.
[0109] During firmware runtime, when the read / write or publish / subscribe interface of the data management module is called to access a data object, the interface reads the timestamp enable flag of the data object from the static initialization table. If the timestamp enable flag is true, the time acquisition interface is called to obtain the current timestamp, and the timestamp is encapsulated together with the data value and returned to the caller; if the timestamp enable flag is false, the data value is returned directly, and the time acquisition interface is not called.
[0110] Understandably, the timestamp enable flag is determined and fixed in the static initialization table during the compilation phase. The runtime data access interface only needs to read this flag to determine whether to obtain the timestamp, without performing any runtime judgments related to configuration parsing. By moving the decision on timestamp requirements from runtime to compile time, it not only meets the differentiated requirements of different data objects carrying timestamps on demand, but also eliminates the additional overhead required for dynamic runtime judgment, making it particularly suitable for energy storage control scenarios with high real-time requirements.
[0111] In this embodiment, the code generator determines the time stamp enable flag of the data object bound to the data subject according to the time stamp requirements of the data subject in the product description file, and registers the flag to the static initialization table. At runtime, it only needs to query the time stamp enable flag of the data object itself to determine whether to obtain the system time. This satisfies the different timestamp requirements of different data while ensuring the real-time performance of the system.
[0112] In the above Figure 1 Based on the corresponding embodiments, in order to more clearly demonstrate the process of dividing the software platform into functional modules and configuring the operating system abstract interface, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system. Figure 7 A flowchart illustrating the construction of a software platform architecture in a software adaptation method for a multi-level controller of an energy storage system provided in this application embodiment is shown below. Figure 7 As shown, before obtaining the platform description file of the software platform and the application description file of the target controller in the multi-level controller in S101 above, the method further includes: S810 divides the software platform into functional modules, resulting in multiple functional modules.
[0113] The system comprises at least three functional modules: a data management module, a communication management module, and an auxiliary tool module. There are no circular dependencies between these modules. The dependency of the auxiliary tool module on the data management module is optional; this dependency is automatically eliminated at compile time when the auxiliary tool module is not enabled.
[0114] Specifically, when building the software platform, it is first modularized according to functional boundaries. The data management module is responsible for the registration, storage, and access management of all data objects within the controller, including providing unified data read / write interfaces and publish / subscribe interfaces, as well as managing data interaction carriers such as shared memory, lightweight databases, and message queues. The communication management module is responsible for the scheduling and transmission / reception of external communication protocols, including the management of multiple communication protocol stacks such as CAN, Modbus, and IEC104, and providing unified transmit / receive interfaces. The auxiliary tools module is responsible for auxiliary support functions such as log recording, data waveform recording, and remote upgrades.
[0115] The functional modules employ an orthogonal design, eliminating circular dependencies between them. Specifically, the dependency of the auxiliary tool module on the data management module is designed as an optional dependency. When a specific auxiliary tool module is not enabled in the configuration, this dependency is automatically eliminated during compilation. For example, when the data recording function is not enabled in the product configuration, the source file corresponding to the recording module is not included in the compilation and linking process, thus eliminating the dependency of the recording module on the data management module and avoiding unnecessary code coupling and firmware bloat.
[0116] The S820 provides a unified operating system abstraction interface for multiple functional modules, which can be used by each functional module to access system resources through the operating system abstraction interface when called.
[0117] Specifically, an Operating System Abstraction Layer (OSAL) is built between the functional modules and the underlying operating system. The OSAL provides a set of standardized operating system abstraction interfaces to the upper-level functional modules, including at least: mutex lock interface, message queue interface, time service interface, inter-kernel communication interface, and thread management interface.
[0118] During runtime, each functional module accesses underlying system resources through the operating system abstraction interface provided by the operating system abstraction layer (OSA), without directly calling any specific operating system's (such as FreeRTOS or Linux) private APIs (Application Programming Interfaces). Internally, the OSA maps the calls to each OSA to the corresponding native APIs of the target operating system based on the actual operating system type running on the target controller (bare metal, RTOS, or Linux). When functional modules access system resources by calling the OSA, the OSA performs the mapping and adaptation to the target operating system's native APIs at the underlying level. For example, when the target controller is running bare metal, calls to the thread management interface are mapped to no-operations or direct function calls; when the target controller is running RTOS, calls to the thread management interface are mapped to RTOS task creation functions; and when the target controller is running Linux, calls to the thread management interface are mapped to Linux thread creation functions.
[0119] In practice, the functional module division and abstract interface configuration work together to form the basic architecture of the software platform. Each functional module accesses system resources through the operating system abstract interface, and its upper-layer application code does not need to be concerned with the differences in the underlying operating system; at the same time, the specific implementation of the operating system abstract interface varies depending on the target controller's operating environment, and the upper-layer functional module code can adapt to different operating system environments without any modification.
[0120] In this embodiment, the software platform is orthogonally divided into functional modules, and a unified operating system abstraction interface is constructed. This allows each functional module to access system resources through this abstraction interface, decoupling the upper-layer business logic from the lower-layer operating system. Using this approach, the different operating system environments running on the three-level controllers are shielded by the operating system abstraction layer. Upper-layer functional module code does not need to be developed and maintained separately for different controllers; a single codebase can be reused across multiple controllers, significantly reducing the complexity and maintenance costs of cross-platform porting.
[0121] In the above Figure 7 Based on the corresponding embodiments, to more clearly demonstrate the differentiated compilation and processing of process isolation constraints under different capability levels, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system. Optionally, based on the above S810-S820, the method further includes: In this embodiment, the data management module provides a unified read / write interface and a publish / subscribe interface. The read / write interface is used to access data objects registered within this controller, and the publish / subscribe interface is used for data exchange between different application modules within this controller.
[0122] Different capability levels support different levels of process isolation: some capability levels support process isolation constraints, while others do not.
[0123] S910, under the capability level that supports process isolation constraints, compiles the isolation check of process isolation constraints into the registration process identifier of the data object at compile time and binds it to the read and write interface. The registration process identifier is used at runtime to verify whether the caller is the registration process of the data object. Cross-process access returns an error code at runtime.
[0124] Specifically, when the target controller's capability level supports process isolation constraints, the code generator obtains the registration process identifier of each data object from the product description file during compilation. This registration process identifier is used as the basis for process isolation constraint checks and bound to the read / write interface of the data management module. The compiled firmware contains process isolation verification logic embedded in the read / write interface.
[0125] During firmware runtime, when a caller accesses a data object through the read / write interface, the read / write interface first obtains the caller's process identifier and compares it with the registered process identifier of the data object already bound to the read / write interface. If the caller's process identifier matches the registered process identifier, the access is allowed, and the read / write interface returns the value of the data object normally; if they do not match, it is determined to be a cross-process access, the read / write interface returns an error code, and the access is rejected.
[0126] In S920, at the capability level that does not support process isolation constraints, the isolation check of process isolation constraints is compiled into a no-operation at compile time and bound to the read-write interface.
[0127] Specifically, when the target controller's capability level is one that does not support process isolation constraints, the code generator compiles the process isolation constraint isolation check as a no-operation during compilation. The resulting firmware does not contain any process isolation verification logic in its read / write interfaces.
[0128] During firmware runtime, when a caller accesses a data object through the read / write interface, the interface directly returns the value of the data object without performing any comparison between the caller's process identifier and the registered process identifier. Therefore, at capability levels that do not support process isolation, the isolation check for process isolation constraints incurs no runtime overhead in the firmware, and the firmware execution flow is completely consistent with that when process isolation constraints are not configured.
[0129] At the same time, data exchange between application modules must be achieved through the publish-subscribe interface, and direct data transfer between modules is not allowed through other channels.
[0130] In this embodiment, by performing differentiated compilation processing on the isolation checks of process isolation constraints based on the capability level of the target controller during compilation, it is not necessary to maintain multiple sets of code branches for different capability levels. One set of source code can cover the entire series of controllers from those that support to those that do not support process isolation.
[0131] In the above Figure 7 Based on the corresponding embodiments, in order to more clearly demonstrate the specific implementation of separating link identifier and device addressing information in the communication management module, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system.
[0132] In this embodiment, the communication management module provides a unified transmit / receive interface, which includes: link identifiers for multiple communication links. Each link identifier only identifies the communication protocol type and does not contain device addressing information. The device addressing information is defined by the application layer in the message payload.
[0133] Specifically, the communication management module provides a unified transmit / receive interface for upper-layer applications, shielding the differences between underlying communication protocols. The communication management module maintains multiple communication links, each corresponding to a specific communication protocol type, such as CAN, Modbus, or IEC104. Each communication link is assigned a link identifier, which is used solely to identify the communication protocol type used by that link.
[0134] In practice, device addressing information (such as the CAN bus message ID, device address in the IEC104 protocol, etc.) is not processed by the communication management module, nor is it included in the link identifier. The device addressing information is written into the payload of the message when the application layer constructs the message to be sent. After receiving the message submitted by the application layer, the communication management module only determines which communication link the message should be sent through based on the link identifier, and delivers the message completely to the physical layer for transmission, without parsing or processing the device addressing information in the message payload.
[0135] In the receiving direction, after receiving a message from the physical layer, the communication management module determines the corresponding link identifier based on the communication link that received the message. It then delivers the link identifier along with the device addressing information in the message payload to the application layer, which distributes and processes the message based on the device addressing information in the payload. The same physical link supports multiple asynchronous receiving subscribers. The communication management module distributes different messages received on the same link to different subscribers based on the message type or the device addressing information in the payload.
[0136] By separating the link identifier from the device addressing information, when a product switches from one communication protocol to another (e.g., from CAN to IEC104), the logic for constructing messages at the application layer remains unchanged; only the link identifier in the configuration needs to be adjusted. Similarly, when the target device address changes under the same communication protocol, the application layer only needs to modify the address field in the message payload; the transceiver interface of the communication management module requires no modification. Thus, the communication management module is decoupled from specific device addressing, and protocol switching and address changes are transparent to the communication management module, further improving the software platform's adaptability and code reusability across different communication scenarios.
[0137] In the above Figure 1 Based on the corresponding embodiments, in order to more clearly demonstrate the process of software and hardware consistency verification after firmware burning, this application also provides a possible implementation of a software adaptation method for a multi-level controller of an energy storage system. Figure 8 This application provides a schematic diagram of the software and hardware consistency verification process in a software adaptation method for a multi-level controller of an energy storage system, as illustrated in the embodiments of this application. Figure 8 As shown, based on the above S101-S102, the method further includes: In this embodiment, the hardware board of the target controller is a general PCB. Different hardware configurations are produced by different soldering through BOM differentiation. Each optional hardware function module has reserved pads and traces on the PCB. Whether the corresponding device is soldered in the BOM table determines whether the module exists. The capability parameters in the product description file correspond one-to-one with the BOM soldering configuration. During compilation, the initialization code and driver code corresponding to the unsoldered modules are automatically trimmed.
[0138] S1010, after burning the firmware to the hardware board of the target controller, reads the status of each hardware function module on the hardware board when the target controller is powered on and started.
[0139] The status of the hardware function module is used to indicate whether the hardware function module actually exists on the hardware board or has been enabled.
[0140] In one possible implementation, the hardware board is a dedicated PCB designed specifically for the target controller. The placement of each hardware functional module on the PCB is determined during the PCB design phase based on the functional requirements of the target controller. In another possible implementation, the hardware board uses a generic PCB design, where the same PCB is used to produce products with different hardware configurations through differentiated soldering methods based on the BOM (Bill of Materials). Specifically, the generic PCB reserves all pads and traces for all optional hardware functional modules (e.g., CAN communication module, IEC104 communication module, high-precision sampling module, etc.). The presence or absence of a hardware functional module is determined by whether the corresponding component is soldered in the BOM. When a hardware functional module is configured to be soldered in the BOM, the corresponding component is mounted on the PCB, and the hardware functional module actually exists; when a hardware functional module is configured not to be soldered in the BOM, the corresponding component is not mounted, and the hardware functional module does not actually exist. During compilation, the compiler adapts the platform source code according to the capability parameters in the product description file. The initialization code and driver code corresponding to the unsoldered modules are not included in the compilation, so that the compiled firmware does not contain any related code of the unsoldered modules, realizing automatic linkage between hardware configuration and software tailoring.
[0141] Regardless of whether the general PCB approach or the independent PCB approach is used, each optional hardware functional module has a corresponding hardware status detection pin reserved during the PCB design phase. This pin is connected to the MCU's general-purpose input / output port. When a hardware functional module is actually soldered with the corresponding component on the hardware board, its corresponding hardware status detection pin outputs the corresponding status signal.
[0142] After the target controller is powered on, the MCU first executes the hardware detection program in the firmware. By reading the level status of each hardware status detection pin, it obtains the actual soldering status of each hardware functional module on the hardware board.
[0143] S1020 performs a consistency check between the status of the hardware functional modules and the corresponding capability parameters in the product description file, and obtains the check result.
[0144] The capability parameters in the product description file include the enable flags for each functional module declared by the target controller during the configuration phase, which are used to indicate the hardware functional modules that the target controller is expected to enable at the software level.
[0145] Specifically, after obtaining the actual soldering status of each hardware functional module, the firmware reads the corresponding enable flags of each functional module from the product description file to obtain the enable status of each hardware functional module as expected by the target controller at the software level. Subsequently, the firmware compares the obtained actual soldering status of each hardware functional module with the enable flags of the corresponding functional modules in the product description file one by one: if the actual soldering status and enable flag of a certain functional module are both "present / enabled" or both are "absent / disabled", then the consistency check of that functional module passes; if the actual soldering status of a certain functional module is "present" but the enable flag is "disabled", or the actual soldering status is "absent" but the enable flag is "enabled", then the consistency check of that functional module fails.
[0146] For example, if the CAN communication module's enable flag is "enabled" in the product description file, but the hardware status of the CAN communication module read is "not soldered", then the CAN communication module verification will fail.
[0147] S1030 If the verification result indicates that the status of any hardware functional module in the hardware board is inconsistent with the corresponding capability parameter, an alarm will be triggered and operation will be stopped.
[0148] Specifically, if any functional module fails verification during the comparison process, it is determined that there is a hardware-software mismatch, meaning the actual hardware configuration of the hardware board does not match the expected software configuration declared in the product description file. In this case, the firmware triggers an alarm, which may be triggered by one or more combinations of methods, including but not limited to: illuminating a fault indicator light, outputting an alarm log, and sending an alarm message to the remote monitoring system. Simultaneously, the firmware prevents the startup and operation of subsequent business logic, keeping the target controller in a safe stop state to avoid unpredictable behavior or equipment damage caused by hardware-software mismatch.
[0149] If the actual soldering status of all hardware functional modules is consistent with the corresponding capability parameters in the product description file, the verification is successful, the firmware continues to execute the subsequent initialization process and business logic, and the target controller starts up and runs normally.
[0150] In this embodiment, by reading the actual status of each hardware functional module on the hardware board after the target controller is powered on and performing a consistency check with the capability parameters in the product description file, and triggering an alarm and stopping operation when the check fails, the on-site failures caused by problems such as the incompatibility between the PCB version and the firmware version are avoided, thereby improving the reliability and maintainability of operation.
[0151] To more clearly illustrate the specific module composition and hierarchical relationship of the software platform proposed in this application, this application also provides a schematic diagram of the overall architecture of the software platform for a software adaptation method of a multi-level controller for an energy storage system. Figure 9 A diagram showing the architecture of a BMS software platform, such as... Figure 9 As shown on the right, from bottom to top, it consists of the hardware board (PCBA) layer, the hardware adapter (HAL) layer, the software platform layer, the interface (API) layer, and the application (APP) layer. The bottom layer is the physical hardware carrier of the multi-level controllers, from PCBA1 to PCBA3. Above this is the hardware adapter layer, which contains a dedicated OSAL (Operating System Abstraction Layer) and low-level drivers. The OSAL provides an operating system abstraction interface to the upper layers, effectively shielding the different operating system environments below, such as bare metal, RTOS, or Linux. Above that is the software platform layer, which is further divided into a data management module, an auxiliary tool module, and a communication management module. The data management module includes data interaction via shared memory, a lightweight database, and a message queue. The auxiliary tools module handles log recording, data logging, and OTA (Over-The-Air) remote upgrades. The communication management module includes communication protocols such as Modbus, CAN, and 104. The software platform layer connects to the upper application (APP) layer through three types of APIs: data API, tool API, and communication API. The application (APP) layer contains the specific business logic of the BMU, BCU, and BAU, such as the SOX algorithm, equalization protection, power estimation, protection logic, and black-start logic. Figure 9 On the left side, there are platform YAML files pre-built by platform developers, application YAML files written for the specific needs of each controller product (such as BAU application YAML, BMU application YAML, BCU application YAML), and product description files generated by merging the two. Figure 9 The overall presentation clearly demonstrates how the software adaptation method establishes a mapping relationship between the platform source code and multi-level controllers, realizing the isolation and combination of platform capabilities and specific product requirements.
[0152] The following describes the software adaptation device and computer equipment for a multi-level controller of an energy storage system provided in this application, and the specific implementation process and technical effects are described above, and will not be repeated below.
[0153] Figure 10 A schematic diagram of a software adaptation device for a multi-level controller of an energy storage system provided in this application embodiment is shown below. Figure 10 As shown, the software adaptation device for the multi-level controller of the energy storage system includes: The acquisition module 1000 is used to acquire the platform description file of the software platform and the application description file of the target controller in the multi-level controller. The platform description file defines: all capability levels supported by the software platform and all software functional modules. The application description file defines: the computing power level of the target controller and the information of the functional modules required by the target controller. Different capability levels correspond to controllers with different computing power levels. Compiler Module 2000 is used to compile the platform source code of the software platform and the application source code of the target controller based on the platform description file and the application description file, and generate firmware adapted to the target controller.
[0154] Optionally, the software platform is an energy storage battery management system (BMS) software platform, and the multi-level controllers include: battery pack management unit (BMU), battery cluster control unit (BCU), and battery array management unit (BAU).
[0155] Optionally, the software adaptation device for the multi-level controller of the energy storage system also includes a generation module 3000, which is used to merge the platform description file and the application description file to generate a product description file for the target controller. The product description file defines the capability level and function enable flag. Based on the product description file, the platform source code of the software platform, and the application source code of the target controller, firmware adapted to the target controller is generated.
[0156] Optionally, the software adaptation device for the multi-level controller of the energy storage system also includes a trimming module 4000, which is used to read the capability level in the product description file to obtain the capability level identifier; read the function enable flag in the product description file to obtain the conditional compilation instructions; trim the platform source code according to the capability level identifier and the conditional compilation instructions to obtain the trimmed platform source code; and compile the trimmed platform source code and the application source code to generate firmware adapted to the target controller.
[0157] Optionally, the compilation module 2000 is specifically used to read the definition information in the product description file, which also defines: requirement data object configuration, requirement theme configuration, and requirement link configuration, and generate strongly typed interface definition information; read the declaration information in the requirement data object configuration, requirement theme configuration, and requirement link configuration, and generate a static initialization table; and compile the trimmed platform source code and application source code according to the strongly typed interface definition information and the static initialization table to generate firmware adapted to the target controller.
[0158] Optionally, the trimming module 4000 is specifically used to determine the trimming rules corresponding to the target controller based on the capability level identifier; different capability levels correspond to different trimming rules; based on the function enable flag in the conditional compilation instructions, the code of the enabled function module is determined from all function module codes in the platform source code; the trimming rules are used to trim the code of the enabled function module to obtain the trimmed platform source code.
[0159] Optionally, the trimming module 4000 is specifically used for trimming rules including: a set of availability functions corresponding to the capability level; the capability level includes four levels: Level 1 corresponds to low computing power MCUs, message delivery degenerates to direct call mode, upgrades and maintenance use basic modules, and process isolation is not supported; Level 2 corresponds to medium computing power MCUs, and the interface supports a limited number of channels; Level 3 corresponds to high computing power MCUs, and the interface supports more channels; Level 4 corresponds to SoC processors, the interface supports multiple channels, upgrades and maintenance use file system modules, and process isolation is supported; using the availability function set in the trimming rules, the code of the enabled function modules is trimmed for availability functions to obtain the trimmed platform source code.
[0160] Optionally, the software adaptation device of the multi-level controller of the energy storage system also includes a configuration module 5000, which is used to determine the time stamp enable flag of the data object bound to the data subject according to the time stamp requirements of the data subject in the product description file; pass the time stamp enable flag to the data object, and register the data object to the static initialization table, so that the firmware can decide whether to obtain the timestamp based on the time stamp enable flag of the data object at runtime.
[0161] Optionally, the platform description file defines a default publishing strategy based on data object categories, with different default publishing times corresponding to different data object categories; the application description file configures a custom publishing strategy for a data topic, which overrides the default publishing strategy and serves as the actual effective strategy for the data topic; topics without a configured custom strategy follow the default publishing strategy.
[0162] Optionally, the configuration module 5000 is also used to divide the software platform into functional modules, resulting in multiple functional modules, which include at least: a data management module, a communication management module, and an auxiliary tool module; there are no circular dependencies among the multiple functional modules, and the dependency of the auxiliary tool module on the data management module is an optional dependency. When the auxiliary tool module is not enabled, the dependency relationship is automatically eliminated at compile time; a unified operating system abstraction interface is provided for the multiple functional modules, and each functional module is used to access system resources through the operating system abstraction interface when it is called.
[0163] Optionally, the compilation module 2000 also provides a unified read / write interface and publish / subscribe interface for the data management module. The read / write interface is used to access data objects registered within this controller, and the publish / subscribe interface is used for data exchange between different application modules within this controller. Under the capability level that supports process isolation constraints, the isolation check of the process isolation constraint is compiled into the registration process identifier of the data object during compilation and bound to the read / write interface. The registration process identifier is used at runtime to verify whether the caller is the registration process of the data object. Cross-process access returns an error code at runtime. In capability levels that do not support process isolation constraints, the isolation check of process isolation constraints is compiled into a no-operation at compile time and bound to the read / write interface.
[0164] Optionally, the configuration module 5000 is also used to provide a unified transmit and receive interface for the communication management module. The transmit and receive interface includes: link identifiers for multiple communication links. The link identifiers for each communication link only identify the communication protocol type and do not contain device addressing information. The device addressing information is defined by the application layer in the message payload.
[0165] Optionally, the software adaptation device for the multi-level controller of the energy storage system also includes a verification module 6000. The hardware board of the target controller is a general-purpose PCB. Different hardware configurations are produced by different soldering through BOM differentiation. Each optional hardware functional module has reserved pads and traces on the PCB. The presence or absence of a module is determined by whether the corresponding device is soldered according to the BOM. The capability parameters in the product description file correspond one-to-one with the BOM soldering configuration. During compilation, the initialization code and driver code corresponding to the unsoldered modules are automatically trimmed. After the firmware is burned to the hardware board of the target controller, the status of each hardware functional module on the hardware board is read when the target controller is powered on. The consistency is verified between the status of the hardware functional modules and the corresponding capability parameters in the product description file to obtain the verification result. If the verification result indicates that the status of any hardware functional module on the hardware board is inconsistent with the corresponding capability parameter, an alarm is triggered and operation is stopped.
[0166] These modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more digital signal processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a system-on-a-chip (SOC).
[0167] Figure 11 This is a schematic diagram of a computer device provided in an embodiment of this application.
[0168] The computer device 10 includes a processor 11, a storage medium 12, and a bus 13. The storage medium 12 stores program instructions executable by the processor 11. When the computer device 10 is executed, the processor 11 communicates with the storage medium 12 via the bus 13, and the processor 11 executes the program instructions to perform the above-described method embodiment. The specific implementation and technical effects are similar and will not be described in detail here.
[0169] Optionally, this application also provides a program product, such as a computer-readable storage medium, including a program that, when executed by a processor, performs the above-described method embodiments.
[0170] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0171] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0172] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.
[0173] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0174] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A software adaptation method for a multi-level controller of an energy storage system, characterized in that, The method includes: Obtain the platform description file of the software platform and the application description file of the target controller in the multi-level controller; the platform description file defines: all capability levels and all software functional modules supported by the software platform; the application description file defines: the computing power level of the target controller, and the information of the functional modules required by the target controller; different capability levels correspond to controllers with different computing power levels; Based on the platform description file and the application description file, the platform source code of the software platform and the application source code of the target controller are compiled to generate firmware adapted to the target controller.
2. The method of claim 1, wherein, The software platform is a battery management system (BMS) software platform, and the multi-level controller includes: a battery pack management unit (BMU), a battery cluster control unit (BCU), and a battery array management unit (BAU).
3. The method of claim 1, wherein, The step of compiling the platform source code of the software platform and the application source code of the target controller according to the platform description file and the application description file to generate firmware adapted to the target controller includes: The platform description file and the application description file are merged to generate the product description file of the target controller; the product description file defines: the capability level and the function enable flag; The firmware adapted to the target controller is generated by compiling the product description file, the platform source code of the software platform, and the application source code of the target controller.
4. The method of claim 3, wherein, The step of compiling firmware adapted to the target controller based on the product description file, the platform source code of the software platform, and the application source code of the target controller includes: Read the capability level from the product description file to obtain the capability level identifier; Read the function enable flag from the product description file to obtain conditional compilation instructions; Based on the capability level identifier and the conditional compilation instructions, the platform source code is trimmed to obtain the trimmed platform source code; The trimmed platform source code and the application source code are compiled to generate firmware adapted to the target controller.
5. The method of claim 4, wherein, The product description file also defines: requirement data object configuration, requirement theme configuration, and requirement link configuration; The method further includes: Read the definition information from the requirement data object configuration, requirement theme configuration, and requirement link configuration in the product description file, and generate strongly typed interface definition information; Read the declaration information from the requirement data object configuration, requirement theme configuration, and requirement link configuration in the product description file, and generate a static initialization table; The step of compiling the trimmed platform source code and the application source code to generate firmware adapted to the target controller includes: Based on the strongly typed interface definition information and the static initialization table, the trimmed platform source code and the application source code are compiled to generate firmware adapted to the target controller.
6. The method of claim 4, wherein, The step of trimming the platform source code according to the capability level identifier and the conditional compilation instructions to obtain the trimmed platform source code includes: Based on the capability level identifier, the pruning rules corresponding to the target controller are determined; different capability levels correspond to different pruning rules; Based on the function enable flag in the conditional compilation directive, determine the code of the enabled function module from all functional module code in the platform source code; Using the aforementioned trimming rules, the code of the enabled functional module is trimmed to obtain the trimmed platform source code.
7. The method of claim 6, wherein, The pruning rules include: a set of available functions corresponding to the capability level; the capability level includes four levels: Level 1 corresponds to low computing power MCU, message delivery degrades to direct call mode, upgrades and maintenance use basic modules, and process isolation is not supported; Level 2 corresponds to medium computing power MCU, the interface supports a limited number of channels; Level 3 corresponds to high computing power MCU, the interface supports more channels; Level 4 corresponds to SoC processor, the interface supports multiple channels, upgrades and maintenance use file system modules, and process isolation is supported; The process involves using the trimming rules to trim the code of the enabled functional module, resulting in the trimmed platform source code, including: The usability feature set in the trimming rules is used to trim the code of the enabled feature module to obtain the trimmed platform source code.
8. The method of claim 5, wherein, The method further includes: Based on the time-stamping requirements of the data theme in the product description file, determine the time-stamping enable flag of the data object bound to the data theme; The timestamp enable flag is passed to the data object, and the data object is registered to the static initialization table, so that the firmware runtime determines whether to obtain the timestamp based on the timestamp enable flag of the data object.
9. The method of claim 1, wherein, The platform description file defines the default publishing strategy according to the data object category, and different categories of data objects correspond to different default publishing times; The application description file configures a custom publishing strategy for the data topic. The custom strategy overrides the default publishing strategy and serves as the actual effective strategy for the data topic. Topics that do not configure the custom strategy will use the default publishing strategy.
10. The method of claim 1, wherein, Before obtaining the platform description file of the software platform and the application description file of the target controller in the multi-level controller, the method further includes: The software platform is divided into functional modules, resulting in multiple functional modules. These multiple functional modules include at least: a data management module, a communication management module, and an auxiliary tool module. There are no circular dependencies among the multiple functional modules. The dependency of the auxiliary tool module on the data management module is an optional dependency. When the auxiliary tool module is not enabled, the dependency relationship is automatically eliminated at compile time. A unified operating system abstraction interface is provided for multiple functional modules, and each functional module is used to access system resources through the operating system abstraction interface when it is invoked.
11. The method according to claim 10, characterized in that, The data management module provides a unified read / write interface and a publish / subscribe interface. The read / write interface is used to access data objects registered within this controller, and the publish / subscribe interface is used for data exchange between different application modules within this controller. The method also includes: Under the capability level that supports process isolation constraints, the isolation check of the process isolation constraint is compiled into the registration process identifier of the data object at compile time and bound to the read and write interface. The registration process identifier is used to verify at runtime whether the caller is the registration process of the data object. Cross-process access returns an error code at runtime. At the capability level that does not support process isolation constraints, the isolation check of the process isolation constraints is compiled into a no-operation at compile time and bound to the read / write interface.
12. The method according to claim 10, characterized in that, The communication management module provides a unified transmit / receive interface, which includes: link identifiers for multiple communication links. Each link identifier only identifies the communication protocol type and does not contain device addressing information. The device addressing information is defined by the application layer in the message payload.
13. The method according to claim 1, characterized in that, The target controller's hardware board is a general-purpose PCB. Different hardware configurations are produced by different soldering through BOM (Bill of Materials). Each optional hardware function module has reserved pads and traces on the PCB. Whether a module is present or not is determined by whether the corresponding device is soldered in the BOM. The capability parameters in the product description file correspond one-to-one with the BOM soldering configuration. During compilation, the initialization code and driver code corresponding to the unsoldered modules are automatically trimmed. The method further includes: After the firmware is burned to the hardware board of the target controller, the status of each hardware functional module on the hardware board is read when the target controller is powered on and started. A consistency check is performed between the status of the hardware functional modules and the corresponding capability parameters in the product description file to obtain the check result. If the verification result indicates that the state of any hardware functional module in the hardware board is inconsistent with the corresponding capability parameter, an alarm will be triggered and operation will be prevented.
14. A software adaptation device for a multi-level controller of an energy storage system, characterized in that, The device includes: The acquisition module is used to acquire the platform description file of the software platform and the application description file of the target controller in the multi-level controller; the platform description file defines: all capability levels and all software functional modules supported by the software platform; the application description file defines: the computing power level of the target controller, and the information of the functional modules required by the target controller; different capability levels correspond to controllers with different computing power levels; The compilation module is used to compile the platform source code of the software platform and the application source code of the target controller according to the platform description file and the application description file, and generate firmware adapted to the target controller.
15. A computer device, characterized in that, include: The system includes a processor, a memory, and a bus. The memory stores program instructions executable by the processor. When the computer device is running, the processor communicates with the memory via the bus. The processor executes the program instructions to perform the steps of the software adaptation method for a multi-level controller of an energy storage system as described in any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, performs the steps of the software adaptation method for a multi-level controller of an energy storage system as described in any one of claims 1 to 13.
