A large-scale satellite-based software architecture method based on dependency injection pattern

By adopting the architecture method of dependency injection mode in large-scale satellite-borne software, the problem of code file modification conflicts in collaborative development is solved, the software module is decoupled and the code maintainability is achieved, and the security of spacecraft software is ensured.

CN117093189BInactive Publication Date: 2025-05-06CHINA ORDNANCE SCI INST +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311095526.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-29
Publication Date
2025-05-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When multiple people collaborate on developing large-scale satellite-borne software, the modification of the same code file by multiple people can easily lead to conflicts, destroy the isolation of the code, and bring hidden dangers to spacecraft safety.

Method used

Using a large-scale satellite-based software architecture method based on the dependency injection mode, by allocating segment space in the program, using LD scripts and __attribute__((section(""))) attributes, the initialization functions of each module are collected into the segment space, and these functions are traversed in the startup boot code to complete the dependency injection operation.

Benefits of technology

It realizes full decoupling of each software module, improves the maintainability of the code, avoids the modification conflicts of the same code file by multiple people, and ensures the security of the spacecraft software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117093189B_ABST
    Figure CN117093189B_ABST
Patent Text Reader

Abstract

The present invention discloses a large-scale satellite software architecture method based on dependency injection mode, including: according to the data type in the program, a corresponding segment space is allocated for storing data used for dependency injection mode; using LD script and __attribute__((section(""))) attribute, the initialization functions in each module are collected into the corresponding segment space; in the startup boot code, the initialization functions in all the segment spaces are traversed and executed in sequence to complete the dependency injection operation. The method implements the dependency injection technology in the satellite software, and uses the technology to design the architecture of the satellite software, so as to achieve the purpose of fully decoupling each software module, which can effectively improve the maintainability of the code and lay a foundation for the development of large-scale satellite software with multi-person collaboration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of spacecraft software development, and more specifically to a large-scale satellite-borne software architecture method based on a dependency injection pattern, which is mainly used in spacecraft software architecture design. Background Art

[0002] At present, as spacecraft software applications become more and more complex and the scale of software becomes larger and larger, the traditional single-person development model can no longer efficiently complete such large-scale software development work, and a team collaborative development model must be adopted. However, in the process of multi-person collaborative development, many challenges have also been encountered. The most prominent problem is that multiple people's changes to the same code file often lead to conflicts, which not only destroys the isolation of the code, but also poses a huge hidden danger to the safety of the spacecraft. Therefore, it is particularly important to decouple the codes of different modules from different people. This is an essential technology for large-scale spaceborne software development under the multi-person collaborative mode.

[0003] In other high-level object-oriented languages ​​(such as JAVA, C++, etc.), the dependency injection mode is usually adopted to implement the idea of ​​control inversion, so as to achieve the purpose of decoupling between different module codes. They are implemented as follows: when class A depends on class B, class B is not directly instantiated in class A, but only the abstract interface of class B is defined in class A, and then the actual class B is injected into class A through the dependency injection program through the configuration file to complete the control inversion operation.

[0004] However, most of the current on-board software is developed in C language, which lacks the real object-oriented technical support of high-level languages ​​and cannot directly implement dependency injection technology based on object-oriented mode. Summary of the invention

[0005] In view of this, the present invention provides a large-scale satellite-borne software architecture method based on the dependency injection mode, which effectively avoids the problem of multiple people modifying the same code file.

[0006] In order to achieve the above object, the present invention adopts the following technical solution:

[0007] The present invention provides a large-scale satellite-borne software architecture method based on a dependency injection mode, comprising the following steps:

[0008] S10, according to the data type in the program, respectively allocate a segment space for storing data used for the dependency injection mode;

[0009] S20, using the LD script and the __attribute__((section(“”))) attribute, collect the initialization functions in each module into the corresponding segment space;

[0010] S30, traversing and sequentially executing all the initialization functions in the segment space in the boot code to complete the dependency injection operation.

[0011] In one embodiment, the step S20 includes:

[0012] Inject each module initialization function pointer into the segment space;

[0013] Use LD script to merge the initialization function segment space of each module.

[0014] In one embodiment, injecting each module initialization function pointer into the segment space includes:

[0015] A macro function is defined to receive a function name of each module as a parameter, automatically generate a pointer to the function, and use the __attribute__((section(""))) attribute to store the function pointer in the segment space.

[0016] In one embodiment, the LD script in step S20 defines start and end symbols for subsequent code to locate the start and end positions of the segment space.

[0017] In one embodiment, step S30 includes:

[0018] Declare and reference the start and end symbols in the LD script as void pointers;

[0019] Forcefully convert the void pointer to an initialization function pointer of the RunBeforeInitFunction type executed before the system starts;

[0020] Using start and end as the start and end marks, all initialization functions in the segment space are traversed and executed in sequence to complete the dependency injection operation.

[0021] In one embodiment, the method further comprises:

[0022] S40. Write an initialization function to complete the initialization operation of processes and components in each module.

[0023] It can be known from the above technical solutions that, compared with the prior art, the present invention discloses a large-scale satellite software architecture method based on the dependency injection mode, including: according to the data type in the program, a corresponding segment space is allocated for storing data used for the dependency injection mode; using LD script and __attribute__((section(""))) attribute, the initialization functions in each module are collected into the corresponding segment space; in the startup boot code, the initialization functions in all the segment spaces are traversed and executed in sequence to complete the dependency injection operation. This method implements the dependency injection technology in the satellite software, and uses the technology to design the architecture of the satellite software, so as to achieve the purpose of fully decoupling each software module, which can effectively improve the maintainability of the code and lay the foundation for the development of large-scale satellite software with multi-person collaboration. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0025] Figure 1 A flow chart of a large-scale satellite-borne software architecture method based on a dependency injection pattern provided by the present invention.

[0026] Figure 2 A comparison diagram of the traditional process configuration method and the process configuration method based on the dependency injection mode provided by the present invention;

[0027] Figure 3 A comparison chart of the traditional instruction group configuration method and the instruction group configuration method based on the dependency injection mode provided by the present invention. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0029] The embodiment of the present invention discloses a large-scale satellite-borne software architecture method based on a dependency injection mode, referring to Figure 1 As shown, including:

[0030] S10, according to the data type in the program, respectively allocate a segment space for storing data used for the dependency injection mode;

[0031] S20, using LD script and __attribute__((section(""))) attribute, collect the initialization functions in each module into the corresponding segment space; wherein each module can be, for example, a process, a component, a configuration table, etc., as long as it can be logically split into multiple similar code blocks, it can be considered a module;

[0032] S30, traversing and sequentially executing all the initialization functions in the segment space in the boot code to complete the dependency injection operation;

[0033] S40. Write an initialization function to complete the initialization operation of processes and components in each module.

[0034] The present invention implements dependency injection technology in satellite-borne software, which effectively avoids the problem of multiple people modifying the same code file, and only needs to modify the code files of respective modules. It does not need to manually centralize configuration information, but integrates the configuration information scattered in various files through "LD script" and __attribute__((section(""))) attribute (this syntax is often used in initialization modules, and adding new modules does not need to modify the previous code.) and centrally stores it in the run_before_init segment space, and completes the dependency injection operation by traversing and sequentially executing the initialization functions in the run_before_init segment in the startup boot code. It is implemented as follows: first, a special segment space (run_before_init) is defined and allocated to store data used for dependency injection mode; then, the initialization functions in each module are collected into the segment run_before_init using the "LD script" and __attribute__((section(""))) attribute to achieve the effect of integrating; finally, the initialization functions in the run_before_init segment are traversed and sequentially executed in the startup boot code to complete the dependency injection operation.

[0035] The following two examples (APP process loading and instruction group construction) in a single machine of a subsystem of an optical remote sensing satellite are used to illustrate the specific implementation of the method. The software is developed using C language and GCC compiler environment.

[0036] Step 1: Allocate segment space to store the initialization function.

[0037] By default, the compiler will only classify the data into different segment spaces according to the data type in the program, and cannot distinguish these data according to specific business needs. However, the present invention needs to automatically execute the initialization function of all modules before the system starts, so it is necessary to define and allocate a special segment space (run_before_init) specifically for storing data used in the dependency injection mode.

[0038] Step 2: Inject each module initialization function pointer into the run_before_init segment.

