Method and device for program replacement of hardware platform in intelligent electric energy meter and storage medium

By using global macros and precompiled instructions in the smart power meter program, the application layer and the underlying driver are decoupled, solving the problem of difficult interface modification when replacing the hardware platform, and achieving rapid migration and reducing maintenance difficulties.

CN119690402AInactive Publication Date: 2025-03-25BEIJING TENGINEER AIOT TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510214909.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-03-25
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the programming of existing smart power meters, the application layer and the underlying driver are highly coupled, which leads to a large number of modifications to the application layer interface when replacing the hardware platform, which is difficult to maintain.

Method used

Isolation and adaptation of the driver interface is achieved by pre-defined global macros in the program to identify different hardware platforms and setting macro definitions according to the target platform at compile time. At the same time, precompiled instructions are added to generate warnings that the interface needs to be ported.

Benefits of technology

It realizes rapid transplantation of smart power meter programs between hardware platforms, reduces the complexity and maintenance difficulty of transplantation, improves transplant efficiency and accuracy, and reduces the use of program storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690402A_ABST
    Figure CN119690402A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for replacing a hardware platform by a program in an intelligent electric energy meter and a storage medium, and the method comprises the steps: modifying the macro definition of the program when detecting that the program in the intelligent electric energy meter needs to change the hardware platform; executing compiling and transplanting a drive interface to modify the macro definition into a target platform; wherein a group of global macros is predefined in the program so as to be used for identifying different hardware platforms; a global macro predefined in the program can be set according to a target platform during compiling, so that the program can select a proper driving interface according to different platforms. Due to pre-compilation isolation of the interface, the original project can be quickly constructed only by modifying the macro definition when the platform is replaced, and the transplantation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of power grid product program architecture, and in particular to a method for separating program application and drive interface of a smart electric energy meter. Background Art

[0002] At present, due to the large number of applications and limited upgrades of electric meter products, most programs are in bare metal form. The application layer and the underlying driver are usually not designed in layers, resulting in a high degree of coupling. When the hardware solution is replaced, a large number of interfaces in the application layer usually need to be modified to adapt to the new underlying hardware, which makes maintenance difficult. Summary of the invention

[0003] In order to solve the above problems, the purpose of the present invention is to provide a method, device and storage medium for replacing the hardware platform of a program in a smart electric energy meter, which belongs to a method for decoupling the application layer and the underlying driver of the smart electric energy meter. The method can realize rapid platform transplantation, and all interfaces that need to be transplanted are visible, without adding additional program storage space and without the need for other documents.

[0004] The present invention provides a method for replacing a hardware platform through a program in a smart electric energy meter, which is applied to the smart electric energy meter. The method comprises: When it is detected that the program in the smart meter needs to change the hardware platform, modify the macro definition of the program; Compile and port the driver interface to modify the macro definitions to the target platform.

[0005] A group of global macros are predefined in the program to identify different hardware platforms; the global macros predefined in the program can be set according to the target platform during compilation to ensure that the program can select appropriate driver interfaces according to different platforms.

[0006] Optionally, all calls to the underlying driver interface in the program of the smart meter are added with platform pre-compilation for isolation; When executing the compilation, all interfaces in the program that need to be transplanted will generate pre-compilation warnings to provide prompts for interface adaptation.

[0007] Optionally, the transplanted interface will no longer give a pre-compilation warning after re-compilation.

[0008] Optionally, when the program in the smart meter changes platform, by setting macro definitions, the code in the original project will be precompiled and isolated according to the new macro definitions, and all parts involving the underlying driver will be excluded.

[0009] The present invention also provides a device for replacing a hardware platform with a program in a smart electric energy meter, the device comprising a processor and a memory storing program instructions, and characterized in that the processor is configured to execute a method for replacing a hardware platform with a program in a smart electric energy meter as described in any of the above items when executing the program instructions.

[0010] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store program codes, and the program codes are used to execute the method for replacing a hardware platform by a program in a smart electric energy meter as described in any one of the above.

[0011] The method, device and storage medium for replacing the hardware platform by a program in a smart electric energy meter of the present invention have the following beneficial effects: (1) Fast migration: Due to the pre-compiled isolation of the interface, when changing the platform, you only need to modify the macro definition to quickly build the original project, which improves the migration efficiency.

[0012] (2) Interface visibility: The precompilation warning mechanism enables developers to clearly identify the interfaces that need to be ported, improving the accuracy and efficiency of porting. Developers can quickly locate the interfaces that need to be modified based on the precompilation warnings, avoiding the tedious work of manual search.

[0013] (3) No additional storage space is required: Through pre-compilation isolation, the storage space of the program is not increased. This is especially important for embedded devices with limited storage space.

[0014] (4) Reduced documentation dependency: The precompilation warning mechanism replaces the traditional documentation method, reducing the workload of document maintenance and the risk of errors. Developers no longer need to rely on documentation to identify the interfaces that need to be ported, but can directly obtain this information through compiler warnings.

[0015] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings: Figure 1 It is a flowchart of a method for replacing a hardware platform by a program in a smart electric energy meter according to an embodiment of the present invention; Figure 2 is a schematic diagram of the global macro definition of an embodiment of the present invention; Figure 3 This is a schematic diagram of adding pre-compilation instructions according to an embodiment of the present invention; Figure 4 The transplanted interface of the embodiment of the present invention does not give a pre-compilation warning indication after re-compilation; Figure 5 It is a pre-compilation warning indication of an embodiment of the present invention; DETAILED DESCRIPTION

[0017] The embodiments of the present invention are described below in conjunction with the accompanying drawings. Those skilled in the art should understand that these embodiments are only used to explain the present invention and are not limiting.

[0018] The embodiment of the present invention provides a method for replacing a hardware platform in a smart electric energy meter by a program, which is applied to a smart electric energy meter, such as Figure 1 As shown, the method includes the following steps S1~S2.

[0019] S1, when it is detected that the program in the smart meter needs to change the hardware platform, the macro definition of the program is modified; S2, compile and transplant the driver interface to modify the macro definition to the target platform, where the target platform is the new hardware platform that needs to be changed.

[0020] In this embodiment, a group of global macros are predefined in the program to identify different hardware platforms; the global macros predefined in the program can be set according to the target platform during compilation to ensure that the program can select appropriate driver interfaces according to different platforms.

[0021] Furthermore, in the program of the smart meter, all calls to the underlying driver interface are isolated by adding platform precompilation; by adding precompilation instructions to the calls to the underlying driver interface, it can be determined whether to compile this part of the code according to the definition of the global platform macro. In this way, when changing the platform, only the macro definition needs to be modified to achieve isolation of different driver interfaces.

[0022] When changing the platform, IS_CPU is equal to CPU_NONE in the original project: When changing the platform, by setting the macro definition, the specific macro (such as IS_CPU) in the original project is equal to CPU_NONE, thereby achieving pre-compilation isolation of the underlying interface.

[0023] When executing compilation, all interfaces that need to be transplanted in the program will generate pre-compilation warnings to prompt interface adaptation. The transplanted interface will no longer give pre-compilation warnings after re-compilation. In other words, after executing compilation, all interfaces that need to be transplanted will give pre-compilation warnings: During the compilation process, due to the effect of pre-compilation isolation, all interfaces that need to be transplanted will generate pre-compilation warnings, prompting developers that these interfaces need to be adapted according to the new platform.

[0024] Since all parts of the project related to the underlying interface are precompiled and isolated and do not participate in compilation; through the above precompilation isolation, all codes related to the underlying interface will not be included during compilation, thereby avoiding unnecessary code compilation and improving compilation efficiency.

[0025] In general, the process of the embodiment of the present invention can be as follows: 1. Creation and application of global platform macro definition: The embodiment of the present invention first defines a group of macros in the configuration file of the program, including IS_CPU, CPU_NONE, CPU_DEFAULT and SPL1050. Among them, IS_CPU: used to determine the current hardware platform type; CPU_NONE: no target platform is set; CPU_DEFAULT: default target platform; SPL1050: new target hardware platform. Figure 2 As shown, these macros are used to isolate platform-dependent code.