[0039] Each version of the C language compiler provides keywords for specifying the segment space for data storage. In the GCC compiler, this operation can be completed by adding the __attribute__((section(""))) attribute before the data. For ease of use, the following INJECT_RUN_BEFORE_INIT macro function is defined here. It receives a function name as a parameter, automatically generates a pointer to the function, and uses the __attribute__((section(""))) attribute to store the function pointer in the segment run_before_init.

[0040] The implementation code is as follows:

[0041]

[0042] Step 3: Use the LD script to merge the initialization function segment spaces of each module.

[0043] In the process of software engineering development, the code needs to be split into multiple files, and the segment space in each file is independent. Therefore, in the linking process, the segment space distributed in different files needs to be reorganized through the LD script. In order to facilitate the subsequent traversal of the data in the run_before_init segment space, the present invention still links the run_before_init segment data in all modules to a separate unified run_before_init segment space. The LD script to implement this operation is as follows:

[0044] The two symbols __RUN_BEFORE_INIT_LIST_START__ and __RUN_BEFORE_INIT_LIST_END__ are defined to help subsequent code locate the start and end positions of the run_before_init segment.

[0045] The implementation code is as follows:

[0046]

[0047]

[0048] Step 4: Scan and execute all initialization functions in the run_before_init segment in the boot code.

[0049] In the above steps, all initialization functions of each module have been injected into the run_before_init segment, and the two symbols __RUN_BEFORE_INIT_LIST_START__ and __RUN_BEFORE_INIT_LIST_END__ are defined to locate the start and end positions of the run_before_init segment. Therefore, the following code can be added to the boot code. The HookRunBeforeInitFunctions function is responsible for traversing and executing the initialization functions before the system starts. It consists of three parts: first, declare and reference the two symbols __RUN_BEFORE_INIT_LIST_START__ and __RUN_BEFORE_INIT_LIST_END__ in the LD script as void pointers; then force them to be RunBeforeInitFunction type initialization function pointers executed before the system starts; finally, use start and end as the start and end marks to traverse and execute all initialization functions in the segment in sequence.

[0050] The implementation code is as follows:

[0051]

[0052]

[0053] Step 5. Write an initialization function to complete the initialization operations of processes and components in each module. This step needs to be customized according to the specific business logic. Here we use two specific instances (APP process loading and instruction group components) in a single machine of a subsystem of an optical remote sensing satellite as an example.

[0054] Example 1: APP process loading

[0055] In the traditional onboard software development process, each person in the team needs to modify the configuration information in the system startup code file every time they add a process. This not only destroys the isolation of the code, but also often causes code conflicts and brings security risks. After the introduction of the dependency injection mode, each developer only needs to add process configuration information to each process's own file and call the registration function. The boot loader will automatically inject the process configuration information into the system startup code before the system starts. Figure 2As shown: the left side is the traditional process configuration method, which requires developers to modify both the process code file and the system startup code file; the right side is the process configuration method based on the dependency injection mode, which only requires developers to modify the process code file, and the boot loader automatically injects the process configuration information into the system startup code.

[0056] To register the APP process configuration information using the dependency injection mode, the following work needs to be done: first, the system needs to provide a unified registration process information interface function RegisterAppToFrame, which receives the APP structure and the App configuration information as input, and fills the App configuration information into the system process configuration table. Since its specific implementation is irrelevant to the present invention, it will not be expanded here; then for ease of use, define the following macro function REGISTER_APP, which receives the APP name and the APP configuration information as input, and automatically generates a function APPNAME_inject that can be injected into the run_before_init segment. This function is to wrap and call the RegisterAppToFrame interface function; finally, the macro function injects the generated wrapper function into the run_before_init segment through INJECT_RUN_BEFORE_INIT.

[0057] The code is implemented as follows:

[0058]

[0059] The practical use example of the above macro is as follows. Developers only need to define the APP structure and APP configuration information in their respective process files, and then pass them to the REGISTER_APP macro. The specific configuration information of APP is irrelevant to the present invention and will not be expanded.

[0060] The code is implemented as follows:

[0061]

[0062]

[0063] Example 2: Instruction Group Component