[0026] 2. Platform pre-compilation isolation of underlying driver interface calls: Add pre-compilation instructions to all places in the program where the underlying driver interface is called, such as Figure 3 As shown. In all places in the program where the underlying driver interface is called, add pre-compilation instructions, add #if(IS_CPU==CPU_DEFAULT) before the code, and add #if(IS_CPU==CPU_NONE), #warning This interface needs to be ported!, and #endif instructions at the end of the code. In this way, when the compiler encounters these pre-compilation instructions, it will decide whether to include the driver interface code for a specific platform based on the macro definition.

[0027] 3. Macro definition setting when the hardware platform is changed: When the hardware platform needs to be changed, the code in the original project will be pre-compiled and isolated according to the new macro definition. All parts involving the underlying driver will be excluded, and a compilation warning will be given to prompt the developer that the interface needs to be transplanted.

[0028] like Figure 3 As shown, before the transplantation, since the macro definition SPL1050 is equal to IS_CPU, the code between line numbers 72-80 is compiled. When the target hardware platform needs to be changed, SPL1050 is set to not equal to IS_CPU. Therefore, when the compilation is executed again, the code between line numbers 72-80 is not involved in the compilation, and a compilation warning will be given, indicating that this interface needs to be transplanted. After the transplantation, SPL1050 is changed to the new target platform macro definition, the interface transplantation is completed, and the compilation warning will be eliminated.

[0029] 4. Effect of pre-compilation isolation: Through the above pre-compilation isolation, all codes related to the underlying interface will not be included during compilation, so that the original project can be quickly built after changing the platform.

[0030] 5. Generation of precompilation warnings: During the compilation process, due to the effect of precompilation isolation, all interfaces that need to be transplanted will generate precompilation warnings, such as Figure 5 shown.

[0031] 6. Platform migration: After changing the hardware platform, developers should Figure 5 To avoid the warnings given during compilation, modify the corresponding interface. After the modification is completed, change the macro definition to the target platform, such as Figure 4 As shown in the figure, the transplanted interface will not give a pre-compilation warning after re-compilation.

[0032] An embodiment of the present invention also provides a device for replacing a hardware platform with a program in a smart electric energy meter, the device comprising a processor and a memory storing program instructions, and characterized in that the processor is configured to execute a method for replacing a hardware platform with a program in a smart electric energy meter as described in the above embodiment when executing the program instructions.

[0033] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store program codes, and the program codes are used to execute the method for replacing a hardware platform by a program in a smart electric energy meter in the above embodiment.

[0034] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. A method for replacing a hardware platform with a program in a smart electric energy meter, characterized in that: Applied to a smart electric meter, the method comprises: When it is detected that the program in the smart meter needs to change the hardware platform, modify the macro definition of the program; Compile and port the driver interface to modify the macro definitions to the target platform; A group of global macros are predefined in the program to identify different hardware platforms; the global macros predefined in the program can be set according to the target platform during compilation to ensure that the program can select appropriate driver interfaces according to different platforms.

2. The method according to claim 1, characterized in that All calls to the underlying driver interface in the program of the smart meter are isolated by adding platform pre-compilation; When executing the compilation, all interfaces in the program that need to be transplanted will generate pre-compilation warnings to provide prompts for interface adaptation.

3. The method according to claim 2, characterized in that No pre-compilation warning will be given after the transplanted interface is compiled again.

4. The method according to claim 1, characterized in that When the program in the smart meter changes platform, by setting macro definitions, the code in the original project will be pre-compiled and isolated according to the new macro definitions, and all parts involving the underlying driver will be excluded.

5. A device for replacing the hardware platform of a program in a smart electric energy meter, characterized in that: The device comprises a processor and a memory storing program instructions, wherein the processor is configured to execute the method for replacing a hardware platform by a program in a smart electric energy meter according to any one of claims 1 to 4 when executing the program instructions.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program codes, and the program codes are used to execute the method for replacing the hardware platform by a program in a smart electric energy meter according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Automatic matching method of hardware board card

    CN104123381A

  • Modular design method for watt-hour meter software

    CN109271146A

  • Program parameter loading method and device, equipment and storage medium

    CN116360887A