[0064] In the traditional onboard software development process, each person in the team needs to modify the configuration information in the instruction group component every time they add an instruction group. This not only destroys the isolation of the code, but also often causes code conflicts and brings security risks. After the introduction of the dependency injection mode, each developer only needs to add the instruction group configuration information in their own code file and call the registration function. The boot program will automatically inject the instruction group configuration information into the instruction group component before the system starts. Figure 3As shown: the left side is the traditional instruction group configuration method, which requires developers to modify both the instruction group code file and the instruction group component file; the right side is the instruction group configuration method based on the dependency injection mode, which only requires developers to modify the instruction group code file, and the boot program automatically injects the instruction group configuration information into the instruction group component.

[0065] To register the instruction group configuration information using the dependency injection mode, the following work needs to be done: first, the system needs to provide a unified registration instruction group information interface function RegisteTCG, which receives the instruction group number and instruction group codeword as input, and fills the instruction group configuration information into the instruction group component configuration table. Since its specific implementation is irrelevant to the present invention, it will not be expanded here; then for ease of use, define the following macro function REGISTER_TCGROUP, which receives the instruction group number TCG_ID as input, and automatically generates a function tcg_inject_TCG_ID that can be injected into the run_before_init segment. This function is to package and call the RegisteTCG interface function; finally, the macro function injects the generated wrapper function into the run_before_init segment through INJECT_RUN_BEFORE_INIT.

[0066] The code is implemented as follows:

[0067]

[0068] The practical use example of the above macro is as follows. Developers only need to pass the instruction group number to the macro RegisterTCG in their respective files, and then define the specific codeword of the instruction group. The specific codeword of the instruction group is irrelevant to the present invention and will not be expanded.

[0069]

[0070] This is the end of the process.

[0071] The present invention uses dependency injection technology to perform architectural design on APP process loading and instruction group components, achieving the purpose of effectively isolating different module codes and avoiding the situation where multiple people modify the same code file. In the APP process loading example, the dependency injection technology proposed in the present invention can be used to directly define and inject process configuration information into each process file without modifying the configuration table in the system startup code file. In the instruction group component example, the dependency injection technology proposed in the present invention can be used to directly define and inject instruction group configuration information into each file without modifying the configuration table in the instruction group component file.

[0072] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0073] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A large-scale satellite-borne software architecture method based on dependency injection mode, characterized in that: The following steps are involved: S10, according to the data type in the program, respectively allocate a segment space for storing data used for the dependency injection mode; S20, using the LD script and the __attribute__((section(""))) attribute, collect the initialization functions in each module into the corresponding segment space; S30, traversing and sequentially executing all the initialization functions in the segment space in the boot code to complete the dependency injection operation.

2. According to claim 1, a large-scale satellite-based software architecture method based on dependency injection mode is characterized in that: The step S20 comprises: Use the __attribute__((section(""))) attribute to inject each module initialization function pointer into the segment space; Use LD script to merge the initialization function segment space of each module.

3. According to claim 2, a large-scale satellite-based software architecture method based on dependency injection mode is characterized in that: Inject each module initialization function pointer into the segment space, including: A macro function is defined to receive a function name of each module as a parameter, automatically generate a pointer to the function, and use the __attribute__((section(""))) attribute to store the function pointer in the segment space.

4. According to claim 2, a large-scale satellite-based software architecture method based on dependency injection mode is characterized in that: The LD script in step S20 defines start and end symbols for subsequent codes to locate the start and end positions of the segment space.

5. A large-scale satellite-borne software architecture method based on dependency injection mode according to claim 4, characterized in that: The step S30 comprises: Declare and reference the start and end symbols in the LD script as void pointers; Forcefully convert the void pointer to an initialization function pointer of the RunBeforeInitFunction type executed before the system starts; Using start and end as the start and end marks, all initialization functions in the segment space are traversed and executed in sequence to complete the dependency injection operation.

6. A large-scale satellite-borne software architecture method based on dependency injection mode according to claim 5, characterized in that: The method further comprises: S40. Write an initialization function to complete the initialization operation of processes and components in each module.

Citation Information

Patent Citations

  • Distributed element dependent relationship managing method based on dependent injection

    CN101251796A

  • Multi-task compiling method based on graphical guarded command calculation

    CN108319458A